From ad0d42f397288fe69a563ae5dce1ab764106687a Mon Sep 17 00:00:00 2001 From: Felipe Hernandez Date: Fri, 18 Oct 2024 13:05:46 -0500 Subject: [PATCH] feat: return error when occurs from secrets flow --- api/secrets/secrets.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/secrets/secrets.go b/api/secrets/secrets.go index 38c4642..c901616 100644 --- a/api/secrets/secrets.go +++ b/api/secrets/secrets.go @@ -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) @@ -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 } @@ -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 } @@ -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.