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

Fix the docker auth configuration overrides problem in #732 #751

Merged
merged 1 commit into from
Apr 13, 2017

Conversation

richardpen
Copy link

@richardpen richardpen commented Apr 4, 2017

Summary

Fix issue #732

Implementation details

Return an nil instead of an empty object for dockerauth.

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:
yes

Description for the changelog

Fix an issue where docker auth information can't be correctly read from file

Licensing

This contribution is under the terms of the Apache 2.0 License:
yes

@@ -37,7 +39,14 @@ func TestSensitiveRawMessage(t *testing.T) {
fmt.Sprint(sensitive),
} {
if str != "[redacted]" {
t.Errorf("#%v: expected redacted, got %s", i, str)
assert.Equal(t, i, str, "expected redacted")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove the if and just have assert.Equal?

@@ -146,9 +147,13 @@ func NewDockerGoClient(clientFactory dockerclient.Factory, cfg *config.Config) (
return nil, err
}

dockerAuthData := json.RawMessage("")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use var dockerAuthData json.RawMessage instead? Somehow seems cleaner to me than parsing an empty string. FWIW, this is how it's being initialized in encoding/stream.go: https://golang.org/src/encoding/json/stream.go#L266

config, err := fileConfig()
assert.NoError(t, err, "reading configuration from file failed")

assert.Equal(t, "TestConfig", config.Cluster, "cluster name not as expected from file")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please extract "TestConfig" into a var/const (here and in the next test)

assert.NoError(t, err, "reading configuration from file failed")

assert.Equal(t, "TestConfig", config.Cluster, "cluster name not as expected from file")
assert.Equal(t, "dockercfg", config.EngineAuthType, "docker auth type not as expected from file")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please extract "dockercfg" into a var/const (here and in the next test)

@@ -157,6 +157,9 @@ type SensitiveRawMessage struct {
// NewSensitiveRawMessage returns a new encapsulated json.RawMessage that
// cannot be accidentally logged via .String/.GoString/%v/%#v
func NewSensitiveRawMessage(data json.RawMessage) *SensitiveRawMessage {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the documentation that this can now return nil when invoked with empty data

DockerAuth returned as an empty object(which is not nil) when it is not
set from environment variable, which won't be overrides from contents
read from file.
@richardpen richardpen merged commit 2ca970b into aws:dev Apr 13, 2017
@samuelkarp samuelkarp added this to the 1.14.2 milestone May 25, 2017
@adnxn adnxn mentioned this pull request May 26, 2017
@richardpen richardpen deleted the issue-732 branch November 21, 2017 01:02
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.

3 participants