diff --git a/controllers/platform/services/properties.go b/controllers/platform/services/properties.go index 55bf0ec85..a29a7f503 100644 --- a/controllers/platform/services/properties.go +++ b/controllers/platform/services/properties.go @@ -24,14 +24,13 @@ import ( "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 476383205..c4cf92549 100644 --- a/controllers/profiles/dev/object_creators_dev.go +++ b/controllers/profiles/dev/object_creators_dev.go @@ -22,13 +22,13 @@ package dev 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 42b9151ab..31596c1e5 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 f5046d05f..356a2adc8 100644 --- a/controllers/profiles/prod/profile_prod.go +++ b/controllers/profiles/prod/profile_prod.go @@ -22,6 +22,7 @@ package prod 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 @@ import ( "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 da981c75f..794ca7a70 100644 --- a/controllers/profiles/profile.go +++ b/controllers/profiles/profile.go @@ -22,10 +22,11 @@ package profiles 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 @@ type ReconciliationState interface { 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 33b4ca672..de6615d53 100644 --- a/workflowproj/operator.go +++ b/workflowproj/operator.go @@ -28,7 +28,6 @@ import ( "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 @@ func GetWorkflowManagedPropertiesConfigMapName(workflow *operatorapi.SonataFlow) 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 afabd7e5c..ce6422540 100644 --- a/workflowproj/workflowproj.go +++ b/workflowproj/workflowproj.go @@ -298,3 +298,12 @@ func (w *workflowProjectHandler) addResourceConfigMapToProject(cm *corev1.Config } 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 +}