瀏覽代碼

Merge pull request #17269 from tonistiigi/trust-deprecation-warning

Show trust variable deprecation warning only if used
Antonio Murdaca 9 年之前
父節點
當前提交
09cd98462b
共有 1 個文件被更改,包括 9 次插入7 次删除
  1. 9 7
      api/client/trust.go

+ 9 - 7
api/client/trust.go

@@ -198,15 +198,17 @@ func (cli *DockerCli) getPassphraseRetriever() passphrase.Retriever {
 
 
 	// Backwards compatibility with old env names. We should remove this in 1.10
 	// Backwards compatibility with old env names. We should remove this in 1.10
 	if env["root"] == "" {
 	if env["root"] == "" {
-		env["root"] = os.Getenv("DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE")
-		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")
-
+		if passphrase := os.Getenv("DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE"); passphrase != "" {
+			env["root"] = passphrase
+			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")
+		}
 	}
 	}
 	if env["snapshot"] == "" || env["targets"] == "" {
 	if env["snapshot"] == "" || env["targets"] == "" {
-		env["snapshot"] = os.Getenv("DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE")
-		env["targets"] = os.Getenv("DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE")
-		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")
-
+		if passphrase := os.Getenv("DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE"); passphrase != "" {
+			env["snapshot"] = passphrase
+			env["targets"] = passphrase
+			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")
+		}
 	}
 	}
 
 
 	return func(keyName string, alias string, createNew bool, numAttempts int) (string, bool, error) {
 	return func(keyName string, alias string, createNew bool, numAttempts int) (string, bool, error) {