1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

registry: un-export config.LoadXXX() functions

Un-export:

- config.LoadAllowNondistributableArtifacts()
- config.LoadInsecureRegistries()
- config.LoadMirrors()

The config type is already un-exported; this also un-exports these functions
to be explicit they're internal only.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-02-26 12:58:41 +01:00
parent 4ebb18479d
commit 6e3e657ea6
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
3 changed files with 14 additions and 14 deletions

View file

@ -79,21 +79,21 @@ func newServiceConfig(options ServiceOptions) (*serviceConfig, error) {
// and Mirrors are only for the official registry anyways. // and Mirrors are only for the official registry anyways.
}, },
} }
if err := config.LoadAllowNondistributableArtifacts(options.AllowNondistributableArtifacts); err != nil { if err := config.loadAllowNondistributableArtifacts(options.AllowNondistributableArtifacts); err != nil {
return nil, err return nil, err
} }
if err := config.LoadMirrors(options.Mirrors); err != nil { if err := config.loadMirrors(options.Mirrors); err != nil {
return nil, err return nil, err
} }
if err := config.LoadInsecureRegistries(options.InsecureRegistries); err != nil { if err := config.loadInsecureRegistries(options.InsecureRegistries); err != nil {
return nil, err return nil, err
} }
return config, nil return config, nil
} }
// LoadAllowNondistributableArtifacts loads allow-nondistributable-artifacts registries into config. // loadAllowNondistributableArtifacts loads allow-nondistributable-artifacts registries into config.
func (config *serviceConfig) LoadAllowNondistributableArtifacts(registries []string) error { func (config *serviceConfig) loadAllowNondistributableArtifacts(registries []string) error {
cidrs := map[string]*registrytypes.NetIPNet{} cidrs := map[string]*registrytypes.NetIPNet{}
hostnames := map[string]bool{} hostnames := map[string]bool{}
@ -129,9 +129,9 @@ func (config *serviceConfig) LoadAllowNondistributableArtifacts(registries []str
return nil return nil
} }
// LoadMirrors loads mirrors to config, after removing duplicates. // loadMirrors loads mirrors to config, after removing duplicates.
// Returns an error if mirrors contains an invalid mirror. // Returns an error if mirrors contains an invalid mirror.
func (config *serviceConfig) LoadMirrors(mirrors []string) error { func (config *serviceConfig) loadMirrors(mirrors []string) error {
mMap := map[string]struct{}{} mMap := map[string]struct{}{}
unique := []string{} unique := []string{}
@ -159,8 +159,8 @@ func (config *serviceConfig) LoadMirrors(mirrors []string) error {
return nil return nil
} }
// LoadInsecureRegistries loads insecure registries to config // loadInsecureRegistries loads insecure registries to config
func (config *serviceConfig) LoadInsecureRegistries(registries []string) error { func (config *serviceConfig) loadInsecureRegistries(registries []string) error {
// Localhost is by default considered as an insecure registry. This is a // Localhost is by default considered as an insecure registry. This is a
// stop-gap for people who are running a private registry on localhost. // stop-gap for people who are running a private registry on localhost.
registries = append(registries, "127.0.0.0/8") registries = append(registries, "127.0.0.0/8")

View file

@ -94,7 +94,7 @@ func TestLoadAllowNondistributableArtifacts(t *testing.T) {
} }
for _, testCase := range testCases { for _, testCase := range testCases {
config := emptyServiceConfig config := emptyServiceConfig
err := config.LoadAllowNondistributableArtifacts(testCase.registries) err := config.loadAllowNondistributableArtifacts(testCase.registries)
if testCase.err == "" { if testCase.err == "" {
if err != nil { if err != nil {
t.Fatalf("expect no error, got '%s'", err) t.Fatalf("expect no error, got '%s'", err)
@ -237,7 +237,7 @@ func TestLoadInsecureRegistries(t *testing.T) {
} }
for _, testCase := range testCases { for _, testCase := range testCases {
config := emptyServiceConfig config := emptyServiceConfig
err := config.LoadInsecureRegistries(testCase.registries) err := config.loadInsecureRegistries(testCase.registries)
if testCase.err == "" { if testCase.err == "" {
if err != nil { if err != nil {
t.Fatalf("expect no error, got '%s'", err) t.Fatalf("expect no error, got '%s'", err)

View file

@ -84,7 +84,7 @@ func (s *defaultService) LoadAllowNondistributableArtifacts(registries []string)
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.config.LoadAllowNondistributableArtifacts(registries) return s.config.loadAllowNondistributableArtifacts(registries)
} }
// LoadMirrors loads registry mirrors for Service // LoadMirrors loads registry mirrors for Service
@ -92,7 +92,7 @@ func (s *defaultService) LoadMirrors(mirrors []string) error {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.config.LoadMirrors(mirrors) return s.config.loadMirrors(mirrors)
} }
// LoadInsecureRegistries loads insecure registries for Service // LoadInsecureRegistries loads insecure registries for Service
@ -100,7 +100,7 @@ func (s *defaultService) LoadInsecureRegistries(registries []string) error {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.config.LoadInsecureRegistries(registries) return s.config.loadInsecureRegistries(registries)
} }
// Auth contacts the public registry with the provided credentials, // Auth contacts the public registry with the provided credentials,