Fix property expansion problem (#248) (#251)
* Fix property expansion problem
* :rewind: adding back old test
---------
Signed-off-by: Ricardo Zanini <zanini@redhat.com>
Co-authored-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>
diff --git a/controllers/profiles/object_creators.go b/controllers/profiles/object_creators.go
index 127012b..f9c3556 100644
--- a/controllers/profiles/object_creators.go
+++ b/controllers/profiles/object_creators.go
@@ -256,6 +256,9 @@
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()
}
diff --git a/controllers/profiles/object_creators_test.go b/controllers/profiles/object_creators_test.go
index 1e5b4bb..a281915 100644
--- a/controllers/profiles/object_creators_test.go
+++ b/controllers/profiles/object_creators_test.go
@@ -20,10 +20,10 @@
"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) {
@@ -54,3 +54,22 @@
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}")
+}
diff --git a/test/testdata/order-processing/04_v1_configmap_properties.yaml b/test/testdata/order-processing/04_v1_configmap_properties.yaml
index 58592dc..ce77601 100644
--- a/test/testdata/order-processing/04_v1_configmap_properties.yaml
+++ b/test/testdata/order-processing/04_v1_configmap_properties.yaml
@@ -19,4 +19,4 @@
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}
diff --git a/test/testdata/order-processing/README.md b/test/testdata/order-processing/README.md
new file mode 100644
index 0000000..450761d
--- /dev/null
+++ b/test/testdata/order-processing/README.md
@@ -0,0 +1,3 @@
+# Order Processing Example
+
+See: https://github.com/kiegroup/kogito-examples/tree/main/serverless-workflow-examples/serverless-workflow-order-processing