From 7435e4a1be22a5a44f945d6b45e1e81273fd868d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 4 Apr 2025 20:39:57 +0200 Subject: [PATCH] registry: remove deprecated ServiceConfig.AllowNondistributableArtifacts This option was deprecated in 1932091e21b64abc52b42320393b0ac5f6921668, and is no longer used. It was only kept to allow priniting a deprecation warning if the config would happen to have the field set. Signed-off-by: Sebastiaan van Stijn --- cmd/dockerd/config.go | 10 +++++----- cmd/dockerd/daemon.go | 5 ----- daemon/config/config.go | 3 ++- daemon/config/config_linux_test.go | 4 ++++ registry/config.go | 2 -- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cmd/dockerd/config.go b/cmd/dockerd/config.go index b8f417fdd7..2fc4983e9c 100644 --- a/cmd/dockerd/config.go +++ b/cmd/dockerd/config.go @@ -13,12 +13,9 @@ import ( // installCommonConfigFlags adds flags to the pflag.FlagSet to configure the daemon func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) { var ( - allowNonDistributable = opts.NewNamedListOptsRef("allow-nondistributable-artifacts", &conf.AllowNondistributableArtifacts, registry.ValidateIndexName) - registryMirrors = opts.NewNamedListOptsRef("registry-mirrors", &conf.Mirrors, registry.ValidateMirror) - insecureRegistries = opts.NewNamedListOptsRef("insecure-registries", &conf.InsecureRegistries, registry.ValidateIndexName) + registryMirrors = opts.NewNamedListOptsRef("registry-mirrors", &conf.Mirrors, registry.ValidateMirror) + insecureRegistries = opts.NewNamedListOptsRef("insecure-registries", &conf.InsecureRegistries, registry.ValidateIndexName) ) - flags.Var(allowNonDistributable, "allow-nondistributable-artifacts", "Allow push of nondistributable artifacts to registry") - _ = flags.MarkDeprecated("allow-nondistributable-artifacts", "Pushing nondistributable artifacts is now enabled by default. ") flags.Var(registryMirrors, "registry-mirror", "Preferred Docker registry mirror") flags.Var(insecureRegistries, "insecure-registry", "Enable insecure registry communication") @@ -77,6 +74,9 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) { flags.Var(opts.NewNamedListOptsRef("cdi-spec-dirs", &conf.CDISpecDirs, nil), "cdi-spec-dir", "CDI specification directories to use") // Deprecated flags / options + allowNonDistributable := opts.NewNamedListOptsRef("allow-nondistributable-artifacts", &([]string{}), registry.ValidateIndexName) + flags.Var(allowNonDistributable, "allow-nondistributable-artifacts", "Allow push of nondistributable artifacts to registry") + _ = flags.MarkDeprecated("allow-nondistributable-artifacts", "Pushing nondistributable artifacts is now enabled by default. ") // TODO(thaJeztah): option is used to produce error when used; remove in next release flags.StringVar(&conf.CorsHeaders, "api-cors-header", "", "Set CORS headers in the Engine API; deprecated: this feature was deprecated in 27.0, and now removed") diff --git a/cmd/dockerd/daemon.go b/cmd/dockerd/daemon.go index c60b6e4b93..b48fff1f03 100644 --- a/cmd/dockerd/daemon.go +++ b/cmd/dockerd/daemon.go @@ -661,11 +661,6 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) { return nil, err } - if len(conf.AllowNondistributableArtifacts) > 0 { - // TODO(thaJeztah): move to config.Validate and change into an error for v29.0 and remove in v30.0. - log.G(context.TODO()).Warn(`DEPRECATED: The "allow-nondistributable-artifacts" config parameter is deprecated and always enabled; this option will be removed in the next release`) - } - return conf, nil } diff --git a/daemon/config/config.go b/daemon/config/config.go index 0d60baede3..eafdf0eaa4 100644 --- a/daemon/config/config.go +++ b/daemon/config/config.go @@ -93,7 +93,8 @@ var skipValidateOptions = map[string]bool{ "builder": true, // Deprecated options that are safe to ignore if present. - "deprecated-key-path": true, + "deprecated-key-path": true, + "allow-nondistributable-artifacts": true, } // skipDuplicates contains configuration keys that diff --git a/daemon/config/config_linux_test.go b/daemon/config/config_linux_test.go index cea38e9487..47d7a19609 100644 --- a/daemon/config/config_linux_test.go +++ b/daemon/config/config_linux_test.go @@ -379,6 +379,10 @@ func TestDaemonLegacyOptions(t *testing.T) { name: "deprecated-key-path", configJSON: `{"deprecated-key-path": "/etc/docker/key.json"}`, }, + { + name: "allow-nondistributable-artifacts", + configJSON: `{"allow-nondistributable-artifacts": ["127.0.0.0/8", "10.10.1.11:5000", "10.10.1.22:5000", "registry.example.com", "registry.example.com"]}`, + }, } for _, tc := range tests { diff --git a/registry/config.go b/registry/config.go index 78936b3621..ce504bd7fa 100644 --- a/registry/config.go +++ b/registry/config.go @@ -19,8 +19,6 @@ import ( // ServiceOptions holds command line options. type ServiceOptions struct { - AllowNondistributableArtifacts []string `json:"allow-nondistributable-artifacts,omitempty"` // Deprecated: non-distributable artifacts are deprecated and enabled by default. This field will be removed in the next release. - Mirrors []string `json:"registry-mirrors,omitempty"` InsecureRegistries []string `json:"insecure-registries,omitempty"` }