Skip to content

Conversation

@fflorens
Copy link

Simple commit to add the ability to use an arbitrary config file instead of ~/.scwrc

@remyleone
Copy link
Member

LGTM

@brmzkw
Copy link
Contributor

brmzkw commented Aug 27, 2018

It would be great to add an unittest

pkg/cli/main.go Outdated
flag.CommandLine.Parse(rawArgs)

if *flConfig != "" {
os.Setenv("SCW_CONFIG_PATH", *flConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should not set the environment variable here, but instead return a default if SCW_CONFIG_PATH is not set below in pkg/config/config.go.

Convey("Testing SaveConfig() with env variable", t, func() {
os.Setenv("SCW_CONFIG_PATH", "./config_testdata2")
rand_org := strconv.FormatInt(rand.Int63(), 16)
rand_token := strconv.FormatInt(rand.Int63(), 16)

Choose a reason for hiding this comment

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

don't use underscores in Go names; var rand_token should be randToken

func TestSave(t *testing.T) {
Convey("Testing SaveConfig() with env variable", t, func() {
os.Setenv("SCW_CONFIG_PATH", "./config_testdata2")
rand_org := strconv.FormatInt(rand.Int63(), 16)

Choose a reason for hiding this comment

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

don't use underscores in Go names; var rand_org should be randOrg

@fflorens
Copy link
Author

fflorens commented Aug 29, 2018

I've cleaned up the commit history, and added the option to specify the orgID and token via env variables too
Also revolved the previous comments

@fflorens
Copy link
Author

Rebased against master

@brmzkw brmzkw merged commit 8c7c75e into scaleway:master Sep 28, 2018
@brmzkw
Copy link
Contributor

brmzkw commented Sep 28, 2018

thanks! <3

clement-gilbert pushed a commit to clement-gilbert/scaleway-cli that referenced this pull request Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants