summaryrefslogtreecommitdiff
path: root/registry/service.go
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2022-02-25 23:45:49 +0100
committerSebastiaan van Stijn <github@gone.nl>2022-03-17 17:08:04 +0100
commit569dc6d692558c056071cd9052208e5a36e269ae (patch)
tree59c985ec83c657ca8e11607e144464994b17d3da /registry/service.go
parent541ed077a66894c96f22eb1f1a74a504fa014567 (diff)
downloaddocker-569dc6d692558c056071cd9052208e5a36e269ae.tar.gz
registry: un-export DefaultService
The DefaultService was not really meant to be used outside of the package, so un-export it, and change NewService()'s signature to return a Service interface. To un-export this type, a test in daemon/images was updated to not use DefaultService, but now using the registry.Service interface itself. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'registry/service.go')
-rw-r--r--registry/service.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/registry/service.go b/registry/service.go
index b134ffad2a..8b5bb9e7b6 100644
--- a/registry/service.go
+++ b/registry/service.go
@@ -36,23 +36,23 @@ type Service interface {
LoadInsecureRegistries([]string) error
}
-// DefaultService is a registry service. It tracks configuration data such as a list
+// defaultService is a registry service. It tracks configuration data such as a list
// of mirrors.
-type DefaultService struct {
+type defaultService struct {
config *serviceConfig
mu sync.Mutex
}
-// NewService returns a new instance of DefaultService ready to be
+// NewService returns a new instance of defaultService ready to be
// installed into an engine.
-func NewService(options ServiceOptions) (*DefaultService, error) {
+func NewService(options ServiceOptions) (Service, error) {
config, err := newServiceConfig(options)
- return &DefaultService{config: config}, err
+ return &defaultService{config: config}, err
}
// ServiceConfig returns the public registry service configuration.
-func (s *DefaultService) ServiceConfig() *registrytypes.ServiceConfig {
+func (s *defaultService) ServiceConfig() *registrytypes.ServiceConfig {
s.mu.Lock()
defer s.mu.Unlock()
@@ -80,7 +80,7 @@ func (s *DefaultService) ServiceConfig() *registrytypes.ServiceConfig {
}
// LoadAllowNondistributableArtifacts loads allow-nondistributable-artifacts registries for Service.
-func (s *DefaultService) LoadAllowNondistributableArtifacts(registries []string) error {
+func (s *defaultService) LoadAllowNondistributableArtifacts(registries []string) error {
s.mu.Lock()
defer s.mu.Unlock()
@@ -88,7 +88,7 @@ func (s *DefaultService) LoadAllowNondistributableArtifacts(registries []string)
}
// LoadMirrors loads registry mirrors for Service
-func (s *DefaultService) LoadMirrors(mirrors []string) error {
+func (s *defaultService) LoadMirrors(mirrors []string) error {
s.mu.Lock()
defer s.mu.Unlock()
@@ -96,7 +96,7 @@ func (s *DefaultService) LoadMirrors(mirrors []string) error {
}
// LoadInsecureRegistries loads insecure registries for Service
-func (s *DefaultService) LoadInsecureRegistries(registries []string) error {
+func (s *defaultService) LoadInsecureRegistries(registries []string) error {
s.mu.Lock()
defer s.mu.Unlock()
@@ -106,7 +106,7 @@ func (s *DefaultService) LoadInsecureRegistries(registries []string) error {
// Auth contacts the public registry with the provided credentials,
// and returns OK if authentication was successful.
// It can be used to verify the validity of a client's credentials.
-func (s *DefaultService) Auth(ctx context.Context, authConfig *types.AuthConfig, userAgent string) (status, token string, err error) {
+func (s *defaultService) Auth(ctx context.Context, authConfig *types.AuthConfig, userAgent string) (status, token string, err error) {
// TODO Use ctx when searching for repositories
var registryHostName = IndexHostname
@@ -159,7 +159,7 @@ func splitReposSearchTerm(reposName string) (string, string) {
// Search queries the public registry for images matching the specified
// search terms, and returns the results.
-func (s *DefaultService) Search(ctx context.Context, term string, limit int, authConfig *types.AuthConfig, userAgent string, headers map[string][]string) (*registrytypes.SearchResults, error) {
+func (s *defaultService) Search(ctx context.Context, term string, limit int, authConfig *types.AuthConfig, userAgent string, headers map[string][]string) (*registrytypes.SearchResults, error) {
// TODO Use ctx when searching for repositories
if err := validateNoScheme(term); err != nil {
return nil, err
@@ -229,7 +229,7 @@ func (s *DefaultService) Search(ctx context.Context, term string, limit int, aut
// ResolveRepository splits a repository name into its components
// and configuration of the associated registry.
-func (s *DefaultService) ResolveRepository(name reference.Named) (*RepositoryInfo, error) {
+func (s *defaultService) ResolveRepository(name reference.Named) (*RepositoryInfo, error) {
s.mu.Lock()
defer s.mu.Unlock()
return newRepositoryInfo(s.config, name)
@@ -247,7 +247,7 @@ type APIEndpoint struct {
}
// TLSConfig constructs a client TLS configuration based on server defaults
-func (s *DefaultService) TLSConfig(hostname string) (*tls.Config, error) {
+func (s *defaultService) TLSConfig(hostname string) (*tls.Config, error) {
s.mu.Lock()
defer s.mu.Unlock()
@@ -255,13 +255,13 @@ func (s *DefaultService) TLSConfig(hostname string) (*tls.Config, error) {
}
// tlsConfig constructs a client TLS configuration based on server defaults
-func (s *DefaultService) tlsConfig(hostname string) (*tls.Config, error) {
+func (s *defaultService) tlsConfig(hostname string) (*tls.Config, error) {
return newTLSConfig(hostname, isSecureIndex(s.config, hostname))
}
// LookupPullEndpoints creates a list of v2 endpoints to try to pull from, in order of preference.
// It gives preference to mirrors over the actual registry, and HTTPS over plain HTTP.
-func (s *DefaultService) LookupPullEndpoints(hostname string) (endpoints []APIEndpoint, err error) {
+func (s *defaultService) LookupPullEndpoints(hostname string) (endpoints []APIEndpoint, err error) {
s.mu.Lock()
defer s.mu.Unlock()
@@ -270,7 +270,7 @@ func (s *DefaultService) LookupPullEndpoints(hostname string) (endpoints []APIEn
// LookupPushEndpoints creates a list of v2 endpoints to try to push to, in order of preference.
// It gives preference to HTTPS over plain HTTP. Mirrors are not included.
-func (s *DefaultService) LookupPushEndpoints(hostname string) (endpoints []APIEndpoint, err error) {
+func (s *defaultService) LookupPushEndpoints(hostname string) (endpoints []APIEndpoint, err error) {
s.mu.Lock()
defer s.mu.Unlock()