mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon: complete the "--graph" / "-g" deprecation
The `-g` / `--graph` options were soft deprecated in favor of `--data-root` in
261ef1fa27
(v17.05.0) and at the time considered
to not be removed. However, with the move towards containerd snapshotters, having
these options around adds additional complexity to handle fallbacks for deprecated
(and hidden) flags, so completing the deprecation.
With this patch:
dockerd --graph=/var/lib/docker --validate
Flag --graph has been deprecated, Use --data-root instead
unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: the "graph" config file option is deprecated; use "data-root" instead
mkdir -p /etc/docker
echo '{"graph":"/var/lib/docker"}' > /etc/docker/daemon.json
dockerd --validate
unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: the "graph" config file option is deprecated; use "data-root" instead
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
6f8ea5b26e
commit
b58de39ca7
3 changed files with 9 additions and 22 deletions
|
@ -65,10 +65,9 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error {
|
||||||
|
|
||||||
// Deprecated flags / options
|
// Deprecated flags / options
|
||||||
|
|
||||||
// "--graph" is "soft-deprecated" in favor of "data-root". This flag was added
|
//nolint:staticcheck // TODO(thaJeztah): remove in next release.
|
||||||
// before Docker 1.0, so won't be removed, only hidden, to discourage its usage.
|
flags.StringVarP(&conf.RootDeprecated, "graph", "g", conf.RootDeprecated, "Root of the Docker runtime")
|
||||||
flags.StringVarP(&conf.Root, "graph", "g", conf.Root, "Root of the Docker runtime")
|
_ = flags.MarkDeprecated("graph", "Use --data-root instead")
|
||||||
_ = flags.MarkHidden("graph")
|
|
||||||
flags.BoolVarP(&conf.AutoRestart, "restart", "r", true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run")
|
flags.BoolVarP(&conf.AutoRestart, "restart", "r", true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run")
|
||||||
_ = flags.MarkDeprecated("restart", "Please use a restart policy on docker run")
|
_ = flags.MarkDeprecated("restart", "Please use a restart policy on docker run")
|
||||||
|
|
||||||
|
|
|
@ -397,9 +397,6 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) {
|
||||||
conf.Hosts = opts.Hosts
|
conf.Hosts = opts.Hosts
|
||||||
conf.LogLevel = opts.LogLevel
|
conf.LogLevel = opts.LogLevel
|
||||||
|
|
||||||
if flags.Changed("graph") && flags.Changed("data-root") {
|
|
||||||
return nil, errors.New(`cannot specify both "--graph" and "--data-root" option`)
|
|
||||||
}
|
|
||||||
if flags.Changed(FlagTLS) {
|
if flags.Changed(FlagTLS) {
|
||||||
conf.TLS = &opts.TLS
|
conf.TLS = &opts.TLS
|
||||||
}
|
}
|
||||||
|
@ -450,10 +447,6 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.Changed("graph") {
|
|
||||||
logrus.Warnf(`The "-g / --graph" flag is deprecated. Please use "--data-root" instead`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if duplicate label-keys with different values are found
|
// Check if duplicate label-keys with different values are found
|
||||||
newLabels, err := config.GetConflictFreeLabels(conf.Labels)
|
newLabels, err := config.GetConflictFreeLabels(conf.Labels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -157,7 +157,7 @@ type CommonConfig struct {
|
||||||
NetworkDiagnosticPort int `json:"network-diagnostic-port,omitempty"`
|
NetworkDiagnosticPort int `json:"network-diagnostic-port,omitempty"`
|
||||||
Pidfile string `json:"pidfile,omitempty"`
|
Pidfile string `json:"pidfile,omitempty"`
|
||||||
RawLogs bool `json:"raw-logs,omitempty"`
|
RawLogs bool `json:"raw-logs,omitempty"`
|
||||||
RootDeprecated string `json:"graph,omitempty"`
|
RootDeprecated string `json:"graph,omitempty"` // Deprecated: use Root instead. TODO(thaJeztah): remove in next release.
|
||||||
Root string `json:"data-root,omitempty"`
|
Root string `json:"data-root,omitempty"`
|
||||||
ExecRoot string `json:"exec-root,omitempty"`
|
ExecRoot string `json:"exec-root,omitempty"`
|
||||||
SocketGroup string `json:"group,omitempty"`
|
SocketGroup string `json:"group,omitempty"`
|
||||||
|
@ -472,16 +472,6 @@ func getConflictFreeConfiguration(configFile string, flags *pflag.FlagSet) (*Con
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.RootDeprecated != "" {
|
|
||||||
logrus.Warn(`The "graph" config file option is deprecated. Please use "data-root" instead.`)
|
|
||||||
|
|
||||||
if config.Root != "" {
|
|
||||||
return nil, errors.New(`cannot specify both "graph" and "data-root" config file options`)
|
|
||||||
}
|
|
||||||
|
|
||||||
config.Root = config.RootDeprecated
|
|
||||||
}
|
|
||||||
|
|
||||||
return &config, nil
|
return &config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,6 +562,11 @@ func findConfigurationConflicts(config map[string]interface{}, flags *pflag.Flag
|
||||||
// such as config.DNS, config.Labels, config.DNSSearch,
|
// such as config.DNS, config.Labels, config.DNSSearch,
|
||||||
// as well as config.MaxConcurrentDownloads, config.MaxConcurrentUploads and config.MaxDownloadAttempts.
|
// as well as config.MaxConcurrentDownloads, config.MaxConcurrentUploads and config.MaxDownloadAttempts.
|
||||||
func Validate(config *Config) error {
|
func Validate(config *Config) error {
|
||||||
|
//nolint:staticcheck // TODO(thaJeztah): remove in next release.
|
||||||
|
if config.RootDeprecated != "" {
|
||||||
|
return errors.New(`the "graph" config file option is deprecated; use "data-root" instead`)
|
||||||
|
}
|
||||||
|
|
||||||
// validate log-level
|
// validate log-level
|
||||||
if config.LogLevel != "" {
|
if config.LogLevel != "" {
|
||||||
if _, err := logrus.ParseLevel(config.LogLevel); err != nil {
|
if _, err := logrus.ParseLevel(config.LogLevel); err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue