當前位置: 首頁>>代碼示例>>Golang>>正文


Golang client.NewClient函數代碼示例

本文整理匯總了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
}
開發者ID:partamonov,項目名稱:terraform,代碼行數:30,代碼來源:manta.go

示例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
}
開發者ID:bac,項目名稱:juju,代碼行數:8,代碼來源:environ_instance.go

示例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), "")
}
開發者ID:asteris-llc,項目名稱:gocommon,代碼行數:9,代碼來源:client_test.go

示例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)
}
開發者ID:asteris-llc,項目名稱:gocommon,代碼行數:9,代碼來源:client_test.go

示例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
}
開發者ID:imoapps,項目名稱:juju,代碼行數:11,代碼來源:environ_instance.go

示例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
}
開發者ID:cehoffman,項目名稱:triton-terraform,代碼行數:14,代碼來源:config.go

示例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
}
開發者ID:jiasir,項目名稱:juju,代碼行數:16,代碼來源:storage.go

示例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
}
開發者ID:RezaDKhan,項目名稱:terraform,代碼行數:21,代碼來源:provider.go

示例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
}
開發者ID:joyent,項目名稱:packer-builder-triton,代碼行數:26,代碼來源:access_config.go

示例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
}
開發者ID:jen20,項目名稱:packer-builder-triton,代碼行數:26,代碼來源:access_config.go

示例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)
}
開發者ID:joyent,項目名稱:gomanta,代碼行數:6,代碼來源:live_test.go

示例12: TestNewClient

func (s *ClientSuite) TestNewClient(c *gc.C) {
	cl := client.NewClient(s.creds.SdcEndpoint.URL, "", s.creds, nil)
	c.Assert(cl, gc.NotNil)
}
開發者ID:asteris-llc,項目名稱:gocommon,代碼行數:4,代碼來源:client_test.go

示例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)
}
開發者ID:richardiux,項目名稱:gomanta,代碼行數:6,代碼來源:live_test.go

示例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)
}
開發者ID:joyent,項目名稱:gosdc,代碼行數:6,代碼來源:local_test.go

示例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)
}
開發者ID:cehoffman,項目名稱:gosdc,代碼行數:6,代碼來源:live_test.go


注:本文中的github.com/joyent/gocommon/client.NewClient函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。