-
Notifications
You must be signed in to change notification settings - Fork 619
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
config: refactor config.go #1353
Conversation
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.
LGTM, minor comment
agent/config/config.go
Outdated
if len(errs) != 0 { | ||
err = apierrors.NewMultiError(errs...) | ||
} else { | ||
err = nil |
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 don't think you need this?
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.
why not?
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 thought the err
is nil
by default.
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.
Just noticed the named return here. urgh. i'll modify this to get rid of that.
a5f4ed1
to
7be6465
Compare
agent/config/config.go
Outdated
// considered fatal. | ||
func NewConfig(ec2client ec2.EC2MetadataClient) (*Config, error) { | ||
var errs []error | ||
var errTmp error |
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.
nit: this can be removed
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.
and probably just call it err
?
agent/config/config.go
Outdated
|
||
var err error | ||
if len(errs) > 0 { | ||
err = apierrors.NewMultiError(errs...) | ||
} else { | ||
err = nil |
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.
nit: this can be removed
The environtConfig() method, spanning few 150 odd lines has now been broken down so that it's easier to read and debug. Parsing individual config fields has been refactored into multiple parse* methods in the parse.go file
7be6465
to
71ab5ea
Compare
Summary
config: refactor config.go
Implementation details
The
environtConfig()
method, spanning few 150 odd lines has now beenbroken down so that it's easier to read and debug. Parsing individual
config fields has been refactored into multiple
parse*
methods inthe
parse.go
fileTesting
make release
)go build -out amazon-ecs-agent.exe ./agent
)make test
) passgo test -timeout=25s ./agent/...
) passmake run-integ-tests
) pass.\scripts\run-integ-tests.ps1
) passmake run-functional-tests
) pass.\scripts\run-functional-tests.ps1
) passNew tests cover the changes:
Description for the changelog
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.