diff --git a/pkg/azclient/configloader/load.go b/pkg/azclient/configloader/load.go index efa79c52be..63d6b18896 100644 --- a/pkg/azclient/configloader/load.go +++ b/pkg/azclient/configloader/load.go @@ -56,22 +56,22 @@ func Load[Type any](ctx context.Context, secretLoaderConfig *K8sSecretLoaderConf var err error if fileLoaderConfig != nil { loadConfigloader := newEmptyLoader[ConfigMergeConfig](&ConfigMergeConfig{CloudConfigType: CloudConfigTypeMerge}) - loadConfigloader = newFileLoader(fileLoaderConfig.FilePath, loadConfigloader, newYamlByteLoader[ConfigMergeConfig]) + loadConfigloader = newFileLoader(fileLoaderConfig.FilePath, loadConfigloader, NewYamlByteLoader[ConfigMergeConfig]) //by default the config load type is merge loadConfig, err = loadConfigloader.Load(ctx) if err != nil { return nil, err } - configloader = newFileLoader(fileLoaderConfig.FilePath, nil, newYamlByteLoader[Type]) + configloader = newFileLoader(fileLoaderConfig.FilePath, nil, NewYamlByteLoader[Type]) if strings.EqualFold(string(loadConfig.CloudConfigType), string(CloudConfigTypeFile)) { return configloader.Load(ctx) } } if secretLoaderConfig != nil { if loadConfig != nil && strings.EqualFold(string(loadConfig.CloudConfigType), string(CloudConfigTypeSecret)) { - configloader = newK8sSecretLoader(&secretLoaderConfig.K8sSecretConfig, secretLoaderConfig.KubeClient, nil, newYamlByteLoader[Type]) + configloader = newK8sSecretLoader(&secretLoaderConfig.K8sSecretConfig, secretLoaderConfig.KubeClient, nil, NewYamlByteLoader[Type]) } else { - configloader = newK8sSecretLoader(&secretLoaderConfig.K8sSecretConfig, secretLoaderConfig.KubeClient, configloader, newYamlByteLoader[Type]) + configloader = newK8sSecretLoader(&secretLoaderConfig.K8sSecretConfig, secretLoaderConfig.KubeClient, configloader, NewYamlByteLoader[Type]) } } return configloader.Load(ctx) diff --git a/pkg/azclient/configloader/loader_file_test.go b/pkg/azclient/configloader/loader_file_test.go index 9b25ab3f8a..d3bee04a9a 100644 --- a/pkg/azclient/configloader/loader_file_test.go +++ b/pkg/azclient/configloader/loader_file_test.go @@ -24,7 +24,7 @@ import ( var _ = Describe("LoaderFile", func() { When("invalid config content is provided", func() { It("should return error", func() { - loader := newFileLoader[TestConfig]("error", nil, newYamlByteLoader[TestConfig]) + loader := newFileLoader[TestConfig]("error", nil, NewYamlByteLoader[TestConfig]) config, err := loader.Load(nil) Expect(err).NotTo(BeNil()) Expect(config).To(BeNil()) @@ -32,7 +32,7 @@ var _ = Describe("LoaderFile", func() { }) When("valid config content is provided", func() { It("should return error", func() { - loader := newFileLoader[TestConfig]("testdata/azure.json", nil, newYamlByteLoader[TestConfig]) + loader := newFileLoader[TestConfig]("testdata/azure.json", nil, NewYamlByteLoader[TestConfig]) config, err := loader.Load(nil) Expect(err).To(BeNil()) Expect(config).NotTo(BeNil()) diff --git a/pkg/azclient/configloader/loader_yaml.go b/pkg/azclient/configloader/loader_yaml.go index c5a8a1f30b..3460258349 100644 --- a/pkg/azclient/configloader/loader_yaml.go +++ b/pkg/azclient/configloader/loader_yaml.go @@ -23,14 +23,14 @@ import ( "sigs.k8s.io/yaml" ) -// yamlByteLoader is a FactoryConfigLoader that loads a YAML file from a byte array. -type yamlByteLoader[Type any] struct { +// YamlByteLoader is a FactoryConfigLoader that loads a YAML file from a byte array. +type YamlByteLoader[Type any] struct { content []byte configLoader[Type] } // Load loads the YAML file from the byte array and returns the client factory config. -func (s *yamlByteLoader[Type]) Load(ctx context.Context) (*Type, error) { +func (s *YamlByteLoader[Type]) Load(ctx context.Context) (*Type, error) { if s.configLoader == nil { s.configLoader = newEmptyLoader[Type](nil) } @@ -45,9 +45,9 @@ func (s *yamlByteLoader[Type]) Load(ctx context.Context) (*Type, error) { return config, nil } -// newYamlByteLoader creates a YamlByteLoader with the specified content and loader. -func newYamlByteLoader[Type any](content []byte, loader configLoader[Type]) configLoader[Type] { - return &yamlByteLoader[Type]{ +// NewYamlByteLoader creates a YamlByteLoader with the specified content and loader. +func NewYamlByteLoader[Type any](content []byte, loader configLoader[Type]) configLoader[Type] { + return &YamlByteLoader[Type]{ content: content, configLoader: loader, } diff --git a/pkg/azclient/configloader/loader_yaml_test.go b/pkg/azclient/configloader/loader_yaml_test.go index f5ef270caf..f2700cf22d 100644 --- a/pkg/azclient/configloader/loader_yaml_test.go +++ b/pkg/azclient/configloader/loader_yaml_test.go @@ -26,7 +26,7 @@ import ( var _ = Describe("LoaderYaml", func() { When("invalid config content is provided", func() { It("should return error", func() { - loader := newYamlByteLoader[TestConfig]([]byte("error"), nil) + loader := NewYamlByteLoader[TestConfig]([]byte("error"), nil) config, err := loader.Load(context.Background()) Expect(err).NotTo(BeNil()) Expect(config).To(BeNil()) @@ -34,7 +34,7 @@ var _ = Describe("LoaderYaml", func() { }) When("valid config content is provided", func() { It("should return error", func() { - loader := newYamlByteLoader[TestConfig]([]byte(`{"value":"123"}`), nil) + loader := NewYamlByteLoader[TestConfig]([]byte(`{"value":"123"}`), nil) config, err := loader.Load(context.Background()) Expect(err).To(BeNil()) Expect(config).NotTo(BeNil()) @@ -43,7 +43,7 @@ var _ = Describe("LoaderYaml", func() { }) When("valid config content is provided with default config", func() { It("should return error", func() { - loader := newYamlByteLoader[TestConfig]([]byte(`{"value":"123"}`), newFileLoader[TestConfig]("wrong", nil, newYamlByteLoader[TestConfig])) + loader := NewYamlByteLoader[TestConfig]([]byte(`{"value":"123"}`), newFileLoader[TestConfig]("wrong", nil, NewYamlByteLoader[TestConfig])) config, err := loader.Load(context.Background()) Expect(err).NotTo(BeNil()) Expect(config).To(BeNil())