From 5ff8150344799936fd1d03a32ba6bd3514b62829 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:10:43 -0500 Subject: [PATCH 1/3] Fix #2751 - Remove references to Quarkus and Kogito versions; Automatic change of platform images based on env context Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> --- ...kie-kogito-data-index-ephemeral-image.yaml | 1 + ...ie-kogito-data-index-postgresql-image.yaml | 1 + ...ie-kogito-jobs-service-allinone-image.yaml | 1 + ...e-kogito-jobs-service-ephemeral-image.yaml | 1 + ...-kogito-jobs-service-postgresql-image.yaml | 1 + .../common/scripts/added/add-extension.sh | 28 ++---- .../scripts/added/quarkus-mvn-plugin.sh | 94 +++++++++++++++++++ .../tests/bats/quarkus-mvn-plugin.bats | 83 ++++++++++++++++ packages/sonataflow-operator/Makefile | 28 +++++- .../config/manager/controllers_cfg.yaml | 3 - .../config/manager/kustomization.yaml | 4 +- ...flow.org_v1alpha08_sonataflowplatform.yaml | 2 +- .../container-builder/api/build_types.go | 2 +- .../builder/kubernetes/builder_kaniko_test.go | 4 +- .../builder/kubernetes/builder_test.go | 2 +- .../kubernetes/testdata/sample.Dockerfile} | 43 ++++++--- .../PlatformBuild_usingKanikowithCache.yaml | 4 +- .../sonataflow-operator/hack/bump-version.sh | 23 ----- .../hack/update_controllers_cfg.py | 93 ++++++++++++++++++ packages/sonataflow-operator/install.js | 75 --------------- .../builder/kogitoserverlessbuild_manager.go | 6 +- .../controller/cfg/controllers_cfg.go | 39 ++++---- .../controller/cfg/controllers_cfg_test.go | 9 +- .../cfg/testdata/controllers-cfg-test.yaml | 3 - .../controller/platform/platformutils_test.go | 13 +-- .../platform/testdata/platformTest.Dockerfile | 2 +- .../profiles/common/object_creators_test.go | 16 ++-- .../profiles/common/persistence/postgresql.go | 2 +- .../profiles/dev/profile_dev_test.go | 2 +- .../preview/deployment_handler_test.go | 2 +- .../sonataflowplatform_controller_test.go | 18 ++-- packages/sonataflow-operator/operator.yaml | 3 - packages/sonataflow-operator/package.json | 3 +- .../ephemeral/02-sonataflow_platform.yaml | 2 +- .../dev/ephemeral/02-sonataflow_platform.yaml | 2 +- .../postgreSQL/02-sonataflow_platform.yaml | 2 +- .../02-sonataflow_platform.yaml | 2 +- .../02-sonataflow_platform.yaml | 2 +- .../02-sonataflow_platform.yaml | 2 +- ...ataflow.org_v1alpha08_sonataflowbuild.yaml | 2 +- ...flow.org_v1alpha08_sonataflowplatform.yaml | 2 +- ...alpha08_sonataflowplatform_withBroker.yaml | 2 +- packages/sonataflow-operator/test/yaml.go | 50 ++++------ 43 files changed, 427 insertions(+), 252 deletions(-) create mode 100644 packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/quarkus-mvn-plugin.sh create mode 100644 packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/tests/bats/quarkus-mvn-plugin.bats rename packages/sonataflow-operator/{test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml => container-builder/builder/kubernetes/testdata/sample.Dockerfile} (50%) create mode 100644 packages/sonataflow-operator/hack/update_controllers_cfg.py delete mode 100644 packages/sonataflow-operator/install.js diff --git a/packages/kogito-data-index-ephemeral-image/resources/incubator-kie-kogito-data-index-ephemeral-image.yaml b/packages/kogito-data-index-ephemeral-image/resources/incubator-kie-kogito-data-index-ephemeral-image.yaml index 8e2f84baad2..a84340f07a5 100644 --- a/packages/kogito-data-index-ephemeral-image/resources/incubator-kie-kogito-data-index-ephemeral-image.yaml +++ b/packages/kogito-data-index-ephemeral-image/resources/incubator-kie-kogito-data-index-ephemeral-image.yaml @@ -49,6 +49,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.dataindex.ephemeral diff --git a/packages/kogito-data-index-postgresql-image/resources/incubator-kie-kogito-data-index-postgresql-image.yaml b/packages/kogito-data-index-postgresql-image/resources/incubator-kie-kogito-data-index-postgresql-image.yaml index 00ae72ecac4..cf4c8027420 100644 --- a/packages/kogito-data-index-postgresql-image/resources/incubator-kie-kogito-data-index-postgresql-image.yaml +++ b/packages/kogito-data-index-postgresql-image/resources/incubator-kie-kogito-data-index-postgresql-image.yaml @@ -51,6 +51,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.dataindex.postgresql diff --git a/packages/kogito-jobs-service-allinone-image/resources/incubator-kie-kogito-jobs-service-allinone-image.yaml b/packages/kogito-jobs-service-allinone-image/resources/incubator-kie-kogito-jobs-service-allinone-image.yaml index 2872d6a0132..03a41ec9d9d 100644 --- a/packages/kogito-jobs-service-allinone-image/resources/incubator-kie-kogito-jobs-service-allinone-image.yaml +++ b/packages/kogito-jobs-service-allinone-image/resources/incubator-kie-kogito-jobs-service-allinone-image.yaml @@ -54,6 +54,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.jobs.service.allinone diff --git a/packages/kogito-jobs-service-ephemeral-image/resources/incubator-kie-kogito-jobs-service-ephemeral-image.yaml b/packages/kogito-jobs-service-ephemeral-image/resources/incubator-kie-kogito-jobs-service-ephemeral-image.yaml index f622fec9eed..e9b17647ad7 100644 --- a/packages/kogito-jobs-service-ephemeral-image/resources/incubator-kie-kogito-jobs-service-ephemeral-image.yaml +++ b/packages/kogito-jobs-service-ephemeral-image/resources/incubator-kie-kogito-jobs-service-ephemeral-image.yaml @@ -51,6 +51,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.jobs.service.ephemeral diff --git a/packages/kogito-jobs-service-postgresql-image/resources/incubator-kie-kogito-jobs-service-postgresql-image.yaml b/packages/kogito-jobs-service-postgresql-image/resources/incubator-kie-kogito-jobs-service-postgresql-image.yaml index f2ccc8bc2c5..06ac396d1cb 100644 --- a/packages/kogito-jobs-service-postgresql-image/resources/incubator-kie-kogito-jobs-service-postgresql-image.yaml +++ b/packages/kogito-jobs-service-postgresql-image/resources/incubator-kie-kogito-jobs-service-postgresql-image.yaml @@ -51,6 +51,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.jobs.service.postgresql diff --git a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/add-extension.sh b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/add-extension.sh index fcddc18727b..5eb3b2b2e8f 100755 --- a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/add-extension.sh +++ b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/add-extension.sh @@ -20,31 +20,15 @@ set -e -script_dir_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # extensions to be added, comma separated. extensions="$1" +if [ -z "$extensions" ]; then + return 0 +fi + # parameter passed which will trigger or not the jvm/maven configuration. ignore_jvm_settings=${2:-false} -# shellcheck source=/dev/null -source "${script_dir_path}"/logging.sh - -if [ "${SCRIPT_DEBUG}" = "true" ] ; then - set -x - export MAVEN_ARGS_APPEND="${MAVEN_ARGS_APPEND} -X --batch-mode" - log_info "Script debugging is enabled, allowing bash commands and their arguments to be printed as they are executed" - printenv -fi - -if [ "${ignore_jvm_settings}" != "true" ]; then - source "${script_dir_path}"/configure-jvm-mvn.sh -fi +source "${KOGITO_HOME}"/launch/quarkus-mvn-plugin.sh -"${MAVEN_HOME}"/bin/mvn -B ${MAVEN_ARGS_APPEND} \ - -nsu \ - -B \ - -s "${MAVEN_SETTINGS_PATH}" \ - -DplatformVersion="${QUARKUS_PLATFORM_VERSION}" \ - -Dextensions="${extensions}" \ - ${QUARKUS_ADD_EXTENSION_ARGS} \ - "${QUARKUS_PLATFORM_GROUPID}":quarkus-maven-plugin:"${QUARKUS_PLATFORM_VERSION}":add-extension +run_quarkus_mvn_add_extension "$extensions", "$ignore_jvm_settings" diff --git a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/quarkus-mvn-plugin.sh b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/quarkus-mvn-plugin.sh new file mode 100644 index 00000000000..44417c39ca8 --- /dev/null +++ b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/quarkus-mvn-plugin.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + + +# Useful functions for runnning Quarkus Maven Plugin. Moved from bare scripts to facilitate testing. + +set -e + +# Default version variables +quarkus_version="${QUARKUS_PLATFORM_VERSION}" +kogito_version="${KOGITO_VERSION}" + +# shellcheck source=/dev/null +source "${KOGITO_HOME}"/launch/logging.sh + +# Function to append the correct version to the extension if needed +append_version() { + local extension="$1" + local group_id + local artifact_id + local version + + # Split extension into groupId, artifactId, and version + IFS=":" read -r group_id artifact_id version <<< "$extension" + + # If the version is missing, append the default version based on the groupId + if [ -z "$version" ]; then + if [[ "$group_id" == "io.quarkus" ]]; then + extension="${group_id}:${artifact_id}:${quarkus_version}" + elif [[ "$group_id" == *"kie"* || "$group_id" == *"kogito"* || "$artifact_id" == *"kogito"* || "$artifact_id" == *"sonataflow"* ]]; then + extension="${group_id}:${artifact_id}:${kogito_version}" + fi + fi + + echo "$extension" +} + +process_extensions() { + local extensions="$1" + local processed_extensions="" + IFS=',' read -r -a extension_array <<< "$extensions" + for ext in "${extension_array[@]}"; do + processed_extensions+=$(append_version "$ext")"," + done + # Remove the trailing comma + processed_extensions="${processed_extensions%,}" + echo "$processed_extensions" +} + +run_quarkus_mvn_add_extension() { + local extensions="$1" + local ignore_jvm_settings=${2:-false} + + local processed_extensions=$(process_extensions "$extensions") + + if [ "${SCRIPT_DEBUG}" = "true" ]; then + set -x + export MAVEN_ARGS_APPEND="${MAVEN_ARGS_APPEND} -X --batch-mode" + log_info "Script debugging is enabled, allowing bash commands and their arguments to be printed as they are executed" + printenv + fi + + if [ "${ignore_jvm_settings}" != "true" ]; then + source "${KOGITO_HOME}"/launch/configure-jvm-mvn.sh + fi + + log_info "Processed extensions to be added ${processed_extensions}" + + "${MAVEN_HOME}"/bin/mvn -B ${MAVEN_ARGS_APPEND} \ + -nsu \ + -B \ + -s "${MAVEN_SETTINGS_PATH}" \ + -DplatformVersion="${QUARKUS_PLATFORM_VERSION}" \ + -Dextensions="${processed_extensions}" \ + ${QUARKUS_ADD_EXTENSION_ARGS} \ + "${QUARKUS_PLATFORM_GROUPID}":quarkus-maven-plugin:"${QUARKUS_PLATFORM_VERSION}":add-extension +} \ No newline at end of file diff --git a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/tests/bats/quarkus-mvn-plugin.bats b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/tests/bats/quarkus-mvn-plugin.bats new file mode 100644 index 00000000000..5bab3a99bf4 --- /dev/null +++ b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/tests/bats/quarkus-mvn-plugin.bats @@ -0,0 +1,83 @@ +#!/usr/bin/env bats +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +set -e + +# Set up some environment variables for testing +setup() { + export QUARKUS_PLATFORM_VERSION="2.0.0" + export KOGITO_VERSION="1.5.0" + export KOGITO_HOME=$BATS_TMPDIR/maven + mkdir -p ${KOGITO_HOME}/"launch" + cp ${BATS_TEST_DIRNAME}/../../../../../kogito-logging/added/logging.sh ${KOGITO_HOME}/launch/logging.sh + + load ${BATS_TEST_DIRNAME}/../../added/quarkus-mvn-plugin.sh +} + +teardown() { + rm -rf ${KOGITO_HOME} +} + +# Test that a full extension with version does not get modified +@test "Extension with version should remain unchanged" { + run process_extensions "io.quarkus:quarkus-resteasy-reactive:2.0.0" + echo "Test Output:" + echo "$output" + [ "$output" == "io.quarkus:quarkus-resteasy-reactive:2.0.0" ] +} + +# Test that an extension without version for io.quarkus gets the default version +@test "io.quarkus extension without version should get the default version" { + run process_extensions "io.quarkus:quarkus-resteasy-reactive" + echo "Test Output:" + echo "$output" + [ "$output" == "io.quarkus:quarkus-resteasy-reactive:2.0.0" ] +} + +# Test that an extension without version for kogito gets the KOGITO version +@test "Kogito extension without version should get the KOGITO version" { + run process_extensions "org.kie:kie-server" + echo "Test Output:" + echo "$output" + [ "$output" == "org.kie:kie-server:1.5.0" ] +} + +# Test that an extension without version for a non-quarkus and non-kogito group gets the default version +@test "Non-quarkus, non-kogito extension without version should get the default version" { + run process_extensions "org.acme:acme-component" + echo "Test Output:" + echo "$output" + [ "$output" == "org.acme:acme-component" ] +} + +# Test that multiple extensions are handled correctly +@test "Multiple extensions should get versions added" { + run process_extensions "io.quarkus:quarkus-resteasy-reactive,org.acme:acme-component,io.quarkus:quarkus-core" + echo "Test Output:" + echo "$output" + [ "$output" == "io.quarkus:quarkus-resteasy-reactive:2.0.0,org.acme:acme-component,io.quarkus:quarkus-core:2.0.0" ] +} + +# Test that the script fails when no extensions are provided +@test "No extensions should cause an error" { + run process_extensions "" + echo "Test Output:" + echo "$output" + [ "$output" == "" ] # Expecting an empty result for no extensions +} \ No newline at end of file diff --git a/packages/sonataflow-operator/Makefile b/packages/sonataflow-operator/Makefile index 1aafc812e07..c21179bae11 100644 --- a/packages/sonataflow-operator/Makefile +++ b/packages/sonataflow-operator/Makefile @@ -42,7 +42,7 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) endif BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) -# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images. +# IMAGE_TAG_BASE defines the image namespace and part of the image name for remote images. # This variable is used to construct full image tags for bundle and catalog images. # # For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both @@ -471,8 +471,8 @@ before-pr: generate-all test ## Run generate-all before executing tests. .PHONY: load-docker-image load-docker-image: install-kind kind load docker-image $(IMG) - kind load docker-image docker.io/apache/incubator-kie-sonataflow-builder:main - kind load docker-image docker.io/apache/incubator-kie-sonataflow-devmode:main + kind load docker-image $(shell pnpm build-env sonataFlowOperator.sonataflowBuilderImage) + kind load docker-image $(shell pnpm build-env sonataFlowOperator.sonataflowDevModeImage) .PHONY: install-kind install-kind: @@ -505,3 +505,25 @@ deploy-grafana: create-cluster .PHONY: delete-cluster delete-cluster: install-kind kind delete cluster && $(BUILDER) rm -f kind-registry + +# Updates the controllers_cfg.yaml file with the images used by the operator. +# These params come from the package.json file processing the env vars at ./env/index.js +.PHONY: update-config +update-config: + @echo "🔧 Preparing to update controllers config file..." + $(eval PARAMS := \ + jobsServicePostgreSQLImageTag=$$(shell build-env sonataFlowOperator.kogitoJobsServicePostgresqlImage) \ + jobsServiceEphemeralImageTag=$$(shell build-env sonataFlowOperator.kogitoJobsServiceEphemeralImage) \ + dataIndexPostgreSQLImageTag=$$(shell build-env sonataFlowOperator.kogitoDataIndexPostgresqlImage) \ + dataIndexEphemeralImageTag=$$(shell build-env sonataFlowOperator.kogitoDataIndexEphemeralImage) \ + sonataFlowBaseBuilderImageTag=$$(shell build-env sonataFlowOperator.sonataflowBuilderImage) \ + sonataFlowDevModeImageTag=$$(shell build-env sonataFlowOperator.sonataflowDevModeImage)) + @if [ -z "$(strip $(PARAMS))" ]; then \ + echo "⚠️ No variables resolved. Skipping updates to controllers config file."; \ + else \ + echo "📋 Resolved variables:"; \ + echo "$(PARAMS)" | tr ' ' '\n'; \ + echo "🚀 Running Python script to update controllers config file..."; \ + python ./hack/update_controllers_cfg.py $(PARAMS); \ + echo "✅ Configuration updated successfully!"; \ + fi diff --git a/packages/sonataflow-operator/config/manager/controllers_cfg.yaml b/packages/sonataflow-operator/config/manager/controllers_cfg.yaml index 5bfcc6c51c9..72780469e03 100644 --- a/packages/sonataflow-operator/config/manager/controllers_cfg.yaml +++ b/packages/sonataflow-operator/config/manager/controllers_cfg.yaml @@ -48,13 +48,10 @@ builderConfigMapName: "sonataflow-operator-builder-config" postgreSQLPersistenceExtensions: - groupId: io.quarkus artifactId: quarkus-jdbc-postgresql - version: 3.8.6 - groupId: io.quarkus artifactId: quarkus-agroal - version: 3.8.6 - groupId: org.kie artifactId: kie-addons-quarkus-persistence-jdbc - version: 999-20241208-SNAPSHOT # If true, the workflow deployments will be configured to send accumulated workflow status change events to the Data # Index Service reducing the number of produced events. Set to false to send individual events. kogitoEventsGrouping: true diff --git a/packages/sonataflow-operator/config/manager/kustomization.yaml b/packages/sonataflow-operator/config/manager/kustomization.yaml index 0c430ec01b1..bcb8522fa41 100644 --- a/packages/sonataflow-operator/config/manager/kustomization.yaml +++ b/packages/sonataflow-operator/config/manager/kustomization.yaml @@ -35,7 +35,9 @@ configMapGenerator: - controllers_cfg.yaml name: controllers-config apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization +kind: + Kustomization + # Changed during "make build", do not attempt to modify it manually! images: - name: controller newName: docker.io/apache/incubator-kie-sonataflow-operator diff --git a/packages/sonataflow-operator/config/samples/sonataflow.org_v1alpha08_sonataflowplatform.yaml b/packages/sonataflow-operator/config/samples/sonataflow.org_v1alpha08_sonataflowplatform.yaml index cc73c324fc9..33d18f2b718 100644 --- a/packages/sonataflow-operator/config/samples/sonataflow.org_v1alpha08_sonataflowplatform.yaml +++ b/packages/sonataflow-operator/config/samples/sonataflow.org_v1alpha08_sonataflowplatform.yaml @@ -23,5 +23,5 @@ spec: build: config: registry: - address: docker.io/apache + address: host/namespace secret: regcred diff --git a/packages/sonataflow-operator/container-builder/api/build_types.go b/packages/sonataflow-operator/container-builder/api/build_types.go index 193142413ee..293c6c1b212 100644 --- a/packages/sonataflow-operator/container-builder/api/build_types.go +++ b/packages/sonataflow-operator/container-builder/api/build_types.go @@ -107,7 +107,7 @@ type PublishTask struct { } // GetRepositoryImageTag gets the full qualified Repository Name for the given image in the PublishTask. -// For example docker.io/myrepo/myimage:latest. +// For example registry.org/myrepo/myimage:latest. func (p *PublishTask) GetRepositoryImageTag() string { if len(p.Registry.Address) > 0 { return fmt.Sprintf("%s/%s", p.Registry.Address, p.Image) diff --git a/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_kaniko_test.go b/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_kaniko_test.go index e2dfdc740e2..b15ac6387b3 100644 --- a/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_kaniko_test.go +++ b/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_kaniko_test.go @@ -41,7 +41,7 @@ func TestNewBuildWithKanikoCustomizations(t *testing.T) { ns := "test" c := test.NewFakeClient() - dockerFile, err := os.ReadFile("testdata/Dockerfile") + dockerFile, err := os.ReadFile("testdata/sample.Dockerfile") assert.NoError(t, err) workflowDefinition, err := os.ReadFile("testdata/greetings.sw.json") @@ -116,7 +116,7 @@ func TestNewBuildWithKanikoWithBuildArgsAndEnv(t *testing.T) { ns := "test" c := test.NewFakeClient() - dockerFile, err := os.ReadFile("testdata/Dockerfile") + dockerFile, err := os.ReadFile("testdata/sample.Dockerfile") assert.NoError(t, err) workflowDefinition, err := os.ReadFile("testdata/greetings.sw.json") diff --git a/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_test.go b/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_test.go index 0d8ef87aae2..a5b029a10ba 100644 --- a/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_test.go +++ b/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_test.go @@ -39,7 +39,7 @@ func TestNewBuild(t *testing.T) { ns := "test" c := test.NewFakeClient() - dockerFile, err := os.ReadFile("testdata/Dockerfile") + dockerFile, err := os.ReadFile("testdata/sample.Dockerfile") assert.NoError(t, err) workflowDefinition, err := os.ReadFile("testdata/greetings.sw.json") diff --git a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml b/packages/sonataflow-operator/container-builder/builder/kubernetes/testdata/sample.Dockerfile similarity index 50% rename from packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml rename to packages/sonataflow-operator/container-builder/builder/kubernetes/testdata/sample.Dockerfile index 178b173a54d..63307297b0b 100644 --- a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml +++ b/packages/sonataflow-operator/container-builder/builder/kubernetes/testdata/sample.Dockerfile @@ -6,7 +6,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -15,14 +15,33 @@ # specific language governing permissions and limitations # under the License. -apiVersion: sonataflow.org/v1alpha08 -kind: SonataFlowPlatform -metadata: - name: sonataflow-platform -spec: - build: - config: - strategy: operator - baseImage: docker.io/apache/incubator-kie-sonataflow-builder:main - strategyOptions: - KanikoBuildCacheEnabled: "true" +# Sample Dockerfile used in tests +FROM ubuntu:20.04 + +# Set environment variables +ENV DEBIAN_FRONTEND=noninteractive + +# Update and install necessary dependencies +RUN apt-get update && apt-get install -y \ + curl \ + git \ + python3 \ + python3-pip \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies (if needed) +COPY requirements.txt /app/requirements.txt +RUN pip3 install -r /app/requirements.txt + +# Set up working directory +WORKDIR /app + +# Copy project files into the container +COPY . /app + +# Expose any ports (if your application needs it) +EXPOSE 8080 + +# Command to run the application or test +CMD ["python3", "app.py"] diff --git a/packages/sonataflow-operator/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml b/packages/sonataflow-operator/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml index a6608195102..81ae3ff6a09 100644 --- a/packages/sonataflow-operator/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml +++ b/packages/sonataflow-operator/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml @@ -18,9 +18,9 @@ name: platform-kaniko-using-cache spec: publishStrategy: "Kaniko" - baseImage: docker.io/apache/incubator-kie-sonataflow-builder:main + baseImage: host/namespace/image:latest registry: - address: docker.io/apache + address: host/namespace secret: regcred PublishStrategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/hack/bump-version.sh b/packages/sonataflow-operator/hack/bump-version.sh index ffc95cef13a..ca7e4b92bad 100755 --- a/packages/sonataflow-operator/hack/bump-version.sh +++ b/packages/sonataflow-operator/hack/bump-version.sh @@ -20,20 +20,10 @@ set -e -script_dir_path=$(dirname "${BASH_SOURCE[0]}") -source "${script_dir_path}"/env.sh - imageName=$(pnpm build-env sonataFlowOperator.registry)/$(pnpm build-env sonataFlowOperator.account)/$(pnpm build-env sonataFlowOperator.name) imageTag=$(pnpm build-env sonataFlowOperator.buildTag) version=$(pnpm build-env sonataFlowOperator.version) -targetSonataflowBuilderImage=$(pnpm build-env sonataFlowOperator.sonataflowBuilderImage) -targetSonataflowDevModeImage=$(pnpm build-env sonataFlowOperator.sonataflowDevModeImage) -targetKogitoDataIndexEphemeralImage=$(pnpm build-env sonataFlowOperator.kogitoDataIndexEphemeralImage) -targetKogitoDataIndexPostgresqlImage=$(pnpm build-env sonataFlowOperator.kogitoDataIndexPostgresqlImage) -targetKogitoJobsServiceEphemeralImage=$(pnpm build-env sonataFlowOperator.kogitoJobsServiceEphemeralImage) -targetKogitoJobsServicePostgresqlImage=$(pnpm build-env sonataFlowOperator.kogitoJobsServicePostgresqlImage) - if [ -z "${version}" ]; then echo "Please inform the new version" exit 1 @@ -51,22 +41,9 @@ node -p "require('replace-in-file').sync({ from: /\bnewName:.*\b/g, to: 'newName node -p "require('replace-in-file').sync({ from: /\bversion: .*\b/g, to: 'version: ${version}', files: ['./images/bundle.yaml'] });" node -p "require('replace-in-file').sync({ from: /\bversion: .*\b/g, to: 'version: ${version}', files: ['./images/manager.yaml'] });" -# Update sonataflow-* images -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-sonataflow-builder:[\w\.]*/g, to: '${targetSonataflowBuilderImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-sonataflow-devmode:[\w\.]*/g, to: '${targetSonataflowDevModeImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-sonataflow-operator:[\w\.]*/g, to: '${targetSonataflowOperatorImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-kogito-data-index-ephemeral:[\w\.]*/g, to: '${targetKogitoDataIndexEphemeralImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-kogito-data-index-postgresql:[\w\.]*/g, to: '${targetKogitoDataIndexPostgresqlImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-kogito-jobs-service-ephemeral:[\w\.]*/g, to: '${targetKogitoJobsServiceEphemeralImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-kogito-jobs-service-postgresql:[\w\.]*/g, to: '${targetKogitoJobsServicePostgresqlImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" - -node -p "require('replace-in-file').sync({ from: /sonataflow-operator-system\/sonataflow-operator:[\w\.]*/g, to: 'sonataflow-operator-system/sonataflow-operator:${imageTag}', files: ['**/*.yaml'] });" - node -p "require('replace-in-file').sync({ from: /\boperatorVersion = .*/g, to: 'operatorVersion = \"${version}\"', files: ['version/version.go'] });" node -p "require('replace-in-file').sync({ from: /\btagVersion = .*/g, to: 'tagVersion = \"${imageTag}\"', files: ['version/version.go'] });" -node -p "require('replace-in-file').sync({ from: /\bcontainerImage:.*\b/g, to: 'containerImage: ${targetSonataflowOperatorImage}', files: ['$(getCsvFile)'] });" - make generate-all make vet diff --git a/packages/sonataflow-operator/hack/update_controllers_cfg.py b/packages/sonataflow-operator/hack/update_controllers_cfg.py new file mode 100644 index 00000000000..f309f07b9d1 --- /dev/null +++ b/packages/sonataflow-operator/hack/update_controllers_cfg.py @@ -0,0 +1,93 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from ruamel.yaml import YAML +import re + +# Relative to the project root +CONFIG_FILE = "config/manager/controllers_cfg.yaml" +BUILDER_DOCKERFILE = "config/manager/SonataFlow-Builder.containerfile" + +# Load the YAML file +yaml = YAML() +yaml.preserve_quotes = True + + +def update_imagetags(attribute_mappings): + """ + Update the YAML file based on provided variable mappings. + + :param attribute_mappings: Dictionary mapping YAML attribute names to their new values. + """ + # Read the YAML file + with open(CONFIG_FILE, "r") as file: + data = yaml.load(file) + + # Apply updates based on var_mappings + for cfg_key, cfg_value in attribute_mappings.items(): + if cfg_key in data and cfg_value: + data[cfg_key] = cfg_value + + # Write the updated YAML back to the file + with open(CONFIG_FILE, "w") as file: + yaml.dump(data, file) + + +def update_dockerfile(base_image_tag): + """ + Update the first FROM clause in the Dockerfile with the specified base image tag. + Preserves any trailing 'AS ' or other content after the image tag. + + :param base_image_tag: The new base image tag for the Dockerfile. + """ + with open(BUILDER_DOCKERFILE, "r") as file: + dockerfile_lines = file.readlines() + + for i, line in enumerate(dockerfile_lines): + if line.strip().startswith("FROM"): + match = re.match(r"FROM\s+(\S+)(.*)", line.strip()) + if match: + trailing_content = match.group(2) # Everything after the image tag + updated_line = f"FROM {base_image_tag}{trailing_content}\n" + print(f"📋 Updating first FROM clause to: {updated_line.strip()}") + dockerfile_lines[i] = updated_line + break + + with open(BUILDER_DOCKERFILE, "w") as file: + file.writelines(dockerfile_lines) + + +if __name__ == "__main__": + import sys + + if len(sys.argv) < 2: + print("Usage: python update_config.py ...") + sys.exit(1) + + # Parse the mappings from the command line arguments + var_mappings = {} + + for mapping in sys.argv[1:]: + yaml_attr, value = mapping.split("=", 1) + var_mappings[yaml_attr] = value + + # Update the YAML file + update_imagetags(var_mappings) + + # Update Dockerfile if the `sonataFlowBaseBuilderImageTag` is provided + if "sonataFlowBaseBuilderImageTag" in var_mappings: + update_dockerfile(var_mappings["sonataFlowBaseBuilderImageTag"]) diff --git a/packages/sonataflow-operator/install.js b/packages/sonataflow-operator/install.js deleted file mode 100644 index cd9c5c35ecb..00000000000 --- a/packages/sonataflow-operator/install.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const fs = require("fs"); -const path = require("path"); -const { env } = require("./env"); - -function getAllYamlFiles(dir) { - let results = []; - const list = fs.readdirSync(dir); - - list.forEach((file) => { - const fullPath = path.join(dir, file); - const stat = fs.statSync(fullPath); - - // Skip node_modules directory - if (stat && stat.isDirectory() && file !== "node_modules") { - // Recurse into subdirectory - results = results.concat(getAllYamlFiles(fullPath)); - } else if (file.endsWith(".yaml")) { - // Add .yaml file to results - results.push(fullPath); - } - }); - - return results; -} - -const baseDir = path.resolve(__dirname, "."); - -const yamlFiles = getAllYamlFiles(baseDir); - -yamlFiles.forEach((filePath) => { - const updatedContent = fs - .readFileSync(filePath, "utf-8") - .replace( - /org\.kie:kie-addons-quarkus-persistence-jdbc:\S*/, - `org.kie:kie-addons-quarkus-persistence-jdbc:${env.versions.kogito}` - ) - .replace( - /org\.kie\.kogito:kogito-addons-quarkus-jobs-knative-eventing:\S*/, - `org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:${env.versions.kogito}` - ) - .replace( - /- groupId: io\.quarkus\s+artifactId: quarkus-jdbc-postgresql\s+version: \S+/g, - `- groupId: io.quarkus\n artifactId: quarkus-jdbc-postgresql\n version: ${env.versions.quarkus}` - ) - .replace( - /- groupId: io\.quarkus\s+artifactId: quarkus-agroal\s+version: \S+/g, - `- groupId: io.quarkus\n artifactId: quarkus-agroal\n version: ${env.versions.quarkus}` - ) - .replace( - /- groupId: org\.kie\s+artifactId: kie-addons-quarkus-persistence-jdbc\s+version: \S+/g, - `- groupId: org.kie\n artifactId: kie-addons-quarkus-persistence-jdbc\n version: ${env.versions.kogito}` - ); - - fs.writeFileSync(filePath, updatedContent); - console.log(`Updated: ${filePath}`); -}); diff --git a/packages/sonataflow-operator/internal/controller/builder/kogitoserverlessbuild_manager.go b/packages/sonataflow-operator/internal/controller/builder/kogitoserverlessbuild_manager.go index b0585c86242..be67b5a33fc 100644 --- a/packages/sonataflow-operator/internal/controller/builder/kogitoserverlessbuild_manager.go +++ b/packages/sonataflow-operator/internal/controller/builder/kogitoserverlessbuild_manager.go @@ -127,7 +127,7 @@ func getBuildArg(buildArgs []v1.EnvVar, name string) *v1.EnvVar { return nil } -func hasAnyExtensionPresent(buildArg *v1.EnvVar, extensions []cfg.GAV) bool { +func hasAnyExtensionPresent(buildArg *v1.EnvVar, extensions []cfg.GroupArtifactId) bool { for _, extension := range extensions { if isExtensionPresent(buildArg, extension) { return true @@ -136,6 +136,6 @@ func hasAnyExtensionPresent(buildArg *v1.EnvVar, extensions []cfg.GAV) bool { return false } -func isExtensionPresent(buildArg *v1.EnvVar, extension cfg.GAV) bool { - return strings.Contains(buildArg.Value, extension.GroupAndArtifact()) +func isExtensionPresent(buildArg *v1.EnvVar, extension cfg.GroupArtifactId) bool { + return strings.Contains(buildArg.Value, extension.String()) } diff --git a/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg.go b/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg.go index 4b6a4fecdec..927d8d62e20 100644 --- a/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg.go +++ b/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg.go @@ -45,36 +45,31 @@ var defaultControllersCfg = &ControllersCfg{ BuilderConfigMapName: "sonataflow-operator-builder-config", } -type GAV struct { +type GroupArtifactId struct { GroupId string `yaml:"groupId,omitempty"` ArtifactId string `yaml:"artifactId,omitempty"` - Version string `yaml:"version,omitempty"` } -func (g *GAV) GroupAndArtifact() string { +func (g *GroupArtifactId) String() string { return fmt.Sprintf("%s:%s", g.GroupId, g.ArtifactId) } -func (g *GAV) String() string { - return fmt.Sprintf("%s:%s:%s", g.GroupId, g.ArtifactId, g.Version) -} - type ControllersCfg struct { - DefaultPvcKanikoSize string `yaml:"defaultPvcKanikoSize,omitempty"` - HealthFailureThresholdDevMode int32 `yaml:"healthFailureThresholdDevMode,omitempty"` - KanikoDefaultWarmerImageTag string `yaml:"kanikoDefaultWarmerImageTag,omitempty"` - KanikoExecutorImageTag string `yaml:"kanikoExecutorImageTag,omitempty"` - JobsServicePostgreSQLImageTag string `yaml:"jobsServicePostgreSQLImageTag,omitempty"` - JobsServiceEphemeralImageTag string `yaml:"jobsServiceEphemeralImageTag,omitempty"` - DataIndexPostgreSQLImageTag string `yaml:"dataIndexPostgreSQLImageTag,omitempty"` - DataIndexEphemeralImageTag string `yaml:"dataIndexEphemeralImageTag,omitempty"` - SonataFlowBaseBuilderImageTag string `yaml:"sonataFlowBaseBuilderImageTag,omitempty"` - SonataFlowDevModeImageTag string `yaml:"sonataFlowDevModeImageTag,omitempty"` - BuilderConfigMapName string `yaml:"builderConfigMapName,omitempty"` - PostgreSQLPersistenceExtensions []GAV `yaml:"postgreSQLPersistenceExtensions,omitempty"` - KogitoEventsGrouping bool `yaml:"kogitoEventsGrouping,omitempty"` - KogitoEventsGroupingBinary bool `yaml:"KogitoEventsGroupingBinary,omitempty"` - KogitoEventsGroupingCompress bool `yaml:"KogitoEventsGroupingCompress,omitempty"` + DefaultPvcKanikoSize string `yaml:"defaultPvcKanikoSize,omitempty"` + HealthFailureThresholdDevMode int32 `yaml:"healthFailureThresholdDevMode,omitempty"` + KanikoDefaultWarmerImageTag string `yaml:"kanikoDefaultWarmerImageTag,omitempty"` + KanikoExecutorImageTag string `yaml:"kanikoExecutorImageTag,omitempty"` + JobsServicePostgreSQLImageTag string `yaml:"jobsServicePostgreSQLImageTag,omitempty"` + JobsServiceEphemeralImageTag string `yaml:"jobsServiceEphemeralImageTag,omitempty"` + DataIndexPostgreSQLImageTag string `yaml:"dataIndexPostgreSQLImageTag,omitempty"` + DataIndexEphemeralImageTag string `yaml:"dataIndexEphemeralImageTag,omitempty"` + SonataFlowBaseBuilderImageTag string `yaml:"sonataFlowBaseBuilderImageTag,omitempty"` + SonataFlowDevModeImageTag string `yaml:"sonataFlowDevModeImageTag,omitempty"` + BuilderConfigMapName string `yaml:"builderConfigMapName,omitempty"` + PostgreSQLPersistenceExtensions []GroupArtifactId `yaml:"postgreSQLPersistenceExtensions,omitempty"` + KogitoEventsGrouping bool `yaml:"kogitoEventsGrouping,omitempty"` + KogitoEventsGroupingBinary bool `yaml:"KogitoEventsGroupingBinary,omitempty"` + KogitoEventsGroupingCompress bool `yaml:"KogitoEventsGroupingCompress,omitempty"` } // InitializeControllersCfg initializes the platform configuration for this instance. diff --git a/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg_test.go b/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg_test.go index 2cdc5e1779f..0e81299c51e 100644 --- a/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg_test.go +++ b/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg_test.go @@ -37,22 +37,19 @@ func TestInitializeControllersCfgAt_ValidFile(t *testing.T) { assert.Equal(t, "local/sonataflow-devmode:1.0.0", cfg.SonataFlowDevModeImageTag) assert.Equal(t, 3, len(cfg.PostgreSQLPersistenceExtensions)) postgresExtensions := cfg.PostgreSQLPersistenceExtensions - assert.Equal(t, GAV{ + assert.Equal(t, GroupArtifactId{ GroupId: "io.quarkus", ArtifactId: "quarkus-jdbc-postgresql", - Version: "3.8.6", }, postgresExtensions[0]) - assert.Equal(t, GAV{ + assert.Equal(t, GroupArtifactId{ GroupId: "io.quarkus", ArtifactId: "quarkus-agroal", - Version: "3.8.6", }, postgresExtensions[1]) - assert.Equal(t, GAV{ + assert.Equal(t, GroupArtifactId{ GroupId: "org.kie", ArtifactId: "kie-addons-quarkus-persistence-jdbc", - Version: "999-20241208-SNAPSHOT", }, postgresExtensions[2]) assert.True(t, cfg.KogitoEventsGrouping) assert.True(t, cfg.KogitoEventsGroupingBinary) diff --git a/packages/sonataflow-operator/internal/controller/cfg/testdata/controllers-cfg-test.yaml b/packages/sonataflow-operator/internal/controller/cfg/testdata/controllers-cfg-test.yaml index e86fd8d56c2..b6d76a7e646 100644 --- a/packages/sonataflow-operator/internal/controller/cfg/testdata/controllers-cfg-test.yaml +++ b/packages/sonataflow-operator/internal/controller/cfg/testdata/controllers-cfg-test.yaml @@ -27,13 +27,10 @@ sonataFlowDevModeImageTag: "local/sonataflow-devmode:1.0.0" postgreSQLPersistenceExtensions: - groupId: io.quarkus artifactId: quarkus-jdbc-postgresql - version: 3.8.6 - groupId: io.quarkus artifactId: quarkus-agroal - version: 3.8.6 - groupId: org.kie artifactId: kie-addons-quarkus-persistence-jdbc - version: 999-20241208-SNAPSHOT kogitoEventsGrouping: true kogitoEventsGroupingBinary: true kogitoEventsGroupingCompress: false diff --git a/packages/sonataflow-operator/internal/controller/platform/platformutils_test.go b/packages/sonataflow-operator/internal/controller/platform/platformutils_test.go index a8208fd517f..4381c7d679d 100644 --- a/packages/sonataflow-operator/internal/controller/platform/platformutils_test.go +++ b/packages/sonataflow-operator/internal/controller/platform/platformutils_test.go @@ -20,6 +20,7 @@ package platform import ( + "fmt" "os" "regexp" "testing" @@ -43,16 +44,16 @@ func TestSonataFlowBuildController(t *testing.T) { assert.Fail(t, "Unable to read base Dockerfile") } dockerfile := string(dockerfileBytes) - // 1 - Let's verify that the default image is used (for this unit test is docker.io/apache/incubator-kie-sonataflow-builder:main) + // 1 - Let's verify that the default image is used resDefault := GetCustomizedBuilderDockerfile(dockerfile, *platform) - foundDefault, err := regexp.MatchString("FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder", resDefault) + foundDefault, err := regexp.MatchString(fmt.Sprintf("FROM %s AS builder", test.CommonImageTag), resDefault) assert.NoError(t, err) assert.True(t, foundDefault) // 2 - Let's try to override using the productized image - platform.Spec.Build.Config.BaseImage = "registry.access.redhat.com/openshift-serverless-1-tech-preview/logic-swf-builder-rhel8" + platform.Spec.Build.Config.BaseImage = "host2.org/namespace2/builder2:main" resProductized := GetCustomizedBuilderDockerfile(dockerfile, *platform) - foundProductized, err := regexp.MatchString("FROM registry.access.redhat.com/openshift-serverless-1-tech-preview/logic-swf-builder-rhel8 AS builder", resProductized) + foundProductized, err := regexp.MatchString(fmt.Sprintf("FROM %s AS builder", platform.Spec.Build.Config.BaseImage), resProductized) assert.NoError(t, err) assert.True(t, foundProductized) } @@ -76,14 +77,14 @@ func TestGetCustomizedBuilderDockerfile_BaseImageCustomizationFromPlatform(t *te Build: v1alpha08.BuildPlatformSpec{ Template: v1alpha08.BuildTemplate{}, Config: v1alpha08.BuildPlatformConfig{ - BaseImage: "docker.io/apache/platfom-sonataflow-builder:main", + BaseImage: test.CommonImageTag, }, }, }, Status: v1alpha08.SonataFlowPlatformStatus{}, } - expectedDockerFile := "FROM docker.io/apache/platfom-sonataflow-builder:main AS builder\n\n# ETC, \n\n# ETC, \n\n# ETC" + expectedDockerFile := fmt.Sprintf("FROM %s AS builder\n\n# ETC, \n\n# ETC, \n\n# ETC", test.CommonImageTag) customizedDockerfile := GetCustomizedBuilderDockerfile(dockerFile, sfp) assert.Equal(t, expectedDockerFile, customizedDockerfile) } diff --git a/packages/sonataflow-operator/internal/controller/platform/testdata/platformTest.Dockerfile b/packages/sonataflow-operator/internal/controller/platform/testdata/platformTest.Dockerfile index c9b902ba326..dd8a8591387 100644 --- a/packages/sonataflow-operator/internal/controller/platform/testdata/platformTest.Dockerfile +++ b/packages/sonataflow-operator/internal/controller/platform/testdata/platformTest.Dockerfile @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder +FROM host/namespace/image:latest AS builder # Kogito User USER 1001 diff --git a/packages/sonataflow-operator/internal/controller/profiles/common/object_creators_test.go b/packages/sonataflow-operator/internal/controller/profiles/common/object_creators_test.go index be84323929f..5abc02f6c18 100644 --- a/packages/sonataflow-operator/internal/controller/profiles/common/object_creators_test.go +++ b/packages/sonataflow-operator/internal/controller/profiles/common/object_creators_test.go @@ -106,7 +106,7 @@ func TestMergePodSpec(t *testing.T) { workflow.Spec.PodTemplate = v1alpha08.FlowPodTemplateSpec{ Container: v1alpha08.ContainerSpec{ // this one we can override - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ // let's override a immutable attribute {Name: utils.DefaultServicePortName, ContainerPort: 9090}, @@ -148,7 +148,7 @@ func TestMergePodSpec(t *testing.T) { assert.Equal(t, "superuser", deployment.Spec.Template.Spec.ServiceAccountName) assert.Len(t, deployment.Spec.Template.Spec.Volumes, 1) flowContainer, _ := kubeutil.GetContainerByName(v1alpha08.DefaultContainerName, &deployment.Spec.Template.Spec) - assert.Equal(t, "docker.io/example/my-workflow:1.0.0", flowContainer.Image) + assert.Equal(t, test.CommonImageTag, flowContainer.Image) assert.Equal(t, int32(8080), flowContainer.Ports[0].ContainerPort) assert.Equal(t, "VALUE_CUSTOM", flowContainer.Env[0].Value) assert.Len(t, flowContainer.VolumeMounts, 1) @@ -162,7 +162,7 @@ func TestMergePodSpecOverrideContainers(t *testing.T) { Containers: []corev1.Container{ { Name: v1alpha08.DefaultContainerName, - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ {Name: utils.DefaultServicePortName, ContainerPort: 9090}, }, @@ -181,7 +181,7 @@ func TestMergePodSpecOverrideContainers(t *testing.T) { assert.Len(t, deployment.Spec.Template.Spec.Containers, 1) flowContainer, _ := kubeutil.GetContainerByName(v1alpha08.DefaultContainerName, &deployment.Spec.Template.Spec) - assert.NotEqual(t, "docker.io/example/my-workflow:1.0.0", flowContainer.Image) + assert.NotEqual(t, test.CommonImageTag, flowContainer.Image) assert.Equal(t, int32(8080), flowContainer.Ports[0].ContainerPort) assert.Empty(t, flowContainer.Env) } @@ -382,7 +382,7 @@ func TestMergePodSpec_WithPostgreSQL_and_JDBC_URL_field(t *testing.T) { PodTemplate: v1alpha08.FlowPodTemplateSpec{ Container: v1alpha08.ContainerSpec{ // this one we can override - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ // let's override a immutable attribute {Name: utils.DefaultServicePortName, ContainerPort: 9090}, @@ -466,7 +466,7 @@ func TestMergePodSpec_WithPostgreSQL_and_JDBC_URL_field(t *testing.T) { assert.Equal(t, "superuser", deployment.Spec.Template.Spec.ServiceAccountName) assert.Len(t, deployment.Spec.Template.Spec.Volumes, 1) flowContainer, _ := kubeutil.GetContainerByName(v1alpha08.DefaultContainerName, &deployment.Spec.Template.Spec) - assert.Equal(t, "docker.io/example/my-workflow:1.0.0", flowContainer.Image) + assert.Equal(t, test.CommonImageTag, flowContainer.Image) assert.Equal(t, int32(8080), flowContainer.Ports[0].ContainerPort) assert.Equal(t, expectedEnvVars, flowContainer.Env) assert.Len(t, flowContainer.VolumeMounts, 1) @@ -485,7 +485,7 @@ func TestMergePodSpec_OverrideContainers_WithPostgreSQL_In_Workflow_CR(t *testin Containers: []corev1.Container{ { Name: v1alpha08.DefaultContainerName, - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ {Name: utils.DefaultServicePortName, ContainerPort: 9090}, }, @@ -658,7 +658,7 @@ func TestMergePodSpec_WithServicedPostgreSQL_In_Platform_And_In_Workflow_CR(t *t Containers: []corev1.Container{ { Name: v1alpha08.DefaultContainerName, - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ {Name: utils.DefaultServicePortName, ContainerPort: 9090}, }, diff --git a/packages/sonataflow-operator/internal/controller/profiles/common/persistence/postgresql.go b/packages/sonataflow-operator/internal/controller/profiles/common/persistence/postgresql.go index b81f3d53d73..e0aa6456230 100644 --- a/packages/sonataflow-operator/internal/controller/profiles/common/persistence/postgresql.go +++ b/packages/sonataflow-operator/internal/controller/profiles/common/persistence/postgresql.go @@ -153,7 +153,7 @@ func UsesPostgreSQLPersistence(workflow *operatorapi.SonataFlow, platform *opera } // GetPostgreSQLExtensions returns the Quarkus extensions required for postgresql persistence. -func GetPostgreSQLExtensions() []cfg.GAV { +func GetPostgreSQLExtensions() []cfg.GroupArtifactId { return cfg.GetCfg().PostgreSQLPersistenceExtensions } diff --git a/packages/sonataflow-operator/internal/controller/profiles/dev/profile_dev_test.go b/packages/sonataflow-operator/internal/controller/profiles/dev/profile_dev_test.go index 78f50629258..7eb43f2768e 100644 --- a/packages/sonataflow-operator/internal/controller/profiles/dev/profile_dev_test.go +++ b/packages/sonataflow-operator/internal/controller/profiles/dev/profile_dev_test.go @@ -241,7 +241,7 @@ func Test_devProfileWithImageSnapshotOverrideWithPlatform(t *testing.T) { // check if the objects have been created deployment := test.MustGetDeployment(t, client, workflow) - assert.Equal(t, "docker.io/customgroup/custom-swf-builder-nightly:42.43.7", deployment.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, test.CommonImageTag, deployment.Spec.Template.Spec.Containers[0].Image) } func Test_devProfileWithWPlatformWithoutDevBaseImageAndWithBaseImage(t *testing.T) { diff --git a/packages/sonataflow-operator/internal/controller/profiles/preview/deployment_handler_test.go b/packages/sonataflow-operator/internal/controller/profiles/preview/deployment_handler_test.go index 099e4d07659..dbc5e405b2d 100644 --- a/packages/sonataflow-operator/internal/controller/profiles/preview/deployment_handler_test.go +++ b/packages/sonataflow-operator/internal/controller/profiles/preview/deployment_handler_test.go @@ -85,7 +85,7 @@ func Test_CheckPodTemplateChangesReflectDeployment(t *testing.T) { assert.True(t, result.Requeue) // Second reconciliation, we do change the image and that must reflect the deployment - expectedImg := "docker.io/apache/my-new-workflow:1.0.0" + expectedImg := test.CommonImageTag workflow.Spec.PodTemplate.Container.Image = expectedImg utilruntime.Must(client.Update(context.TODO(), workflow)) result, objects, err = handler.Reconcile(context.TODO(), workflow) diff --git a/packages/sonataflow-operator/internal/controller/sonataflowplatform_controller_test.go b/packages/sonataflow-operator/internal/controller/sonataflowplatform_controller_test.go index cb983e82f51..b1de0db704a 100644 --- a/packages/sonataflow-operator/internal/controller/sonataflowplatform_controller_test.go +++ b/packages/sonataflow-operator/internal/controller/sonataflowplatform_controller_test.go @@ -83,7 +83,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.Equal(t, v1alpha08.PlatformClusterKubernetes, ksp.Status.Cluster) @@ -121,7 +121,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.DataIndex) @@ -214,7 +214,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.DataIndex) @@ -524,7 +524,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.JobService) @@ -612,7 +612,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.JobService) @@ -688,7 +688,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.DataIndex) @@ -780,7 +780,7 @@ func TestSonataFlowPlatformController(t *testing.T) { // Perform some checks on the created CR assert.True(t, ksp.Status.IsReady()) assert.True(t, kscp.Status.IsReady()) - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.DataIndex) @@ -894,7 +894,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Eventing) @@ -994,7 +994,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Eventing) diff --git a/packages/sonataflow-operator/operator.yaml b/packages/sonataflow-operator/operator.yaml index c90861259e7..050b16eec7a 100644 --- a/packages/sonataflow-operator/operator.yaml +++ b/packages/sonataflow-operator/operator.yaml @@ -28166,13 +28166,10 @@ data: postgreSQLPersistenceExtensions: - groupId: io.quarkus artifactId: quarkus-jdbc-postgresql - version: 3.8.6 - groupId: io.quarkus artifactId: quarkus-agroal - version: 3.8.6 - groupId: org.kie artifactId: kie-addons-quarkus-persistence-jdbc - version: 999-20241208-SNAPSHOT # If true, the workflow deployments will be configured to send accumulated workflow status change events to the Data # Index Service reducing the number of produced events. Set to false to send individual events. kogitoEventsGrouping: true diff --git a/packages/sonataflow-operator/package.json b/packages/sonataflow-operator/package.json index 615fabf297e..655c7e6cac0 100644 --- a/packages/sonataflow-operator/package.json +++ b/packages/sonataflow-operator/package.json @@ -22,6 +22,7 @@ "bump-version": "run-script-os", "bump-version:darwin:linux": "./hack/bump-version.sh", "bump-version:win32": "echo 'Bumping version not supported on Windows'", + "controllers:update:cfg": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && make update-config", "format": "prettier --write . --ignore-path=../../.prettierignore --ignore-path=../../.gitignore", "image:build": "run-script-os", "image:build:darwin:win32": "echo 'Image build not supported on Windows and macOS'", @@ -30,7 +31,7 @@ "image:bundle:build:darwin:win32": "echo 'Build Operator bundle image not supported on Windows and macOS'", "image:bundle:build:linux": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && run-script-if --bool \"$(build-env containerImages.build)\" --then \"make bundle bundle-build\"", "install": "run-script-os", - "install:darwin:linux": "rimraf bin && go work sync && go mod tidy && node install.js && pnpm bump-version && pnpm format", + "install:darwin:linux": "rimraf bin && go work sync && go mod tidy && pnpm controllers:update:cfg && pnpm bump-version && pnpm format", "install:win32": "echo 'Install not supported on Windows'", "test": "run-script-os", "test:darwin:linux": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && run-script-if --ignore-errors \"$(build-env tests.ignoreFailures)\" --bool \"$(build-env tests.run)\" --then \"make test\"", diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml index ec547059f9f..066fb9e3615 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml @@ -30,7 +30,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml index 3c1ede7bd34..49c82e2103e 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml index b5a5baae84a..22b909957d7 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSIONS - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing services: dataIndex: enabled: false diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml index df922c072f9..76de2a4fac0 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml index 9274169d2c1..0377ef62717 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml index 45f60eb9597..1784c72a431 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowbuild.yaml b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowbuild.yaml index 9b018ec72a1..bd07aba6733 100644 --- a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowbuild.yaml +++ b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowbuild.yaml @@ -24,7 +24,7 @@ spec: timeout: 0s status: buildPhase: Succeeded - imageTag: 10.100.163.129/greeting:0.0.1 + imageTag: host/namespace/image:latest innerBuild: metadata: name: greeting diff --git a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform.yaml b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform.yaml index 6d38cb2e4d4..93498cd04ac 100644 --- a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform.yaml +++ b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform.yaml @@ -28,5 +28,5 @@ spec: config: strategy: operator registry: - address: docker.io/apache + address: host/namespace secret: regcred diff --git a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml index 9d93ca147f9..73688a31931 100644 --- a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml +++ b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml @@ -28,7 +28,7 @@ spec: config: strategy: operator registry: - address: docker.io/apache + address: host/namespace secret: regcred eventing: broker: diff --git a/packages/sonataflow-operator/test/yaml.go b/packages/sonataflow-operator/test/yaml.go index 1793153ff5d..56139718a21 100644 --- a/packages/sonataflow-operator/test/yaml.go +++ b/packages/sonataflow-operator/test/yaml.go @@ -45,24 +45,22 @@ import ( ) const ( - sonataFlowOrderProcessingFolder = "order-processing" - sonataFlowSampleYamlCR = "sonataflow.org_v1alpha08_sonataflow.yaml" - SonataFlowGreetingsWithDataInputSchemaCR = "sonataflow.org_v1alpha08_sonataflow_greetings_datainput.yaml" - SonataFlowGreetingsWithStaticResourcesCR = "sonataflow.org_v1alpha08_sonataflow-metainf.yaml" - SonataFlowSimpleOpsYamlCR = "sonataflow.org_v1alpha08_sonataflow-simpleops.yaml" - SonataFlowVetWithEventCR = "sonataflow.org_v1alpha08_sonataflow_vet_event.yaml" - SonataFlowGreetingsDataInputSchemaConfig = "v1_configmap_greetings_datainput.yaml" - SonataFlowGreetingsStaticFilesConfig = "v1_configmap_greetings_staticfiles.yaml" - sonataFlowPlatformYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform.yaml" - sonataFlowPlatformWithBrokerYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml" - sonataFlowPlatformWithCacheMinikubeYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml" - sonataFlowPlatformForOpenshift = "sonataflow.org_v1alpha08_sonataflowplatform_openshift.yaml" - sonataFlowClusterPlatformYamlCR = "sonataflow.org_v1alpha08_sonataflowclusterplatform.yaml" - sonataFlowBuilderConfig = "sonataflow-operator-builder-config_v1_configmap.yaml" - sonataFlowBuildSucceed = "sonataflow.org_v1alpha08_sonataflowbuild.yaml" - knativeDefaultBrokerCR = "knative_default_broker.yaml" - e2eSamples = "test/testdata/" - manifestsPath = "bundle/manifests/" + CommonImageRegistryAccount = "host/namespace" + CommonImageTag = CommonImageRegistryAccount + "/image:latest" + sonataFlowSampleYamlCR = "sonataflow.org_v1alpha08_sonataflow.yaml" + SonataFlowGreetingsWithDataInputSchemaCR = "sonataflow.org_v1alpha08_sonataflow_greetings_datainput.yaml" + SonataFlowGreetingsWithStaticResourcesCR = "sonataflow.org_v1alpha08_sonataflow-metainf.yaml" + SonataFlowSimpleOpsYamlCR = "sonataflow.org_v1alpha08_sonataflow-simpleops.yaml" + SonataFlowVetWithEventCR = "sonataflow.org_v1alpha08_sonataflow_vet_event.yaml" + SonataFlowGreetingsDataInputSchemaConfig = "v1_configmap_greetings_datainput.yaml" + SonataFlowGreetingsStaticFilesConfig = "v1_configmap_greetings_staticfiles.yaml" + sonataFlowPlatformYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform.yaml" + sonataFlowPlatformWithBrokerYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml" + sonataFlowClusterPlatformYamlCR = "sonataflow.org_v1alpha08_sonataflowclusterplatform.yaml" + sonataFlowBuilderConfig = "sonataflow-operator-builder-config_v1_configmap.yaml" + sonataFlowBuildSucceed = "sonataflow.org_v1alpha08_sonataflowbuild.yaml" + knativeDefaultBrokerCR = "knative_default_broker.yaml" + manifestsPath = "bundle/manifests/" ) var projectDir = "" @@ -248,7 +246,7 @@ func GetBasePlatformWithBaseImageInReadyPhase(namespace string) *operatorapi.Son platform := GetBasePlatform() platform.Namespace = namespace platform.Status.Manager().MarkTrue(api.SucceedConditionType) - platform.Spec.Build.Config.BaseImage = "docker.io/customx/custom-swf-builder:24.8.17" + platform.Spec.Build.Config.BaseImage = CommonImageTag return platform } @@ -256,7 +254,7 @@ func GetBasePlatformWithDevBaseImageInReadyPhase(namespace string) *operatorapi. platform := GetBasePlatform() platform.Namespace = namespace platform.Status.Manager().MarkTrue(api.SucceedConditionType) - platform.Spec.DevMode.BaseImage = "docker.io/customgroup/custom-swf-builder-nightly:42.43.7" + platform.Spec.DevMode.BaseImage = CommonImageTag return platform } @@ -272,18 +270,6 @@ func GetBasePlatformWithBrokerInReadyPhase(namespace string) *operatorapi.Sonata return GetSonataFlowPlatformInReadyPhase(sonataFlowPlatformWithBrokerYamlCR, namespace) } -func GetPlatformMinikubeE2eTest() string { - return e2eSamples + sonataFlowPlatformWithCacheMinikubeYamlCR -} - -func GetPlatformOpenshiftE2eTest() string { - return e2eSamples + sonataFlowPlatformForOpenshift -} - -func GetSonataFlowE2eOrderProcessingFolder() string { - return GetPathFromE2EDirectory("order-processing") -} - func GetPathFromDataDirectory(join ...string) string { return filepath.Join(append([]string{getTestDataDir()}, join...)...) } From 576b340ab6e608bd28aaabb248ccc72ea7846454 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:18:26 -0500 Subject: [PATCH 2/3] Fix operator.yaml formatting Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> --- packages/sonataflow-operator/operator.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/sonataflow-operator/operator.yaml b/packages/sonataflow-operator/operator.yaml index 050b16eec7a..34e649129da 100644 --- a/packages/sonataflow-operator/operator.yaml +++ b/packages/sonataflow-operator/operator.yaml @@ -28164,12 +28164,12 @@ data: # Quarkus extensions required for workflows persistence. These extensions are used by the SonataFlow build system, # in cases where the workflow being built has configured postgresql persistence. postgreSQLPersistenceExtensions: - - groupId: io.quarkus - artifactId: quarkus-jdbc-postgresql - - groupId: io.quarkus - artifactId: quarkus-agroal - - groupId: org.kie - artifactId: kie-addons-quarkus-persistence-jdbc + - groupId: io.quarkus + artifactId: quarkus-jdbc-postgresql + - groupId: io.quarkus + artifactId: quarkus-agroal + - groupId: org.kie + artifactId: kie-addons-quarkus-persistence-jdbc # If true, the workflow deployments will be configured to send accumulated workflow status change events to the Data # Index Service reducing the number of produced events. Set to false to send individual events. kogitoEventsGrouping: true From eadb0d1752b6cfd7473d39f4b74f526e58b72e5c Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Thu, 12 Dec 2024 15:59:20 -0500 Subject: [PATCH 3/3] Fix formatting Signed-off-by: Ricardo Zanini --- packages/sonataflow-operator/operator.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/sonataflow-operator/operator.yaml b/packages/sonataflow-operator/operator.yaml index 34e649129da..050b16eec7a 100644 --- a/packages/sonataflow-operator/operator.yaml +++ b/packages/sonataflow-operator/operator.yaml @@ -28164,12 +28164,12 @@ data: # Quarkus extensions required for workflows persistence. These extensions are used by the SonataFlow build system, # in cases where the workflow being built has configured postgresql persistence. postgreSQLPersistenceExtensions: - - groupId: io.quarkus - artifactId: quarkus-jdbc-postgresql - - groupId: io.quarkus - artifactId: quarkus-agroal - - groupId: org.kie - artifactId: kie-addons-quarkus-persistence-jdbc + - groupId: io.quarkus + artifactId: quarkus-jdbc-postgresql + - groupId: io.quarkus + artifactId: quarkus-agroal + - groupId: org.kie + artifactId: kie-addons-quarkus-persistence-jdbc # If true, the workflow deployments will be configured to send accumulated workflow status change events to the Data # Index Service reducing the number of produced events. Set to false to send individual events. kogitoEventsGrouping: true