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 5ebaf85e Issue #402 - Move profiles check to workflowproj module (#403)
5ebaf85e is described below
commit 5ebaf85efc665378640d6ec609c5ad8a099fe4f9
Author: Ricardo Zanini <[email protected]>
AuthorDate: Mon Feb 19 15:05:04 2024 -0300
Issue #402 - Move profiles check to workflowproj module (#403)
---
controllers/platform/services/properties.go | 3 +--
controllers/profiles/dev/object_creators_dev.go | 2 +-
controllers/profiles/dev/profile_dev.go | 2 +-
controllers/profiles/prod/profile_prod.go | 2 +-
controllers/profiles/profile.go | 22 ++++------------------
workflowproj/operator.go | 5 ++---
workflowproj/workflowproj.go | 9 +++++++++
7 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/controllers/platform/services/properties.go
b/controllers/platform/services/properties.go
index 55bf0ec8..a29a7f50 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 47638320..c4cf9254 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 42b9151a..31596c1e 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 f5046d05..356a2adc 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 da981c75..794ca7a7 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 33b4ca67..de6615d5 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 30d9db74..79359e4b 100644
--- a/workflowproj/workflowproj.go
+++ b/workflowproj/workflowproj.go
@@ -301,3 +301,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
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]