Skip to content

Commit aab947d

Browse files
committed
cli/config/types: update deprecation comment for AuthConfig.Email
Relates to [cli@27b2797], which forked this type from the Moby API, and [moby@6cfff7e], which made the same change on the API side. The Email field was originally used to create a new Docker Hub account through the `docker login` command. The `docker login` command could be used both to log in to an existing account (providing only username and password), or to create a new account (providing desired username and password, and an e-mail address to use for the new account). This functionality was confusing, because it was implemented when Docker Hub was the only registry, but the same functionality could not be used for other registries. This functionality was removed in Docker 1.11 (API version 1.23) through [moby@aee260d], which also removed the Email field ([engine-api@9a9e468]) as it was no longer used. However, this caused issues when using a new CLI connecting with an old daemon, as the field would no longer be serialized, and the deprecation may not yet be picked up by custom registries, so [engine-api@167efc7] added the field back, deprecated it, and added an "omitempty". There was no official "deprecated" format yet at the time, so let's make sure the deprecation follows the proper format to make sure it gets noticed. [cli@27b2797]: 27b2797 [moby@6cfff7e]: moby/moby@6cfff7e [moby@aee260d]: moby/moby@aee260d [engine-api@9a9e468]: docker-archive-public/docker.engine-api@9a9e468 [engine-api@167efc7]: docker-archive-public/docker.engine-api@167efc7 Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 5ab12e6 commit aab947d

File tree

3 files changed

+30
-66
lines changed

3 files changed

+30
-66
lines changed

cli/config/credentials/file_store_test.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ func TestFileStoreIdempotent(t *testing.T) {
4343
},
4444
})
4545
authOne := types.AuthConfig{
46+
Username: "[email protected]",
4647
Auth: "super_secret_token",
47-
4848
ServerAddress: "https://example.com",
4949
}
5050
authTwo := types.AuthConfig{
51+
Username: "[email protected]",
5152
Auth: "also_super_secret_token",
52-
5353
ServerAddress: "https://other.example.com",
5454
}
5555

