-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perform exhaustive region discovery #9
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9 +/- ##
=======================================
Coverage 89.34% 89.34%
=======================================
Files 7 7
Lines 779 779
=======================================
Hits 696 696
Misses 54 54
Partials 29 29 Continue to review full report at Codecov.
|
cmd/main.go
Outdated
if defaultProfileRegion, err := getProfileRegion(defaultProfile); err == nil { | ||
sess.Config.Region = &defaultProfileRegion | ||
} | ||
if sess.Config.Region == nil || *sess.Config.Region == "" { | ||
if defaultRegion, ok := os.LookupEnv(defaultRegionEnvVar); ok && defaultRegion != "" { | ||
sess.Config.Region = &defaultRegion | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add some logs in here when the resolution fails? Similar to line 273
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to add warning in the other places because they're not required to be specified, so I didn't want a warning to come up all the time when someone only has their AWS_REGION env var set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did add a new pretty long error message when no region could be found that specifies the places it looked.
cmd/main.go
Outdated
|
||
func getProfileRegion(profileName string) (string, error) { | ||
if profileName != defaultProfile { | ||
profileName = fmt.Sprintf("%s %s", "profile", profileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this better than writing fmt.Sprintf("profile %s", profileName)
? Also, why not print when it's the default profile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha nope, fmt.Sprintf("profile %s", profileName)
is way clearer :)
But it's not printing, it's creating a string with the static string "profile" prepended. The AWS config file prepends profile for custom profiles but does not for the "default" profile.
Here's an example file:
$ cat ~/.aws/config
[default]
region = us-east-1
output = json
[profile jason]
region = us-east-2
output = json
[profile test]
output = json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
Issue #, if available:
N/A
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.