Skip to content

Commit

Permalink
Don't bail out from gen-manifests early
Browse files Browse the repository at this point in the history
make gen-manifests would bail out without setting the image when it was
set to false.
To fix it that section is in its own condition, and the rest of the
script can continue if need. Also the default is now true.

Another addition to the Makefile is that we now don't need to specify
the WORKFLOW_ID argument but instead can call it like a target:

   make move2kube gen-manifests

Signed-off-by: Roy Golan <[email protected]>
  • Loading branch information
rgolangh committed Jul 15, 2024
1 parent 62c0961 commit ed22ee0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@
# .git_token file exists with current Token (or injected as the GIT_TOKEN env var)
# Linux OS

ifndef WORKFLOW_ID
$(error WORKFLOW_ID variable is not defined. Please provide the required value)
endif
WORKFLOWS = \
greeting \
escalation \
move2kube \
mta \
mta-v6.x \
mta-v7.x \
$(NULL)

# Dynamic rule patten that uses one of the workflows and sets the workflow id
# for the rest of the execution. Use with other targets, e.g, make move2kube gen-manifests
.PHONY: $(WORKFLOWS)
$(WORKFLOWS):
$(eval WORKFLOW_ID="$@")
@echo Specify one of the targets: build-image, push-image, gen-manifests, push-manifests

ifndef APPLICATION_ID
APPLICATION_ID = UNDEFINED
Expand Down Expand Up @@ -86,7 +98,7 @@ endif
DEPLOYMENT_REPO ?= parodos-dev/serverless-workflows-config
DEPLOYMENT_BRANCH ?= main

ENABLE_PERSISTENCE ?= false
ENABLE_PERSISTENCE ?= true

# extra extensions needed for persistence at build time.
# The extentions listed below are included in the cache in image quay.io/kiegroup/kogito-swf-builder:9.99.1.CR1 or available from maven central repository
Expand Down Expand Up @@ -167,8 +179,8 @@ save-oci: build-image
# Usage: make gen-manifests
gen-manifests: prepare-workdir
cd $(WORKDIR)
@$(CONTAINER_ENGINE) run --rm -v $(WORKDIR):/workdir -w /workdir \
$(LINUX_IMAGE) /bin/bash -c "${SCRIPTS_DIR}/gen_manifests.sh $(WORKFLOW_ID) $(ENABLE_PERSISTENCE)"
@$(CONTAINER_ENGINE) run --rm -v $(WORKDIR):/workdir:Z -w /workdir \
$(LINUX_IMAGE) /bin/bash -c "ENABLE_PERSISTENCE=$(ENABLE_PERSISTENCE) ${SCRIPTS_DIR}/gen_manifests.sh $(WORKFLOW_ID)"
@echo "Manifests are available in workdir $(WORKDIR)/$(WORKFLOW_ID)/manifests"

# Target: push-manifests
Expand Down
45 changes: 19 additions & 26 deletions scripts/gen_manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

WORKFLOW_ID=$1

ENABLE_PERSISTENCE=false
if [ "$2" = "true" ]; then
ENABLE_PERSISTENCE=true
fi

if [ ! -f kn ]; then
echo "Installing kn-workflow CLI"
KN_CLI_URL="https://mirror.openshift.com/pub/openshift-v4/clients/serverless/1.11.2/kn-linux-amd64.tar.gz"
Expand All @@ -24,10 +19,6 @@ echo -e "\nquarkus.flyway.migrate-at-start=true" >> application.properties
../kn workflow gen-manifest --namespace ""


if [ "$ENABLE_PERSISTENCE" = false ]; then
exit
fi

# Find the workflow file with .sw.yaml suffix since kn-cli uses the ID to generate resource names
workflow_file=$(printf '%s\n' ./*.sw.yaml 2>/dev/null | head -n 1)

Expand All @@ -51,22 +42,24 @@ yq --inplace eval '.metadata.annotations["sonataflow.org/profile"] = "prod"' "${

yq --inplace ".spec.podTemplate.container.image=\"quay.io/orchestrator/serverless-workflow-${workflow_id}:latest\"" "${SONATAFLOW_CR}"

yq --inplace ".spec |= (
. + {
\"persistence\": {
\"postgresql\": {
\"secretRef\": {
\"name\": \"sonataflow-psql-postgresql\",
\"userKey\": \"postgres-username\",
\"passwordKey\": \"postgres-password\"
},
\"serviceRef\": {
\"name\": \"sonataflow-psql-postgresql\",
\"port\": 5432,
\"databaseName\": \"sonataflow\",
\"databaseSchema\": \"${WORKFLOW_ID}\"
if [ "${ENABLE_PERSISTENCE}" = true ]; then
yq --inplace ".spec |= (
. + {
\"persistence\": {
\"postgresql\": {
\"secretRef\": {
\"name\": \"sonataflow-psql-postgresql\",
\"userKey\": \"postgres-username\",
\"passwordKey\": \"postgres-password\"
},
\"serviceRef\": {
\"name\": \"sonataflow-psql-postgresql\",
\"port\": 5432,
\"databaseName\": \"sonataflow\",
\"databaseSchema\": \"${WORKFLOW_ID}\"
}
}
}
}
}
}
)" "${SONATAFLOW_CR}"
)" "${SONATAFLOW_CR}"
fi

0 comments on commit ed22ee0

Please sign in to comment.