-
Notifications
You must be signed in to change notification settings - Fork 123
fix(resolve): restore relative task path resolution for repository paths #2554
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,11 +33,14 @@ func assembleTaskFQDNs(pipelineURL string, tasks []string) ([]string, error) { | |
| return tasks, nil // no pipeline URL, return tasks as is | ||
| } | ||
|
|
||
| // Only HTTP(S) URLs can serve as base for relative task resolution. | ||
| // Only HTTP(S) URLs and repository file paths can serve as base for relative task resolution. | ||
| // Hub catalog references (e.g., "catalog://resource:version") use a | ||
| // different scheme where relative paths are meaningless. | ||
| lowered := strings.ToLower(pipelineURL) | ||
| if !strings.HasPrefix(lowered, "http://") && !strings.HasPrefix(lowered, "https://") { | ||
| isHTTP := strings.HasPrefix(lowered, "http://") || strings.HasPrefix(lowered, "https://") | ||
| isRepoPath := strings.Contains(lowered, "/") && !strings.Contains(lowered, "://") | ||
|
|
||
| if !isHTTP && !isRepoPath { | ||
| return tasks, nil | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition To make this more robust, consider also checking for a file extension. Hub tasks are unlikely to have
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -562,10 +562,10 @@ func TestAssembleTaskFQDNs(t *testing.T) { | |
| expected: []string{"https://example.com/repo/task.yaml"}, | ||
| }, | ||
| { | ||
| name: "repository file path URL returns tasks unchanged", | ||
| name: "repository file path URL resolves relative tasks", | ||
| pipelineURL: "share/pipelines/build.yaml", | ||
| tasks: []string{"../tasks/t.yaml", "tasks/other-task.yaml"}, | ||
| expected: []string{"../tasks/t.yaml", "tasks/other-task.yaml"}, | ||
| expected: []string{"share/tasks/t.yaml", "share/pipelines/tasks/other-task.yaml"}, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have tried to restore the original behaviour of the function but a bit doubtful if the second resolution is what we expect expect. |
||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,9 +54,10 @@ func TestGiteaPullRequestTaskAnnotations(t *testing.T) { | |
| Regexp: successRegexp, | ||
| TargetEvent: triggertype.PullRequest.String(), | ||
| YAMLFiles: map[string]string{ | ||
| ".tekton/pipeline.yaml": "testdata/pipeline_in_tektondir.yaml", | ||
| ".other-tasks/task-referenced-internally.yaml": "testdata/task_referenced_internally.yaml", | ||
| ".tekton/pr.yaml": "testdata/pipelinerun_remote_task_annotations.yaml", | ||
| ".tekton/pipeline.yaml": "testdata/pipeline_in_tektondir.yaml", | ||
| ".other-tasks/task-referenced-internally.yaml": "testdata/task_referenced_internally.yaml", | ||
| ".other-tasks/task2-referenced-internally.yaml": "testdata/task2_referenced_internally.yaml", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both tasks are same, one is referenced using its absolute path in the repo and the other with relative path pipelinesascode.tekton.dev/task: "[.other-tasks/task-referenced-internally.yaml]"
pipelinesascode.tekton.dev/task-3: "[../.other-tasks/task2-referenced-internally.yaml]" |
||
| ".tekton/pr.yaml": "testdata/pipelinerun_remote_task_annotations.yaml", | ||
| }, | ||
| CheckForStatus: "success", | ||
| ExtraArgs: map[string]string{ | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests are skipped but still modified them (not tested). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| apiVersion: tekton.dev/v1beta1 | ||
| kind: Task | ||
| metadata: | ||
| name: task2-referenced-internally | ||
| spec: | ||
| steps: | ||
| - name: task2-remote | ||
| image: gcr.io/distroless/python3:nonroot | ||
| script: | | ||
| #!/usr/bin/python3 | ||
| print("Hello Task Referenced Internally") |


Uh oh!
There was an error while loading. Please reload this page.