当前位置: 首页>>代码示例>>Golang>>正文


Golang AuthConfig.IdentityToken方法代码示例

本文整理汇总了Golang中github.com/docker/engine-api/types.AuthConfig.IdentityToken方法的典型用法代码示例。如果您正苦于以下问题:Golang AuthConfig.IdentityToken方法的具体用法?Golang AuthConfig.IdentityToken怎么用?Golang AuthConfig.IdentityToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/docker/engine-api/types.AuthConfig的用法示例。


在下文中一共展示了AuthConfig.IdentityToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getCredentialsFromStore

// getCredentialsFromStore executes the command to get the credentials from the native store.
func (c *nativeStore) getCredentialsFromStore(serverAddress string) (types.AuthConfig, error) {
	var ret types.AuthConfig

	cmd := c.commandFn("get")
	cmd.Input(strings.NewReader(serverAddress))

	out, err := cmd.Output()
	if err != nil {
		t := strings.TrimSpace(string(out))

		// do not return an error if the credentials are not
		// in the keyckain. Let docker ask for new credentials.
		if t == errCredentialsNotFound.Error() {
			return ret, nil
		}

		logrus.Debugf("error getting credentials - err: %v, out: `%s`", err, t)
		return ret, fmt.Errorf(t)
	}

	var resp credentialsGetResponse
	if err := json.NewDecoder(bytes.NewReader(out)).Decode(&resp); err != nil {
		return ret, err
	}

	if resp.Username == tokenUsername {
		ret.IdentityToken = resp.Secret
	} else {
		ret.Password = resp.Secret
		ret.Username = resp.Username
	}

	ret.ServerAddress = serverAddress
	return ret, nil
}
开发者ID:RAMESHBABUK,项目名称:docker,代码行数:36,代码来源:native_store.go

示例2: Store

// Store saves the given credentials in the file store.
func (c *nativeStore) Store(authConfig types.AuthConfig) error {
	if err := c.storeCredentialsInStore(authConfig); err != nil {
		return err
	}
	authConfig.Username = ""
	authConfig.Password = ""
	authConfig.IdentityToken = ""

	// Fallback to old credential in plain text to save only the email
	return c.fileStore.Store(authConfig)
}
开发者ID:CheggEng,项目名称:docker,代码行数:12,代码来源:native_store.go

示例3: getCredentialsFromStore

// getCredentialsFromStore executes the command to get the credentials from the native store.
func (c *nativeStore) getCredentialsFromStore(serverAddress string) (types.AuthConfig, error) {
	var ret types.AuthConfig

	creds, err := client.Get(c.programFunc, serverAddress)
	if err != nil {
		if credentials.IsErrCredentialsNotFound(err) {
			// do not return an error if the credentials are not
			// in the keyckain. Let docker ask for new credentials.
			return ret, nil
		}
		return ret, err
	}

	if creds.Username == tokenUsername {
		ret.IdentityToken = creds.Secret
	} else {
		ret.Password = creds.Secret
		ret.Username = creds.Username
	}

	ret.ServerAddress = serverAddress
	return ret, nil
}
开发者ID:CheggEng,项目名称:docker,代码行数:24,代码来源:native_store.go


注:本文中的github.com/docker/engine-api/types.AuthConfig.IdentityToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。