Issue #402 - Move profiles check to workflowproj module (#403)
diff --git a/controllers/platform/services/properties.go b/controllers/platform/services/properties.go
index 55bf0ec..a29a7f5 100644
--- a/controllers/platform/services/properties.go
+++ b/controllers/platform/services/properties.go
@@ -24,14 +24,13 @@
"net/url"
"strings"
+ "github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/workflowdef"
-
"github.com/apache/incubator-kie-kogito-serverless-operator/log"
"github.com/apache/incubator-kie-kogito-serverless-operator/utils"
"k8s.io/klog/v2"
operatorapi "github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
- "github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles/common/constants"
"github.com/magiconair/properties"
diff --git a/controllers/profiles/dev/object_creators_dev.go b/controllers/profiles/dev/object_creators_dev.go
index 4763832..c4cf925 100644
--- a/controllers/profiles/dev/object_creators_dev.go
+++ b/controllers/profiles/dev/object_creators_dev.go
@@ -22,13 +22,13 @@
import (
"path"
+ "github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
operatorapi "github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
- "github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles/common"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/workflowdef"
kubeutil "github.com/apache/incubator-kie-kogito-serverless-operator/utils/kubernetes"
diff --git a/controllers/profiles/dev/profile_dev.go b/controllers/profiles/dev/profile_dev.go
index 42b9151..31596c1 100644
--- a/controllers/profiles/dev/profile_dev.go
+++ b/controllers/profiles/dev/profile_dev.go
@@ -20,13 +20,13 @@
package dev
import (
+ "github.com/apache/incubator-kie-kogito-serverless-operator/api/metadata"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/discovery"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
- "github.com/apache/incubator-kie-kogito-serverless-operator/api/metadata"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles/common"
"github.com/apache/incubator-kie-kogito-serverless-operator/log"
diff --git a/controllers/profiles/prod/profile_prod.go b/controllers/profiles/prod/profile_prod.go
index f5046d0..356a2ad 100644
--- a/controllers/profiles/prod/profile_prod.go
+++ b/controllers/profiles/prod/profile_prod.go
@@ -22,6 +22,7 @@
import (
"time"
+ "github.com/apache/incubator-kie-kogito-serverless-operator/api/metadata"
"k8s.io/client-go/rest"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/discovery"
@@ -29,7 +30,6 @@
"sigs.k8s.io/controller-runtime/pkg/client"
- "github.com/apache/incubator-kie-kogito-serverless-operator/api/metadata"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles/common"
)
diff --git a/controllers/profiles/profile.go b/controllers/profiles/profile.go
index da981c7..794ca7a 100644
--- a/controllers/profiles/profile.go
+++ b/controllers/profiles/profile.go
@@ -22,10 +22,11 @@
import (
"context"
+ "github.com/apache/incubator-kie-kogito-serverless-operator/api/metadata"
+ "github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
- "github.com/apache/incubator-kie-kogito-serverless-operator/api/metadata"
operatorapi "github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
)
@@ -73,20 +74,5 @@
PostReconcile(ctx context.Context, workflow *operatorapi.SonataFlow) error
}
-// IsDevProfile detects if the workflow is using the Dev profile or not
-func IsDevProfile(workflow *operatorapi.SonataFlow) bool {
- profile := workflow.Annotations[metadata.Profile]
- if len(profile) == 0 {
- return false
- }
- return metadata.ProfileType(profile) == metadata.DevProfile
-}
-
-// IsProdProfile detects if the workflow is using the Prod profile or not
-func IsProdProfile(workflow *operatorapi.SonataFlow) bool {
- profile := workflow.Annotations[metadata.Profile]
- if len(profile) == 0 {
- return false
- }
- return metadata.ProfileType(profile) == metadata.ProdProfile
-}
+// IsDevProfile is an alias for workflowproj.IsDevProfile
+var IsDevProfile = workflowproj.IsDevProfile
diff --git a/workflowproj/operator.go b/workflowproj/operator.go
index 33b4ca6..de6615d 100644
--- a/workflowproj/operator.go
+++ b/workflowproj/operator.go
@@ -28,7 +28,6 @@
"github.com/apache/incubator-kie-kogito-serverless-operator/api/metadata"
operatorapi "github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
- "github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
)
const (
@@ -74,10 +73,10 @@
return workflow.Name + workflowManagedConfigMapNameSuffix
}
-// GetWorkflowManagedPropertiesConfigMapName gets the default ConfigMap name that holds the managed application property for the given workflow
+// GetManagedPropertiesFileName gets the default ConfigMap name that holds the managed application property for the given workflow
func GetManagedPropertiesFileName(workflow *operatorapi.SonataFlow) string {
profile := metadata.ProdProfile
- if profiles.IsDevProfile(workflow) {
+ if IsDevProfile(workflow) {
profile = metadata.DevProfile
}
return fmt.Sprintf("application-%s.properties", profile)
diff --git a/workflowproj/workflowproj.go b/workflowproj/workflowproj.go
index 30d9db7..79359e4 100644
--- a/workflowproj/workflowproj.go
+++ b/workflowproj/workflowproj.go
@@ -301,3 +301,12 @@
}
return nil
}
+
+// IsDevProfile detects if the workflow is using the Dev profile or not
+func IsDevProfile(workflow *operatorapi.SonataFlow) bool {
+ profile := workflow.Annotations[metadata.Profile]
+ if len(profile) == 0 {
+ return false
+ }
+ return metadata.ProfileType(profile) == metadata.DevProfile
+}