-
Notifications
You must be signed in to change notification settings - Fork 617
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
Conversation
agent/config/types_test.go
Outdated
@@ -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") |
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.
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("") |
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.
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
agent/config/config_test.go
Outdated
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") |
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.
Please extract "TestConfig"
into a var/const (here and in the next test)
agent/config/config_test.go
Outdated
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") |
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.
Please extract "dockercfg"
into a var/const (here and in the next test)
agent/config/types.go
Outdated
@@ -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 { |
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.
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.
Summary
Fix issue #732
Implementation details
Return an nil instead of an empty object for dockerauth.
Testing
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:
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