This commit is contained in:
Seth Pollack
2018-08-09 14:45:56 -04:00
parent f881c19bb6
commit 7406dda074
2 changed files with 4 additions and 7 deletions

View File

@@ -89,10 +89,10 @@ func (f *SecretFactory) MakeSecret(args *types.SecretArgs) (*corev1.Secret, erro
func addKvToSecret(secret *corev1.Secret, keyName, data string) error {
// Note, the rules for SecretKeys keys are the exact same as the ones for ConfigMap.
if errs := validation.IsConfigMapKey(keyName); len(errs) != 0 {
return fmt.Errorf("%q is not a valid key name for a ConfigMap: %s", keyName, strings.Join(errs, ";"))
return fmt.Errorf("%q is not a valid key name for a Secret: %s", keyName, strings.Join(errs, ";"))
}
if _, entryExists := secret.Data[keyName]; entryExists {
return fmt.Errorf("cannot add key %s, another key by that name already exists: %v", keyName, secret.Data)
return fmt.Errorf("cannot add key %s, another key by that name already exists", keyName)
}
secret.Data[keyName] = []byte(data)
return nil
@@ -110,7 +110,6 @@ func (f *SecretFactory) keyValuesFromCommands(sources map[string]string) ([]kvPa
var kvs []kvPair
for k, cmd := range sources {
content, err := f.createSecretKey(cmd)
fmt.Println("createSecretKey:", content)
if err != nil {
return nil, err
}

View File

@@ -120,17 +120,15 @@ type SecretArgs struct {
}
// CommandSources contains some generic sources for secrets.
// Only one field can be set.
type CommandSources struct {
// Map of keys to commands to generate the values
Commands map[string]string `json:"commands,omitempty" yaml:"literals,omitempty"`
Commands map[string]string `json:"commands,omitempty" yaml:"commands,omitempty"`
// EnvCommand to output lines of key=val pairs to create a secret.
// i.e. a Docker .env file or a .ini file.
EnvCommand string `json:"envCommand,omitempty" yaml:"env,omitempty"`
EnvCommand string `json:"envCommand,omitempty" yaml:"envCommand,omitempty"`
}
// DataSources contains some generic sources for configmaps.
// Only one field can be set.
type DataSources struct {
// LiteralSources is a list of literal sources.
// Each literal source should be a key and literal value,