Skip to content

Commit

Permalink
ensure target-auth-mode has a valid value
Browse files Browse the repository at this point in the history
  • Loading branch information
TiberiuGC committed Apr 25, 2024
1 parent a21a8c1 commit f34dd6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/actions/accessentry/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewMigrator(
}

func (m *Migrator) MigrateToAccessEntry(ctx context.Context, options MigrationOptions) error {
if m.tgAuthMode == ekstypes.AuthenticationModeConfigMap {
if m.tgAuthMode != ekstypes.AuthenticationModeApi && m.tgAuthMode != ekstypes.AuthenticationModeApiAndConfigMap {
return fmt.Errorf("target authentication mode is invalid, must be either %s or %s", ekstypes.AuthenticationModeApi, ekstypes.AuthenticationModeApiAndConfigMap)
}
if m.curAuthMode == ekstypes.AuthenticationModeApi {
Expand Down
2 changes: 2 additions & 0 deletions pkg/actions/accessentry/migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ var _ = Describe("Migrate Access Entry", func() {

Entry("[Validation Error] current authentication mode is API", migrateToAccessEntryEntry{
curAuthMode: ekstypes.AuthenticationModeApi,
tgAuthMode: ekstypes.AuthenticationModeApi,
validateCustomLoggerOutput: func(output string) {
Expect(output).To(ContainSubstring(fmt.Sprintf("cluster authentication mode is already %s; there is no need to migrate to access entries", ekstypes.AuthenticationModeApi)))
},
}),

Entry("[API Error] getting access entries fails", migrateToAccessEntryEntry{
curAuthMode: ekstypes.AuthenticationModeApiAndConfigMap,
tgAuthMode: ekstypes.AuthenticationModeApi,
mockAccessEntries: func(getter *fakes.FakeGetterInterface) {
getter.GetReturns(nil, genericErr)
},
Expand Down

0 comments on commit f34dd6f

Please sign in to comment.