mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Remove command line flag install from registry package.
Settings flags is the responsibility of the application (cmd/) not a library Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
15b8d0420b
commit
73ec0ff86b
4 changed files with 16 additions and 33 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
"github.com/docker/docker/opts"
|
"github.com/docker/docker/opts"
|
||||||
|
"github.com/docker/docker/registry"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ const (
|
||||||
func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) {
|
func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) {
|
||||||
var maxConcurrentDownloads, maxConcurrentUploads int
|
var maxConcurrentDownloads, maxConcurrentUploads int
|
||||||
|
|
||||||
conf.ServiceOptions.InstallCliFlags(flags)
|
installRegistryServiceFlags(&conf.ServiceOptions, flags)
|
||||||
|
|
||||||
flags.Var(opts.NewNamedListOptsRef("storage-opts", &conf.GraphOptions, nil), "storage-opt", "Storage driver options")
|
flags.Var(opts.NewNamedListOptsRef("storage-opts", &conf.GraphOptions, nil), "storage-opt", "Storage driver options")
|
||||||
flags.Var(opts.NewNamedListOptsRef("authorization-plugins", &conf.AuthorizationPlugins, nil), "authorization-plugin", "Authorization plugins to load")
|
flags.Var(opts.NewNamedListOptsRef("authorization-plugins", &conf.AuthorizationPlugins, nil), "authorization-plugin", "Authorization plugins to load")
|
||||||
|
@ -75,3 +76,17 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) {
|
||||||
conf.MaxConcurrentDownloads = &maxConcurrentDownloads
|
conf.MaxConcurrentDownloads = &maxConcurrentDownloads
|
||||||
conf.MaxConcurrentUploads = &maxConcurrentUploads
|
conf.MaxConcurrentUploads = &maxConcurrentUploads
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func installRegistryServiceFlags(options *registry.ServiceOptions, flags *pflag.FlagSet) {
|
||||||
|
ana := opts.NewNamedListOptsRef("allow-nondistributable-artifacts", &options.AllowNondistributableArtifacts, registry.ValidateIndexName)
|
||||||
|
mirrors := opts.NewNamedListOptsRef("registry-mirrors", &options.Mirrors, registry.ValidateMirror)
|
||||||
|
insecureRegistries := opts.NewNamedListOptsRef("insecure-registries", &options.InsecureRegistries, registry.ValidateIndexName)
|
||||||
|
|
||||||
|
flags.Var(ana, "allow-nondistributable-artifacts", "Allow push of nondistributable artifacts to registry")
|
||||||
|
flags.Var(mirrors, "registry-mirror", "Preferred Docker registry mirror")
|
||||||
|
flags.Var(insecureRegistries, "insecure-registry", "Enable insecure registry communication")
|
||||||
|
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
|
flags.BoolVar(&options.V2Only, "disable-legacy-registry", true, "Disable contacting legacy registries")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,10 +10,8 @@ import (
|
||||||
|
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
registrytypes "github.com/docker/docker/api/types/registry"
|
registrytypes "github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/opts"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/pflag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceOptions holds command line options.
|
// ServiceOptions holds command line options.
|
||||||
|
@ -72,20 +70,6 @@ var (
|
||||||
// for mocking in unit tests
|
// for mocking in unit tests
|
||||||
var lookupIP = net.LookupIP
|
var lookupIP = net.LookupIP
|
||||||
|
|
||||||
// InstallCliFlags adds command-line options to the top-level flag parser for
|
|
||||||
// the current process.
|
|
||||||
func (options *ServiceOptions) InstallCliFlags(flags *pflag.FlagSet) {
|
|
||||||
ana := opts.NewNamedListOptsRef("allow-nondistributable-artifacts", &options.AllowNondistributableArtifacts, ValidateIndexName)
|
|
||||||
mirrors := opts.NewNamedListOptsRef("registry-mirrors", &options.Mirrors, ValidateMirror)
|
|
||||||
insecureRegistries := opts.NewNamedListOptsRef("insecure-registries", &options.InsecureRegistries, ValidateIndexName)
|
|
||||||
|
|
||||||
flags.Var(ana, "allow-nondistributable-artifacts", "Allow push of nondistributable artifacts to registry")
|
|
||||||
flags.Var(mirrors, "registry-mirror", "Preferred Docker registry mirror")
|
|
||||||
flags.Var(insecureRegistries, "insecure-registry", "Enable insecure registry communication")
|
|
||||||
|
|
||||||
options.installCliPlatformFlags(flags)
|
|
||||||
}
|
|
||||||
|
|
||||||
// newServiceConfig returns a new instance of ServiceConfig
|
// newServiceConfig returns a new instance of ServiceConfig
|
||||||
func newServiceConfig(options ServiceOptions) *serviceConfig {
|
func newServiceConfig(options ServiceOptions) *serviceConfig {
|
||||||
config := &serviceConfig{
|
config := &serviceConfig{
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/pflag"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// CertsDir is the directory where certificates are stored
|
// CertsDir is the directory where certificates are stored
|
||||||
CertsDir = "/etc/docker/certs.d"
|
CertsDir = "/etc/docker/certs.d"
|
||||||
|
@ -18,8 +14,3 @@ var (
|
||||||
func cleanPath(s string) string {
|
func cleanPath(s string) string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// installCliPlatformFlags handles any platform specific flags for the service.
|
|
||||||
func (options *ServiceOptions) installCliPlatformFlags(flags *pflag.FlagSet) {
|
|
||||||
flags.BoolVar(&options.V2Only, "disable-legacy-registry", true, "Disable contacting legacy registries")
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,8 +4,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CertsDir is the directory where certificates are stored
|
// CertsDir is the directory where certificates are stored
|
||||||
|
@ -18,8 +16,3 @@ var CertsDir = os.Getenv("programdata") + `\docker\certs.d`
|
||||||
func cleanPath(s string) string {
|
func cleanPath(s string) string {
|
||||||
return filepath.FromSlash(strings.Replace(s, ":", "", -1))
|
return filepath.FromSlash(strings.Replace(s, ":", "", -1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// installCliPlatformFlags handles any platform specific flags for the service.
|
|
||||||
func (options *ServiceOptions) installCliPlatformFlags(flags *pflag.FlagSet) {
|
|
||||||
// No Windows specific flags.
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue