Skip to content

Commit

Permalink
Bypass it when a config is invalid.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjbae1212 committed Sep 3, 2021
1 parent dd5f3c6 commit 41a8287
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ builds:
- all=-trimpath={{.Env.GOPATH}}
ldflags:
- -s -w
- -X main.gossmVersion=v1.4.0 # version
- -X main.gossmVersion=v1.4.1 # version
ignore:
- goos: windows
goarch: arm64
Expand Down
10 changes: 5 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ func initConfig() {
} else {
sharedCredFile, err = filepath.Abs(sharedCredFile)
if err != nil {
color.Red("[err] invalid AWS_SHARED_CREDENTIALS_FILE environments path, such as %w", err)
color.Yellow("[Warning] invalid AWS_SHARED_CREDENTIALS_FILE environments path, such as %w", err)
os.Unsetenv("AWS_SHARED_CREDENTIALS_FILE")
sharedCredFile = ""
} else {
if _, err := os.Stat(sharedCredFile); os.IsNotExist(err) {
color.Red("[err] not found AWS_SHARED_CREDENTIALS_FILE environments file, such as %s", sharedCredFile)
color.Yellow("[Warning] not found AWS_SHARED_CREDENTIALS_FILE environments file, such as %s", sharedCredFile)
os.Unsetenv("AWS_SHARED_CREDENTIALS_FILE")
sharedCredFile = ""
}
Expand Down Expand Up @@ -205,11 +205,11 @@ func initConfig() {
// get cred by only config
temporaryConfig, err = internal.NewSharedConfig(context.Background(), _credential.awsProfile,
[]string{config.DefaultSharedConfigFilename()}, []string{})
if err != nil {
panicRed(internal.WrapError(err))
if err == nil {
temporaryCredentials, err = temporaryConfig.Credentials.Retrieve(context.Background())
}

temporaryCredentials, err = temporaryConfig.Credentials.Retrieve(context.Background())
// error is raised or temporaryCredentials is invalid.
if err != nil || temporaryCredentials.Expired() ||
temporaryCredentials.AccessKeyID == "" || temporaryCredentials.SecretAccessKey == "" ||
(subcmd.Use == "mfa" && temporaryCredentials.SessionToken != "") {
Expand Down

0 comments on commit 41a8287

Please sign in to comment.