-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ISV-5128): add new Tekton task to update component sboms
Signed-off-by: Wai Cheang <[email protected]>
- Loading branch information
Showing
7 changed files
with
126 additions
and
14 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
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 @@ | ||
# update-component-sbom | ||
|
||
Tekton task to update component-level SBOMs with purls containing release-time info. | ||
|
||
## Parameters | ||
|
||
| Name | Description | Optional | Default value | | ||
|---------------------|--------------------------------------------------------------------------|----------|------------------| | ||
| dataJsonPath | Path to the JSON string of the merged data containing the release notes | No | - | | ||
| downloadedSbomPath | Path to the directory holding previously downloaded SBOMs to be updated. | Yes | downloaded-sboms | |
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,13 @@ | ||
#!/usr/bin/env bash | ||
set -eux | ||
|
||
function update_component_sbom() { | ||
echo Mock update_component_sbom called with: "$*" | ||
echo "$*" >> "$(workspaces.data.path)/mock_update.txt" | ||
|
||
if [[ "$*" != "update_component_sbom --data-path $(workspaces.data.path)/data.json --input-path $(workspaces.data.path)/downloaded-sboms --output-path $(workspaces.data.path)/updated-sboms" ]] | ||
then | ||
echo Error: Unexpected call | ||
exit 1 | ||
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,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
TASK_PATH=$1 | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
yq -i '.spec.steps[0].script = load_str("'"$SCRIPT_DIR"'/mocks.sh") + .spec.steps[0].script' "$TASK_PATH" | ||
yq -i '.spec.steps[0].script = load_str("'"$SCRIPT_DIR"'/mocks.sh") + .spec.steps[1].script' "$TASK_PATH" |
38 changes: 38 additions & 0 deletions
38
tasks/update-component-sbom/tests/test-update-component-sbom-basic.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,38 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
name: test-update-component-sbom-basic | ||
spec: | ||
description: | | ||
Update a component-level SBOM where components contain only one purl. | ||
workspaces: | ||
- name: tests-workspace | ||
tasks: | ||
- name: run-task | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
taskRef: | ||
name: update-component-sbom | ||
params: | ||
- name: dataJsonPath | ||
value: "data.json" | ||
- name: downloadedSbomPath | ||
value: downloaded-sboms | ||
- name: check-result | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
params: | ||
- name: sbomPath | ||
value: $(tasks.run-task.results.sbomPath) | ||
taskSpec: | ||
steps: | ||
- name: check-result | ||
image: quay.io/konflux-ci/release-service-utils:e39e8d32c8263474c63fc1e922d7954d37e32374 | ||
script: | | ||
#!/usr/bin/env bash | ||
set -eux | ||
test "$(params.sbomPath)" == "$(workspaces.data.path)/updated-sboms" |
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,43 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Task | ||
metadata: | ||
name: update-component-sbom | ||
labels: | ||
app.kubernetes.io/version: "0.0.1" | ||
annotations: | ||
tekton.dev/pipelines.minVersion: "0.12.1" | ||
tekton.dev/tags: release | ||
spec: | ||
description: >- | ||
Update component-level SBOM with purls with release-time info. | ||
params: | ||
- name: dataJsonPath | ||
description: Relative path to the JSON data file in the workspace. | ||
- name: downloadedSbomPath | ||
description: | | ||
Path to the directory holding previously downloaded SBOMs to be updated. | ||
type: string | ||
default: downloaded-sboms | ||
workspaces: | ||
- name: data | ||
description: The workspace where the SBOM files reside. | ||
results: | ||
- name: sbomPath | ||
description: Relative path to the updated component-level SBOM in the data workspace. | ||
steps: | ||
- name: update-component-sbom-purls | ||
image: quay.io/konflux-ci/release-service-utils:e39e8d32c8263474c63fc1e922d7954d37e32374 | ||
script: | | ||
#!/usr/bin/env bash | ||
set -eux | ||
INPUT_PATH="$(workspaces.data.path)/$(params.downloadedSbomPath)" | ||
OUTPUT_PATH="$(workspaces.data.path)/updated-sboms" | ||
update_component_sbom \ | ||
--data-path "$(workspaces.data.path)/$(params.dataJsonPath)" \ | ||
--input-path "$INPUT_PATH" \ | ||
--output-path "$OUTPUT_PATH" | ||
echo -n "$OUTPUT_PATH" > "$(results.sbomPath.path)" |