-
Notifications
You must be signed in to change notification settings - Fork 133
fix(KONFLUX-10809): fail incrementer on empty tag list #2328
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
Open
FilipNikolovski
wants to merge
1
commit into
konflux-ci:development
Choose a base branch
from
FilipNikolovski:KONFLUX-10809
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+180
−3
Open
Changes from all commits
Commits
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
131 changes: 131 additions & 0 deletions
131
tasks/managed/apply-mapping/tests/test-apply-mapping-fail-empty-tags-existing-repo.yaml
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,131 @@ | ||
| --- | ||
| apiVersion: tekton.dev/v1 | ||
| kind: Pipeline | ||
| metadata: | ||
| name: test-apply-mapping-fail-empty-tags-existing-repo | ||
| annotations: | ||
| test/assert-task-failure: "run-task" | ||
| spec: | ||
| description: | | ||
| Run the apply-mapping task with a component that uses {{ incrementer }} against a repository | ||
| that exists but returns an empty tag list. The task should fail instead of silently falling | ||
| back to increment 1, which could overwrite existing tags. | ||
| params: | ||
| - name: ociStorage | ||
| description: The OCI repository where the Trusted Artifacts are stored. | ||
| type: string | ||
| - name: ociArtifactExpiresAfter | ||
| description: Expiration date for the trusted artifacts created in the | ||
| OCI repository. An empty string means the artifacts do not expire. | ||
| type: string | ||
| default: "1d" | ||
| - name: orasOptions | ||
| description: oras options to pass to Trusted Artifacts calls | ||
| type: string | ||
| default: "--insecure" | ||
| - name: trustedArtifactsDebug | ||
| description: Flag to enable debug logging in trusted artifacts. Set to a non-empty string to enable. | ||
| type: string | ||
| default: "" | ||
| - name: dataDir | ||
| description: The location where data will be stored | ||
| type: string | ||
| tasks: | ||
| - name: setup | ||
| taskSpec: | ||
| results: | ||
| - name: sourceDataArtifact | ||
| type: string | ||
| volumes: | ||
| - name: workdir | ||
| emptyDir: {} | ||
| stepTemplate: | ||
| volumeMounts: | ||
| - mountPath: /var/workdir | ||
| name: workdir | ||
| env: | ||
| - name: IMAGE_EXPIRES_AFTER | ||
| value: $(params.ociArtifactExpiresAfter) | ||
| - name: "ORAS_OPTIONS" | ||
| value: "$(params.orasOptions)" | ||
| - name: "DEBUG" | ||
| value: "$(params.trustedArtifactsDebug)" | ||
| steps: | ||
| - name: setup-values | ||
| image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 | ||
| script: | | ||
| #!/usr/bin/env sh | ||
| set -eux | ||
|
|
||
| mkdir -p "$(params.dataDir)/$(context.pipelineRun.uid)" | ||
| cat > "$(params.dataDir)/$(context.pipelineRun.uid)/test_data.json" << EOF | ||
| { | ||
| "mapping": { | ||
| "components": [ | ||
| { | ||
| "name": "comp1", | ||
| "repositories": [ | ||
| { | ||
| "url": "repo-empty-tags-existing", | ||
| "tags": [ | ||
| "v1.0.0-{{ incrementer }}" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| EOF | ||
|
|
||
| cat > "$(params.dataDir)/$(context.pipelineRun.uid)/test_snapshot_spec.json" << EOF | ||
| { | ||
| "application": "myapp", | ||
| "components": [ | ||
| { | ||
| "name": "comp1", | ||
| "containerImage": "registry.io/image1@sha256:123456", | ||
| "source": { | ||
| "git": { | ||
| "revision": "testrevision", | ||
| "url": "myurl" | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| EOF | ||
| - name: create-trusted-artifact | ||
| ref: | ||
| name: create-trusted-artifact | ||
| params: | ||
| - name: ociStorage | ||
| value: $(params.ociStorage) | ||
| - name: workDir | ||
| value: $(params.dataDir) | ||
| - name: sourceDataArtifact | ||
| value: $(results.sourceDataArtifact.path) | ||
| - name: run-task | ||
| taskRef: | ||
| name: apply-mapping | ||
| params: | ||
| - name: snapshotPath | ||
| value: $(context.pipelineRun.uid)/test_snapshot_spec.json | ||
| - name: dataPath | ||
| value: $(context.pipelineRun.uid)/test_data.json | ||
| - name: ociStorage | ||
| value: $(params.ociStorage) | ||
| - name: orasOptions | ||
| value: $(params.orasOptions) | ||
| - name: sourceDataArtifact | ||
| value: "$(tasks.setup.results.sourceDataArtifact)=$(params.dataDir)" | ||
| - name: dataDir | ||
| value: $(params.dataDir) | ||
| - name: trustedArtifactsDebug | ||
| value: $(params.trustedArtifactsDebug) | ||
| - name: taskGitUrl | ||
| value: "http://localhost" | ||
| - name: taskGitRevision | ||
| value: "main" | ||
| runAfter: | ||
| - setup |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix!
One small suggestion: consider adding an explicit mock for repo-empty-tags-existing for the skopeo inspect call. Currently it works via the default fallthrough, but making it explicit improves test clarity:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, updated!