本文整理匯總了Golang中k8s/io/kubernetes/pkg/api.Secret.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang Secret.Name方法的具體用法?Golang Secret.Name怎麽用?Golang Secret.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/api.Secret
的用法示例。
在下文中一共展示了Secret.Name方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createAppEnvConfigSecret
func createAppEnvConfigSecret(secretsClient client.SecretsInterface, secretName string, env map[string]interface{}) error {
newSecret := new(api.Secret)
newSecret.Name = secretName
newSecret.Type = api.SecretTypeOpaque
newSecret.Data = make(map[string][]byte)
for k, v := range env {
newSecret.Data[k] = []byte(fmt.Sprintf("%v", v))
}
if _, err := secretsClient.Create(newSecret); err != nil {
if apierrors.IsAlreadyExists(err) {
if _, err = secretsClient.Update(newSecret); err != nil {
return err
}
return nil
}
return err
}
return nil
}
示例2: Get
// Get is the ClusterID interface implementation
func (c clusterIDFromPersistentStorage) Get() (string, error) {
c.rwm.Lock()
defer c.rwm.Unlock()
secret, err := c.secretGetterCreator.Get(wfmSecretName)
//If we don't have the secret we shouldn't be returning error and instead a create a new one
if err != nil && !apierrors.IsNotFound(err) {
return "", err
}
// if we don't have secret data for the cluster ID we assume a new cluster
// and create a new secret
if secret.Data[clusterIDSecretKey] == nil {
newSecret := new(api.Secret)
newSecret.Name = wfmSecretName
newSecret.Data = make(map[string][]byte)
newSecret.Data[clusterIDSecretKey] = []byte(uuid.NewV4().String())
fromAPI, err := c.secretGetterCreator.Create(newSecret)
if err != nil {
return "", err
}
secret = fromAPI
}
return string(secret.Data[clusterIDSecretKey]), nil
}