Skip to content
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

feat/provider: read .scwrc #111

Merged
merged 1 commit into from
Mar 8, 2019
Merged

feat/provider: read .scwrc #111

merged 1 commit into from
Mar 8, 2019

Conversation

nicolai86
Copy link
Contributor

@nicolai86 nicolai86 commented Feb 15, 2019

once merged, the provider will fallback to scaleways ~/.scwrc to get
access credentials.

closes #104

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @nicolai86

Thanks for this PR - taking a look through this mostly LGTM, if we can address the comments this otherwise should be good 👍

Thanks!

defer f.Close()

var data scalewayConfig
err = json.NewDecoder(f).Decode(&data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there's an error parsing this should we also return:

Suggested change
err = json.NewDecoder(f).Decode(&data)
err = json.NewDecoder(f).Decode(&data)
if err != nil {
return "", "", err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I'll update this

if apiKey == "" {
if path, err := homedir.Expand(d.Get(".scwrc").(string)); err == nil {
scwAPIKey, scwOrganization, err := readScalewayConfig(path)
if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we invert this and raise this error?

Suggested change
if err == nil {
if err != nil {
return fmt.Errorf("Error loading credentials from SCW: %s", err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a miss, yes it should be inverted

scaleway/provider.go Show resolved Hide resolved
@ghost ghost added size/M and removed size/S labels Mar 8, 2019
@nicolai86
Copy link
Contributor Author

Ran all the tests over night, without setting environment variables - they all passed. Will pull this in :)

@nicolai86 nicolai86 merged commit 489881d into master Mar 8, 2019
@nicolai86 nicolai86 deleted the feat/read-scwrc branch March 8, 2019 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Read Organization ID and API Token from ~/.scwrc
2 participants