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


Golang SecretsInterface.Get方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/client/unversioned.SecretsInterface.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang SecretsInterface.Get方法的具體用法?Golang SecretsInterface.Get怎麽用?Golang SecretsInterface.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/client/unversioned.SecretsInterface的用法示例。


在下文中一共展示了SecretsInterface.Get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getDetailsFromDockerConfigSecret

func getDetailsFromDockerConfigSecret(secretGetter client.SecretsInterface, secret string) (map[string]string, error) {
	configSecret, err := secretGetter.Get(secret)
	if err != nil {
		return nil, err
	}
	dockerConfigJSONBytes := configSecret.Data[api.DockerConfigJsonKey]
	var secretData map[string]interface{}
	if err = json.Unmarshal(dockerConfigJSONBytes, &secretData); err != nil {
		return nil, err
	}

	var authdata map[string]interface{}
	var hostname string
	for key, value := range secretData["auths"].(map[string]interface{}) {
		hostname = key
		authdata = value.(map[string]interface{})
	}
	token := authdata["auth"].(string)
	decodedToken, err := base64.StdEncoding.DecodeString(token)
	if err != nil {
		return nil, err
	}
	parts := strings.SplitN(string(decodedToken), ":", 2)
	if len(parts) != 2 {
		return nil, errors.New("Invalid token in docker config secret")
	}
	user := parts[0]
	password := parts[1]
	regDetails := make(map[string]string)
	regDetails["DEIS_REGISTRY_USERNAME"] = user
	regDetails["DEIS_REGISTRY_PASSWORD"] = password
	regDetails["DEIS_REGISTRY_HOSTNAME"] = hostname
	return regDetails, nil
}
開發者ID:mboersma,項目名稱:builder,代碼行數:34,代碼來源:registry.go

示例2: getDetailsFromRegistrySecret

func getDetailsFromRegistrySecret(secretGetter client.SecretsInterface, secret string) (map[string]string, error) {
	regSecret, err := secretGetter.Get(secret)
	if err != nil {
		return nil, err
	}
	regDetails := make(map[string]string)
	for key, value := range regSecret.Data {
		regDetails[key] = string(value)
	}
	return regDetails, nil
}
開發者ID:mboersma,項目名稱:builder,代碼行數:11,代碼來源:registry.go

示例3: installationStarted

func installationStarted(c kclient.PodInterface, name string, s kclient.SecretsInterface) wait.ConditionFunc {
	return func() (bool, error) {
		pod, err := c.Get(name)
		if err != nil {
			return false, err
		}
		if pod.Status.Phase == kapi.PodPending {
			return false, nil
		}
		// delete a secret named the same as the pod if it exists
		if secret, err := s.Get(name); err == nil {
			if secret.Annotations[newcmd.GeneratedForJob] == "true" &&
				secret.Annotations[newcmd.GeneratedForJobFor] == pod.Annotations[newcmd.GeneratedForJobFor] {
				if err := s.Delete(name); err != nil {
					glog.V(4).Infof("Failed to delete install secret %s: %v", name, err)
				}
			}
		}
		return true, nil
	}
}
開發者ID:poomsujarit,項目名稱:origin,代碼行數:21,代碼來源:newapp.go


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