Skip to content

Commit

Permalink
Fix property expansion problem (#248)
Browse files Browse the repository at this point in the history
* Fix property expansion problem

Signed-off-by: Ricardo Zanini <[email protected]>

* ⏪ adding back old test

Signed-off-by: Ricardo Zanini <[email protected]>

---------

Signed-off-by: Ricardo Zanini <[email protected]>
  • Loading branch information
ricardozanini authored Sep 8, 2023
1 parent 9057b97 commit bedb0e8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions controllers/profiles/object_creators.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ func ensureWorkflowPropertiesConfigMapMutator(workflow *operatorapi.SonataFlow,
originalProps := properties.MustLoadString(original.(*corev1.ConfigMap).Data[workflowproj.ApplicationPropertiesFileName])
// we overwrite with the defaults
props.Merge(originalProps)
// Disable expansions since it's not our responsibility
// Property expansion means resolving ${} within the properties and environment context. Quarkus will do that in runtime.
props.DisableExpansion = true
cm.Data[workflowproj.ApplicationPropertiesFileName] = props.String()
}

Expand Down
23 changes: 21 additions & 2 deletions controllers/profiles/object_creators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"github.com/magiconair/properties"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"

"github.com/kiegroup/kogito-serverless-operator/workflowproj"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/kiegroup/kogito-serverless-operator/test"
"github.com/kiegroup/kogito-serverless-operator/workflowproj"
)

func Test_ensureWorkflowPropertiesConfigMapMutator(t *testing.T) {
Expand Down Expand Up @@ -54,3 +54,22 @@ func Test_ensureWorkflowPropertiesConfigMapMutator(t *testing.T) {
assert.Equal(t, "0.0.0.0", props.GetString("quarkus.http.host", ""))
assert.Equal(t, "1", props.GetString("my.new.prop", ""))
}

func Test_ensureWorkflowPropertiesConfigMapMutator_DollarReplacement(t *testing.T) {
workflow := test.GetBaseSonataFlowWithDevProfile(t.Name())
existingCM := &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: workflow.Name,
Namespace: workflow.Namespace,
UID: "0000-0001-0002-0003",
},
Data: map[string]string{
workflowproj.ApplicationPropertiesFileName: "mp.messaging.outgoing.kogito_outgoing_stream.url=${kubernetes:services.v1/event-listener}",
},
}
mutateVisitorFn := ensureWorkflowPropertiesConfigMapMutator(workflow, defaultProdApplicationProperties)

err := mutateVisitorFn(existingCM)()
assert.NoError(t, err)
assert.Contains(t, existingCM.Data[workflowproj.ApplicationPropertiesFileName], "${kubernetes:services.v1/event-listener}")
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ metadata:
data:
application.properties: |
quarkus.log.level = INFO
mp.messaging.outgoing.kogito_outgoing_stream.url = kubernetes:services.v1/event-listener
mp.messaging.outgoing.kogito_outgoing_stream.url = ${kubernetes:services.v1/event-listener}
3 changes: 3 additions & 0 deletions test/testdata/order-processing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Order Processing Example

See: https://github.com/kiegroup/kogito-examples/tree/main/serverless-workflow-examples/serverless-workflow-order-processing

0 comments on commit bedb0e8

Please sign in to comment.