mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Avoid unnecessary shell execution in secretFactory.
This commit is contained in:
@@ -72,22 +72,23 @@ func (f *SecretFactory) MakeSecret(args *types.SecretArgs, options *types.Genera
|
||||
log.Println("SecretArgs.TimeoutSeconds will be deprected in next release. Please use GeneratorOptions.TimeoutSeconds instread.")
|
||||
timeout = time.Duration(*args.TimeoutSeconds) * time.Second
|
||||
}
|
||||
|
||||
pairs, err := f.keyValuesFromEnvFileCommand(args.EnvCommand, timeout, options)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf(
|
||||
"env source file: %s",
|
||||
args.EnvCommand))
|
||||
if args.EnvCommand != "" {
|
||||
pairs, err := f.keyValuesFromEnvFileCommand(args.EnvCommand, timeout, options)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf(
|
||||
"env source file: %s",
|
||||
args.EnvCommand))
|
||||
}
|
||||
all = append(all, pairs...)
|
||||
}
|
||||
all = append(all, pairs...)
|
||||
|
||||
pairs, err = f.keyValuesFromCommands(args.Commands, timeout, options)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf(
|
||||
"commands %v", args.Commands))
|
||||
if len(args.Commands) != 0 {
|
||||
pairs, err := f.keyValuesFromCommands(args.Commands, timeout, options)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf(
|
||||
"commands %v", args.Commands))
|
||||
}
|
||||
all = append(all, pairs...)
|
||||
}
|
||||
all = append(all, pairs...)
|
||||
|
||||
for _, kv := range all {
|
||||
err = addKvToSecret(s, kv.key, kv.value)
|
||||
if err != nil {
|
||||
|
||||
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package configmapandsecret
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/pkg/fs"
|
||||
@@ -55,11 +54,8 @@ func TestMakeSecretNoCommandsBadDir(t *testing.T) {
|
||||
EnvCommand: "",
|
||||
}}
|
||||
_, err := factory.MakeSecret(&args, nil)
|
||||
if err == nil {
|
||||
t.Fatalf("expected error: %v", err)
|
||||
}
|
||||
if !strings.Contains(err.Error(), "not a directory") {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user