chore: expose azure.KubeClient

This commit is contained in:
andyzhangx 2020-03-30 08:12:41 +00:00
parent e03c7756c7
commit 56cb04db4c
3 changed files with 6 additions and 6 deletions

View File

@ -262,7 +262,7 @@ type Cloud struct {
// routeCIDRs holds cache for route CIDRs.
routeCIDRs map[string]string
kubeClient clientset.Interface
KubeClient clientset.Interface
eventBroadcaster record.EventBroadcaster
eventRecorder record.EventRecorder
routeUpdater *delayedRouteUpdater
@ -639,9 +639,9 @@ func parseConfig(configReader io.Reader) (*Config, error) {
// Initialize passes a Kubernetes clientBuilder interface to the cloud provider
func (az *Cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) {
az.kubeClient = clientBuilder.ClientOrDie("azure-cloud-provider")
az.KubeClient = clientBuilder.ClientOrDie("azure-cloud-provider")
az.eventBroadcaster = record.NewBroadcaster()
az.eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: az.kubeClient.CoreV1().Events("")})
az.eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: az.KubeClient.CoreV1().Events("")})
az.eventRecorder = az.eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "azure-cloud-provider"})
az.InitializeCloudFromSecret()
}

View File

@ -69,7 +69,7 @@ func (az *Cloud) getConfigFromSecret() (*Config, error) {
return nil, nil
}
secret, err := az.kubeClient.CoreV1().Secrets(cloudConfigNamespace).Get(context.TODO(), cloudConfigSecretName, metav1.GetOptions{})
secret, err := az.KubeClient.CoreV1().Secrets(cloudConfigNamespace).Get(context.TODO(), cloudConfigSecretName, metav1.GetOptions{})
if err != nil {
return nil, fmt.Errorf("failed to get secret %s: %v", cloudConfigSecretName, err)
}

View File

@ -134,7 +134,7 @@ func TestGetConfigFromSecret(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
az := &Cloud{
kubeClient: fakeclient.NewSimpleClientset(),
KubeClient: fakeclient.NewSimpleClientset(),
}
if test.existingConfig != nil {
az.Config = *test.existingConfig
@ -154,7 +154,7 @@ func TestGetConfigFromSecret(t *testing.T) {
"cloud-config": secretData,
}
}
_, err := az.kubeClient.CoreV1().Secrets(cloudConfigNamespace).Create(context.TODO(), secret, metav1.CreateOptions{})
_, err := az.KubeClient.CoreV1().Secrets(cloudConfigNamespace).Create(context.TODO(), secret, metav1.CreateOptions{})
assert.NoError(t, err, test.name)
}