Browse code

Add conflict check for flags, and update deprecation versions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2017/03/28 23:19:35
Showing 3 changed files
... ...
@@ -22,7 +22,11 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) {
22 22
 	flags.Var(opts.NewNamedListOptsRef("exec-opts", &conf.ExecOptions, nil), "exec-opt", "Runtime execution options")
23 23
 	flags.StringVarP(&conf.Pidfile, "pidfile", "p", defaultPidFile, "Path to use for daemon PID file")
24 24
 	flags.StringVarP(&conf.Root, "graph", "g", defaultDataRoot, "Root of the Docker runtime")
25
-	flags.MarkDeprecated("graph", "Please use --data-root instead")
25
+
26
+	// "--graph" is "soft-deprecated" in favor of "data-root". This flag was added
27
+	// before Docker 1.0, so won't be removed, only hidden, to discourage its usage.
28
+	flags.MarkHidden("graph")
29
+
26 30
 	flags.StringVar(&conf.Root, "data-root", defaultDataRoot, "Root directory of persistent Docker state")
27 31
 
28 32
 	flags.BoolVarP(&conf.AutoRestart, "restart", "r", true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run")
... ...
@@ -423,6 +423,10 @@ func loadDaemonCliConfig(opts daemonOptions) (*config.Config, error) {
423 423
 		conf.CommonTLSOptions.KeyFile = opts.common.TLSOptions.KeyFile
424 424
 	}
425 425
 
426
+	if flags.Changed("graph") && flags.Changed("data-root") {
427
+		return nil, fmt.Errorf(`cannot specify both "--graph" and "--data-root" option`)
428
+	}
429
+
426 430
 	if opts.configFile != "" {
427 431
 		c, err := config.MergeDaemonConfigurations(conf, flags, opts.configFile)
428 432
 		if err != nil {
... ...
@@ -441,6 +445,10 @@ func loadDaemonCliConfig(opts daemonOptions) (*config.Config, error) {
441 441
 		return nil, err
442 442
 	}
443 443
 
444
+	if flags.Changed("graph") {
445
+		logrus.Warnf(`the "-g / --graph" flag is deprecated. Please use "--data-root" instead`)
446
+	}
447
+
444 448
 	// Labels of the docker engine used to allow multiple values associated with the same key.
445 449
 	// This is deprecated in 1.13, and, be removed after 3 release cycles.
446 450
 	// The following will check the conflict of labels, and report a warning for deprecation.
... ...
@@ -22,15 +22,16 @@ see [Feature Deprecation Policy](https://docs.docker.com/engine/#feature-depreca
22 22
 
23 23
 ### `-g` and `--graph` flags on `dockerd`
24 24
 
25
-**Deprecated In Release: v1.14.0**
26
-
27
-**Target For Removal In Release: v1.17**
25
+**Deprecated In Release: v17.05.0**
28 26
 
29 27
 The `-g` or `--graph` flag for the `dockerd` or `docker daemon` command was
30 28
 used to indicate the directory in which to store persistent data and resource
31 29
 configuration and has been replaced with the more descriptive `--data-root`
32 30
 flag.
33 31
 
32
+These flags were added before Docker 1.0, so will not be _removed_, only
33
+_hidden_, to discourage their use.
34
+
34 35
 ### Top-level network properties in NetworkSettings
35 36
 
36 37
 **Deprecated In Release: [v1.13.0](https://github.com/docker/docker/releases/tag/v1.13.0)**