daemon: unexport Daemon.ID and Daemon.RegistryService

These are used internally only, and set by daemon.NewDaemon(). If they're
used externally, we should add an accessor added (which may be something
we want to do for daemon.registryService (which should be its own backend)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-03-02 11:43:33 +01:00
parent a27f8aecad
commit ac2cd5a8f2
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
6 changed files with 17 additions and 17 deletions

View File

@ -9,5 +9,5 @@ import (
// AuthenticateToRegistry checks the validity of credentials in authConfig // AuthenticateToRegistry checks the validity of credentials in authConfig
func (daemon *Daemon) AuthenticateToRegistry(ctx context.Context, authConfig *types.AuthConfig) (string, string, error) { func (daemon *Daemon) AuthenticateToRegistry(ctx context.Context, authConfig *types.AuthConfig) (string, string, error) {
return daemon.RegistryService.Auth(ctx, authConfig, dockerversion.DockerUserAgent(ctx)) return daemon.registryService.Auth(ctx, authConfig, dockerversion.DockerUserAgent(ctx))
} }

View File

@ -78,7 +78,7 @@ var (
// Daemon holds information about the Docker daemon. // Daemon holds information about the Docker daemon.
type Daemon struct { type Daemon struct {
ID string id string
repository string repository string
containers container.Store containers container.Store
containersReplica container.ViewDB containersReplica container.ViewDB
@ -88,7 +88,7 @@ type Daemon struct {
configStore *config.Config configStore *config.Config
statsCollector *stats.Collector statsCollector *stats.Collector
defaultLogConfig containertypes.LogConfig defaultLogConfig containertypes.LogConfig
RegistryService registry.Service registryService registry.Service
EventsService *events.Events EventsService *events.Events
netController libnetwork.NetworkController netController libnetwork.NetworkController
volumes *volumesservice.VolumesService volumes *volumesservice.VolumesService
@ -852,7 +852,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
} }
} }
d.RegistryService = registryService d.registryService = registryService
logger.RegisterPluginGetter(d.PluginStore) logger.RegisterPluginGetter(d.PluginStore)
metricsSockPath, err := d.listenMetricsSock() metricsSockPath, err := d.listenMetricsSock()
@ -1021,7 +1021,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
return nil, errors.New("Devices cgroup isn't mounted") return nil, errors.New("Devices cgroup isn't mounted")
} }
d.ID = trustKey.PublicKey().KeyID() d.id = trustKey.PublicKey().KeyID()
d.repository = daemonRepo d.repository = daemonRepo
d.containers = container.NewMemoryStore() d.containers = container.NewMemoryStore()
if d.containersReplica, err = container.NewViewDB(); err != nil { if d.containersReplica, err = container.NewViewDB(); err != nil {

View File

@ -91,7 +91,7 @@ func (daemon *Daemon) LogDaemonEventWithAttributes(action string, attributes map
attributes["name"] = info.Name attributes["name"] = info.Name
} }
actor := events.Actor{ actor := events.Actor{
ID: daemon.ID, ID: daemon.id,
Attributes: attributes, Attributes: attributes,
} }
daemon.EventsService.Log(action, events.DaemonEventType, actor) daemon.EventsService.Log(action, events.DaemonEventType, actor)

View File

@ -32,7 +32,7 @@ func (daemon *Daemon) SystemInfo() *types.Info {
sysInfo := daemon.RawSysInfo() sysInfo := daemon.RawSysInfo()
v := &types.Info{ v := &types.Info{
ID: daemon.ID, ID: daemon.id,
Images: daemon.imageService.CountImages(), Images: daemon.imageService.CountImages(),
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled, IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled, BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled,
@ -50,7 +50,7 @@ func (daemon *Daemon) SystemInfo() *types.Info {
IndexServerAddress: registry.IndexServer, IndexServerAddress: registry.IndexServer,
OSType: platform.OSType, OSType: platform.OSType,
Architecture: platform.Architecture, Architecture: platform.Architecture,
RegistryConfig: daemon.RegistryService.ServiceConfig(), RegistryConfig: daemon.registryService.ServiceConfig(),
NCPU: sysinfo.NumCPU(), NCPU: sysinfo.NumCPU(),
MemTotal: memInfo().MemTotal, MemTotal: memInfo().MemTotal,
GenericResources: daemon.genericResources, GenericResources: daemon.genericResources,

View File

@ -184,7 +184,7 @@ func (daemon *Daemon) reloadAllowNondistributableArtifacts(conf *config.Config,
// Update corresponding configuration. // Update corresponding configuration.
if conf.IsValueSet("allow-nondistributable-artifacts") { if conf.IsValueSet("allow-nondistributable-artifacts") {
daemon.configStore.AllowNondistributableArtifacts = conf.AllowNondistributableArtifacts daemon.configStore.AllowNondistributableArtifacts = conf.AllowNondistributableArtifacts
if err := daemon.RegistryService.LoadAllowNondistributableArtifacts(conf.AllowNondistributableArtifacts); err != nil { if err := daemon.registryService.LoadAllowNondistributableArtifacts(conf.AllowNondistributableArtifacts); err != nil {
return err return err
} }
} }
@ -209,7 +209,7 @@ func (daemon *Daemon) reloadInsecureRegistries(conf *config.Config, attributes m
// update corresponding configuration // update corresponding configuration
if conf.IsValueSet("insecure-registries") { if conf.IsValueSet("insecure-registries") {
daemon.configStore.InsecureRegistries = conf.InsecureRegistries daemon.configStore.InsecureRegistries = conf.InsecureRegistries
if err := daemon.RegistryService.LoadInsecureRegistries(conf.InsecureRegistries); err != nil { if err := daemon.registryService.LoadInsecureRegistries(conf.InsecureRegistries); err != nil {
return err return err
} }
} }
@ -234,7 +234,7 @@ func (daemon *Daemon) reloadRegistryMirrors(conf *config.Config, attributes map[
// update corresponding configuration // update corresponding configuration
if conf.IsValueSet("registry-mirrors") { if conf.IsValueSet("registry-mirrors") {
daemon.configStore.Mirrors = conf.Mirrors daemon.configStore.Mirrors = conf.Mirrors
if err := daemon.RegistryService.LoadMirrors(conf.Mirrors); err != nil { if err := daemon.registryService.LoadMirrors(conf.Mirrors); err != nil {
return err return err
} }
} }

View File

@ -58,7 +58,7 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) {
var err error var err error
// Initialize daemon with some registries. // Initialize daemon with some registries.
daemon.RegistryService, err = registry.NewService(registry.ServiceOptions{ daemon.registryService, err = registry.NewService(registry.ServiceOptions{
AllowNondistributableArtifacts: []string{ AllowNondistributableArtifacts: []string{
"127.0.0.0/8", "127.0.0.0/8",
"10.10.1.11:5000", "10.10.1.11:5000",
@ -95,7 +95,7 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) {
} }
var actual []string var actual []string
serviceConfig := daemon.RegistryService.ServiceConfig() serviceConfig := daemon.registryService.ServiceConfig()
for _, value := range serviceConfig.AllowNondistributableArtifactsCIDRs { for _, value := range serviceConfig.AllowNondistributableArtifactsCIDRs {
actual = append(actual, value.String()) actual = append(actual, value.String())
} }
@ -113,7 +113,7 @@ func TestDaemonReloadMirrors(t *testing.T) {
muteLogs() muteLogs()
var err error var err error
daemon.RegistryService, err = registry.NewService(registry.ServiceOptions{ daemon.registryService, err = registry.NewService(registry.ServiceOptions{
InsecureRegistries: []string{}, InsecureRegistries: []string{},
Mirrors: []string{ Mirrors: []string{
"https://mirror.test1.example.com", "https://mirror.test1.example.com",
@ -180,7 +180,7 @@ func TestDaemonReloadMirrors(t *testing.T) {
// mirrors should be valid, should be no error // mirrors should be valid, should be no error
t.Fatal(err) t.Fatal(err)
} }
registryService := daemon.RegistryService.ServiceConfig() registryService := daemon.registryService.ServiceConfig()
if len(registryService.Mirrors) != len(value.after) { if len(registryService.Mirrors) != len(value.after) {
t.Fatalf("Expected %d daemon mirrors %s while get %d with %s", t.Fatalf("Expected %d daemon mirrors %s while get %d with %s",
@ -215,7 +215,7 @@ func TestDaemonReloadInsecureRegistries(t *testing.T) {
var err error var err error
// initialize daemon with existing insecure registries: "127.0.0.0/8", "10.10.1.11:5000", "10.10.1.22:5000" // initialize daemon with existing insecure registries: "127.0.0.0/8", "10.10.1.11:5000", "10.10.1.22:5000"
daemon.RegistryService, err = registry.NewService(registry.ServiceOptions{ daemon.registryService, err = registry.NewService(registry.ServiceOptions{
InsecureRegistries: []string{ InsecureRegistries: []string{
"127.0.0.0/8", "127.0.0.0/8",
"10.10.1.11:5000", "10.10.1.11:5000",
@ -256,7 +256,7 @@ func TestDaemonReloadInsecureRegistries(t *testing.T) {
// After Reload, daemon.RegistryService will be changed which is useful // After Reload, daemon.RegistryService will be changed which is useful
// for registry communication in daemon. // for registry communication in daemon.
registries := daemon.RegistryService.ServiceConfig() registries := daemon.registryService.ServiceConfig()
// After Reload(), newConfig has come to registries.InsecureRegistryCIDRs and registries.IndexConfigs in daemon. // After Reload(), newConfig has come to registries.InsecureRegistryCIDRs and registries.IndexConfigs in daemon.
// Then collect registries.InsecureRegistryCIDRs in dataMap. // Then collect registries.InsecureRegistryCIDRs in dataMap.