Skip to content

Commit

Permalink
Add an alias to profiles package
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Zanini <[email protected]>
  • Loading branch information
ricardozanini committed Feb 19, 2024
1 parent 5dcd50a commit b06f285
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
7 changes: 3 additions & 4 deletions controllers/platform/services/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ 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/workflowproj"

"github.com/apache/incubator-kie-kogito-serverless-operator/log"
"github.com/apache/incubator-kie-kogito-serverless-operator/utils"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -163,7 +162,7 @@ func GenerateDataIndexWorkflowProperties(workflow *operatorapi.SonataFlow, platf
props.Set(constants.KogitoProcessDefinitionsEventsEnabled, "false")
props.Set(constants.KogitoProcessInstancesEventsEnabled, "false")
di := NewDataIndexHandler(platform)
if workflow != nil && !workflowproj.IsDevProfile(workflow) && di.IsServiceEnabled() {
if workflow != nil && !profiles.IsDevProfile(workflow) && di.IsServiceEnabled() {
props.Set(constants.KogitoProcessDefinitionsEventsEnabled, "true")
props.Set(constants.KogitoProcessDefinitionsEventsErrorsEnabled, "true")
props.Set(constants.KogitoProcessInstancesEventsEnabled, "true")
Expand All @@ -189,7 +188,7 @@ func GenerateJobServiceWorkflowProperties(workflow *operatorapi.SonataFlow, plat
props.Set(constants.JobServiceRequestEventsConnector, constants.QuarkusHTTP)
props.Set(constants.JobServiceRequestEventsURL, fmt.Sprintf("%s://localhost/v2/jobs/events", constants.JobServiceURLProtocol))
js := NewJobServiceHandler(platform)
if workflow != nil && !workflowproj.IsDevProfile(workflow) && js.IsServiceEnabled() {
if workflow != nil && !profiles.IsDevProfile(workflow) && js.IsServiceEnabled() {
if workflowdef.HasTimeouts(workflow) {
props.Set(constants.KogitoJobServiceHealthCheckEnabled, "true")
}
Expand Down
3 changes: 2 additions & 1 deletion controllers/profiles/dev/object_creators_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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"
Expand All @@ -47,7 +48,7 @@ func serviceCreator(workflow *operatorapi.SonataFlow) (client.Object, error) {
object, _ := common.ServiceCreator(workflow)
service := object.(*corev1.Service)
// Let's double-check that the workflow is using the Dev Profile we would like to expose it via NodePort
if workflowproj.IsDevProfile(workflow) {
if profiles.IsDevProfile(workflow) {
service.Spec.Type = corev1.ServiceTypeNodePort
}
return service, nil
Expand Down
4 changes: 4 additions & 0 deletions controllers/profiles/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ 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"

Expand Down Expand Up @@ -72,3 +73,6 @@ type ReconciliationState interface {
// PostReconcile performs the actions to perform after the reconciliation that are not mandatory
PostReconcile(ctx context.Context, workflow *operatorapi.SonataFlow) error
}

// IsDevProfile is an alias for workflowproj.IsDevProfile
var IsDevProfile = workflowproj.IsDevProfile
7 changes: 3 additions & 4 deletions controllers/profiles/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ package profiles
import (
"testing"

"github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj"
"github.com/stretchr/testify/assert"

"github.com/apache/incubator-kie-kogito-serverless-operator/test"
)

func Test_workflowIsDevProfile(t *testing.T) {
workflowWithDevProfile := test.GetBaseSonataFlowWithDevProfile(t.Name())
assert.True(t, workflowproj.IsDevProfile(workflowWithDevProfile))
assert.True(t, IsDevProfile(workflowWithDevProfile))

workflowWithNoProfile := test.GetBaseSonataFlow(t.Name())
assert.False(t, workflowproj.IsDevProfile(workflowWithNoProfile))
assert.False(t, IsDevProfile(workflowWithNoProfile))

workflowWithProdProfile := test.GetBaseSonataFlowWithProdProfile(t.Name())
assert.False(t, workflowproj.IsDevProfile(workflowWithProdProfile))
assert.False(t, IsDevProfile(workflowWithProdProfile))
}

0 comments on commit b06f285

Please sign in to comment.