Browse code

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>

Sebastiaan van Stijn authored on 2022/03/02 19:43:33
Showing 6 changed files
... ...
@@ -9,5 +9,5 @@ import (
9 9
 
10 10
 // AuthenticateToRegistry checks the validity of credentials in authConfig
11 11
 func (daemon *Daemon) AuthenticateToRegistry(ctx context.Context, authConfig *types.AuthConfig) (string, string, error) {
12
-	return daemon.RegistryService.Auth(ctx, authConfig, dockerversion.DockerUserAgent(ctx))
12
+	return daemon.registryService.Auth(ctx, authConfig, dockerversion.DockerUserAgent(ctx))
13 13
 }
... ...
@@ -78,7 +78,7 @@ var (
78 78
 
79 79
 // Daemon holds information about the Docker daemon.
80 80
 type Daemon struct {
81
-	ID                    string
81
+	id                    string
82 82
 	repository            string
83 83
 	containers            container.Store
84 84
 	containersReplica     container.ViewDB
... ...
@@ -88,7 +88,7 @@ type Daemon struct {
88 88
 	configStore           *config.Config
89 89
 	statsCollector        *stats.Collector
90 90
 	defaultLogConfig      containertypes.LogConfig
91
-	RegistryService       registry.Service
91
+	registryService       registry.Service
92 92
 	EventsService         *events.Events
93 93
 	netController         libnetwork.NetworkController
94 94
 	volumes               *volumesservice.VolumesService
... ...
@@ -852,7 +852,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
852 852
 		}
853 853
 	}
854 854
 
855
-	d.RegistryService = registryService
855
+	d.registryService = registryService
856 856
 	logger.RegisterPluginGetter(d.PluginStore)
857 857
 
858 858
 	metricsSockPath, err := d.listenMetricsSock()
... ...
@@ -1021,7 +1021,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
1021 1021
 		return nil, errors.New("Devices cgroup isn't mounted")
1022 1022
 	}
1023 1023
 
1024
-	d.ID = trustKey.PublicKey().KeyID()
1024
+	d.id = trustKey.PublicKey().KeyID()
1025 1025
 	d.repository = daemonRepo
1026 1026
 	d.containers = container.NewMemoryStore()
1027 1027
 	if d.containersReplica, err = container.NewViewDB(); err != nil {
... ...
@@ -91,7 +91,7 @@ func (daemon *Daemon) LogDaemonEventWithAttributes(action string, attributes map
91 91
 			attributes["name"] = info.Name
92 92
 		}
93 93
 		actor := events.Actor{
94
-			ID:         daemon.ID,
94
+			ID:         daemon.id,
95 95
 			Attributes: attributes,
96 96
 		}
97 97
 		daemon.EventsService.Log(action, events.DaemonEventType, actor)
... ...
@@ -32,7 +32,7 @@ func (daemon *Daemon) SystemInfo() *types.Info {
32 32
 	sysInfo := daemon.RawSysInfo()
33 33
 
34 34
 	v := &types.Info{
35
-		ID:                 daemon.ID,
35
+		ID:                 daemon.id,
36 36
 		Images:             daemon.imageService.CountImages(),
37 37
 		IPv4Forwarding:     !sysInfo.IPv4ForwardingDisabled,
38 38
 		BridgeNfIptables:   !sysInfo.BridgeNFCallIPTablesDisabled,
... ...
@@ -50,7 +50,7 @@ func (daemon *Daemon) SystemInfo() *types.Info {
50 50
 		IndexServerAddress: registry.IndexServer,
51 51
 		OSType:             platform.OSType,
52 52
 		Architecture:       platform.Architecture,
53
-		RegistryConfig:     daemon.RegistryService.ServiceConfig(),
53
+		RegistryConfig:     daemon.registryService.ServiceConfig(),
54 54
 		NCPU:               sysinfo.NumCPU(),
55 55
 		MemTotal:           memInfo().MemTotal,
56 56
 		GenericResources:   daemon.genericResources,
... ...
@@ -184,7 +184,7 @@ func (daemon *Daemon) reloadAllowNondistributableArtifacts(conf *config.Config,
184 184
 	// Update corresponding configuration.
185 185
 	if conf.IsValueSet("allow-nondistributable-artifacts") {
186 186
 		daemon.configStore.AllowNondistributableArtifacts = conf.AllowNondistributableArtifacts
187
-		if err := daemon.RegistryService.LoadAllowNondistributableArtifacts(conf.AllowNondistributableArtifacts); err != nil {
187
+		if err := daemon.registryService.LoadAllowNondistributableArtifacts(conf.AllowNondistributableArtifacts); err != nil {
188 188
 			return err
189 189
 		}
190 190
 	}
... ...
@@ -209,7 +209,7 @@ func (daemon *Daemon) reloadInsecureRegistries(conf *config.Config, attributes m
209 209
 	// update corresponding configuration
210 210
 	if conf.IsValueSet("insecure-registries") {
211 211
 		daemon.configStore.InsecureRegistries = conf.InsecureRegistries
212
-		if err := daemon.RegistryService.LoadInsecureRegistries(conf.InsecureRegistries); err != nil {
212
+		if err := daemon.registryService.LoadInsecureRegistries(conf.InsecureRegistries); err != nil {
213 213
 			return err
214 214
 		}
215 215
 	}
... ...
@@ -234,7 +234,7 @@ func (daemon *Daemon) reloadRegistryMirrors(conf *config.Config, attributes map[
234 234
 	// update corresponding configuration
235 235
 	if conf.IsValueSet("registry-mirrors") {
236 236
 		daemon.configStore.Mirrors = conf.Mirrors
237
-		if err := daemon.RegistryService.LoadMirrors(conf.Mirrors); err != nil {
237
+		if err := daemon.registryService.LoadMirrors(conf.Mirrors); err != nil {
238 238
 			return err
239 239
 		}
240 240
 	}
... ...
@@ -58,7 +58,7 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) {
58 58
 
59 59
 	var err error
60 60
 	// Initialize daemon with some registries.
61
-	daemon.RegistryService, err = registry.NewService(registry.ServiceOptions{
61
+	daemon.registryService, err = registry.NewService(registry.ServiceOptions{
62 62
 		AllowNondistributableArtifacts: []string{
63 63
 			"127.0.0.0/8",
64 64
 			"10.10.1.11:5000",
... ...
@@ -95,7 +95,7 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) {
95 95
 	}
96 96
 
97 97
 	var actual []string
98
-	serviceConfig := daemon.RegistryService.ServiceConfig()
98
+	serviceConfig := daemon.registryService.ServiceConfig()
99 99
 	for _, value := range serviceConfig.AllowNondistributableArtifactsCIDRs {
100 100
 		actual = append(actual, value.String())
101 101
 	}
... ...
@@ -113,7 +113,7 @@ func TestDaemonReloadMirrors(t *testing.T) {
113 113
 	muteLogs()
114 114
 
115 115
 	var err error
116
-	daemon.RegistryService, err = registry.NewService(registry.ServiceOptions{
116
+	daemon.registryService, err = registry.NewService(registry.ServiceOptions{
117 117
 		InsecureRegistries: []string{},
118 118
 		Mirrors: []string{
119 119
 			"https://mirror.test1.example.com",
... ...
@@ -180,7 +180,7 @@ func TestDaemonReloadMirrors(t *testing.T) {
180 180
 				// mirrors should be valid, should be no error
181 181
 				t.Fatal(err)
182 182
 			}
183
-			registryService := daemon.RegistryService.ServiceConfig()
183
+			registryService := daemon.registryService.ServiceConfig()
184 184
 
185 185
 			if len(registryService.Mirrors) != len(value.after) {
186 186
 				t.Fatalf("Expected %d daemon mirrors %s while get %d with %s",
... ...
@@ -215,7 +215,7 @@ func TestDaemonReloadInsecureRegistries(t *testing.T) {
215 215
 
216 216
 	var err error
217 217
 	// initialize daemon with existing insecure registries: "127.0.0.0/8", "10.10.1.11:5000", "10.10.1.22:5000"
218
-	daemon.RegistryService, err = registry.NewService(registry.ServiceOptions{
218
+	daemon.registryService, err = registry.NewService(registry.ServiceOptions{
219 219
 		InsecureRegistries: []string{
220 220
 			"127.0.0.0/8",
221 221
 			"10.10.1.11:5000",
... ...
@@ -256,7 +256,7 @@ func TestDaemonReloadInsecureRegistries(t *testing.T) {
256 256
 
257 257
 	// After Reload, daemon.RegistryService will be changed which is useful
258 258
 	// for registry communication in daemon.
259
-	registries := daemon.RegistryService.ServiceConfig()
259
+	registries := daemon.registryService.ServiceConfig()
260 260
 
261 261
 	// After Reload(), newConfig has come to registries.InsecureRegistryCIDRs and registries.IndexConfigs in daemon.
262 262
 	// Then collect registries.InsecureRegistryCIDRs in dataMap.