-
Notifications
You must be signed in to change notification settings - Fork 11
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
[WIP] Adds support for v1 versions of Tekton #47
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 |
---|---|---|
|
@@ -22,7 +22,7 @@ import ( | |
|
||
"github.com/tektoncd/catlin/pkg/parser" | ||
"github.com/tektoncd/catlin/pkg/validator" | ||
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" | ||
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" | ||
) | ||
|
||
type taskLinter struct { | ||
|
@@ -88,7 +88,7 @@ func NewScriptLinter(r *parser.Resource) *taskLinter { | |
} | ||
|
||
// nolint: staticcheck | ||
func (t *taskLinter) validateScript(taskName string, s v1beta1.Step, configs []config) validator.Result { | ||
func (t *taskLinter) validateScript(taskName string, s v1.Step, configs []config) validator.Result { | ||
result := validator.Result{} | ||
|
||
// use /bin/sh by default if no shbang | ||
|
@@ -148,7 +148,7 @@ func (t *taskLinter) validateScript(taskName string, s v1beta1.Step, configs []c | |
} | ||
|
||
// nolint: staticcheck | ||
func (t *taskLinter) collectOverSteps(steps []v1beta1.Step, name string, result *validator.Result) { | ||
func (t *taskLinter) collectOverSteps(steps []v1.Step, name string, result *validator.Result) { | ||
for _, step := range steps { | ||
if step.Script != "" { | ||
result.Append(t.validateScript(name, step, t.configs)) | ||
|
@@ -167,11 +167,11 @@ func (t *taskLinter) Validate() validator.Result { | |
|
||
switch strings.ToLower(t.res.Kind) { | ||
case "task": | ||
task := res.(*v1beta1.Task) | ||
t.collectOverSteps(task.Spec.Steps, task.ObjectMeta.Name, &result) | ||
case "clustertask": | ||
task := res.(*v1beta1.ClusterTask) | ||
task := res.(*v1.Task) | ||
t.collectOverSteps(task.Spec.Steps, task.ObjectMeta.Name, &result) | ||
// case "clustertask": | ||
// task := res.(*v1beta1.ClusterTask) | ||
// t.collectOverSteps(task.Spec.Steps, task.ObjectMeta.Name, &result) | ||
Comment on lines
+172
to
+174
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. let's remove this? |
||
} | ||
return result | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,19 +59,19 @@ spec: | |
echo "hello world" | ||
` | ||
|
||
const clusterTaskTest = ` | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: ClusterTask | ||
metadata: | ||
name: hello-moto | ||
spec: | ||
steps: | ||
- name: nogood | ||
image: image1 | ||
script: | | ||
#!/usr/bin/env sh | ||
' | ||
` | ||
// const clusterTaskTest = ` | ||
// apiVersion: tekton.dev/v1beta1 | ||
// kind: ClusterTask | ||
// metadata: | ||
// name: hello-moto | ||
// spec: | ||
// steps: | ||
// - name: nogood | ||
// image: image1 | ||
// script: | | ||
// #!/usr/bin/env sh | ||
// ' | ||
// ` | ||
Comment on lines
+62
to
+74
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. same |
||
|
||
const pipelineWithTaskRef = ` | ||
apiVersion: tekton.dev/v1beta1 | ||
|
@@ -141,17 +141,17 @@ func Test_Pipeline_skip(t *testing.T) { | |
assert.Assert(t, is.Nil(result.Lints)) | ||
} | ||
|
||
func Test_ClusterTaskParse(t *testing.T) { | ||
r := strings.NewReader(clusterTaskTest) | ||
parser := parser.ForReader(r) | ||
// func Test_ClusterTaskParse(t *testing.T) { | ||
// r := strings.NewReader(clusterTaskTest) | ||
// parser := parser.ForReader(r) | ||
|
||
res, err := parser.Parse() | ||
assert.NilError(t, err) | ||
// res, err := parser.Parse() | ||
// assert.NilError(t, err) | ||
|
||
tl := &taskLinter{ | ||
res: res, | ||
configs: configSh, | ||
} | ||
result := tl.Validate() | ||
assert.Equal(t, 1, result.Errors) | ||
} | ||
// tl := &taskLinter{ | ||
// res: res, | ||
// configs: configSh, | ||
// } | ||
// result := tl.Validate() | ||
// assert.Equal(t, 1, result.Errors) | ||
// } | ||
Comment on lines
+144
to
+157
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. same or let's add t.Skip() if we need to keep it |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,11 +29,12 @@ import ( | |
"knative.dev/pkg/apis" | ||
|
||
"github.com/tektoncd/catlin/pkg/consts" | ||
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" | ||
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" | ||
) | ||
|
||
func registerSchema() { | ||
beta1 := runtime.NewSchemeBuilder(v1beta1.AddToScheme) | ||
beta1 := runtime.NewSchemeBuilder(v1beta1.AddToScheme, v1.AddToScheme) | ||
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. let's rename the variable from |
||
_ = beta1.AddToScheme(scheme.Scheme) | ||
} | ||
|
||
|
@@ -154,7 +155,7 @@ type tektonResource interface { | |
func typeForKind(kind string) (tektonResource, error) { | ||
switch kind { | ||
case "Task": | ||
return &v1beta1.Task{}, nil | ||
return &v1.Task{}, 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. should we add tests for both v1 and v1beta1 to ensure things are working for both API version ? |
||
case "ClusterTask": | ||
return &v1beta1.ClusterTask{}, nil | ||
case "Pipeline": | ||
|
@@ -166,5 +167,5 @@ func typeForKind(kind string) (tektonResource, error) { | |
|
||
func isTektonKind(gvk *schema.GroupVersionKind) bool { | ||
id := gvk.GroupVersion().Identifier() | ||
return id == v1beta1.SchemeGroupVersion.Identifier() | ||
return id == v1beta1.SchemeGroupVersion.Identifier() || id == v1.SchemeGroupVersion.Identifier() | ||
} |
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.
nit: