Skip to content

Commit

Permalink
Fixed typos (#1617)
Browse files Browse the repository at this point in the history
Signed-off-by: Le Tran <le.tran@kasten.io>

Signed-off-by: Le Tran <le.tran@kasten.io>
Co-authored-by: Le Tran <le.tran@kasten.io>
  • Loading branch information
leuyentran and Le Tran committed Sep 9, 2022
1 parent 3a92e0a commit c106938
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
14 changes: 7 additions & 7 deletions pkg/blockstorage/azure/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
}
Expand Down
28 changes: 14 additions & 14 deletions pkg/blockstorage/azure/auth_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/blockstorage/azure/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
24 changes: 12 additions & 12 deletions pkg/blockstorage/azure/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down Expand Up @@ -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",
},
Expand All @@ -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",
Expand All @@ -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: "",
},
Expand All @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/blockstorage/blockstorage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/blockstorage/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c106938

Please sign in to comment.