本文整理汇总了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
}
示例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
}
示例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
}
}