fix: better prompts & matching for secret removal
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
decentral1se 2022-03-13 10:59:19 +01:00
parent 6a50981120
commit 7f315315f0
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410

View File

@ -229,10 +229,10 @@ Example:
remoteSecretNames[cont.Spec.Annotations.Name] = true
}
match := false
secretToRm := c.Args().Get(1)
for sec := range secrets {
secretName := secret.ParseSecretEnvVarName(sec)
parsed := secret.ParseGeneratedSecretName(secretName, app)
secVal, err := secret.ParseSecretEnvVarValue(secrets[sec])
if err != nil {
@ -242,20 +242,31 @@ Example:
secretRemoteName := fmt.Sprintf("%s_%s_%s", app.StackName(), secretName, secVal.Version)
if _, ok := remoteSecretNames[secretRemoteName]; ok {
if secretToRm != "" {
if parsed == secretToRm {
if err := secretRm(cl, app, secretRemoteName, parsed); err != nil {
if secretName == secretToRm {
if err := secretRm(cl, app, secretRemoteName, secretName); err != nil {
logrus.Fatal(err)
}
return nil
}
} else {
if err := secretRm(cl, app, secretRemoteName, parsed); err != nil {
match = true
if err := secretRm(cl, app, secretRemoteName, secretName); err != nil {
logrus.Fatal(err)
}
}
}
}
if !match && secretToRm != "" {
logrus.Fatalf("%s doesn't exist on server?", secretToRm)
}
if !match {
logrus.Fatal("no secrets to remove?")
}
return nil
},
}