-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escape label names when writing to disk.
Github/other providers allow labels to contain special characters like /. These cannot easily be represented as filenames. This commit URL encodes these label keys, which should provide a safe mechanism for writing these names as files. I've been unable to find documentation containing an exhaustive list of characters allowed in labels, but this change works with everything in the Tekton repos. This PR also includes a sample YAML that ensures a Tekton PR has been approved, which caught this issue.
- Loading branch information
1 parent
1fc4d3d
commit 1699fd8
Showing
3 changed files
with
293 additions
and
6 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,51 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: tekton-pr | ||
spec: | ||
type: pullRequest | ||
params: | ||
- name: url | ||
# I just picked a random PR. The first couple didn't have any interesting comments or labels. | ||
value: https://github.com/tektoncd/pipeline/pull/100 | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: dump-pr-task | ||
spec: | ||
inputs: | ||
resources: | ||
- name: pr | ||
type: pullRequest | ||
steps: | ||
- name: dump-workspace | ||
image: ubuntu | ||
command: ["sh"] | ||
args: ["-c", "find $(inputs.resources.pr.path)/* -type f | xargs tail -n +1"] | ||
- name: ensure-approved | ||
image: ubuntu | ||
command: ["/bin/bash"] | ||
args: | ||
- -c | ||
- | | ||
if [ -f "$(inputs.resources.pr.path)/labels/approved" ]; then | ||
echo "PR is approved!" | ||
else | ||
echo "PR is not approved!" | ||
exit 1 | ||
fi | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: TaskRun | ||
metadata: | ||
name: dump-pr-task-run | ||
spec: | ||
inputs: | ||
resources: | ||
- name: pr | ||
resourceRef: | ||
name: tekton-pr | ||
taskRef: | ||
name: dump-pr-task | ||
--- |