diff --git a/pkg/blockstorage/azure/auth.go b/pkg/blockstorage/azure/auth.go index 3156b73159..181abeed1f 100644 --- a/pkg/blockstorage/azure/auth.go +++ b/pkg/blockstorage/azure/auth.go @@ -14,15 +14,15 @@ import ( // determine if the combination of creds are client secret creds func isClientCredsAvailable(config map[string]string) bool { return (config[blockstorage.AzureTenantID] != "" && - config[blockstorage.AzureCientID] != "" && - config[blockstorage.AzureClentSecret] != "") + config[blockstorage.AzureClientID] != "" && + config[blockstorage.AzureClientSecret] != "") } // determine if the combination of creds are MSI creds func isMSICredsAvailable(config map[string]string) bool { return (config[blockstorage.AzureTenantID] == "" && - config[blockstorage.AzureCientID] != "" && - config[blockstorage.AzureClentSecret] == "") + config[blockstorage.AzureClientID] != "" && + config[blockstorage.AzureClientSecret] == "") } // Public interface to authenticate with different Azure credentials type @@ -51,7 +51,7 @@ func (m *msiAuthenticator) Authenticate(creds map[string]string) error { } // create a service principal token msiConfig := auth.NewMSIConfig() - msiConfig.ClientID = creds[blockstorage.AzureCientID] + msiConfig.ClientID = creds[blockstorage.AzureClientID] spt, err := msiConfig.ServicePrincipalToken() if err != nil { return errors.Wrap(err, "Failed to create a service principal token") @@ -93,12 +93,12 @@ func getCredConfigForAuth(config map[string]string) (auth.ClientCredentialsConfi return auth.ClientCredentialsConfig{}, errors.New("Cannot get tenantID from config") } - clientID, ok := config[blockstorage.AzureCientID] + clientID, ok := config[blockstorage.AzureClientID] if !ok { return auth.ClientCredentialsConfig{}, errors.New("Cannot get clientID from config") } - clientSecret, ok := config[blockstorage.AzureClentSecret] + clientSecret, ok := config[blockstorage.AzureClientSecret] if !ok { return auth.ClientCredentialsConfig{}, errors.New("Cannot get clientSecret from config") } diff --git a/pkg/blockstorage/azure/auth_tests.go b/pkg/blockstorage/azure/auth_tests.go index 20c76fe8e2..c36a92251e 100644 --- a/pkg/blockstorage/azure/auth_tests.go +++ b/pkg/blockstorage/azure/auth_tests.go @@ -29,9 +29,9 @@ func (s *AuthSuite) SetUpSuite(c *C) { func (s *AuthSuite) TestIsClientCredsvailable(c *C) { // success config := map[string]string{ - blockstorage.AzureTenantID: "some-tenant-id", - blockstorage.AzureCientID: "some-client-id", - blockstorage.AzureClentSecret: "someclient-secret", + blockstorage.AzureTenantID: "some-tenant-id", + blockstorage.AzureClientID: "some-client-id", + blockstorage.AzureClientSecret: "someclient-secret", } c.Assert(isClientCredsAvailable(config), Equals, true) @@ -40,16 +40,16 @@ func (s *AuthSuite) TestIsClientCredsvailable(c *C) { c.Assert(isClientCredsAvailable(config), Equals, false) // remove client secret, only client ID left - delete(config, blockstorage.AzureClentSecret) + delete(config, blockstorage.AzureClientSecret) c.Assert(isClientCredsAvailable(config), Equals, false) } func (s *AuthSuite) TestIsMSICredsAvailable(c *C) { // success config := map[string]string{ - blockstorage.AzureTenantID: "some-tenant-id", - blockstorage.AzureCientID: "some-client-id", - blockstorage.AzureClentSecret: "someclient-secret", + blockstorage.AzureTenantID: "some-tenant-id", + blockstorage.AzureClientID: "some-client-id", + blockstorage.AzureClientSecret: "someclient-secret", } c.Assert(isMSICredsAvailable(config), Equals, false) @@ -58,16 +58,16 @@ func (s *AuthSuite) TestIsMSICredsAvailable(c *C) { c.Assert(isMSICredsAvailable(config), Equals, false) // remove client secret, only client ID left - delete(config, blockstorage.AzureClentSecret) + delete(config, blockstorage.AzureClientSecret) c.Assert(isMSICredsAvailable(config), Equals, true) } func (s *AuthSuite) TestNewAzureAutheticator(c *C) { // successful with client secret creds config := map[string]string{ - blockstorage.AzureTenantID: "some-tenant-id", - blockstorage.AzureCientID: "some-client-id", - blockstorage.AzureClentSecret: "some-client-secret", + blockstorage.AzureTenantID: "some-tenant-id", + blockstorage.AzureClientID: "some-client-id", + blockstorage.AzureClientSecret: "some-client-secret", } authenticator, err := NewAzureAutheticator(config) c.Assert(err, IsNil) @@ -76,7 +76,7 @@ func (s *AuthSuite) TestNewAzureAutheticator(c *C) { // successful with msi creds config = map[string]string{ - blockstorage.AzureCientID: "some-client-id", + blockstorage.AzureClientID: "some-client-id", } authenticator, err = NewAzureAutheticator(config) c.Assert(err, IsNil) @@ -85,8 +85,8 @@ func (s *AuthSuite) TestNewAzureAutheticator(c *C) { // unsuccessful with an undefined combo of creds config = map[string]string{ - blockstorage.AzureCientID: "some-client-id", - blockstorage.AzureClentSecret: "some-client-secret", + blockstorage.AzureClientID: "some-client-id", + blockstorage.AzureClientSecret: "some-client-secret", } authenticator, err = NewAzureAutheticator(config) c.Assert(err, NotNil) diff --git a/pkg/blockstorage/azure/client.go b/pkg/blockstorage/azure/client.go index 5233157f1b..e4b3f60ac8 100644 --- a/pkg/blockstorage/azure/client.go +++ b/pkg/blockstorage/azure/client.go @@ -124,7 +124,7 @@ func getClientCredsAuthorizer(env azure.Environment, config map[string]string) ( func getMSIsAuthorizer(config map[string]string) (*autorest.BearerAuthorizer, error) { msiConfig := auth.NewMSIConfig() - msiConfig.ClientID = config[blockstorage.AzureCientID] + msiConfig.ClientID = config[blockstorage.AzureClientID] a, err := msiConfig.Authorizer() if err != nil { return nil, errors.Wrap(err, "Failed to get Azure MSI authorizer") diff --git a/pkg/blockstorage/azure/client_test.go b/pkg/blockstorage/azure/client_test.go index e551377521..a49c1be597 100644 --- a/pkg/blockstorage/azure/client_test.go +++ b/pkg/blockstorage/azure/client_test.go @@ -42,8 +42,8 @@ func (s *ClientSuite) TestClient(c *C) { config := make(map[string]string) config[blockstorage.AzureSubscriptionID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureSubscriptionID) config[blockstorage.AzureTenantID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureTenantID) - config[blockstorage.AzureCientID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureCientID) - config[blockstorage.AzureClentSecret] = envconfig.GetEnvOrSkip(c, blockstorage.AzureClentSecret) + config[blockstorage.AzureClientID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureClientID) + config[blockstorage.AzureClientSecret] = envconfig.GetEnvOrSkip(c, blockstorage.AzureClientSecret) config[blockstorage.AzureResurceGroup] = envconfig.GetEnvOrSkip(c, blockstorage.AzureResurceGroup) config[blockstorage.AzureCloudEnvironmentID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureCloudEnvironmentID) azCli, err := NewClient(context.Background(), config) @@ -62,8 +62,8 @@ func (s ClientSuite) TestGetRegions(c *C) { config := map[string]string{} config[blockstorage.AzureSubscriptionID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureSubscriptionID) config[blockstorage.AzureTenantID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureTenantID) - config[blockstorage.AzureCientID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureCientID) - config[blockstorage.AzureClentSecret] = envconfig.GetEnvOrSkip(c, blockstorage.AzureClentSecret) + config[blockstorage.AzureClientID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureClientID) + config[blockstorage.AzureClientSecret] = envconfig.GetEnvOrSkip(c, blockstorage.AzureClientSecret) config[blockstorage.AzureResurceGroup] = envconfig.GetEnvOrSkip(c, blockstorage.AzureResurceGroup) // config[blockstorage.AzureCloudEnviornmentID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureCloudEnviornmentID) @@ -96,8 +96,8 @@ func (s *ClientSuite) TestGetCredConfig(c *C) { env: azure.PublicCloud, config: map[string]string{ blockstorage.AzureTenantID: "atid", - blockstorage.AzureCientID: "acid", - blockstorage.AzureClentSecret: "acs", + blockstorage.AzureClientID: "acid", + blockstorage.AzureClientSecret: "acs", blockstorage.AzureActiveDirEndpoint: "aade", blockstorage.AzureActiveDirResourceID: "aadrid", }, @@ -113,9 +113,9 @@ func (s *ClientSuite) TestGetCredConfig(c *C) { { env: azure.PublicCloud, config: map[string]string{ - blockstorage.AzureTenantID: "atid", - blockstorage.AzureCientID: "acid", - blockstorage.AzureClentSecret: "acs", + blockstorage.AzureTenantID: "atid", + blockstorage.AzureClientID: "acid", + blockstorage.AzureClientSecret: "acs", }, expCCC: auth.ClientCredentialsConfig{ ClientID: "acid", @@ -130,8 +130,8 @@ func (s *ClientSuite) TestGetCredConfig(c *C) { env: azure.USGovernmentCloud, config: map[string]string{ blockstorage.AzureTenantID: "atid", - blockstorage.AzureCientID: "acid", - blockstorage.AzureClentSecret: "acs", + blockstorage.AzureClientID: "acid", + blockstorage.AzureClientSecret: "acs", blockstorage.AzureActiveDirEndpoint: "", blockstorage.AzureActiveDirResourceID: "", }, @@ -148,7 +148,7 @@ func (s *ClientSuite) TestGetCredConfig(c *C) { env: azure.USGovernmentCloud, config: map[string]string{ blockstorage.AzureTenantID: "atid", - blockstorage.AzureCientID: "acid", + blockstorage.AzureClientID: "acid", }, errChecker: NotNil, }, diff --git a/pkg/blockstorage/blockstorage_test.go b/pkg/blockstorage/blockstorage_test.go index ff524f0339..6595de8920 100644 --- a/pkg/blockstorage/blockstorage_test.go +++ b/pkg/blockstorage/blockstorage_test.go @@ -291,8 +291,8 @@ func (s *BlockStorageProviderSuite) getConfig(c *C, region string) map[string]st case blockstorage.TypeAD: config[blockstorage.AzureSubscriptionID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureSubscriptionID) config[blockstorage.AzureTenantID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureTenantID) - config[blockstorage.AzureCientID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureCientID) - config[blockstorage.AzureClentSecret] = envconfig.GetEnvOrSkip(c, blockstorage.AzureClentSecret) + config[blockstorage.AzureClientID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureClientID) + config[blockstorage.AzureClientSecret] = envconfig.GetEnvOrSkip(c, blockstorage.AzureClientSecret) config[blockstorage.AzureResurceGroup] = envconfig.GetEnvOrSkip(c, blockstorage.AzureResurceGroup) config[blockstorage.AzureCloudEnvironmentID] = envconfig.GetEnvOrSkip(c, blockstorage.AzureCloudEnvironmentID) s.args[blockstorage.AzureMigrateStorageAccount] = envconfig.GetEnvOrSkip(c, blockstorage.AzureMigrateStorageAccount) diff --git a/pkg/blockstorage/helpers.go b/pkg/blockstorage/helpers.go index 6b73433647..20ea680d19 100644 --- a/pkg/blockstorage/helpers.go +++ b/pkg/blockstorage/helpers.go @@ -30,8 +30,8 @@ const ( AzureStorageKey = "AZURE_STORAGE_ACCOUNT_KEY" AzureSubscriptionID = "AZURE_SUBSCRIPTION_ID" AzureTenantID = "AZURE_TENANT_ID" - AzureCientID = "AZURE_CLIENT_ID" - AzureClentSecret = "AZURE_CLIENT_SECRET" + AzureClientID = "AZURE_CLIENT_ID" + AzureClientSecret = "AZURE_CLIENT_SECRET" AzureResurceGroup = "AZURE_RESOURCE_GROUP" AzureResurceMgrEndpoint = "AZURE_RESOURCE_MANAGER_ENDPOINT" AzureMigrateStorageAccount = "AZURE_MIGRATE_STORAGE_ACCOUNT_NAME"