-
Notifications
You must be signed in to change notification settings - Fork 156
Add --config option for arbitrary config file #521
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
Conversation
|
LGTM |
|
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) |
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 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.
pkg/config/config_test.go
Outdated
| 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) |
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.
don't use underscores in Go names; var rand_token should be randToken
pkg/config/config_test.go
Outdated
| 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) |
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.
don't use underscores in Go names; var rand_org should be randOrg
|
I've cleaned up the commit history, and added the option to specify the orgID and token via env variables too |
SCW_API_TOKEN = your token to access the api SCW_API_ORGID = your organization ID to access the api
|
Rebased against master |
|
thanks! <3 |
Simple commit to add the ability to use an arbitrary config file instead of
~/.scwrc