-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: swf-builder generate manifests using kn-workflow
Generate manifests and save them in the runtime image. Generating manifests is an opt-in as part of the build ran by /launch/build-app.sh When setting GEN_MANIFESTS=true during container build the build-app.sh script will call a new generate-manifests.sh script that will use _kn-workflow_ cli and will store the manifests under $KOGITO_HOME/build/manifests Later in the runtime image user can copy and store those manifests for later use: COPY --from=builder --chown=185 /home/kogito/build/manifests /deployments/manifests The manifests can be extracted for example by echoing them from the image: podman run builder:latest cat /deployment/manifests/* > manifests-all.yaml or by podman cp: podman cp $(podman create builder:latest):/deployment/manifests . Signed-off-by: Roy Golan <[email protected]>
- Loading branch information
Showing
7 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
modules/kogito-workflow-manifests/added/generate-manifests.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/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. | ||
# | ||
set -x | ||
resource_dir="${1:-${KOGITO_HOME}/serverless-workflow-project/src/main/resources}" | ||
target_dir="${KOGITO_HOME}/build/manifests" | ||
if [ "${GEN_MANIFESTS}" = "true" ]; then | ||
# kn-workflow doesn't support source dir yet, we have to get in | ||
pushd "${resource_dir}" || exit | ||
kn-workflow gen-manifest --custom-generated-manifests-dir "${target_dir}" --namespace "" | ||
popd || exit | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/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. | ||
# | ||
# | ||
set -x | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
cp -v "${SCRIPT_DIR}"/added/* "${KOGITO_HOME}"/launch | ||
|
||
chown -R 1001:0 "${KOGITO_HOME}"/launch | ||
chmod -R ug+rwX "${KOGITO_HOME}"/launch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
# | ||
# 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 -x | ||
|
||
cp /tmp/artifacts/kn-workflow-"$(uname --machine)" /usr/local/bin/kn-workflow | ||
chmod +x-w /usr/local/bin/kn-workflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# 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. | ||
# | ||
schema_version: 1 | ||
name: org.kie.kogito.workflow-manifests | ||
version: "999-SNAPSHOT" | ||
description: Module to install kn-workflow tool and scripts | ||
execute: | ||
- script: configure | ||
envs: | ||
- name: KN_CLI | ||
value: /usr/local/bin/kn-workflow | ||
- name: GEN_MANIFESTS | ||
value: false | ||
|
||
artifacts: | ||
- name: kn-workflow-x86_64 | ||
url: https://github.com/rgolangh/kie-tools/releases/download/0.0.2/kn-workflow-linux-amd64 | ||
md5: defdb771fd65d47c0255fd4389127656 | ||
script: install.sh |
74 changes: 74 additions & 0 deletions
74
modules/kogito-workflow-manifests/tests/bats/kogito-workflow-manifest.bats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/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. | ||
# | ||
|
||
|
||
setup() { | ||
export KOGITO_HOME=/tmp/kogito | ||
export HOME="${KOGITO_HOME}" | ||
mkdir -p "${KOGITO_HOME}"/launch | ||
mock_bin kn-workflow | ||
mkdir -p "${KOGITO_HOME}"/serverless-workflow-project/src/main/resources/schemas | ||
|
||
touch "${KOGITO_HOME}"/launch/configure-jvm-mvn.sh | ||
cp $BATS_TEST_DIRNAME/../../added/generate-manifests.sh "${KOGITO_HOME}"/launch/ | ||
cp $BATS_TEST_DIRNAME/../../../kogito-logging/added/logging.sh "${KOGITO_HOME}"/launch/ | ||
cp $BATS_TEST_DIRNAME/../../../kogito-swf/common/scripts/added/build-app.sh "${KOGITO_HOME}"/launch/ | ||
} | ||
|
||
teardown() { | ||
rm -rf "${KOGITO_HOME}" | ||
rm -rf /tmp/resources | ||
} | ||
|
||
@test "verify generate manifest is working" { | ||
TEMPD=$(mktemp -d) | ||
cp -r $BATS_TEST_DIRNAME/../../../../tests/shell/kogito-swf-builder/resources/greet-with-inputschema/* ${TEMPD} | ||
|
||
# opt-in to generate-manifests | ||
export GEN_MANIFESTS=true | ||
# We don't care about the errors to try to execute and build the program, just the copy matters | ||
source ${KOGITO_HOME}/launch/build-app.sh ${TEMPD} || true | ||
|
||
# this tests the call to kn-workflow actually happend | ||
[ -f "${KOGITO_HOME}"/bin/kn-workflow_invocation.txt ] | ||
} | ||
|
||
@test "verify generate manifest is an opt-in" { | ||
TEMPD=$(mktemp -d) | ||
cp -r $BATS_TEST_DIRNAME/../../../../tests/shell/kogito-swf-builder/resources/greet-with-inputschema/* ${TEMPD} | ||
|
||
# opt-out to generate-manifests | ||
export GEN_MANIFESTS=false | ||
# We don't care about the errors to try to execute and build the program, just the copy matters | ||
source ${KOGITO_HOME}/launch/build-app.sh ${TEMPD} || true | ||
|
||
# this tests that the call to kn-workflow didn't happend | ||
[ ! -f "${KOGITO_HOME}"/bin/kn-workflow_invocation.txt ] | ||
} | ||
|
||
mock_bin() { | ||
mkdir -p "${KOGITO_HOME}"/bin | ||
PATH+=":${KOGITO_HOME}/bin/" | ||
cat << EOF > "${KOGITO_HOME}"/bin/$1 | ||
echo $1 "$@" > $"${KOGITO_HOME}"/bin/$1_invocation.txt | ||
EOF | ||
chmod +x "${KOGITO_HOME}"/bin/$1 | ||
} | ||
|