Skip to content

Commit 4c6f586

Browse files
authored
Merge pull request moby#50426 from thaJeztah/no_empty_auth
api/types/registry: EncodeAuthConfig: use empty string for zero value
2 parents 098ff1a + 3a447bc commit 4c6f586

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

api/types/registry/authconfig.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ type AuthConfig struct {
5252
//
5353
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
5454
func EncodeAuthConfig(authConfig AuthConfig) (string, error) {
55+
if authConfig == (AuthConfig{}) {
56+
return "", nil
57+
}
5558
buf, err := json.Marshal(authConfig)
5659
if err != nil {
5760
return "", errInvalidParameter{err}

api/types/registry/authconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ func TestEncodeAuthConfig(t *testing.T) {
111111
{
112112
doc: "empty",
113113
input: AuthConfig{},
114-
outBase64: `e30=`,
115-
outPlain: `{}`,
114+
outBase64: ``,
115+
outPlain: ``,
116116
},
117117
{
118118
doc: "test authConfig",

0 commit comments

Comments
 (0)