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


Golang AuthConfig.Username方法代碼示例

本文整理匯總了Golang中github.com/docker/engine-api/types.AuthConfig.Username方法的典型用法代碼示例。如果您正苦於以下問題:Golang AuthConfig.Username方法的具體用法?Golang AuthConfig.Username怎麽用?Golang AuthConfig.Username使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/docker/engine-api/types.AuthConfig的用法示例。


在下文中一共展示了AuthConfig.Username方法的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
	}

	ret.Username = resp.Username
	ret.Password = resp.Password
	ret.ServerAddress = serverAddress
	return ret, nil
}
開發者ID:contiv,項目名稱:docker,代碼行數:31,代碼來源: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 = ""

	// Fallback to old credential in plain text to save only the email
	return c.fileStore.Store(authConfig)
}
開發者ID:contiv,項目名稱:docker,代碼行數:11,代碼來源: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.Username方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。