Skip to content

Commit

Permalink
Ensure that localProvider is always the 0th provider listed in the pr…
Browse files Browse the repository at this point in the history
…ovider selection prompt. (#389)
  • Loading branch information
crobby authored Sep 7, 2024
1 parent d231ad1 commit eca4a72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion cmd/kubectl_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,12 @@ func getAuthProviders(server string) ([]TypedProvider, error) {
if err != nil {
return nil, fmt.Errorf("attempting to decode the auth provider of type %s: %w", providerType, err)
}
supportedProviders = append(supportedProviders, typedProvider)

if typedProvider.GetType() == "localProvider" {
supportedProviders = append([]TypedProvider{typedProvider}, supportedProviders...)
} else {
supportedProviders = append(supportedProviders, typedProvider)
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/kubectl_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func Test_getAuthProviders(t *testing.T) {
name: "response ok",
server: setupServer(responseOK),
expectedProviders: []TypedProvider{
&apiv3.LocalProvider{
AuthProvider: apiv3.AuthProvider{
Type: "localProvider",
},
},
&apiv3.AzureADProvider{
AuthProvider: apiv3.AuthProvider{
Type: "azureADProvider",
Expand All @@ -44,11 +49,6 @@ func Test_getAuthProviders(t *testing.T) {
},
},
},
&apiv3.LocalProvider{
AuthProvider: apiv3.AuthProvider{
Type: "localProvider",
},
},
},
},
{
Expand Down

0 comments on commit eca4a72

Please sign in to comment.