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 <[email protected]>
  • Loading branch information
kaovilai committed Oct 24, 2023
1 parent 941dd00 commit 1528d8b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/6995-kaovilai
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix unified repository (kopia) s3 credentials profile selection
6 changes: 6 additions & 0 deletions config/crd/v1/bases/velero.io_restores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ spec:
- Continue
- Fail
type: string
waitForReady:
description: WaitForReady ensures command will
be launched when container is Ready instead
of Running.
nullable: true
type: boolean
waitTimeout:
description: WaitTimeout defines the maximum amount
of time Velero should wait for the container
Expand Down
4 changes: 2 additions & 2 deletions config/crd/v1/crds/crds.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pkg/apis/velero/v1/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 @@ -62,7 +62,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 65 in pkg/repository/config/aws.go

View check run for this annotation

Codecov / codecov/patch

pkg/repository/config/aws.go#L65

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

Expand All @@ -87,6 +87,7 @@ func GetS3Credentials(config map[string]string) (*aws.Credentials, error) {
// as credentials of a BSL
awsconfig.WithSharedConfigFiles([]string{credentialsFile}))
}
opts = append(opts, awsconfig.WithSharedConfigProfile(config[awsProfileKey]))

cfg, err := awsconfig.LoadDefaultConfig(context.Background(), opts...)
if err != nil {
Expand Down

0 comments on commit 1528d8b

Please sign in to comment.