From 4e3a8e73f20f93c69a05c46fef5d25441d8cdff6 Mon Sep 17 00:00:00 2001 From: GunaKKIBM <92353386+GunaKKIBM@users.noreply.github.com> Date: Mon, 30 Jan 2023 19:29:28 +0530 Subject: [PATCH] Fixing client code (#60) * Fixing client code * Moving secret provider to auth config * Updating lib and rebasing * Rebasing with master branch * Changes to pass secret provider interface * Update go.mod * Updating lib * Updating sample code * Fixing UT * Updating lib and addressing comments * Fix done while testing * Addressing comments * Addressing comments * Passing k8s client * Updating lib * Updating lib * Removing GC dependency * make vet fix * Moving to G2 resource group ID * Updating lib --- block/provider/create_snapshot.go | 2 +- block/provider/provider.go | 69 ++++++++------------------- block/provider/provider_test.go | 13 +++-- block/utils/init_provider.go | 9 ++-- common/auth/factory.go | 11 +++-- common/auth/factory_test.go | 25 +++++++--- common/iam/token_exchange_iks.go | 22 ++++----- common/iam/token_exchange_iks_test.go | 21 ++++---- etc/libconfig.toml | 4 +- go.mod | 16 ++++--- go.sum | 61 +++++++++++++++-------- iks/provider/provider.go | 13 ++--- iks/provider/provider_test.go | 13 +++-- samples/main.go | 14 +++--- 14 files changed, 160 insertions(+), 133 deletions(-) diff --git a/block/provider/create_snapshot.go b/block/provider/create_snapshot.go index 53cf14f..84b0f7d 100644 --- a/block/provider/create_snapshot.go +++ b/block/provider/create_snapshot.go @@ -47,7 +47,7 @@ func (vpcs *VPCSession) CreateSnapshot(sourceVolumeID string, snapshotParameters snapshotTemplate := &models.Snapshot{ Name: snapshotParameters.Name, SourceVolume: &models.SourceVolume{ID: sourceVolumeID}, - ResourceGroup: &models.ResourceGroup{ID: vpcs.Config.VPCConfig.ResourceGroupID}, + ResourceGroup: &models.ResourceGroup{ID: vpcs.Config.VPCConfig.G2ResourceGroupID}, } err = retry(vpcs.Logger, func() error { diff --git a/block/provider/provider.go b/block/provider/provider.go index fd84e14..314312e 100644 --- a/block/provider/provider.go +++ b/block/provider/provider.go @@ -26,6 +26,8 @@ import ( "strings" "time" + "github.com/IBM/secret-utils-lib/pkg/k8s_utils" + "github.com/IBM/ibmcloud-volume-interface/config" "github.com/IBM/ibmcloud-volume-interface/lib/metrics" "github.com/IBM/ibmcloud-volume-interface/lib/provider" @@ -70,61 +72,32 @@ type VPCBlockProvider struct { var _ local.Provider = &VPCBlockProvider{} // NewProvider initialises an instance of an IaaS provider. -func NewProvider(conf *vpcconfig.VPCBlockConfig, logger *zap.Logger) (local.Provider, error) { +func NewProvider(conf *vpcconfig.VPCBlockConfig, k8sClient *k8s_utils.KubernetesClient, logger *zap.Logger) (local.Provider, error) { logger.Info("Entering NewProvider") if conf.VPCConfig == nil { return nil, errors.New("incomplete config for VPCBlockProvider") } - //Do config validation and enable only one generationType (i.e VPC-Classic | VPC-NG) - gcConfigFound := (conf.VPCConfig.EndpointURL != "" || conf.VPCConfig.PrivateEndpointURL != "") && (conf.VPCConfig.TokenExchangeURL != "" || conf.VPCConfig.IKSTokenExchangePrivateURL != "") && (conf.VPCConfig.APIKey != "") && (conf.VPCConfig.ResourceGroupID != "") - g2ConfigFound := (conf.VPCConfig.G2EndpointPrivateURL != "" || conf.VPCConfig.G2EndpointURL != "") && (conf.VPCConfig.IKSTokenExchangePrivateURL != "" || conf.VPCConfig.G2TokenExchangeURL != "") && (conf.VPCConfig.G2APIKey != "") && (conf.VPCConfig.G2ResourceGroupID != "") - //if both config found, look for VPCTypeEnabled, otherwise default to GC - //Incase of NG configurations, override the base properties. - if (gcConfigFound && g2ConfigFound && conf.VPCConfig.VPCTypeEnabled == VPCNextGen) || (!gcConfigFound && g2ConfigFound) { - // overwrite the common variable in case of g2 i.e gen2, first preferences would be private endpoint - if conf.VPCConfig.G2EndpointPrivateURL != "" { - conf.VPCConfig.EndpointURL = conf.VPCConfig.G2EndpointPrivateURL - } else { - conf.VPCConfig.EndpointURL = conf.VPCConfig.G2EndpointURL - } - - // update iam based public toke exchange endpoint - conf.VPCConfig.TokenExchangeURL = conf.VPCConfig.G2TokenExchangeURL - - conf.VPCConfig.APIKey = conf.VPCConfig.G2APIKey - conf.VPCConfig.ResourceGroupID = conf.VPCConfig.G2ResourceGroupID + if conf.VPCConfig.G2EndpointPrivateURL != "" { + conf.VPCConfig.G2EndpointURL = conf.VPCConfig.G2EndpointPrivateURL + } - //Set API Generation As 2 (if unspecified in config/ENV-VAR) - if conf.VPCConfig.G2VPCAPIGeneration <= 0 { - conf.VPCConfig.G2VPCAPIGeneration = NEXTGenProvider - } - conf.VPCConfig.VPCAPIGeneration = conf.VPCConfig.G2VPCAPIGeneration + //Set API Generation As 2 + conf.VPCConfig.G2VPCAPIGeneration = NEXTGenProvider - //Set the APIVersion Date, it can be different in GC and NG - if conf.VPCConfig.G2APIVersion != "" { - conf.VPCConfig.APIVersion = conf.VPCConfig.G2APIVersion - } + //Set the APIVersion Date, it can be different in GC and NG + if conf.VPCConfig.G2APIVersion != "" { + conf.VPCConfig.APIVersion = conf.VPCConfig.G2APIVersion + } - //set provider-type (this usually comes from the secret) - if conf.VPCConfig.VPCBlockProviderType != VPCNextGen { - conf.VPCConfig.VPCBlockProviderType = VPCNextGen - } + //set provider-type + conf.VPCConfig.VPCBlockProviderType = VPCNextGen - //Mark this as enabled/active - if conf.VPCConfig.VPCTypeEnabled != VPCNextGen { - conf.VPCConfig.VPCTypeEnabled = VPCNextGen - } - } else { //This is GC, no-override required - conf.VPCConfig.VPCBlockProviderType = VPCClassic //incase of gc, i dont see its being set in slclient.toml, but NG cluster has this - // For backward compatibility as some of the cluster storage secret may not have private gc endpoint url - if conf.VPCConfig.PrivateEndpointURL != "" { - conf.VPCConfig.EndpointURL = conf.VPCConfig.PrivateEndpointURL - } - } + //Mark this as enabled/active + conf.VPCConfig.VPCTypeEnabled = VPCNextGen - contextCF, err := vpcauth.NewVPCContextCredentialsFactory(conf) + contextCF, err := vpcauth.NewVPCContextCredentialsFactory(conf, k8sClient) if err != nil { return nil, err } @@ -153,11 +126,11 @@ func NewProvider(conf *vpcconfig.VPCBlockConfig, logger *zap.Logger) (local.Prov ContextCF: contextCF, httpClient: httpClient, APIConfig: riaas.Config{ - BaseURL: conf.VPCConfig.EndpointURL, + BaseURL: conf.VPCConfig.G2EndpointURL, HTTPClient: httpClient, - APIVersion: conf.VPCConfig.APIVersion, - APIGeneration: conf.VPCConfig.VPCAPIGeneration, - ResourceGroup: conf.VPCConfig.ResourceGroupID, + APIVersion: conf.VPCConfig.G2APIVersion, + APIGeneration: conf.VPCConfig.G2VPCAPIGeneration, + ResourceGroup: conf.VPCConfig.G2ResourceGroupID, }, } // Update VPC config for IKS deployment diff --git a/block/provider/provider_test.go b/block/provider/provider_test.go index 2a860ab..8f7e474 100644 --- a/block/provider/provider_test.go +++ b/block/provider/provider_test.go @@ -22,6 +22,8 @@ import ( "context" "net/http" "net/http/httptest" + "os" + "path/filepath" "testing" "time" @@ -33,6 +35,7 @@ import ( vpcconfig "github.com/IBM/ibmcloud-volume-vpc/block/vpcconfig" "github.com/IBM/ibmcloud-volume-vpc/common/vpcclient/riaas/fakes" volumeServiceFakes "github.com/IBM/ibmcloud-volume-vpc/common/vpcclient/vpcvolume/fakes" + "github.com/IBM/secret-utils-lib/pkg/k8s_utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap" @@ -105,9 +108,13 @@ func TestNewProvider(t *testing.T) { }, } - prov, err := NewProvider(conf, logger) - assert.Nil(t, prov) - assert.NotNil(t, err) + kc, _ := k8s_utils.FakeGetk8sClientSet() + pwd, _ := os.Getwd() + file := filepath.Join(pwd, "..", "..", "etc", "libconfig.toml") + err = k8s_utils.FakeCreateSecret(kc, "DEFAULT", file) + prov, err := NewProvider(conf, &kc, logger) + assert.NotNil(t, prov) + assert.Nil(t, err) } func GetTestProvider(t *testing.T, logger *zap.Logger) (*VPCBlockProvider, error) { diff --git a/block/utils/init_provider.go b/block/utils/init_provider.go index 048daa3..27186b6 100644 --- a/block/utils/init_provider.go +++ b/block/utils/init_provider.go @@ -27,19 +27,20 @@ import ( vpcconfig "github.com/IBM/ibmcloud-volume-vpc/block/vpcconfig" "github.com/IBM/ibmcloud-volume-vpc/common/registry" iks_vpc_provider "github.com/IBM/ibmcloud-volume-vpc/iks/provider" + "github.com/IBM/secret-utils-lib/pkg/k8s_utils" "go.uber.org/zap" "golang.org/x/net/context" ) // InitProviders initialization for all providers as per configurations -func InitProviders(conf *vpcconfig.VPCBlockConfig, logger *zap.Logger) (registry.Providers, error) { +func InitProviders(conf *vpcconfig.VPCBlockConfig, k8sClient *k8s_utils.KubernetesClient, logger *zap.Logger) (registry.Providers, error) { var haveProviders bool providerRegistry := ®istry.ProviderRegistry{} // VPC provider registration if conf.VPCConfig != nil && conf.VPCConfig.Enabled { logger.Info("Configuring VPC Block Provider") - prov, err := vpc_provider.NewProvider(conf, logger) + prov, err := vpc_provider.NewProvider(conf, k8sClient, logger) if err != nil { logger.Info("VPC block provider error!") return nil, err @@ -51,7 +52,7 @@ func InitProviders(conf *vpcconfig.VPCBlockConfig, logger *zap.Logger) (registry // IKS provider registration if conf.IKSConfig != nil && conf.IKSConfig.Enabled { logger.Info("Configuring IKS-VPC Block Provider") - prov, err := iks_vpc_provider.NewProvider(conf, logger) + prov, err := iks_vpc_provider.NewProvider(conf, k8sClient, logger) if err != nil { logger.Info("VPC block provider error!") return nil, err @@ -106,7 +107,7 @@ func GenerateContextCredentials(conf *vpcconfig.VPCBlockConfig, providerID strin switch { case (conf.VPCConfig != nil && providerID == conf.VPCConfig.VPCBlockProviderName): ctxLogger.Info("Calling provider/init_provider.go ForIAMAccessToken") - return contextCredentialsFactory.ForIAMAccessToken(conf.VPCConfig.APIKey, ctxLogger) + return contextCredentialsFactory.ForIAMAccessToken(conf.VPCConfig.G2APIKey, ctxLogger) case (conf.IKSConfig != nil && providerID == conf.IKSConfig.IKSBlockProviderName): return provider.ContextCredentials{}, nil // Get credentials in OpenSession method diff --git a/common/auth/factory.go b/common/auth/factory.go index 7976f00..38f216a 100644 --- a/common/auth/factory.go +++ b/common/auth/factory.go @@ -22,26 +22,27 @@ import ( "github.com/IBM/ibmcloud-volume-interface/provider/iam" vpcconfig "github.com/IBM/ibmcloud-volume-vpc/block/vpcconfig" vpciam "github.com/IBM/ibmcloud-volume-vpc/common/iam" + "github.com/IBM/secret-utils-lib/pkg/k8s_utils" ) // NewVPCContextCredentialsFactory ... -func NewVPCContextCredentialsFactory(config *vpcconfig.VPCBlockConfig) (*auth.ContextCredentialsFactory, error) { +func NewVPCContextCredentialsFactory(config *vpcconfig.VPCBlockConfig, k8sClient *k8s_utils.KubernetesClient) (*auth.ContextCredentialsFactory, error) { authConfig := &iam.AuthConfiguration{ - IamURL: config.VPCConfig.TokenExchangeURL, + IamURL: config.VPCConfig.G2TokenExchangeURL, IamClientID: config.VPCConfig.IamClientID, IamClientSecret: config.VPCConfig.IamClientSecret, } - ccf, err := auth.NewContextCredentialsFactory(authConfig, iam.VPC) + ccf, err := auth.NewContextCredentialsFactory(authConfig, k8sClient, iam.VPC) if err != nil { return nil, err } if config.VPCConfig.IKSTokenExchangePrivateURL != "" { authIKSConfig := &vpciam.IksAuthConfiguration{ - IamAPIKey: config.VPCConfig.APIKey, + IamAPIKey: config.VPCConfig.G2APIKey, PrivateAPIRoute: config.VPCConfig.IKSTokenExchangePrivateURL, // Only for private cluster CSRFToken: config.APIConfig.PassthroughSecret, // required for private cluster } - ccf.TokenExchangeService, err = vpciam.NewTokenExchangeIKSService(authIKSConfig) + ccf.TokenExchangeService, err = vpciam.NewTokenExchangeIKSService(authIKSConfig, k8sClient) if err != nil { return nil, err } diff --git a/common/auth/factory_test.go b/common/auth/factory_test.go index 7222a73..7f63ce7 100644 --- a/common/auth/factory_test.go +++ b/common/auth/factory_test.go @@ -18,24 +18,35 @@ package auth import ( + "os" + "path/filepath" "testing" "github.com/IBM/ibmcloud-volume-interface/config" vpcconfig "github.com/IBM/ibmcloud-volume-vpc/block/vpcconfig" + "github.com/IBM/secret-utils-lib/pkg/k8s_utils" "github.com/stretchr/testify/assert" ) func TestNewContextCredentialsFactory(t *testing.T) { conf := &vpcconfig.VPCBlockConfig{ VPCConfig: &config.VPCProviderConfig{ - Enabled: true, - EndpointURL: "test-iam-url", - VPCTimeout: "30s", - IamClientID: "test-iam_client_id", - IamClientSecret: "test-iam_client_secret", + Enabled: true, + EndpointURL: "test-iam-url", + VPCTimeout: "30s", + IamClientID: "test-iam_client_id", + IamClientSecret: "test-iam_client_secret", + IKSTokenExchangePrivateURL: "token-exchange-private-URL", + }, + APIConfig: &config.APIConfig{ + PassthroughSecret: "pass-through-secret", }, } - _, err := NewVPCContextCredentialsFactory(conf) - assert.NotNil(t, err) + kc, _ := k8s_utils.FakeGetk8sClientSet() + pwd, _ := os.Getwd() + file := filepath.Join(pwd, "..", "..", "etc", "libconfig.toml") + _ = k8s_utils.FakeCreateSecret(kc, "DEFAULT", file) + _, err := NewVPCContextCredentialsFactory(conf, &kc) + assert.Nil(t, err) } diff --git a/common/iam/token_exchange_iks.go b/common/iam/token_exchange_iks.go index 34498a6..782643e 100644 --- a/common/iam/token_exchange_iks.go +++ b/common/iam/token_exchange_iks.go @@ -29,15 +29,16 @@ import ( util "github.com/IBM/ibmcloud-volume-interface/lib/utils" "github.com/IBM/ibmcloud-volume-interface/provider/iam" "github.com/IBM/secret-common-lib/pkg/secret_provider" + k8s_utils "github.com/IBM/secret-utils-lib/pkg/k8s_utils" sp "github.com/IBM/secret-utils-lib/pkg/secret_provider" "go.uber.org/zap" ) // tokenExchangeIKSService ... type tokenExchangeIKSService struct { - iksAuthConfig *IksAuthConfiguration - httpClient *http.Client - secretprovider sp.SecretProviderInterface + iksAuthConfig *IksAuthConfiguration + httpClient *http.Client + spObject sp.SecretProviderInterface } // IksAuthConfiguration ... @@ -51,7 +52,7 @@ type IksAuthConfiguration struct { var _ iam.TokenExchangeService = &tokenExchangeIKSService{} // NewTokenExchangeIKSService ... -func NewTokenExchangeIKSService(iksAuthConfig *IksAuthConfiguration) (iam.TokenExchangeService, error) { +func NewTokenExchangeIKSService(iksAuthConfig *IksAuthConfiguration, k8sClient *k8s_utils.KubernetesClient) (iam.TokenExchangeService, error) { httpClient, err := config.GeneralCAHttpClient() if err != nil { return nil, err @@ -59,14 +60,11 @@ func NewTokenExchangeIKSService(iksAuthConfig *IksAuthConfiguration) (iam.TokenE providerType := map[string]string{ secret_provider.ProviderType: secret_provider.VPC, } - spObject, err := secret_provider.NewSecretProvider(providerType) - if err != nil { - return nil, err - } + spObject, err := secret_provider.NewSecretProvider(k8sClient, providerType) return &tokenExchangeIKSService{ - iksAuthConfig: iksAuthConfig, - httpClient: httpClient, - secretprovider: spObject, + iksAuthConfig: iksAuthConfig, + httpClient: httpClient, + spObject: spObject, }, nil } @@ -94,7 +92,7 @@ func (tes *tokenExchangeIKSService) ExchangeRefreshTokenForAccessToken(refreshTo // ExchangeIAMAPIKeyForAccessToken ... func (tes *tokenExchangeIKSService) ExchangeIAMAPIKeyForAccessToken(iamAPIKey string, logger *zap.Logger) (*iam.AccessToken, error) { logger.Info("Fetching using secret provider") - token, _, err := tes.secretprovider.GetDefaultIAMToken(false) + token, _, err := tes.spObject.GetDefaultIAMToken(false) if err != nil { logger.Error("Error fetching iam token", zap.Error(err)) return nil, err diff --git a/common/iam/token_exchange_iks_test.go b/common/iam/token_exchange_iks_test.go index aed35bb..d83805b 100644 --- a/common/iam/token_exchange_iks_test.go +++ b/common/iam/token_exchange_iks_test.go @@ -23,6 +23,7 @@ import ( "net/http" "net/http/httptest" "os" + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -33,6 +34,7 @@ import ( util "github.com/IBM/ibmcloud-volume-interface/lib/utils" "github.com/IBM/ibmcloud-volume-interface/lib/utils/reasoncode" "github.com/IBM/ibmcloud-volume-interface/provider/iam" + "github.com/IBM/secret-utils-lib/pkg/k8s_utils" sp "github.com/IBM/secret-utils-lib/pkg/secret_provider" ) @@ -79,7 +81,7 @@ func Test_IKSExchangeRefreshTokenForAccessToken_Success(t *testing.T) { tes.httpClient, err = config.GeneralCAHttpClient() assert.Nil(t, err) tes.iksAuthConfig = iksAuthConfig - tes.secretprovider = new(sp.FakeSecretProvider) + tes.spObject = new(sp.FakeSecretProvider) r, err := tes.ExchangeRefreshTokenForAccessToken("testrefreshtoken", logger) assert.Nil(t, err) @@ -121,7 +123,7 @@ func Test_IKSExchangeRefreshTokenForAccessToken_FailedDuringRequest(t *testing.T tes.httpClient, err = config.GeneralCAHttpClient() assert.Nil(t, err) tes.iksAuthConfig = iksAuthConfig - tes.secretprovider = new(sp.FakeSecretProvider) + tes.spObject = new(sp.FakeSecretProvider) r, err := tes.ExchangeRefreshTokenForAccessToken("badrefreshtoken", logger) assert.Nil(t, r) @@ -154,7 +156,7 @@ func Test_IKSExchangeRefreshTokenForAccessToken_FailedDuringRequest_no_message(t tes.httpClient, err = config.GeneralCAHttpClient() assert.Nil(t, err) tes.iksAuthConfig = iksAuthConfig - tes.secretprovider = new(sp.FakeSecretProvider) + tes.spObject = new(sp.FakeSecretProvider) r, err := tes.ExchangeRefreshTokenForAccessToken("badrefreshtoken", logger) assert.Nil(t, r) @@ -188,7 +190,7 @@ func Test_IKSExchangeRefreshTokenForAccessToken_FailedWrongApiUrl(t *testing.T) tes.httpClient, err = config.GeneralCAHttpClient() assert.Nil(t, err) tes.iksAuthConfig = iksAuthConfig - tes.secretprovider = new(sp.FakeSecretProvider) + tes.spObject = new(sp.FakeSecretProvider) r, err := tes.ExchangeRefreshTokenForAccessToken("testrefreshtoken", logger) assert.Nil(t, r) @@ -260,7 +262,7 @@ func Test_IKSExchangeIAMAPIKeyForAccessToken(t *testing.T) { tes.httpClient, err = config.GeneralCAHttpClient() assert.Nil(t, err) tes.iksAuthConfig = iksAuthConfig - tes.secretprovider = new(sp.FakeSecretProvider) + tes.spObject = new(sp.FakeSecretProvider) _, actualError := tes.ExchangeIAMAPIKeyForAccessToken("apikey1", logger) if testCase.expectedError == nil { @@ -276,9 +278,12 @@ func TestNewTokenExchangeIKSService(t *testing.T) { iksAuthConfig := &IksAuthConfiguration{ PrivateAPIRoute: server.URL, } - - _, err := NewTokenExchangeIKSService(iksAuthConfig) - assert.NotNil(t, err) + kc, _ := k8s_utils.FakeGetk8sClientSet() + pwd, _ := os.Getwd() + file := filepath.Join(pwd, "..", "..", "etc", "libconfig.toml") + _ = k8s_utils.FakeCreateSecret(kc, "DEFAULT", file) + _, err := NewTokenExchangeIKSService(iksAuthConfig, &kc) + assert.Nil(t, err) } func TestExchangeAccessTokenForIMSToken(t *testing.T) { diff --git a/etc/libconfig.toml b/etc/libconfig.toml index b8f2851..5aa1aeb 100644 --- a/etc/libconfig.toml +++ b/etc/libconfig.toml @@ -6,7 +6,7 @@ g2_riaas_endpoint_url = "https://us-south-stage01.iaasdev.cloud.ibm.com/" g2_riaas_endpoint_private_url = "https://us-south-stage01.iaasdev.cloud.ibm.com" g2_resource_group_id = "" - g2_api_key = "" + g2_api_key = "api-key" provider_type = "g2" vpc_block_provider_name = "vpc" vpc_volume_type="vpc-block" @@ -23,4 +23,4 @@ iks_block_provider_name = "iks-vpc-classic" [API] - PassthroughSecret = "" \ No newline at end of file + PassthroughSecret = "" diff --git a/go.mod b/go.mod index 49a0ee0..d7fbd31 100644 --- a/go.mod +++ b/go.mod @@ -4,9 +4,9 @@ go 1.18 require ( github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7 - github.com/IBM/ibmcloud-volume-interface v1.1.1 - github.com/IBM/secret-common-lib v1.1.1 - github.com/IBM/secret-utils-lib v1.1.1 + github.com/IBM/ibmcloud-volume-interface v1.1.2 + github.com/IBM/secret-common-lib v1.1.2 + github.com/IBM/secret-utils-lib v1.1.2 github.com/fatih/structs v1.1.0 github.com/gofrs/uuid v4.2.0+incompatible github.com/golang-jwt/jwt/v4 v4.2.0 @@ -32,8 +32,9 @@ require ( github.com/go-openapi/jsonreference v0.19.5 // indirect github.com/go-openapi/strfmt v0.21.1 // indirect github.com/go-openapi/swag v0.19.14 // indirect - github.com/go-playground/locales v0.13.0 // indirect - github.com/go-playground/universal-translator v0.17.0 // indirect + github.com/go-playground/locales v0.14.0 // indirect + github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/go-playground/validator/v10 v10.11.1 // indirect github.com/go-stack/stack v1.8.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect @@ -45,7 +46,7 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kelseyhightower/envconfig v1.4.0 // indirect - github.com/leodido/go-urn v1.2.0 // indirect + github.com/leodido/go-urn v1.2.1 // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/mapstructure v1.3.3 // indirect @@ -62,13 +63,14 @@ require ( go.mongodb.org/mongo-driver v1.7.5 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect + golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1 // indirect + google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0 // indirect google.golang.org/grpc v1.47.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 // indirect diff --git a/go.sum b/go.sum index c99e0fd..e22a32c 100644 --- a/go.sum +++ b/go.sum @@ -39,12 +39,13 @@ 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.1.1 h1:RlwEj8bq+aASdb90Lng4rINMYR96/G6yUvyk/ATmptA= -github.com/IBM/ibmcloud-volume-interface v1.1.1/go.mod h1:coaQ/FD5NRgFfaAnjkoxv+e6MNSl2UAeQwC38szQ5G8= -github.com/IBM/secret-common-lib v1.1.1 h1:Ijm7lRnbChQzFtDKKwsUg9ojxQ2KFw06hD/P+bmso10= -github.com/IBM/secret-common-lib v1.1.1/go.mod h1:XAMi3upx2DZRblj8UII+LRopY5lpW1sd3d/vs92DWoA= -github.com/IBM/secret-utils-lib v1.1.1 h1:hipBsSa7FqWTI015BaAmxEwBIL2ZffGB6vrF4GfpYtI= -github.com/IBM/secret-utils-lib v1.1.1/go.mod h1:Yfla8xgZ938htp3tgw1NVYPKa8UOGq3QcRIpBE3gLgU= +github.com/IBM/ibmcloud-volume-interface v1.1.2 h1:7IByqGhG09a3aycsf3TQn9vkQDncMJYdvpo4hGQAN5A= +github.com/IBM/ibmcloud-volume-interface v1.1.2/go.mod h1:H6bm3Tzq7cjN0De207du/A8mzrirEgxwV89j3ouwCwg= +github.com/IBM/secret-common-lib v1.1.2 h1:wBcsxukRdAn0JkZE4SvOEEyHd3E1sqViMtxYr1Pp6QQ= +github.com/IBM/secret-common-lib v1.1.2/go.mod h1:M5eindyf0mG0kKR2za65AQZegAnI1ppQdEJQNv84kWc= +github.com/IBM/secret-utils-lib v1.1.2 h1:CQXQiH2YeYTjDamSfYVAHFJ0iHp/nTYuL5pTV9q4hoU= +github.com/IBM/secret-utils-lib v1.1.2/go.mod h1:fRbx/4DCxqwResj6kjsRUMK3Al6BnzueBSf7llIolU8= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= @@ -63,6 +64,7 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -72,6 +74,7 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= @@ -86,6 +89,7 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= @@ -119,10 +123,16 @@ github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrC github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng= github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0= @@ -160,7 +170,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -227,12 +236,16 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= @@ -252,7 +265,6 @@ github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= @@ -267,6 +279,7 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -291,8 +304,12 @@ github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFB github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= @@ -342,6 +359,9 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38= +golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -364,7 +384,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -407,8 +426,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -466,10 +485,11 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -481,6 +501,7 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -531,7 +552,6 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -592,8 +612,8 @@ google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1 h1:E7wSQBXkH3T3diucK+9Z1kjn4+/9tNG7lZLr75oOhh8= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0 h1:5Tbluzus3QxoAJx4IefGt1W0HQZW4nuMrVk684jI74Q= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -608,7 +628,7 @@ google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8= google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -630,8 +650,9 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= diff --git a/iks/provider/provider.go b/iks/provider/provider.go index c8bc787..49f4ba3 100644 --- a/iks/provider/provider.go +++ b/iks/provider/provider.go @@ -29,6 +29,7 @@ import ( vpcauth "github.com/IBM/ibmcloud-volume-vpc/common/auth" userError "github.com/IBM/ibmcloud-volume-vpc/common/messages" "github.com/IBM/ibmcloud-volume-vpc/common/vpcclient/riaas" + k8s_utils "github.com/IBM/secret-utils-lib/pkg/k8s_utils" "go.uber.org/zap" ) @@ -43,10 +44,10 @@ type IksVpcBlockProvider struct { var _ local.Provider = &IksVpcBlockProvider{} // NewProvider handles both IKS and RIAAS sessions -func NewProvider(conf *vpcconfig.VPCBlockConfig, logger *zap.Logger) (local.Provider, error) { +func NewProvider(conf *vpcconfig.VPCBlockConfig, k8sClient *k8s_utils.KubernetesClient, logger *zap.Logger) (local.Provider, error) { var err error //Setup vpc provider - provider, err := vpcprovider.NewProvider(conf, logger) + provider, err := vpcprovider.NewProvider(conf, k8sClient, logger) if err != nil { logger.Error("Error initializing VPC Provider", zap.Error(err)) return nil, err @@ -54,7 +55,7 @@ func NewProvider(conf *vpcconfig.VPCBlockConfig, logger *zap.Logger) (local.Prov vpcBlockProvider, _ := provider.(*vpcprovider.VPCBlockProvider) // Setup IKS provider - provider, err = vpcprovider.NewProvider(conf, logger) + provider, err = vpcprovider.NewProvider(conf, k8sClient, logger) if err != nil { logger.Error("Error initializing IKS Provider", zap.Error(err)) return nil, err @@ -70,7 +71,7 @@ func NewProvider(conf *vpcconfig.VPCBlockConfig, logger *zap.Logger) (local.Prov iksBlockProvider: iksBlockProvider, } - iksVpcBlockProvider.iksBlockProvider.ContextCF, err = vpcauth.NewVPCContextCredentialsFactory(iksVpcBlockProvider.vpcBlockProvider.Config) + iksVpcBlockProvider.iksBlockProvider.ContextCF, err = vpcauth.NewVPCContextCredentialsFactory(iksVpcBlockProvider.vpcBlockProvider.Config, k8sClient) if err != nil { logger.Error("Error initializing context credentials factory", zap.Error(err)) return nil, err @@ -89,7 +90,7 @@ func (iksp *IksVpcBlockProvider) OpenSession(ctx context.Context, contextCredent ctxLogger.Info("Opening VPC block session") ccf, _ := iksp.vpcBlockProvider.ContextCredentialsFactory(nil) ctxLogger.Info("Its IKS dual session. Getttng IAM token for VPC block session") - vpcContextCredentials, err := ccf.ForIAMAccessToken(iksp.iksBlockProvider.Config.VPCConfig.APIKey, ctxLogger) + vpcContextCredentials, err := ccf.ForIAMAccessToken(iksp.iksBlockProvider.Config.VPCConfig.G2APIKey, ctxLogger) if err != nil { ctxLogger.Error("Error occurred while generating IAM token for VPC", zap.Error(err)) if util.ErrorReasonCode(err) == utilReasonCode.EndpointNotReachable { @@ -114,7 +115,7 @@ func (iksp *IksVpcBlockProvider) OpenSession(ctx context.Context, contextCredent iksp.iksBlockProvider.ClientProvider = riaas.IKSRegionalAPIClientProvider{} ctxLogger.Info("Its ISK dual session. Getttng IAM token for IKS block session") - iksContextCredentials, err := ccf.ForIAMAccessToken(iksp.iksBlockProvider.Config.VPCConfig.APIKey, ctxLogger) + iksContextCredentials, err := ccf.ForIAMAccessToken(iksp.iksBlockProvider.Config.VPCConfig.G2APIKey, ctxLogger) if err != nil { ctxLogger.Warn("Error occurred while generating IAM token for IKS. But continue with VPC session alone. \n Volume Mount operation will fail but volume provisioning will work", zap.Error(err)) session = &vpcprovider.VPCSession{ diff --git a/iks/provider/provider_test.go b/iks/provider/provider_test.go index f16c812..e234555 100644 --- a/iks/provider/provider_test.go +++ b/iks/provider/provider_test.go @@ -19,12 +19,15 @@ package provider import ( "bytes" + "os" + "path/filepath" "testing" "github.com/IBM/ibmcloud-volume-interface/config" "github.com/IBM/ibmcloud-volume-interface/provider/auth" "github.com/IBM/ibmcloud-volume-interface/provider/local" vpcconfig "github.com/IBM/ibmcloud-volume-vpc/block/vpcconfig" + "github.com/IBM/secret-utils-lib/pkg/k8s_utils" "github.com/stretchr/testify/assert" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -95,7 +98,11 @@ func TestNewProvider(t *testing.T) { logger, teardown := GetTestLogger(t) defer teardown() - prov, err := NewProvider(conf, logger) - assert.NotNil(t, err) - assert.Nil(t, prov) + kc, _ := k8s_utils.FakeGetk8sClientSet() + pwd, _ := os.Getwd() + file := filepath.Join(pwd, "..", "..", "etc", "libconfig.toml") + err = k8s_utils.FakeCreateSecret(kc, "DEFAULT", file) + prov, err := NewProvider(conf, &kc, logger) + assert.Nil(t, err) + assert.NotNil(t, prov) } diff --git a/samples/main.go b/samples/main.go index f7439ff..f460647 100644 --- a/samples/main.go +++ b/samples/main.go @@ -23,17 +23,17 @@ import ( "os" "strings" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" - "golang.org/x/net/context" - "github.com/IBM/ibmcloud-volume-interface/config" "github.com/IBM/ibmcloud-volume-interface/lib/provider" userError "github.com/IBM/ibmcloud-volume-interface/lib/utils" "github.com/IBM/ibmcloud-volume-interface/provider/local" provider_util "github.com/IBM/ibmcloud-volume-vpc/block/utils" vpcconfig "github.com/IBM/ibmcloud-volume-vpc/block/vpcconfig" + "github.com/IBM/secret-utils-lib/pkg/k8s_utils" uid "github.com/gofrs/uuid" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" + "golang.org/x/net/context" ) var ( @@ -79,8 +79,8 @@ func main() { defer logger.Sync() // Load config file - goPath := os.Getenv("GOPATH") - conf, err := config.ReadConfig(goPath+"/src/github.com/IBM/ibmcloud-volume-vpc/etc/libconfig.toml", logger) + k8sClient, _ := k8s_utils.FakeGetk8sClientSet() + conf, err := config.ReadConfig(k8sClient, logger) if err != nil { logger.Fatal("Error loading configuration") } @@ -99,7 +99,7 @@ func main() { ServerConfig: conf.Server, } // Prepare provider registry - providerRegistry, err := provider_util.InitProviders(vpcBlockConfig, logger) + providerRegistry, err := provider_util.InitProviders(vpcBlockConfig, &k8sClient, logger) if err != nil { logger.Fatal("Error configuring providers", local.ZapError(err)) }