forked from toolshed/abra
feat: add app secret rm
This commit is contained in:
@ -65,6 +65,13 @@ func ParseSecretEnvVarName(secretEnvVar string) string {
|
||||
return strings.ToLower(withoutSuffix)
|
||||
}
|
||||
|
||||
func ParseGeneratedSecretName(secret string, appEnv config.App) string {
|
||||
name := fmt.Sprintf("%s_", appEnv.StackName())
|
||||
withoutAppName := strings.TrimPrefix(secret, name)
|
||||
idx := strings.LastIndex(withoutAppName, "_")
|
||||
return withoutAppName[:idx]
|
||||
}
|
||||
|
||||
func ParseSecretEnvVarValue(secretValue string) (SecretValue, error) {
|
||||
values := strings.Split(secretValue, "#")
|
||||
if len(values) == 0 {
|
||||
@ -150,3 +157,21 @@ func PassInsertSecret(secretValue, secretName, appName, server string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func PassRmSecret(secretName, appName, server string) error {
|
||||
_, err := exec.LookPath("pass")
|
||||
if err != nil {
|
||||
return errors.New("pass cannot be found on your $PATH, is it installed?")
|
||||
}
|
||||
|
||||
cmd := fmt.Sprintf(
|
||||
"pass rm --force hosts/%s/%s/%s",
|
||||
server, appName, secretName,
|
||||
)
|
||||
|
||||
if err := exec.Command("bash", "-c", cmd).Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user