Skip to content

Commit

Permalink
feat: return error when occurs from secrets flow
Browse files Browse the repository at this point in the history
  • Loading branch information
btfhernandez committed Oct 18, 2024
1 parent fab4782 commit ad0d42f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/secrets/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (secretObj *SecretObj) GetSecretFlow(secretsToRetrieve []string, separator
secretsToRetrieve = utils.ValidatePaths(secretsToRetrieve, false, separator, secretObj.log)
secretObj.log.Info(fmt.Sprintf("Retrieving %v Secrets", len(secretsToRetrieve)))
secretDictionary := make(map[string]string)
var saveLastErr error = nil

for _, secretToRetrieve := range secretsToRetrieve {
retrievalData := strings.Split(secretToRetrieve, separator)
Expand All @@ -65,9 +66,11 @@ func (secretObj *SecretObj) GetSecretFlow(secretsToRetrieve []string, separator
secretPath = strings.TrimSuffix(strings.Join(retrievalData, separator), separator)
}

var err error
secret, err := secretObj.SecretGetSecretByPath(secretPath, secretTitle, separator, "secrets-safe/secrets")

if err != nil {
saveLastErr = err
secretObj.log.Error(err.Error() + "secretPath:" + secretPath + separator + secretTitle)
continue
}
Expand All @@ -76,6 +79,7 @@ func (secretObj *SecretObj) GetSecretFlow(secretsToRetrieve []string, separator
if strings.ToUpper(secret.SecretType) == "FILE" {
fileSecretContent, err := secretObj.SecretGetFileSecret(secret.Id, "secrets-safe/secrets/")
if err != nil {
saveLastErr = err
secretObj.log.Error(err.Error() + "secretPath:" + secretPath + separator + secretTitle)
continue
}
Expand All @@ -93,7 +97,7 @@ func (secretObj *SecretObj) GetSecretFlow(secretsToRetrieve []string, separator
}
}

return secretDictionary, nil
return secretDictionary, saveLastErr
}

// SecretGetSecretByPath returns secret object for a specific path, title.
Expand Down

0 comments on commit ad0d42f

Please sign in to comment.