Browse code

Remove deprecated Docker Content Trust ENV passphrase variables

Since 1.9, Docker Content Trust Offline key has been renamed to
Root key and the Tagging key has been renamed to Repository key.
The corresponding environment variables
`DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE`
`DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE`
have also been deprecated and renamed to
`DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE`
`DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE`

This fix removed the deprecated ENV passphrase variables for
1.12 and updated the docs.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Yong Tang authored on 2016/05/08 01:26:34
Showing 4 changed files
... ...
@@ -217,22 +217,6 @@ func (cli *DockerCli) getPassphraseRetriever() passphrase.Retriever {
217 217
 		"default":  os.Getenv("DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE"),
218 218
 	}
219 219
 
220
-	// Backwards compatibility with old env names. We should remove this in 1.10
221
-	if env["root"] == "" {
222
-		if passphrase := os.Getenv("DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE"); passphrase != "" {
223
-			env["root"] = passphrase
224
-			fmt.Fprintf(cli.err, "[DEPRECATED] The environment variable DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE has been deprecated and will be removed in v1.10. Please use DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE\n")
225
-		}
226
-	}
227
-	if env["snapshot"] == "" || env["targets"] == "" || env["default"] == "" {
228
-		if passphrase := os.Getenv("DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE"); passphrase != "" {
229
-			env["snapshot"] = passphrase
230
-			env["targets"] = passphrase
231
-			env["default"] = passphrase
232
-			fmt.Fprintf(cli.err, "[DEPRECATED] The environment variable DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE has been deprecated and will be removed in v1.10. Please use DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE\n")
233
-		}
234
-	}
235
-
236 220
 	return func(keyName string, alias string, createNew bool, numAttempts int) (string, bool, error) {
237 221
 		if v := env[alias]; v != "" {
238 222
 			return v, numAttempts > 1, nil
... ...
@@ -140,9 +140,9 @@ Version 1.9 adds a flag (`--disable-legacy-registry=false`) which prevents the d
140 140
 ### Docker Content Trust ENV passphrase variables name change
141 141
 **Deprecated In Release: v1.9**
142 142
 
143
-**Target For Removal In Release: v1.10**
143
+**Removed In Release: v1.12**
144 144
 
145
-As of 1.9, Docker Content Trust Offline key will be renamed to Root key and the Tagging key will be renamed to Repository key. Due to this renaming, we're also changing the corresponding environment variables
145
+Since 1.9, Docker Content Trust Offline key has been renamed to Root key and the Tagging key has been renamed to Repository key. Due to this renaming, we're also changing the corresponding environment variables
146 146
 
147
-- DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE will now be named DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE
148
-- DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE will now be named DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE
147
+- DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE is named DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE
148
+- DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE is named DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE
... ...
@@ -315,20 +315,6 @@ func (s *DockerTrustSuite) TestTrustedPushWithEnvPasswords(c *check.C) {
315 315
 	c.Assert(string(out), checker.Contains, "Status: Downloaded", check.Commentf(out))
316 316
 }
317 317
 
318
-// This test ensures backwards compatibility with old ENV variables. Should be
319
-// deprecated by 1.10
320
-func (s *DockerTrustSuite) TestTrustedPushWithDeprecatedEnvPasswords(c *check.C) {
321
-	repoName := fmt.Sprintf("%v/dockercli/trusteddeprecated:latest", privateRegistryURL)
322
-	// tag the image and upload it to the private registry
323
-	dockerCmd(c, "tag", "busybox", repoName)
324
-
325
-	pushCmd := exec.Command(dockerBinary, "push", repoName)
326
-	s.trustedCmdWithDeprecatedEnvPassphrases(pushCmd, "12345678", "12345678")
327
-	out, _, err := runCommandWithOutput(pushCmd)
328
-	c.Assert(err, check.IsNil, check.Commentf("Error running trusted push: %s\n%s", err, out))
329
-	c.Assert(out, checker.Contains, "Signing and pushing trust metadata", check.Commentf("Missing expected output on trusted push"))
330
-}
331
-
332 318
 func (s *DockerTrustSuite) TestTrustedPushWithFailingServer(c *check.C) {
333 319
 	repoName := fmt.Sprintf("%v/dockerclitrusted/failingserver:latest", privateRegistryURL)
334 320
 	// tag the image and upload it to the private registry
... ...
@@ -423,28 +409,6 @@ func (s *DockerTrustSuite) TestTrustedPushWithIncorrectPassphraseForNonRoot(c *c
423 423
 	c.Assert(out, checker.Contains, "could not find necessary signing keys", check.Commentf("Missing expected output on trusted push with short targets/snapsnot passphrase"))
424 424
 }
425 425
 
426
-// This test ensures backwards compatibility with old ENV variables. Should be
427
-// deprecated by 1.10
428
-func (s *DockerTrustSuite) TestTrustedPushWithIncorrectDeprecatedPassphraseForNonRoot(c *check.C) {
429
-	repoName := fmt.Sprintf("%v/dockercliincorretdeprecatedpwd/trusted:latest", privateRegistryURL)
430
-	// tag the image and upload it to the private registry
431
-	dockerCmd(c, "tag", "busybox", repoName)
432
-
433
-	// Push with default passphrases
434
-	pushCmd := exec.Command(dockerBinary, "push", repoName)
435
-	s.trustedCmd(pushCmd)
436
-	out, _, err := runCommandWithOutput(pushCmd)
437
-	c.Assert(err, check.IsNil, check.Commentf("trusted push failed: %s\n%s", err, out))
438
-	c.Assert(out, checker.Contains, "Signing and pushing trust metadata", check.Commentf("Missing expected output on trusted push"))
439
-
440
-	// Push with wrong passphrases
441
-	pushCmd = exec.Command(dockerBinary, "push", repoName)
442
-	s.trustedCmdWithDeprecatedEnvPassphrases(pushCmd, "12345678", "87654321")
443
-	out, _, err = runCommandWithOutput(pushCmd)
444
-	c.Assert(err, check.NotNil, check.Commentf("Error missing from trusted push with short targets passphrase: \n%s", out))
445
-	c.Assert(out, checker.Contains, "could not find necessary signing keys", check.Commentf("Missing expected output on trusted push with short targets/snapsnot passphrase"))
446
-}
447
-
448 426
 func (s *DockerTrustSuite) TestTrustedPushWithExpiredSnapshot(c *check.C) {
449 427
 	c.Skip("Currently changes system time, causing instability")
450 428
 	repoName := fmt.Sprintf("%v/dockercliexpiredsnapshot/trusted:latest", privateRegistryURL)
... ...
@@ -177,10 +177,6 @@ func (s *DockerTrustSuite) trustedCmdWithPassphrases(cmd *exec.Cmd, rootPwd, rep
177 177
 	trustCmdEnv(cmd, notaryURL, rootPwd, repositoryPwd)
178 178
 }
179 179
 
180
-func (s *DockerTrustSuite) trustedCmdWithDeprecatedEnvPassphrases(cmd *exec.Cmd, offlinePwd, taggingPwd string) {
181
-	trustCmdDeprecatedEnv(cmd, notaryURL, offlinePwd, taggingPwd)
182
-}
183
-
184 180
 func trustCmdEnv(cmd *exec.Cmd, server, rootPwd, repositoryPwd string) {
185 181
 	env := []string{
186 182
 		"DOCKER_CONTENT_TRUST=1",
... ...
@@ -191,18 +187,6 @@ func trustCmdEnv(cmd *exec.Cmd, server, rootPwd, repositoryPwd string) {
191 191
 	cmd.Env = append(os.Environ(), env...)
192 192
 }
193 193
 
194
-// Helper method to test the old env variables OFFLINE and TAGGING that will
195
-// be deprecated by 1.10
196
-func trustCmdDeprecatedEnv(cmd *exec.Cmd, server, offlinePwd, taggingPwd string) {
197
-	env := []string{
198
-		"DOCKER_CONTENT_TRUST=1",
199
-		fmt.Sprintf("DOCKER_CONTENT_TRUST_SERVER=%s", server),
200
-		fmt.Sprintf("DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE=%s", offlinePwd),
201
-		fmt.Sprintf("DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE=%s", taggingPwd),
202
-	}
203
-	cmd.Env = append(os.Environ(), env...)
204
-}
205
-
206 194
 func (s *DockerTrustSuite) setupTrustedImage(c *check.C, name string) string {
207 195
 	repoName := fmt.Sprintf("%v/dockercli/%s:latest", privateRegistryURL, name)
208 196
 	// tag the image and upload it to the private registry