From 2c07e65096b5aa43be0a9532acc1d77b4ac2c435 Mon Sep 17 00:00:00 2001 From: Sameer Shaikh <79081767+sameshai@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:47:36 +0530 Subject: [PATCH] VolumeLables for unmanaged clusters (#44) * VolumeLables for unmanaged clusters * VolumeLables for unmanaged clusters * VolumeLables for unmanaged clusters * VolumeLables for unmanaged clusters * VolumeLables for unmanaged clusters --- go.mod | 4 ++-- go.sum | 8 ++++---- pkg/ibmcloudprovider/volume_provider.go | 5 ++++- pkg/ibmcloudprovider/volume_provider_test.go | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 9ef5c8a1..5bb94439 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/IBM/ibm-csi-common go 1.16 require ( - github.com/IBM/ibmcloud-volume-interface v1.0.1-beta4 - github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta5 + github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5 + github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta6 github.com/container-storage-interface/spec v1.3.0 github.com/elazarl/goproxy v0.0.0-20191011121108-aa519ddbe484 // indirect github.com/gofrs/uuid v4.2.0+incompatible diff --git a/go.sum b/go.sum index 19f46755..86364cac 100644 --- a/go.sum +++ b/go.sum @@ -55,10 +55,10 @@ github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7 h1:eHgfQl6IeSmzWUyiSi13CvoFYsovoyq github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs= github.com/IBM/go-sdk-core/v5 v5.9.1 h1:06pXbD9Rgmqqe2HA5YAeQbB4eYRRFgIoOT+Kh3cp1zo= github.com/IBM/go-sdk-core/v5 v5.9.1/go.mod h1:axE2JrRq79gIJTjKPBwV6gWHswvVptBjbcvvCPIxARM= -github.com/IBM/ibmcloud-volume-interface v1.0.1-beta4 h1:h5vUOeIitxpLTV/iD6F8OvuxHvvHoMDaZu3VXcUMfjw= -github.com/IBM/ibmcloud-volume-interface v1.0.1-beta4/go.mod h1:v1aT8G3Tib8pCwdr9VweNFYa94GejBuqIVTysoaVI0g= -github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta5 h1:FJk99J6Bk5WFI/EOmlVtxX2JXJMURlkezPJLjvS6+A0= -github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta5/go.mod h1:nB0Pk0f7Prvl99DtQRUfpkQdAzFXv34Dd1lkCQrlJyQ= +github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5 h1:XPNIrp4g7oEx7QOy6eB98jZs7n1tB6DTsUjEigOhouM= +github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5/go.mod h1:v1aT8G3Tib8pCwdr9VweNFYa94GejBuqIVTysoaVI0g= +github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta6 h1:D5wkqGoGfIqqH3fJwUwDj5zfQVzQqSnA7qNPiR4sYog= +github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta6/go.mod h1:CFBvpt4SKwf0mQg3u53qkZ5SxZH9gZSfdhWBa8GIP3Y= github.com/IBM/secret-common-lib v1.0.3 h1:rhhAtAE1ANSuxhA8Nulzzc2IbXWHGE8reoRSr98rRi8= github.com/IBM/secret-common-lib v1.0.3/go.mod h1:uoYY5M9G1nJVT8ytPIicdTUujcBXKldBw7ijWolU0yU= github.com/IBM/secret-utils-lib v1.0.2 h1:AdhKHo/bMmFLMz7+ZjnqSUHuU22CMQsG5meddvwKaV8= diff --git a/pkg/ibmcloudprovider/volume_provider.go b/pkg/ibmcloudprovider/volume_provider.go index ba8bc522..0d01f88f 100644 --- a/pkg/ibmcloudprovider/volume_provider.go +++ b/pkg/ibmcloudprovider/volume_provider.go @@ -45,7 +45,7 @@ type IBMCloudStorageProvider struct { var _ CloudProviderInterface = &IBMCloudStorageProvider{} // NewIBMCloudStorageProvider ... -func NewIBMCloudStorageProvider(configPath string, logger *zap.Logger) (*IBMCloudStorageProvider, error) { +func NewIBMCloudStorageProvider(configPath string, clusterVolumeLabel string, logger *zap.Logger) (*IBMCloudStorageProvider, error) { logger.Info("NewIBMCloudStorageProvider-Reading provider configuration...") // Load config file conf, err := config.ReadConfig(configPath, logger) @@ -80,6 +80,9 @@ func NewIBMCloudStorageProvider(configPath string, logger *zap.Logger) (*IBMClou logger.Info("Fetched clusterInfo..") } + //Initialize the clusterVolumeLabel once which will be used for tagging by the library. + conf.VPC.ClusterVolumeLabel = clusterVolumeLabel + // Update the CSRF Token if conf.Bluemix.PrivateAPIRoute != "" { conf.Bluemix.CSRFToken = string([]byte{}) // TODO~ Need to remove it diff --git a/pkg/ibmcloudprovider/volume_provider_test.go b/pkg/ibmcloudprovider/volume_provider_test.go index c8185547..2217071b 100644 --- a/pkg/ibmcloudprovider/volume_provider_test.go +++ b/pkg/ibmcloudprovider/volume_provider_test.go @@ -45,7 +45,7 @@ func TestNewIBMCloudStorageProvider(t *testing.T) { } configPath := filepath.Join(pwd, "..", "..", "test-fixtures", "slconfig.toml") - ibmCloudProvider, err := NewIBMCloudStorageProvider(configPath, logger) + ibmCloudProvider, err := NewIBMCloudStorageProvider(configPath, "test", logger) assert.NotNil(t, err) assert.Nil(t, ibmCloudProvider) }