Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from apache:main #20

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
28 changes: 25 additions & 3 deletions packages/sonataflow-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ spec:
build:
config:
registry:
address: docker.io/apache
address: host/namespace
secret: regcred
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading
Loading