-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
Move config loading out of main and add tests for it #413
Conversation
conf.LicenseType, | ||
conf.PatchBeanstalkUserdata, | ||
) | ||
log.Printf("Configuration flags: %#v", conf) |
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.
Pulled this change from #354.
@@ -88,3 +93,103 @@ type Config struct { | |||
// authentication method | |||
PatchBeanstalkUserdata string | |||
} | |||
|
|||
// ParseConfig loads configuration from command line flags, environments variables, and config files. | |||
func ParseConfig(conf *Config) { |
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.
Function ParseConfig
has 85 lines of code (exceeds 50 allowed). Consider refactoring.
core/config.go
Outdated
"\tExample: ./AutoSpotting --patch_beanstalk_userdata true\n") | ||
|
||
printVersion := flagSet.Bool("version", false, "Print version number and exit.\n") | ||
flagSet.Parse(os.Args[1:]) |
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.
Error return value of flagSet.Parse
is not checked (from errcheck
)
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.
Fixed
@@ -88,3 +93,103 @@ type Config struct { | |||
// authentication method | |||
PatchBeanstalkUserdata string | |||
} | |||
|
|||
// ParseConfig loads configuration from command line flags, environments variables, and config files. | |||
func ParseConfig(conf *Config) { |
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.
Renamed from parseCommandLineFlags
since it loads config from environment variables and config files too.
4129535
to
acf5ea2
Compare
@@ -88,3 +93,106 @@ type Config struct { | |||
// authentication method | |||
PatchBeanstalkUserdata string | |||
} | |||
|
|||
// ParseConfig loads configuration from command line flags, environments variables, and config files. | |||
func ParseConfig(conf *Config) { |
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.
Function ParseConfig
has 87 lines of code (exceeds 50 allowed). Consider refactoring.
"testing" | ||
"time" | ||
|
||
"gotest.tools/v3/assert" |
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 can remove this, but it makes writing assertions a lot easier. It also has a package for testing binaries, which I think will be useful to get autospotting.go
under test.
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.
Thanks, I'll check it out.
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.
Thanks for your contribution!
core/config.go
Outdated
conf.LogFlag = log.Ldate | log.Ltime | log.Lshortfile | ||
conf.MainRegion = region | ||
conf.SleepMultiplier = 1 | ||
conf.LicenseType = os.Getenv("LICENSE") |
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.
This looks unnecessary, it should be handled below
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.
Thanks, that was copied from the old parseCommandLineFlags
. Updated.
The loading of config was previously untested.
acf5ea2
to
322c16a
Compare
@@ -88,3 +93,105 @@ type Config struct { | |||
// authentication method | |||
PatchBeanstalkUserdata string | |||
} | |||
|
|||
// ParseConfig loads configuration from command line flags, environments variables, and config files. | |||
func ParseConfig(conf *Config) { |
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.
Function ParseConfig
has 86 lines of code (exceeds 50 allowed). Consider refactoring.
Code Climate has analyzed commit 322c16a and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
The loading of config was previously untested.
Issue Type
Summary
Move
parseCommandLineFlags
intoconfig.go
and add some tests for it.Code contribution checklist
code under any software license.
to it.
guidelines.
test coverage doesn't decrease.
make full-test
.variables which are also passed as parameters to the
CloudFormation
and
Terraform
stacks defined as infrastructure code.
support per-group overrides using tags.
configurations.
proven to work using log output from various test runs.
appropriate) and formatted consistently to the existing log output.
new configuration options for both stack parameters and tag overrides.
contribution actually resolves it.