Merge pull request #24822 from swernli/skipV1push
Fixing v2 registry restriction for non-linux platforms. Upstream-commit: 0eb1323fba5a46209e4aa99282129b0673c491e3 Component: engine
This commit is contained in:
@ -69,14 +69,14 @@ func NewDaemonCli() *DaemonCli {
|
||||
daemonConfig.LogConfig.Config = make(map[string]string)
|
||||
daemonConfig.ClusterOpts = make(map[string]string)
|
||||
|
||||
if runtime.GOOS != "linux" {
|
||||
daemonConfig.V2Only = true
|
||||
}
|
||||
|
||||
daemonConfig.InstallFlags(flag.CommandLine, presentInHelp)
|
||||
configFile := flag.CommandLine.String([]string{daemonConfigFileFlag}, defaultDaemonConfigFile, "Daemon configuration file")
|
||||
flag.CommandLine.Require(flag.Exact, 0)
|
||||
|
||||
if runtime.GOOS != "linux" {
|
||||
daemonConfig.V2Only = true
|
||||
}
|
||||
|
||||
return &DaemonCli{
|
||||
Config: daemonConfig,
|
||||
commonFlags: cliflags.InitCommonFlags(),
|
||||
|
||||
@ -267,7 +267,7 @@ func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
|
||||
configFile := f.Name()
|
||||
defer os.Remove(configFile)
|
||||
|
||||
f.Write([]byte(`{"registry-mirrors": ["https://mirrors.docker.com"], "insecure-registries": ["https://insecure.docker.com"], "disable-legacy-registry": true}`))
|
||||
f.Write([]byte(`{"registry-mirrors": ["https://mirrors.docker.com"], "insecure-registries": ["https://insecure.docker.com"]}`))
|
||||
f.Close()
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(c, flags, common, configFile)
|
||||
@ -287,8 +287,4 @@ func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
|
||||
if len(r) != 1 {
|
||||
t.Fatalf("expected 1 insecure registries, got %d", len(r))
|
||||
}
|
||||
|
||||
if !loadedConfig.V2Only {
|
||||
t.Fatal("expected disable-legacy-registry to be true, got false")
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
cliflags "github.com/docker/docker/cli/flags"
|
||||
@ -210,3 +211,32 @@ func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
|
||||
t.Fatal("expected userland proxy to be enabled, got disabled")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithLegacyRegistryOptions(t *testing.T) {
|
||||
c := &daemon.Config{}
|
||||
common := &cliflags.CommonFlags{}
|
||||
flags := mflag.NewFlagSet("test", mflag.ContinueOnError)
|
||||
c.ServiceOptions.InstallCliFlags(flags, absentFromHelp)
|
||||
|
||||
f, err := ioutil.TempFile("", "docker-config-")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
configFile := f.Name()
|
||||
defer os.Remove(configFile)
|
||||
|
||||
f.Write([]byte(`{"disable-legacy-registry": true}`))
|
||||
f.Close()
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(c, flags, common, configFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if loadedConfig == nil {
|
||||
t.Fatal("expected configuration, got nil")
|
||||
}
|
||||
|
||||
if !loadedConfig.V2Only {
|
||||
t.Fatal("expected disable-legacy-registry to be true, got false")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user