registry: serviceConfig: don't embed registry.ServiceConfig
Just define it as a type, which makes it slightly easier to consume. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
2b5dc81582
commit
bee8f006fe
|
@ -20,9 +20,7 @@ type ServiceOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// serviceConfig holds daemon configuration for the registry service.
|
// serviceConfig holds daemon configuration for the registry service.
|
||||||
type serviceConfig struct {
|
type serviceConfig registry.ServiceConfig
|
||||||
registry.ServiceConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(thaJeztah) both the "index.docker.io" and "registry-1.docker.io" domains
|
// TODO(thaJeztah) both the "index.docker.io" and "registry-1.docker.io" domains
|
||||||
// are here for historic reasons and backward-compatibility. These domains
|
// are here for historic reasons and backward-compatibility. These domains
|
||||||
|
@ -65,14 +63,7 @@ var (
|
||||||
|
|
||||||
// newServiceConfig returns a new instance of ServiceConfig
|
// newServiceConfig returns a new instance of ServiceConfig
|
||||||
func newServiceConfig(options ServiceOptions) (*serviceConfig, error) {
|
func newServiceConfig(options ServiceOptions) (*serviceConfig, error) {
|
||||||
config := &serviceConfig{
|
config := &serviceConfig{}
|
||||||
ServiceConfig: registry.ServiceConfig{
|
|
||||||
InsecureRegistryCIDRs: make([]*registry.NetIPNet, 0),
|
|
||||||
IndexConfigs: make(map[string]*registry.IndexInfo),
|
|
||||||
// Hack: Bypass setting the mirrors to IndexConfigs since they are going away
|
|
||||||
// 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
|
||||||
}
|
}
|
||||||
|
@ -87,15 +78,15 @@ func newServiceConfig(options ServiceOptions) (*serviceConfig, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy constructs a new ServiceConfig with a copy of the configuration in config.
|
// copy constructs a new ServiceConfig with a copy of the configuration in config.
|
||||||
func (config *serviceConfig) copy() *registrytypes.ServiceConfig {
|
func (config *serviceConfig) copy() *registry.ServiceConfig {
|
||||||
ic := make(map[string]*registrytypes.IndexInfo)
|
ic := make(map[string]*registry.IndexInfo)
|
||||||
for key, value := range config.IndexConfigs {
|
for key, value := range config.IndexConfigs {
|
||||||
ic[key] = value
|
ic[key] = value
|
||||||
}
|
}
|
||||||
return ®istrytypes.ServiceConfig{
|
return ®istry.ServiceConfig{
|
||||||
AllowNondistributableArtifactsCIDRs: append([]*registrytypes.NetIPNet(nil), config.AllowNondistributableArtifactsCIDRs...),
|
AllowNondistributableArtifactsCIDRs: append([]*registry.NetIPNet(nil), config.AllowNondistributableArtifactsCIDRs...),
|
||||||
AllowNondistributableArtifactsHostnames: append([]string(nil), config.AllowNondistributableArtifactsHostnames...),
|
AllowNondistributableArtifactsHostnames: append([]string(nil), config.AllowNondistributableArtifactsHostnames...),
|
||||||
InsecureRegistryCIDRs: append([]*registrytypes.NetIPNet(nil), config.InsecureRegistryCIDRs...),
|
InsecureRegistryCIDRs: append([]*registry.NetIPNet(nil), config.InsecureRegistryCIDRs...),
|
||||||
IndexConfigs: ic,
|
IndexConfigs: ic,
|
||||||
Mirrors: append([]string(nil), config.Mirrors...),
|
Mirrors: append([]string(nil), config.Mirrors...),
|
||||||
}
|
}
|
||||||
|
@ -158,11 +149,13 @@ func (config *serviceConfig) loadMirrors(mirrors []string) error {
|
||||||
config.Mirrors = unique
|
config.Mirrors = unique
|
||||||
|
|
||||||
// Configure public registry since mirrors may have changed.
|
// Configure public registry since mirrors may have changed.
|
||||||
config.IndexConfigs[IndexName] = ®istry.IndexInfo{
|
config.IndexConfigs = map[string]*registry.IndexInfo{
|
||||||
|
IndexName: {
|
||||||
Name: IndexName,
|
Name: IndexName,
|
||||||
Mirrors: config.Mirrors,
|
Mirrors: unique,
|
||||||
Secure: true,
|
Secure: true,
|
||||||
Official: true,
|
Official: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue