This is an automated email from the ASF dual-hosted git repository.
ricardozanini pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-serverless-operator.git
The following commit(s) were added to refs/heads/main by this push:
new 23b711c8 added isValidProfile to ProfileType (#479)
23b711c8 is described below
commit 23b711c87b4d7fb804ed6a866fcb640b18db1794
Author: Dmitrii Tikhomirov <[email protected]>
AuthorDate: Thu Jun 13 09:47:53 2024 -0700
added isValidProfile to ProfileType (#479)
---
api/metadata/annotations.go | 5 +++++
api/metadata/annotations_test.go | 16 ++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/api/metadata/annotations.go b/api/metadata/annotations.go
index a8f56091..f17897ed 100644
--- a/api/metadata/annotations.go
+++ b/api/metadata/annotations.go
@@ -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
diff --git a/api/metadata/annotations_test.go b/api/metadata/annotations_test.go
index b0437bb3..f69dbe91 100644
--- a/api/metadata/annotations_test.go
+++ b/api/metadata/annotations_test.go
@@ -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")
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]