-
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(RELEASE-1158): introduce reduce-snapshot
- This PR contains a new Task called reduce-snapshot - It is designed to reduce a Snapshot to a Single Component such that the Snapshot can be passed downstream to other tasks. - It uses a shared script from Enterprise Contract so that the ITS EC pipeline uses the same logic to reduce the snapshot. - A new step was added to the collect-data task, to provide data needed for the parameters of the reduce-snapshot task. - A new RPA data parameter called `singleComponentMode` is used to activate the feature. Signed-off-by: Scott Hebert <[email protected]>
- Loading branch information
Showing
14 changed files
with
708 additions
and
2 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
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,13 @@ | ||
# reduce-snapshot | ||
|
||
Tekton task to reduce a snapshot to a single component based on the component that the snapshot was built for. | ||
|
||
## Parameters | ||
|
||
| Name | Description | Optional | Default value | | ||
|-------------------------------------|----------------------------------------------------------|----------|---------------| | ||
| SNAPSHOT | String representation of Snapshot spec | No | - | | ||
| SINGLE_COMPONENT | Single mode component enabled | No | - | | ||
| SINGLE_COMPONENT_CUSTOM_RESOURCE | Custom Resource to query for built component in Snapshot | No | - | | ||
| SINGLE_COMPONENT_CUSTOM_RESOURCE_NS | Namespace where Custom Resource is found | No | - | | ||
| SNAPSHOT_PATH | The location to place the reduced Snapshot | 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,49 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Task | ||
metadata: | ||
name: reduce-snapshot | ||
labels: | ||
app.kubernetes.io/version: "0.1.0" | ||
annotations: | ||
tekton.dev/pipelines.minVersion: "0.12.1" | ||
tekton.dev/tags: release | ||
spec: | ||
description: >- | ||
Tekton task to reduce snapshot | ||
params: | ||
- name: SNAPSHOT | ||
type: string | ||
description: String representation of Snapshot spec | ||
- name: SINGLE_COMPONENT | ||
type: string | ||
description: Single mode component enabled | ||
- name: SINGLE_COMPONENT_CUSTOM_RESOURCE | ||
type: string | ||
description: Custom Resource to query for built component in Snapshot | ||
- name: SINGLE_COMPONENT_CUSTOM_RESOURCE_NS | ||
type: string | ||
default: "" | ||
description: Namespace where Custom Resource is found | ||
- name: SNAPSHOT_PATH | ||
type: string | ||
description: The location to place the reduced Snapshot | ||
workspaces: | ||
- name: data | ||
description: Workspace to save the CR jsons to | ||
steps: | ||
- name: reduce | ||
env: | ||
- name: SNAPSHOT | ||
value: $(params.SNAPSHOT) | ||
- name: SINGLE_COMPONENT | ||
value: $(params.SINGLE_COMPONENT) | ||
- name: CUSTOM_RESOURCE | ||
value: $(params.SINGLE_COMPONENT_CUSTOM_RESOURCE) | ||
- name: CUSTOM_RESOURCE_NAMESPACE | ||
value: $(params.SINGLE_COMPONENT_CUSTOM_RESOURCE_NS) | ||
- name: SNAPSHOT_PATH | ||
value: $(params.SNAPSHOT_PATH) | ||
image: quay.io/enterprise-contract/ec-cli@sha256:913c7dac3d41877b01835d2e55bcd970c6cdbf4944f8176e9e3de9548642a2b4 | ||
command: [reduce-snapshot.sh] | ||
onError: continue # progress even if the step fails |
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 | ||
|
||
# Install the CRDs so we can create/get them | ||
.github/scripts/install_crds.sh | ||
|
||
# Add RBAC so that the SA executing the tests can retrieve CRs | ||
kubectl apply -f .github/resources/crd_rbac.yaml |
95 changes: 95 additions & 0 deletions
95
tasks/reduce-snapshot/tests/test-reduce-snapshot-disabled-single-component-mode.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,95 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
name: test-reduce-snapshot-disabled-single-component-mode | ||
spec: | ||
description: | | ||
Run the reduce snapshot task with single component mode being false | ||
workspaces: | ||
- name: tests-workspace | ||
tasks: | ||
- name: setup | ||
taskSpec: | ||
steps: | ||
- name: create-crs | ||
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
script: | | ||
#!/usr/bin/env bash | ||
set -eux | ||
cat > snapshot << EOF | ||
apiVersion: appstudio.redhat.com/v1alpha1 | ||
kind: Snapshot | ||
metadata: | ||
name: snapshot-sample | ||
namespace: default | ||
labels: | ||
test.appstudio.openshift.io/type: component | ||
appstudio.openshift.io/component: tom | ||
spec: | ||
application: foo | ||
components: | ||
- name: scott | ||
containerImage: newimage | ||
- name: tom | ||
containerImage: newimage2 | ||
EOF | ||
kubectl apply -f snapshot | ||
kubectl get snapshot/snapshot-sample -ojson | jq .spec | tee "$(workspaces.data.path)/snapshot.json" | ||
chmod 666 "$(workspaces.data.path)/snapshot.json" | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
- name: run-task | ||
taskRef: | ||
name: reduce-snapshot | ||
params: | ||
- name: SNAPSHOT | ||
value: $(workspaces.data.path)/snapshot.json | ||
- name: SINGLE_COMPONENT | ||
value: false | ||
- name: SINGLE_COMPONENT_CUSTOM_RESOURCE | ||
value: snapshot/snapshot-sample | ||
- name: SINGLE_COMPONENT_CUSTOM_RESOURCE_NS | ||
value: default | ||
- name: SNAPSHOT_PATH | ||
value: $(workspaces.data.path)/snapshot.json | ||
runAfter: | ||
- setup | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
- name: check-result | ||
workspaces: | ||
- name: data | ||
workspace: tests-workspace | ||
runAfter: | ||
- run-task | ||
taskSpec: | ||
workspaces: | ||
- name: data | ||
steps: | ||
- name: check-result | ||
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
script: | | ||
#!/usr/bin/env bash | ||
set -eux | ||
cat "$(workspaces.data.path)/snapshot.json" | ||
if [ "$(jq '.components | length' < "$(workspaces.data.path)/snapshot.json")" -ne 2 ]; then | ||
echo "ERROR: Resulting snapshot does not contain 2 components" | ||
exit 1 | ||
fi | ||
finally: | ||
- name: cleanup | ||
taskSpec: | ||
steps: | ||
- name: delete-crs | ||
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
script: | | ||
#!/usr/bin/env sh | ||
set -eux | ||
kubectl delete snapshot snapshot-sample |
Oops, something went wrong.