-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MMENG-4168): add mrrc-collect-params task (#493)
This commit adds a task for collecting params for MRRC from data json of collect-data task. Signed-off-by: Gang Li <[email protected]>
- Loading branch information
Showing
4 changed files
with
169 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# collect-mrrc-params | ||
|
||
Tekton task that collects MRRC(maven.repository.redhat.com) configuration options from the data file. MRRC is used to host maven artifacts of Red Hat Middleware products. | ||
This task looks at the data file in the workspace to extract the params like `mrrc.*`, `cosignPubKeySecret` and `charonAWSSecret` keys for MRRC. `mrrc.*` will be stored in a mrrc.env file and are emitted as task results with other three for downstream tasks to use. | ||
|
||
## Parameters | ||
|
||
| Name | Description | Optional | Default value | | ||
|------|-------------|----------|---------------| | ||
| dataPath | Path to the merged data JSON file generated by collect-data task and containing the mrrc configuration options to use | No | | |
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,52 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Task | ||
metadata: | ||
name: collect-mrrc-params | ||
spec: | ||
params: | ||
- name: dataJsonPath | ||
type: string | ||
description: path to data json file | ||
results: | ||
- name: mrrcParamFilePath | ||
description: path of the env file for following tasks | ||
- name: cosignPubKeyConfig | ||
description: the configmap name for cosign verify public key | ||
- name: charonAWSSecret | ||
description: the secret name for charon aws credential file | ||
steps: | ||
- name: collect-mrrc-params | ||
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
script: | | ||
#!/usr/bin/env bash | ||
set -eux | ||
WORK_DIR=$(workspaces.data.path) | ||
cd $WORK_DIR | ||
DATA_FILE="$WORK_DIR/$(params.dataJsonPath)" | ||
MRRC_ENV_FILE_PATH="$(dirname $(params.dataJsonPath))/mrrc.env" | ||
environment="$(jq -re '.mrrc.environment' $DATA_FILE)" | ||
release="$(jq -re '.mrrc.release' $DATA_FILE)" | ||
target="$environment-maven-$release" | ||
echo "export MRRC_TARGET=$target" >> "$MRRC_ENV_FILE_PATH" | ||
productName="$(jq -re '.mrrc.product.name' $DATA_FILE)" | ||
productVersion="$(jq -re '.mrrc.product.version' $DATA_FILE)" | ||
echo "export MRRC_PRODUCT_NAME=$productName" >> "$MRRC_ENV_FILE_PATH" | ||
echo "export MRRC_PRODUCT_VERSION=$productVersion" >> "$MRRC_ENV_FILE_PATH" | ||
zipRegistry="$(jq -re '.mrrc.product.zipRegistry' $DATA_FILE)" | ||
echo "export MRRC_ZIP_REGISTRY=$zipRegistry" >> "$MRRC_ENV_FILE_PATH" | ||
awsSecret="$(jq -re '.mrrc.awsSecret' $DATA_FILE)" | ||
echo -n "$awsSecret" > "$(results.charonAWSSecret.path)" | ||
cosignPubKey="$(jq -j '.mrrc.product.cosignPubKeyConfig // "cosign-pub-key"' $DATA_FILE)" | ||
echo -n "$cosignPubKey" > "$(results.cosignPubKeyConfig.path)" | ||
echo -n "$MRRC_ENV_FILE_PATH" > "$(results.mrrcParamFilePath.path)" | ||
workspaces: | ||
- name: data |
22 changes: 22 additions & 0 deletions
22
tasks/collect-mrrc-params/tests/test-collect-mrrc-params-fail-no-data.yaml
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,22 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
name: test-collect-mrrc-params-fail-no-data | ||
annotations: | ||
test/assert-task-failure: "run-task" | ||
spec: | ||
description: | | ||
Run the collect-mrrc-params task with no data file and verify the taks fails as expected | ||
workspaces: | ||
- name: tests-workspace | ||
tasks: | ||
- name: run-task | ||
taskRef: | ||
name: collect-mrrc-params | ||
params: | ||
- name: dataJsonPath | ||
value: data.json | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace |
85 changes: 85 additions & 0 deletions
85
tasks/collect-mrrc-params/tests/test-collect-mrrc-params.yaml
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,85 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
name: test-collect-mrrc-params | ||
spec: | ||
description: | | ||
Run the collect-mrrc-params task | ||
workspaces: | ||
- name: tests-workspace | ||
tasks: | ||
- name: setup | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
taskSpec: | ||
steps: | ||
- name: setup-values | ||
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
script: | | ||
#!/usr/bin/env sh | ||
set -eux | ||
cat > "$(workspaces.data.path)/data.json" << EOF | ||
{ | ||
"mrrc": { | ||
"product": { | ||
"name": "activemq", | ||
"version": "0.0.1", | ||
"cosignPubKeyConfig": "test-cosign-pub-key", | ||
"zipRegistry": "quay.io/ligangty/activemq.zip:0.0.1" | ||
}, | ||
"awsSecret": "charon-aws-credentials", | ||
"environment": "dev", | ||
"release": "ga" | ||
} | ||
} | ||
EOF | ||
- name: run-task | ||
taskRef: | ||
name: collect-mrrc-params | ||
params: | ||
- name: dataJsonPath | ||
value: data.json | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
runAfter: | ||
- setup | ||
- name: check-result | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
params: | ||
- name: mrrcParamFilePath | ||
value: $(tasks.run-task.results.mrrcParamFilePath) | ||
- name: cosignPubKeyConfig | ||
value: $(tasks.run-task.results.cosignPubKeyConfig) | ||
- name: charonAWSSecret | ||
value: $(tasks.run-task.results.charonAWSSecret) | ||
taskSpec: | ||
params: | ||
- name: mrrcParamFilePath | ||
- name: cosignPubKeyConfig | ||
- name: charonAWSSecret | ||
steps: | ||
- name: check-result | ||
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
script: | | ||
#!/usr/bin/env sh | ||
set -eux | ||
test "$(params.cosignPubKeyConfig)" == "test-cosign-pub-key" | ||
test "$(params.charonAWSSecret)" == "charon-aws-credentials" | ||
MRRC_FILE="$(workspaces.data.path)/$(params.mrrcParamFilePath)" | ||
test -f "$MRRC_FILE" | ||
. "$MRRC_FILE" | ||
test "$MRRC_ZIP_REGISTRY" == "quay.io/ligangty/activemq.zip:0.0.1" | ||
test "$MRRC_TARGET" == "dev-maven-ga" | ||
test "$MRRC_PRODUCT_NAME" == "activemq" | ||
test "$MRRC_PRODUCT_VERSION" == "0.0.1" | ||
runAfter: | ||
- run-task |