Skip to content

Commit

Permalink
fix: Omit versionId unless specified
Browse files Browse the repository at this point in the history
  • Loading branch information
jkayani committed Sep 7, 2021
1 parent 733d62d commit f7c18ea
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
6 changes: 2 additions & 4 deletions pkg/backends/awssecretsmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"

"github.com/IBM/argocd-vault-plugin/pkg/types"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/secretsmanager"
"github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface"
Expand All @@ -30,12 +29,11 @@ func (a *AWSSecretsManager) Login() error {
// GetSecrets gets secrets from aws secrets manager and returns the formatted data
func (a *AWSSecretsManager) GetSecrets(path string, version string, annotations map[string]string) (map[string]interface{}, error) {
input := &secretsmanager.GetSecretValueInput{
SecretId: aws.String(path),
VersionId: aws.String(types.AWSCurrentSecretVersion),
SecretId: aws.String(path),
}

if version != "" {
input.VersionId = aws.String(version)
input.SetVersionId(version)
}

result, err := a.Client.GetSecretValue(input)
Expand Down
3 changes: 1 addition & 2 deletions pkg/backends/awssecretsmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

"github.com/IBM/argocd-vault-plugin/pkg/backends"
"github.com/IBM/argocd-vault-plugin/pkg/types"
"github.com/aws/aws-sdk-go/service/secretsmanager"
"github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface"
)
Expand All @@ -19,7 +18,7 @@ func (m *mockSecretsManagerClient) GetSecretValue(input *secretsmanager.GetSecre

switch *input.SecretId {
case "test":
if *input.VersionId == types.AWSCurrentSecretVersion {
if input.VersionId == nil {
string := "{\"test-secret\":\"current-value\"}"
data.SecretString = &string
} else {
Expand Down
1 change: 0 additions & 1 deletion pkg/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const (
GithubAuth = "github"
IAMAuth = "iam"
AwsDefaultRegion = "us-east-2"
AWSCurrentSecretVersion = "AWSCURRENT"
GCPCurrentSecretVersion = "latest"

// Supported annotations
Expand Down

0 comments on commit f7c18ea

Please sign in to comment.