Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added isValidProfile to ProfileType #479

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/metadata/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ func GetProfileOrDefault(annotation map[string]string) ProfileType {
}
}

func (p ProfileType) isValidProfile() bool {
_, ok := supportedProfiles[p]
return ok
}

func IsDevProfile(annotation map[string]string) bool {
if annotation == nil {
return false
Expand Down
16 changes: 16 additions & 0 deletions api/metadata/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,19 @@ func TestGetProfile(t *testing.T) {
})
}
}

func TestIsValidProfile(t *testing.T) {
profiles := []ProfileType{DefaultProfile, GitOpsProfile, DevProfile}
for _, profile := range profiles {
if !profile.isValidProfile() {
t.Errorf("Profile %s is not valid", profile)
}
}
if ProdProfile.isValidProfile() {
t.Errorf("ProdProfile is deprecated and should not be valid")
}
// any random string should not be a valid profile
if ProfileType("random").isValidProfile() {
t.Errorf("random is not a valid profile")
}
}
Loading