@@ -106,8 +106,8 @@ func TestFileStoreAddCredentials(t *testing.T) {
106106

107107
s := NewFileStore(f)
108108
auth := types.AuthConfig{
109+
Username: "[email protected]",
109110
Auth: "super_secret_token",
110-
111111
ServerAddress: "https://example.com",
112112
}
113113
err := s.Store(auth)
@@ -122,8 +122,8 @@ func TestFileStoreAddCredentials(t *testing.T) {
122122
func TestFileStoreGet(t *testing.T) {
123123
f := &fakeStore{configs: map[string]types.AuthConfig{
124124
"https://example.com": {
125+
Username: "[email protected]",
125126
Auth: "super_secret_token",
126-
127127
ServerAddress: "https://example.com",
128128
},
129129
}}
@@ -136,8 +136,8 @@ func TestFileStoreGet(t *testing.T) {
136136
if a.Auth != "super_secret_token" {
137137
t.Fatalf("expected auth `super_secret_token`, got %s", a.Auth)
138138
}
139-
if a.Email != "[email protected]" {
140-
t.Fatalf("expected email `[email protected]`, got %s", a.Email)
139+
if a.Username != "[email protected]" {
140+
t.Fatalf("expected username `[email protected]`, got %s", a.Username)
141141
}
142142
}
143143

@@ -146,13 +146,13 @@ func TestFileStoreGetAll(t *testing.T) {
146146
s2 := "https://example2.example.com"
147147
f := &fakeStore{configs: map[string]types.AuthConfig{
148148
s1: {
149+
Username: "[email protected]",
149150
Auth: "super_secret_token",
150-
151151
ServerAddress: "https://example.com",
152152
},
153153
s2: {
154+
Username: "[email protected]",
154155
Auth: "super_secret_token2",
155-
156156
ServerAddress: "https://example2.example.com",
157157
},
158158
}}
@@ -168,22 +168,22 @@ func TestFileStoreGetAll(t *testing.T) {
168168
if as[s1].Auth != "super_secret_token" {
169169
t.Fatalf("expected auth `super_secret_token`, got %s", as[s1].Auth)
170170
}
171-
if as[s1].Email != "[email protected]" {
172-
t.Fatalf("expected email `[email protected]`, got %s", as[s1].Email)
171+
if as[s1].Username != "[email protected]" {
172+
t.Fatalf("expected username `[email protected]`, got %s", as[s1].Username)
173173
}
174174
if as[s2].Auth != "super_secret_token2" {
175175
t.Fatalf("expected auth `super_secret_token2`, got %s", as[s2].Auth)
176176
}
177-
if as[s2].Email != "[email protected]" {
178-
t.Fatalf("expected email `[email protected]`, got %s", as[s2].Email)
177+
if as[s2].Username != "[email protected]" {
178+
t.Fatalf("expected username `[email protected]`, got %s", as[s2].Username)
179179
}
180180
}
181181

182182
func TestFileStoreErase(t *testing.T) {
183183
f := &fakeStore{configs: map[string]types.AuthConfig{
184184
"https://example.com": {
185+
Username: "[email protected]",
185186
Auth: "super_secret_token",
186-
187187
ServerAddress: "https://example.com",
188188
},
189189
}}
@@ -203,9 +203,6 @@ func TestFileStoreErase(t *testing.T) {
203203
if a.Auth != "" {
204204
t.Fatalf("expected empty auth token, got %s", a.Auth)
205205
}
206-
if a.Email != "" {
207-
t.Fatalf("expected empty email, got %s", a.Email)
208-
}
209206
}
210207

211208
func TestConvertToHostname(t *testing.T) {

cli/config/credentials/native_store_test.go

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func TestNativeStoreAddCredentials(t *testing.T) {
9999
auth := types.AuthConfig{
100100
Username: "foo",
101101
Password: "bar",
102-
103102
ServerAddress: validServerAddress,
104103
}
105104
err := s.Store(auth)
@@ -109,7 +108,6 @@ func TestNativeStoreAddCredentials(t *testing.T) {
109108
actual, ok := f.GetAuthConfigs()[validServerAddress]
110109
assert.Check(t, ok)
111110
expected := types.AuthConfig{
112-
Email: auth.Email,
113111
ServerAddress: auth.ServerAddress,
114112
}
115113
assert.Check(t, is.DeepEqual(expected, actual))
@@ -124,7 +122,6 @@ func TestNativeStoreAddInvalidCredentials(t *testing.T) {
124122
err := s.Store(types.AuthConfig{
125123
Username: "foo",
126124
Password: "bar",
127-
128125
ServerAddress: invalidServerAddress,
129126
})
130127
assert.ErrorContains(t, err, "program failed")
@@ -134,7 +131,7 @@ func TestNativeStoreAddInvalidCredentials(t *testing.T) {
134131
func TestNativeStoreGet(t *testing.T) {
135132
f := &fakeStore{configs: map[string]types.AuthConfig{
136133
validServerAddress: {
137-
134+
Username: "[email protected]",
138135
},
139136
}}
140137
s := &nativeStore{
@@ -147,17 +144,14 @@ func TestNativeStoreGet(t *testing.T) {
147144
expected := types.AuthConfig{
148145
Username: "foo",
149146
Password: "bar",
150-
151147
ServerAddress: validServerAddress,
152148
}
153149
assert.Check(t, is.DeepEqual(expected, actual))
154150
}
155151

156152
func TestNativeStoreGetIdentityToken(t *testing.T) {
157153
f := &fakeStore{configs: map[string]types.AuthConfig{
158-
validServerAddress2: {
159-
160-
},
154+
validServerAddress2: {},
161155
}}
162156

163157
s := &nativeStore{
@@ -169,17 +163,14 @@ func TestNativeStoreGetIdentityToken(t *testing.T) {
169163

170164
expected := types.AuthConfig{
171165
IdentityToken: "abcd1234",
172-
173166
ServerAddress: validServerAddress2,
174167
}
175168
assert.Check(t, is.DeepEqual(expected, actual))
176169
}
177170

178171
func TestNativeStoreGetAll(t *testing.T) {
179172
f := &fakeStore{configs: map[string]types.AuthConfig{
180-
validServerAddress: {
181-
182-
},
173+
validServerAddress: {},
183174
}}
184175

185176
s := &nativeStore{
@@ -189,38 +180,20 @@ func TestNativeStoreGetAll(t *testing.T) {
189180
as, err := s.GetAll()
190181
assert.NilError(t, err)
191182
assert.Check(t, is.Len(as, 2))
192-
193-
if as[validServerAddress].Username != "foo" {
194-
t.Fatalf("expected username `foo` for %s, got %s", validServerAddress, as[validServerAddress].Username)
195-
}
196-
if as[validServerAddress].Password != "bar" {
197-
t.Fatalf("expected password `bar` for %s, got %s", validServerAddress, as[validServerAddress].Password)
198-
}
199-
if as[validServerAddress].IdentityToken != "" {
200-
t.Fatalf("expected identity to be empty for %s, got %s", validServerAddress, as[validServerAddress].IdentityToken)
201-
}
202-
if as[validServerAddress].Email != "[email protected]" {
203-
t.Fatalf("expected email `[email protected]` for %s, got %s", validServerAddress, as[validServerAddress].Email)
204-
}
205-
if as[validServerAddress2].Username != "" {
206-
t.Fatalf("expected username to be empty for %s, got %s", validServerAddress2, as[validServerAddress2].Username)
207-
}
208-
if as[validServerAddress2].Password != "" {
209-
t.Fatalf("expected password to be empty for %s, got %s", validServerAddress2, as[validServerAddress2].Password)
210-
}
211-
if as[validServerAddress2].IdentityToken != "abcd1234" {
212-
t.Fatalf("expected identity token `abcd1324` for %s, got %s", validServerAddress2, as[validServerAddress2].IdentityToken)
213-
}
214-
if as[validServerAddress2].Email != "" {
215-
t.Fatalf("expected no email for %s, got %s", validServerAddress2, as[validServerAddress2].Email)
183+
expected := types.AuthConfig{
184+
Username: "foo",
185+
Password: "bar",
186+
ServerAddress: "https://index.docker.io/v1",
187+
IdentityToken: "",
216188
}
189+
actual, ok := as[validServerAddress]
190+
assert.Check(t, ok)
191+
assert.Check(t, is.DeepEqual(expected, actual))
217192
}
218193

219194
func TestNativeStoreGetMissingCredentials(t *testing.T) {
220195
f := &fakeStore{configs: map[string]types.AuthConfig{
221-
validServerAddress: {
222-
223-
},
196+
validServerAddress: {},
224197
}}
225198

226199
s := &nativeStore{
@@ -233,9 +206,7 @@ func TestNativeStoreGetMissingCredentials(t *testing.T) {
233206

234207
func TestNativeStoreGetInvalidAddress(t *testing.T) {
235208
f := &fakeStore{configs: map[string]types.AuthConfig{
236-
validServerAddress: {
237-
238-
},
209+
validServerAddress: {},
239210
}}
240211

241212
s := &nativeStore{
@@ -248,9 +219,7 @@ func TestNativeStoreGetInvalidAddress(t *testing.T) {
248219

249220
func TestNativeStoreErase(t *testing.T) {
250221
f := &fakeStore{configs: map[string]types.AuthConfig{
251-
validServerAddress: {
252-
253-
},
222+
validServerAddress: {},
254223
}}
255224

256225
s := &nativeStore{
@@ -264,9 +233,7 @@ func TestNativeStoreErase(t *testing.T) {
264233

265234
func TestNativeStoreEraseInvalidAddress(t *testing.T) {
266235
f := &fakeStore{configs: map[string]types.AuthConfig{
267-
validServerAddress: {
268-
269-
},
236+
validServerAddress: {},
270237
}}
271238

272239
s := &nativeStore{

cli/config/types/authconfig.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ type AuthConfig struct {
77
Auth string `json:"auth,omitempty"`
88

99
// Email is an optional value associated with the username.
10-
// This field is deprecated and will be removed in a later
11-
// version of docker.
10+
//
11+
// Deprecated: This field is deprecated since docker 1.11 (API v1.23) and will be removed in the next release.
1212
Email string `json:"email,omitempty"`
1313

1414
ServerAddress string `json:"serveraddress,omitempty"`

0 commit comments

Comments
 (0)