diff --git a/windows-agent/internal/config/config.go b/windows-agent/internal/config/config.go index 473ed8e3f..ff29f8b9d 100644 --- a/windows-agent/internal/config/config.go +++ b/windows-agent/internal/config/config.go @@ -83,7 +83,7 @@ func New(ctx context.Context, cachePath string, args ...Option) (m *Config) { } // Subscription returns the ProToken and the method it was acquired with (if any). -func (c *Config) Subscription(ctx context.Context) (token string, source ConfigSource, err error) { +func (c *Config) Subscription(ctx context.Context) (token string, source Source, err error) { c.mu.Lock() defer c.mu.Unlock() @@ -141,7 +141,7 @@ func (c *Config) ProvisioningTasks(ctx context.Context, distroName string) ([]ta } // SetSubscription overwrites the value of the pro token and the method with which it has been acquired. -func (c *Config) SetSubscription(ctx context.Context, proToken string, source ConfigSource) error { +func (c *Config) SetSubscription(ctx context.Context, proToken string, source Source) error { c.mu.Lock() defer c.mu.Unlock() @@ -163,7 +163,7 @@ func (c *Config) SetSubscription(ctx context.Context, proToken string, source Co } // LandscapeClientConfig returns the value of the landscape server URL. -func (c *Config) LandscapeClientConfig(ctx context.Context) (string, ConfigSource, error) { +func (c *Config) LandscapeClientConfig(ctx context.Context) (string, Source, error) { c.mu.Lock() defer c.mu.Unlock() diff --git a/windows-agent/internal/config/config_layering.go b/windows-agent/internal/config/config_layering.go index 44d10b9ab..049532738 100644 --- a/windows-agent/internal/config/config_layering.go +++ b/windows-agent/internal/config/config_layering.go @@ -2,13 +2,13 @@ package config import "fmt" -// ConfigSource indicates the method a configuration parameter was acquired. -type ConfigSource int +// Source indicates the method a configuration parameter was acquired. +type Source int // ConfigSource types. const ( // SourceNone -> no data. - SourceNone ConfigSource = iota + SourceNone Source = iota // SourceRegistry -> the data was obtained from the registry. SourceRegistry @@ -27,7 +27,7 @@ type subscription struct { Checksum string } -func (s subscription) resolve() (string, ConfigSource) { +func (s subscription) resolve() (string, Source) { if s.Store != "" { return s.Store, SourceMicrosoftStore } @@ -43,17 +43,17 @@ func (s subscription) resolve() (string, ConfigSource) { return "", SourceNone } -func (s *subscription) Set(src ConfigSource, proToken string) { +func (s *subscription) Set(src Source, proToken string) { ptr := s.src(src) *ptr = proToken } -func (s *subscription) Get(src ConfigSource) string { +func (s *subscription) Get(src Source) string { return *s.src(src) } // src is a helper to avoid duplicationg the mapping in Get and Set. -func (s *subscription) src(src ConfigSource) *string { +func (s *subscription) src(src Source) *string { switch src { case SourceNone: // TODO: Panic? Warning? @@ -77,7 +77,7 @@ type landscapeConf struct { Checksum string } -func (p landscapeConf) resolve() (string, ConfigSource) { +func (p landscapeConf) resolve() (string, Source) { if p.GUIConfig != "" { return p.GUIConfig, SourceGUI } diff --git a/windows-agent/internal/config/config_test.go b/windows-agent/internal/config/config_test.go index d1e5127ad..485d66d83 100644 --- a/windows-agent/internal/config/config_test.go +++ b/windows-agent/internal/config/config_test.go @@ -58,7 +58,7 @@ func TestSubscription(t *testing.T) { settingsState settingsState wantToken string - wantSource config.ConfigSource + wantSource config.Source wantError bool }{ "Success": {settingsState: userTokenHasValue, wantToken: "user_token", wantSource: config.SourceGUI}, @@ -112,7 +112,7 @@ func TestLandscapeConfig(t *testing.T) { settingsState settingsState wantLandscapeConfig string - wantSource config.ConfigSource + wantSource config.Source wantError bool }{ "Success": {settingsState: userLandscapeConfigHasValue, wantLandscapeConfig: "[client]\nuser=JohnDoe", wantSource: config.SourceGUI}, diff --git a/windows-agent/internal/proservices/landscape/landscape.go b/windows-agent/internal/proservices/landscape/landscape.go index a2f5dd639..7ca080449 100644 --- a/windows-agent/internal/proservices/landscape/landscape.go +++ b/windows-agent/internal/proservices/landscape/landscape.go @@ -54,9 +54,9 @@ type connection struct { // Config is a configuration provider for ProToken and the Landscape URL. type Config interface { - LandscapeClientConfig(context.Context) (string, config.ConfigSource, error) + LandscapeClientConfig(context.Context) (string, config.Source, error) - Subscription(context.Context) (string, config.ConfigSource, error) + Subscription(context.Context) (string, config.Source, error) LandscapeAgentUID(context.Context) (string, error) SetLandscapeAgentUID(context.Context, string) error diff --git a/windows-agent/internal/proservices/landscape/landscape_test.go b/windows-agent/internal/proservices/landscape/landscape_test.go index 9a27997c9..e9a47e454 100644 --- a/windows-agent/internal/proservices/landscape/landscape_test.go +++ b/windows-agent/internal/proservices/landscape/landscape_test.go @@ -798,7 +798,7 @@ type mockConfig struct { mu sync.Mutex } -func (m *mockConfig) LandscapeClientConfig(ctx context.Context) (string, config.ConfigSource, error) { +func (m *mockConfig) LandscapeClientConfig(ctx context.Context) (string, config.Source, error) { m.mu.Lock() defer m.mu.Unlock() @@ -812,7 +812,7 @@ func (m *mockConfig) ProvisioningTasks(ctx context.Context, distroName string) ( return nil, nil } -func (m *mockConfig) Subscription(ctx context.Context) (string, config.ConfigSource, error) { +func (m *mockConfig) Subscription(ctx context.Context) (string, config.Source, error) { m.mu.Lock() defer m.mu.Unlock() diff --git a/windows-agent/internal/proservices/ui/ui.go b/windows-agent/internal/proservices/ui/ui.go index 117b7867f..d5a0d3327 100644 --- a/windows-agent/internal/proservices/ui/ui.go +++ b/windows-agent/internal/proservices/ui/ui.go @@ -16,9 +16,9 @@ import ( // Config is a provider for the subcription configuration. type Config interface { - SetSubscription(ctx context.Context, token string, source config.ConfigSource) error + SetSubscription(ctx context.Context, token string, source config.Source) error IsReadOnly() (bool, error) - Subscription(context.Context) (string, config.ConfigSource, error) + Subscription(context.Context) (string, config.Source, error) FetchMicrosoftStoreSubscription(context.Context) error } diff --git a/windows-agent/internal/proservices/ui/ui_test.go b/windows-agent/internal/proservices/ui/ui_test.go index 49d76f919..fadc2b81a 100644 --- a/windows-agent/internal/proservices/ui/ui_test.go +++ b/windows-agent/internal/proservices/ui/ui_test.go @@ -218,11 +218,11 @@ type mockConfig struct { subscriptionErr bool // Config errors out in Subscription function fetchErr bool // Config errors out in FetchMicrosoftStoreSubscription function - token string // stores the configured Pro token - source config.ConfigSource // stores the configured subscription source. + token string // stores the configured Pro token + source config.Source // stores the configured subscription source. } -func (m *mockConfig) SetSubscription(ctx context.Context, token string, source config.ConfigSource) error { +func (m *mockConfig) SetSubscription(ctx context.Context, token string, source config.Source) error { if m.setSubscriptionErr { return errors.New("SetSubscription error") } @@ -236,7 +236,7 @@ func (m mockConfig) IsReadOnly() (bool, error) { } return m.registryReadOnly, nil } -func (m mockConfig) Subscription(context.Context) (string, config.ConfigSource, error) { +func (m mockConfig) Subscription(context.Context) (string, config.Source, error) { if m.subscriptionErr { return "", config.SourceNone, errors.New("Subscription error") }