From 6e3e657ea65b9c29535d678c6d9e03cfd997c6d4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 26 Feb 2022 12:58:41 +0100 Subject: [PATCH] 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 --- registry/config.go | 18 +++++++++--------- registry/config_test.go | 4 ++-- registry/service.go | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/registry/config.go b/registry/config.go index 97bc679fe0..9cf39452f5 100644 --- a/registry/config.go +++ b/registry/config.go @@ -79,21 +79,21 @@ func newServiceConfig(options ServiceOptions) (*serviceConfig, error) { // 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 } - if err := config.LoadMirrors(options.Mirrors); err != nil { + if err := config.loadMirrors(options.Mirrors); err != nil { return nil, err } - if err := config.LoadInsecureRegistries(options.InsecureRegistries); err != nil { + if err := config.loadInsecureRegistries(options.InsecureRegistries); err != nil { return nil, err } return config, nil } -// LoadAllowNondistributableArtifacts loads allow-nondistributable-artifacts registries into config. -func (config *serviceConfig) LoadAllowNondistributableArtifacts(registries []string) error { +// loadAllowNondistributableArtifacts loads allow-nondistributable-artifacts registries into config. +func (config *serviceConfig) loadAllowNondistributableArtifacts(registries []string) error { cidrs := map[string]*registrytypes.NetIPNet{} hostnames := map[string]bool{} @@ -129,9 +129,9 @@ func (config *serviceConfig) LoadAllowNondistributableArtifacts(registries []str 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. -func (config *serviceConfig) LoadMirrors(mirrors []string) error { +func (config *serviceConfig) loadMirrors(mirrors []string) error { mMap := map[string]struct{}{} unique := []string{} @@ -159,8 +159,8 @@ func (config *serviceConfig) LoadMirrors(mirrors []string) error { return nil } -// LoadInsecureRegistries loads insecure registries to config -func (config *serviceConfig) LoadInsecureRegistries(registries []string) error { +// loadInsecureRegistries loads insecure registries to config +func (config *serviceConfig) loadInsecureRegistries(registries []string) error { // Localhost is by default considered as an insecure registry. This is a // stop-gap for people who are running a private registry on localhost. registries = append(registries, "127.0.0.0/8") diff --git a/registry/config_test.go b/registry/config_test.go index c939eff56f..2968058d23 100644 --- a/registry/config_test.go +++ b/registry/config_test.go @@ -94,7 +94,7 @@ func TestLoadAllowNondistributableArtifacts(t *testing.T) { } for _, testCase := range testCases { config := emptyServiceConfig - err := config.LoadAllowNondistributableArtifacts(testCase.registries) + err := config.loadAllowNondistributableArtifacts(testCase.registries) if testCase.err == "" { if err != nil { t.Fatalf("expect no error, got '%s'", err) @@ -237,7 +237,7 @@ func TestLoadInsecureRegistries(t *testing.T) { } for _, testCase := range testCases { config := emptyServiceConfig - err := config.LoadInsecureRegistries(testCase.registries) + err := config.loadInsecureRegistries(testCase.registries) if testCase.err == "" { if err != nil { t.Fatalf("expect no error, got '%s'", err) diff --git a/registry/service.go b/registry/service.go index 7903918064..a8ea446e37 100644 --- a/registry/service.go +++ b/registry/service.go @@ -84,7 +84,7 @@ func (s *defaultService) LoadAllowNondistributableArtifacts(registries []string) s.mu.Lock() defer s.mu.Unlock() - return s.config.LoadAllowNondistributableArtifacts(registries) + return s.config.loadAllowNondistributableArtifacts(registries) } // LoadMirrors loads registry mirrors for Service @@ -92,7 +92,7 @@ func (s *defaultService) LoadMirrors(mirrors []string) error { s.mu.Lock() defer s.mu.Unlock() - return s.config.LoadMirrors(mirrors) + return s.config.loadMirrors(mirrors) } // LoadInsecureRegistries loads insecure registries for Service @@ -100,7 +100,7 @@ func (s *defaultService) LoadInsecureRegistries(registries []string) error { s.mu.Lock() defer s.mu.Unlock() - return s.config.LoadInsecureRegistries(registries) + return s.config.loadInsecureRegistries(registries) } // Auth contacts the public registry with the provided credentials,