-
Notifications
You must be signed in to change notification settings - Fork 7
Update POLICY_BUNDLE_DIGEST in tekton-task bundle and catalog #217
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
635f24e
Update POLICY_BUNDLE_DIGEST in tekton-task bundle and tekton-catalog
joejstuart c8c495c
Use yq instead of sed for POLICY_BUNDLE_DIGEST update
joejstuart 2331799
Fail fast when no task files contain POLICY_BUNDLE_DIGEST
joejstuart 418fdc0
Split tekton-catalog-release into independent tekton-task-bundle and …
joejstuart 41db128
Extract task prep into shared update-task-definitions job
joejstuart 1e79bd5
Extract digest update logic into hack/update-policy-digest.sh
joejstuart 1e4c13a
Add shellspec tests for extract and digest update scripts
joejstuart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,75 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright The Conforma Contributors | ||
| # | ||
| # Licensed 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. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Extracts all task definitions from a Tekton bundle and arranges them in | ||
| # the catalog directory layout: tasks/<task-name>/<version>/<task-name>.yaml | ||
| # | ||
| # Unlike extract-tested-tasks.sh, this script extracts every task in the | ||
| # bundle, not just those referenced in acceptance pipelines. | ||
| # | ||
| # Usage: | ||
| # extract-all-bundle-tasks.sh <bundle-ref> <output-dir> | ||
| # | ||
| # Arguments: | ||
| # bundle-ref - OCI reference for the Tekton bundle (tag or digest) | ||
| # output-dir - Directory to write extracted tasks into | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| BUNDLE="${1:?Usage: extract-all-bundle-tasks.sh <bundle-ref> <output-dir>}" | ||
| OUTPUT_DIR="${2:?Usage: extract-all-bundle-tasks.sh <bundle-ref> <output-dir>}" | ||
|
|
||
| REPO="${BUNDLE%@*}" | ||
| REPO="${REPO%:*}" | ||
|
joejstuart marked this conversation as resolved.
|
||
|
|
||
| MANIFEST=$(crane manifest "$BUNDLE") | ||
|
|
||
| TASK_LAYERS=$(echo "$MANIFEST" | jq -c ' | ||
| .layers[] | select(.annotations["dev.tekton.image.kind"] == "task")') | ||
|
|
||
| if [ -z "$TASK_LAYERS" ]; then | ||
| echo "ERROR: No task layers found in bundle ${BUNDLE}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| COUNT=0 | ||
| while IFS= read -r layer; do | ||
| [ -z "$layer" ] && continue | ||
|
|
||
| DIGEST=$(echo "$layer" | jq -r '.digest') | ||
| NAME=$(echo "$layer" | jq -r '.annotations["dev.tekton.image.name"]') | ||
|
|
||
| echo "Extracting task: $NAME" | ||
|
|
||
| TASK_YAML=$(crane blob "${REPO}@${DIGEST}" | gunzip | tar -xO) | ||
|
|
||
| VERSION=$(echo "$TASK_YAML" | yq eval '.metadata.labels["app.kubernetes.io/version"]' -) | ||
| if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then | ||
| echo "ERROR: Task $NAME is missing the app.kubernetes.io/version label" | ||
| exit 1 | ||
| fi | ||
|
|
||
| TASK_DIR="${OUTPUT_DIR}/tasks/${NAME}/${VERSION}" | ||
| mkdir -p "$TASK_DIR" | ||
| echo "$TASK_YAML" | yq eval '.' -P - > "${TASK_DIR}/${NAME}.yaml" | ||
|
|
||
| echo " Written to ${TASK_DIR}/${NAME}.yaml" | ||
| COUNT=$((COUNT + 1)) | ||
| done <<< "$TASK_LAYERS" | ||
|
|
||
| echo "" | ||
| echo "Done. Extracted ${COUNT} task(s) to ${OUTPUT_DIR}" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.