Fix: Secret interpolation not working as intended for fetching secrets by name

This commit is contained in:
Daniel Hougaard
2024-04-12 14:05:43 +02:00
parent 51f164c399
commit 71575b1d2e

View File

@@ -478,6 +478,17 @@ func getSecretsByNames(cmd *cobra.Command, args []string) {
util.HandleError(err, "To fetch all secrets")
}
if shouldExpand {
authParams := models.ExpandSecretsAuthentication{}
if token != nil && token.Type == "service-token" {
authParams.InfisicalToken = token.Token
} else if token != nil && token.Type == "universal-auth-token" {
authParams.UniversalAuthAccessToken = token.Token
}
secrets = util.ExpandSecrets(secrets, authParams, "")
}
requestedSecrets := []models.SingleEnvironmentVariable{}
secretsMap := getSecretsByKeys(secrets)
@@ -494,18 +505,6 @@ func getSecretsByNames(cmd *cobra.Command, args []string) {
}
}
if shouldExpand {
authParams := models.ExpandSecretsAuthentication{}
if token != nil && token.Type == "service-token" {
authParams.InfisicalToken = token.Token
} else if token != nil && token.Type == "universal-auth-token" {
authParams.UniversalAuthAccessToken = token.Token
}
requestedSecrets = util.ExpandSecrets(requestedSecrets, authParams, "")
}
if showOnlyValue && len(requestedSecrets) > 1 {
util.PrintErrorMessageAndExit("--raw-value only works with one secret.")
}