Repository: kubernetes-sigs/cloud-provider-azure
Pull request #754 (2021-08-18 02:24:47)

chore: expose some public functions
<!--  Thanks for sending a pull request!  Here are some tips for you:

1. If this is your first time, please read our contributor guidelines: https://git.k8s.io/community/contributors/guide#your-first-contribution and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request. For reference on required PR/issue labels, read here:
https://git.k8s.io/community/contributors/devel/release.md#issue-kind-label
3. Ensure you have added or ran the appropriate tests for your PR: https://git.k8s.io/community/contributors/devel/testing.md
4. If you want *faster* PR reviews, read how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
5. Follow the instructions for writing a release note: https://git.k8s.io/community/contributors/guide/release-notes.md
6. If the PR is unfinished, see how to mark it: https://git.k8s.io/community/contributors/guide/pull-requests.md#marking-unfinished-pull-requests
-->

**What type of PR is this?**
/kind cleanup

**What this PR does / why we need it**:
chore: expose some public functions

**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #

**Special notes for your reviewer**:


**Release note**:
```
chore: expose some public functions
```



Patch:
diff --git a/pkg/provider/azure.go b/pkg/provider/azure.go
index 820c47582..81c5b796a 100644
--- a/pkg/provider/azure.go
+++ b/pkg/provider/azure.go
@@ -427,7 +427,7 @@ func NewCloudFromSecret(clientBuilder cloudprovider.ControllerClientBuilder, sec
 // NewCloudWithoutFeatureGates returns a Cloud without trying to wire the feature gates.  This is used by the unit tests
 // that don't load the actual features being used in the cluster.
 func NewCloudWithoutFeatureGates(configReader io.Reader, callFromCCM bool) (*Cloud, error) {
-	config, err := parseConfig(configReader)
+	config, err := ParseConfig(configReader)
 	if err != nil {
 		return nil, err
 	}
@@ -809,8 +809,8 @@ func (az *Cloud) getAzureClientConfig(servicePrincipalToken *adal.ServicePrincip
 	return azClientConfig
 }
 
-// parseConfig returns a parsed configuration for an Azure cloudprovider config file
-func parseConfig(configReader io.Reader) (*Config, error) {
+// ParseConfig returns a parsed configuration for an Azure cloudprovider config file
+func ParseConfig(configReader io.Reader) (*Config, error) {
 	var config Config
 	if configReader == nil {
 		return nil, nil
diff --git a/pkg/provider/azure_config.go b/pkg/provider/azure_config.go
index b4478e94b..4b0af9e7e 100644
--- a/pkg/provider/azure_config.go
+++ b/pkg/provider/azure_config.go
@@ -40,7 +40,7 @@ const (
 
 // InitializeCloudFromSecret initializes Azure cloud provider from Kubernetes secret.
 func (az *Cloud) InitializeCloudFromSecret() error {
-	config, err := az.getConfigFromSecret()
+	config, err := az.GetConfigFromSecret()
 	if err != nil {
 		klog.Errorf("Failed to get cloud-config from secret: %v", err)
 		return fmt.Errorf("InitializeCloudFromSecret: failed to get cloud config from secret %s/%s: %w", az.SecretNamespace, az.SecretName, err)
@@ -59,7 +59,7 @@ func (az *Cloud) InitializeCloudFromSecret() error {
 	return nil
 }
 
-func (az *Cloud) getConfigFromSecret() (*Config, error) {
+func (az *Cloud) GetConfigFromSecret() (*Config, error) {
 	// Read config from file and no override, return nil.
 	if az.Config.CloudConfigType == cloudConfigTypeFile {
 		return nil, nil


Test patch:
diff --git a/pkg/provider/azure_config_test.go b/pkg/provider/azure_config_test.go
index 68350af17..3da00c653 100644
--- a/pkg/provider/azure_config_test.go
+++ b/pkg/provider/azure_config_test.go
@@ -177,7 +177,7 @@ func TestGetConfigFromSecret(t *testing.T) {
 				assert.NoError(t, err, test.name)
 			}
 
-			real, err := az.getConfigFromSecret()
+			real, err := az.GetConfigFromSecret()
 			if test.expectErr {
 				assert.Error(t, err, test.name)
 				return
diff --git a/pkg/provider/azure_ratelimit_test.go b/pkg/provider/azure_ratelimit_test.go
index 43087ee13..3395cb248 100644
--- a/pkg/provider/azure_ratelimit_test.go
+++ b/pkg/provider/azure_ratelimit_test.go
@@ -152,14 +152,14 @@ func TestParseConfig(t *testing.T) {
 	}
 
 	buffer := bytes.NewBufferString(testAzureConfig)
-	config, err := parseConfig(buffer)
+	config, err := ParseConfig(buffer)
 	assert.NoError(t, err)
 	assert.Equal(t, expected, config)
 }
 
 func TestInitializeCloudProviderRateLimitConfig(t *testing.T) {
 	buffer := bytes.NewBufferString(testAzureConfig)
-	config, err := parseConfig(buffer)
+	config, err := ParseConfig(buffer)
 	assert.NoError(t, err)
 
 	InitializeCloudProviderRateLimitConfig(&config.CloudProviderRateLimitConfig)
diff --git a/pkg/provider/azure_test.go b/pkg/provider/azure_test.go
index 78019e015..37bfdfd29 100644
--- a/pkg/provider/azure_test.go
+++ b/pkg/provider/azure_test.go
@@ -2128,7 +2128,7 @@ func getCloudFromConfig(t *testing.T, config string) *Cloud {
 	defer ctrl.Finish()
 
 	configReader := strings.NewReader(config)
-	c, err := parseConfig(configReader)
+	c, err := ParseConfig(configReader)
 	assert.NoError(t, err)
 
 	az := &Cloud{