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

config: refactor config.go #1353

Merged
merged 1 commit into from
Apr 19, 2018
Merged

config: refactor config.go #1353

merged 1 commit into from
Apr 19, 2018

Conversation

aaithal
Copy link
Contributor

@aaithal aaithal commented Apr 18, 2018

Summary

config: refactor config.go

Implementation details

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

Testing

  • Builds on Linux (make release)
  • Builds on Windows (go build -out amazon-ecs-agent.exe ./agent)
  • Unit tests on Linux (make test) pass
  • Unit tests on Windows (go test -timeout=25s ./agent/...) pass
  • Integration tests on Linux (make run-integ-tests) pass
  • Integration tests on Windows (.\scripts\run-integ-tests.ps1) pass
  • Functional tests on Linux (make run-functional-tests) pass
  • Functional tests on Windows (.\scripts\run-functional-tests.ps1) pass

New 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.

@aaithal aaithal added this to the 1.18.0 milestone Apr 18, 2018
Copy link

@richardpen richardpen left a comment

Choose a reason for hiding this comment

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

LGTM, minor comment

if len(errs) != 0 {
err = apierrors.NewMultiError(errs...)
} else {
err = nil

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not?

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.

Copy link
Contributor Author

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.

@aaithal aaithal force-pushed the refactorConfigPackage branch 2 times, most recently from a5f4ed1 to 7be6465 Compare April 19, 2018 17:43
// considered fatal.
func NewConfig(ec2client ec2.EC2MetadataClient) (*Config, error) {
var errs []error
var errTmp error
Copy link
Contributor

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

Copy link
Contributor

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?


var err error
if len(errs) > 0 {
err = apierrors.NewMultiError(errs...)
} else {
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.

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
@aaithal aaithal force-pushed the refactorConfigPackage branch from 7be6465 to 71ab5ea Compare April 19, 2018 18:30
@aaithal aaithal merged commit b98c4cf into aws:dev Apr 19, 2018
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