Add support for tekton.dev/v1 Task and Pipeline types#75
Conversation
catlin was hard-wired to v1beta1. Register both v1 and v1beta1 schemes in the parser, normalize parsed resources to v1 types, and switch the task validator and script linter to v1.Step/v1.Task. Since the fields catlin inspects are identical across versions, v1beta1 resources are decoded straight into v1 types, keeping full backward compatibility. Adds v1 fixtures and tests for the parser, validator, linter and the validate command. Fixes tektoncd#10
There was a problem hiding this comment.
Pull request overview
Adds tekton.dev/v1 support across parsing, validation, and linting while preserving existing tekton.dev/v1beta1 behavior by registering both schemes and normalizing typed decoding to v1 objects.
Changes:
- Register both Tekton
v1andv1beta1schemes and accept either GVK during parsing; normalize typed conversions tov1Task/Pipeline. - Update task validation and script linting to operate on
v1.Task/v1.Step. - Add
v1fixtures/tests for validator, linter, and thevalidatecommand testdata.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/parser.go | Registers both schemes and treats both v1/v1beta1 as Tekton resources while normalizing typed objects to v1. |
| pkg/validator/task_validator.go | Switches task validation to tekton.dev/v1 Task/Step types. |
| pkg/validator/task_validator_test.go | Adds tekton.dev/v1 Task validation test coverage alongside existing v1beta1 tests. |
| pkg/linter/script.go | Switches script linter to tekton.dev/v1 Task/Step types. |
| pkg/linter/script_test.go | Adds tekton.dev/v1 script-lint fixture/test. |
| pkg/cmd/validate/validate_test.go | Extends validate command tests to include a tekton.dev/v1 task path. |
| pkg/cmd/validate/testdata/task/v1-hello/0.1/v1-hello.yaml | Adds a minimal tekton.dev/v1 Task fixture for validate command tests. |
Comments suppressed due to low confidence (1)
pkg/linter/script.go:100
- validateScript slices s.Script with fixed indexes (e.g. s.Script[0:2], s.Script[0:14]) without checking length, which can panic for short scripts such as "#!/bin/sh\n...". Use strings.HasPrefix instead of slicing to make this safe.
// use /bin/sh by default if no shbang
if s.Script[0:2] != "#!" {
s.Script = "#!/usr/bin/env sh\n" + s.Script
} else { // using a shbang, check if we have /usr/bin/env
if s.Script[0:14] != "#!/usr/bin/env" {
result.Warn("step: %s is not using #!/usr/bin/env ", taskName)
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/lgtm |
|
/approve |
|
@divyansh42: changing LGTM is restricted to collaborators DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: chmouel The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Changes
Adds support for validating and linting
tekton.dev/v1resources, while keeping full backward compatibility withtekton.dev/v1beta1.Fixes #10
catlin was hard-wired to
v1beta1. This PR:pkg/parser: registers both thev1andv1beta1schemes, accepts both API group versions, and normalizes parsed resources tov1types. Since the fields catlin inspects (Step.Image/Env/EnvFrom/Script,Task.Spec.Steps) are identical across versions,v1beta1resources are decoded straight intov1types.pkg/validator: task validator now operates onv1.Task/v1.Step.pkg/linter: script linter now operates onv1.Task/v1.Step.ClusterTaskwas already removed upstream and from catlin, so no work was needed there. The dependency is already ontektoncd/pipeline v1.4.0, which ships thev1API, so no further dependency bumps were required.Adds
v1fixtures and tests for the parser, validator, linter and thevalidatecommand; existingv1beta1tests are retained to prove backward compatibility.Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes