本文整理汇总了Golang中github.com/joyent/gocommon/client.NewClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClient函数的具体用法?Golang NewClient怎么用?Golang NewClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: mantaFactory
func mantaFactory(conf map[string]string) (Client, error) {
path, ok := conf["path"]
if !ok {
return nil, fmt.Errorf("missing 'path' configuration")
}
objectName, ok := conf["objectName"]
if !ok {
objectName = DEFAULT_OBJECT_NAME
}
creds, err := getCredentialsFromEnvironment()
if err != nil {
return nil, fmt.Errorf("Error getting Manta credentials: %s", err.Error())
}
client := manta.New(joyentclient.NewClient(
creds.MantaEndpoint.URL,
"",
creds,
log.New(os.Stderr, "", log.LstdFlags),
))
return &MantaClient{
Client: client,
Path: path,
ObjectName: objectName,
}, nil
}
示例2: newCompute
func newCompute(cloud environs.CloudSpec) (*joyentCompute, error) {
creds, err := credentials(cloud)
if err != nil {
return nil, err
}
client := client.NewClient(cloud.Endpoint, cloudapi.DefaultAPIVersion, creds, newGoLogger())
return &joyentCompute{cloudapi: cloudapi.New(client)}, nil
}
示例3: TestSignURL
func (s *ClientSuite) TestSignURL(c *gc.C) {
cl := client.NewClient(s.creds.MantaEndpoint.URL, "", s.creds, nil)
c.Assert(cl, gc.NotNil)
path := fmt.Sprintf("/%s/stor", s.creds.UserAuthentication.User)
singedUrl, err := cl.SignURL(path, time.Now().Add(time.Minute*5))
c.Assert(err, gc.IsNil)
c.Assert(singedUrl, gc.Not(gc.Equals), "")
}
示例4: TestSendRequest
func (s *ClientSuite) TestSendRequest(c *gc.C) {
cl := client.NewClient(s.creds.SdcEndpoint.URL, "", s.creds, nil)
c.Assert(cl, gc.NotNil)
req := joyenthttp.RequestData{}
resp := joyenthttp.ResponseData{ExpectedStatus: []int{http.StatusOK}}
err := cl.SendRequest(client.GET, "", "", &req, &resp)
c.Assert(err, gc.IsNil)
}
示例5: newCompute
func newCompute(cfg *environConfig) (*joyentCompute, error) {
creds, err := credentials(cfg)
if err != nil {
return nil, err
}
client := client.NewClient(cfg.sdcUrl(), cloudapi.DefaultAPIVersion, creds, &logger)
return &joyentCompute{
ecfg: cfg,
cloudapi: cloudapi.New(client)}, nil
}
示例6: Cloud
// Cloud returns a configured cloudapi.Client instance
func (c *Config) Cloud() (*cloudapi.Client, error) {
creds, err := c.Creds()
if err != nil {
return nil, err
}
return cloudapi.New(client.NewClient(
c.URL,
cloudapi.DefaultAPIVersion,
creds,
&cloudapi.Logger,
)), nil
}
示例7: newStorage
func newStorage(cfg *environConfig, name string) (storage.Storage, error) {
creds, err := credentials(cfg)
if err != nil {
return nil, err
}
client := client.NewClient(cfg.mantaUrl(), "", creds, &logger)
if name == "" {
name = cfg.controlDir()
}
return &JoyentStorage{
ecfg: cfg,
containerName: name,
manta: manta.New(client)}, nil
}
示例8: getSDCClient
func (c SDCConfig) getSDCClient() (*cloudapi.Client, error) {
userauth, err := auth.NewAuth(c.Account, c.KeyMaterial, "rsa-sha256")
if err != nil {
return nil, err
}
creds := &auth.Credentials{
UserAuthentication: userauth,
SdcKeyId: c.KeyID,
SdcEndpoint: auth.Endpoint{URL: c.URL},
}
client := cloudapi.New(client.NewClient(
c.URL,
cloudapi.DefaultAPIVersion,
creds,
log.New(os.Stderr, "", log.LstdFlags),
))
return client, nil
}
示例9: CreateTritonClient
// CreateTritonClient returns an SDC client configured with the appropriate client credentials
// or an error if creating the client fails.
func (c *AccessConfig) CreateTritonClient() (*cloudapi.Client, error) {
keyData, err := processKeyMaterial(c.KeyMaterial)
if err != nil {
return nil, err
}
userauth, err := auth.NewAuth(c.Account, string(keyData), "rsa-sha256")
if err != nil {
return nil, err
}
creds := &auth.Credentials{
UserAuthentication: userauth,
SdcKeyId: c.KeyID,
SdcEndpoint: auth.Endpoint{URL: c.Endpoint},
}
return cloudapi.New(client.NewClient(
c.Endpoint,
cloudapi.DefaultAPIVersion,
creds,
log.New(os.Stdout, "", log.Flags()),
)), nil
}
示例10: CreateSDCClient
// CreateSDCClient returns an SDC client configured with the appropriate client credentials
// or an error if creating the client fails.
func (c *AccessConfig) CreateSDCClient() (*cloudapi.Client, error) {
keyData, err := ioutil.ReadFile(c.KeyPath)
if err != nil {
return nil, err
}
userauth, err := auth.NewAuth(c.Account, string(keyData), "rsa-sha256")
if err != nil {
return nil, err
}
creds := &auth.Credentials{
UserAuthentication: userauth,
SdcKeyId: c.KeyID,
SdcEndpoint: auth.Endpoint{URL: c.Endpoint},
}
return cloudapi.New(client.NewClient(
c.Endpoint,
cloudapi.DefaultAPIVersion,
creds,
&cloudapi.Logger,
)), nil
}
示例11: SetUpTest
func (s *LiveTests) SetUpTest(c *gc.C) {
client := client.NewClient(s.creds.MantaEndpoint.URL, "", s.creds, log.New(os.Stderr, "", log.LstdFlags))
c.Assert(client, gc.NotNil)
s.testClient = manta.New(client)
c.Assert(s.testClient, gc.NotNil)
}
示例12: TestNewClient
func (s *ClientSuite) TestNewClient(c *gc.C) {
cl := client.NewClient(s.creds.SdcEndpoint.URL, "", s.creds, nil)
c.Assert(cl, gc.NotNil)
}
示例13: SetUpTest
func (s *LiveTests) SetUpTest(c *gc.C) {
client := client.NewClient(s.creds.MantaEndpoint.URL, "", s.creds, &manta.Logger)
c.Assert(client, gc.NotNil)
s.testClient = manta.New(client)
c.Assert(s.testClient, gc.NotNil)
}
示例14: SetUpTest
func (s *LocalTests) SetUpTest(c *gc.C) {
client := client.NewClient(s.creds.SdcEndpoint.URL, cloudapi.DefaultAPIVersion, s.creds, log.New(os.Stderr, "", log.LstdFlags))
c.Assert(client, gc.NotNil)
s.testClient = cloudapi.New(client)
c.Assert(s.testClient, gc.NotNil)
}
示例15: SetUpTest
func (s *LiveTests) SetUpTest(c *gc.C) {
client := client.NewClient(s.creds.SdcEndpoint.URL, cloudapi.DefaultAPIVersion, s.creds, &cloudapi.Logger)
c.Assert(client, gc.NotNil)
s.testClient = cloudapi.New(client)
c.Assert(s.testClient, gc.NotNil)
}