Skip to content

Commit

Permalink
kopia/repository/config/aws.go: Set session.Options profile from config
Browse files Browse the repository at this point in the history
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
  • Loading branch information
kaovilai committed Oct 20, 2023
1 parent 5c4fdfe commit 01cc1bd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/6997-kaovilai
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix unified repository (kopia) s3 credentials profile selection
31 changes: 2 additions & 29 deletions pkg/apis/velero/v2alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/repository/config/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func GetS3ResticEnvVars(config map[string]string) (map[string]string, error) {
result[awsSecretKeyEnvVar] = creds.SecretAccessKey
result[awsSessTokenEnvVar] = creds.SessionToken
result[awsCredentialsFileEnvVar] = ""
result[awsProfileEnvVar] = ""
result[awsProfileEnvVar] = "" // profile is not needed since we have the credentials from profile via GetS3Credentials

Check warning on line 67 in pkg/repository/config/aws.go

View check run for this annotation

Codecov / codecov/patch

pkg/repository/config/aws.go#L67

Added line #L67 was not covered by tests
result[awsConfigFileEnvVar] = ""
}

Expand All @@ -87,6 +87,7 @@ func GetS3Credentials(config map[string]string) (*credentials.Value, error) {
opts.SharedConfigFiles = append(opts.SharedConfigFiles, credentialsFile)
opts.SharedConfigState = session.SharedConfigEnable
}
opts.Profile = config[awsProfileKey]

sess, err := session.NewSessionWithOptions(opts)
if err != nil {
Expand Down

0 comments on commit 01cc1bd

Please sign in to comment.