Skip to content

Commit ef347af

Browse files
piyush-gargtekton-robot
authored andcommitted
Fix e2e test by converting to v1beta1 resources
This will move all the structs and yaml resources used in e2e for pipeline, pipelinerun, task, taskrun and clustertask to v1beta1
1 parent 986905c commit ef347af

21 files changed

+175
-185
lines changed

test/builder/builder.go

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ import (
3030
"github.com/jonboulle/clockwork"
3131
"github.com/tektoncd/cli/pkg/formatted"
3232
"github.com/tektoncd/cli/test/framework"
33-
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
33+
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
34+
"github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
3435
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3536
)
3637

37-
func GetTask(c *framework.Clients, name string) *v1alpha1.Task {
38+
func GetTask(c *framework.Clients, name string) *v1beta1.Task {
3839

3940
task, err := c.TaskClient.Get(context.Background(), name, metav1.GetOptions{})
4041
if err != nil {
@@ -44,15 +45,15 @@ func GetTask(c *framework.Clients, name string) *v1alpha1.Task {
4445
return task
4546
}
4647

47-
func GetClusterTask(c *framework.Clients, name string) *v1alpha1.ClusterTask {
48+
func GetClusterTask(c *framework.Clients, name string) *v1beta1.ClusterTask {
4849
clustertask, err := c.ClusterTaskClient.Get(context.Background(), name, metav1.GetOptions{})
4950
if err != nil {
5051
log.Fatalf("Couldn't get expected clustertask %s", err)
5152
}
5253
return clustertask
5354
}
5455

55-
func GetTaskList(c *framework.Clients) *v1alpha1.TaskList {
56+
func GetTaskList(c *framework.Clients) *v1beta1.TaskList {
5657

5758
tasklist, err := c.TaskClient.List(context.Background(), metav1.ListOptions{})
5859

@@ -63,15 +64,15 @@ func GetTaskList(c *framework.Clients) *v1alpha1.TaskList {
6364
return tasklist
6465
}
6566

66-
func GetClusterTaskList(c *framework.Clients) *v1alpha1.ClusterTaskList {
67+
func GetClusterTaskList(c *framework.Clients) *v1beta1.ClusterTaskList {
6768
clustertasklist, err := c.ClusterTaskClient.List(context.Background(), metav1.ListOptions{})
6869
if err != nil {
6970
log.Fatalf("Couldn't get expected clustertasklist %s", err)
7071
}
7172
return clustertasklist
7273
}
7374

74-
func GetTaskRun(c *framework.Clients, name string) *v1alpha1.TaskRun {
75+
func GetTaskRun(c *framework.Clients, name string) *v1beta1.TaskRun {
7576

7677
taskRun, err := c.TaskRunClient.Get(context.Background(), name, metav1.GetOptions{})
7778

@@ -82,7 +83,7 @@ func GetTaskRun(c *framework.Clients, name string) *v1alpha1.TaskRun {
8283
return taskRun
8384
}
8485

85-
func GetTaskRunList(c *framework.Clients) *v1alpha1.TaskRunList {
86+
func GetTaskRunList(c *framework.Clients) *v1beta1.TaskRunList {
8687
taskRunlist, err := c.TaskRunClient.List(context.Background(), metav1.ListOptions{})
8788

8889
if err != nil {
@@ -114,7 +115,7 @@ func GetPipelineResourceList(c *framework.Clients) *v1alpha1.PipelineResourceLis
114115
return pipelineResourceList
115116
}
116117

117-
func GetPipeline(c *framework.Clients, name string) *v1alpha1.Pipeline {
118+
func GetPipeline(c *framework.Clients, name string) *v1beta1.Pipeline {
118119

119120
pipeline, err := c.PipelineClient.Get(context.Background(), name, metav1.GetOptions{})
120121

@@ -125,7 +126,7 @@ func GetPipeline(c *framework.Clients, name string) *v1alpha1.Pipeline {
125126
return pipeline
126127
}
127128

128-
func GetPipelineList(c *framework.Clients) *v1alpha1.PipelineList {
129+
func GetPipelineList(c *framework.Clients) *v1beta1.PipelineList {
129130

130131
pipelineList, err := c.PipelineClient.List(context.Background(), metav1.ListOptions{})
131132

@@ -136,7 +137,7 @@ func GetPipelineList(c *framework.Clients) *v1alpha1.PipelineList {
136137
return pipelineList
137138
}
138139

139-
func GetPipelineRun(c *framework.Clients, name string) *v1alpha1.PipelineRun {
140+
func GetPipelineRun(c *framework.Clients, name string) *v1beta1.PipelineRun {
140141

141142
pipelineRun, err := c.PipelineRunClient.Get(context.Background(), name, metav1.GetOptions{})
142143

@@ -147,7 +148,7 @@ func GetPipelineRun(c *framework.Clients, name string) *v1alpha1.PipelineRun {
147148
return pipelineRun
148149
}
149150

150-
func GetPipelineRunListWithName(c *framework.Clients, pname string, sortByStartTime bool) *v1alpha1.PipelineRunList {
151+
func GetPipelineRunListWithName(c *framework.Clients, pname string, sortByStartTime bool) *v1beta1.PipelineRunList {
151152
opts := metav1.ListOptions{
152153
LabelSelector: fmt.Sprintf("tekton.dev/pipeline=%s", pname),
153154
}
@@ -164,7 +165,7 @@ func GetPipelineRunListWithName(c *framework.Clients, pname string, sortByStartT
164165
return pipelineRunList
165166
}
166167

167-
func GetTaskRunListByLabel(c *framework.Clients, tname string, sortByStartTime bool, label string) *v1alpha1.TaskRunList {
168+
func GetTaskRunListByLabel(c *framework.Clients, tname string, sortByStartTime bool, label string) *v1beta1.TaskRunList {
168169
opts := metav1.ListOptions{
169170
LabelSelector: label,
170171
}
@@ -183,17 +184,17 @@ func GetTaskRunListByLabel(c *framework.Clients, tname string, sortByStartTime b
183184
return taskRunList
184185
}
185186

186-
func GetTaskRunListWithTaskName(c *framework.Clients, tname string, sortByStartTime bool) *v1alpha1.TaskRunList {
187+
func GetTaskRunListWithTaskName(c *framework.Clients, tname string, sortByStartTime bool) *v1beta1.TaskRunList {
187188
label := fmt.Sprintf("tekton.dev/task=%s", tname)
188189
return GetTaskRunListByLabel(c, tname, sortByStartTime, label)
189190
}
190191

191-
func GetTaskRunListWithClusterTaskName(c *framework.Clients, ctname string, sortByStartTime bool) *v1alpha1.TaskRunList {
192+
func GetTaskRunListWithClusterTaskName(c *framework.Clients, ctname string, sortByStartTime bool) *v1beta1.TaskRunList {
192193
label := fmt.Sprintf("tekton.dev/clusterTask=%s", ctname)
193194
return GetTaskRunListByLabel(c, ctname, sortByStartTime, label)
194195
}
195196

196-
func GetPipelineRunList(c *framework.Clients) *v1alpha1.PipelineRunList {
197+
func GetPipelineRunList(c *framework.Clients) *v1beta1.PipelineRunList {
197198

198199
pipelineRunList, err := c.PipelineRunClient.List(context.Background(), metav1.ListOptions{})
199200

@@ -213,7 +214,7 @@ func ListResourceNamesForJSONPath(obj interface{}) string {
213214
w := tabwriter.NewWriter(&tmplBytes, 0, 5, 3, ' ', tabwriter.TabIndent)
214215

215216
switch obj := obj.(type) {
216-
case *v1alpha1.TaskList:
217+
case *v1beta1.TaskList:
217218

218219
if len(obj.Items) == 0 {
219220

@@ -227,7 +228,7 @@ func ListResourceNamesForJSONPath(obj interface{}) string {
227228
}
228229
w.Flush()
229230
return tmplBytes.String()
230-
case *v1alpha1.TaskRunList:
231+
case *v1beta1.TaskRunList:
231232
if len(obj.Items) == 0 {
232233

233234
return emptyMsg
@@ -242,7 +243,7 @@ func ListResourceNamesForJSONPath(obj interface{}) string {
242243
}
243244
w.Flush()
244245
return tmplBytes.String()
245-
case *v1alpha1.PipelineList:
246+
case *v1beta1.PipelineList:
246247
if len(obj.Items) == 0 {
247248
return emptyMsg
248249
}
@@ -255,7 +256,7 @@ func ListResourceNamesForJSONPath(obj interface{}) string {
255256
w.Flush()
256257
return tmplBytes.String()
257258

258-
case *v1alpha1.PipelineRunList:
259+
case *v1beta1.PipelineRunList:
259260
if len(obj.Items) == 0 {
260261
return emptyMsg
261262
}
@@ -279,7 +280,7 @@ func ListResourceNamesForJSONPath(obj interface{}) string {
279280
}
280281
w.Flush()
281282
return tmplBytes.String()
282-
case *v1alpha1.ClusterTaskList:
283+
case *v1beta1.ClusterTaskList:
283284
if len(obj.Items) == 0 {
284285
return emptyMsg
285286
}
@@ -367,7 +368,7 @@ func ListAllClusterTasksOutput(t *testing.T, cs *framework.Clients, td map[int]i
367368
return tmplBytes.String()
368369
}
369370

370-
func GetTaskListWithTestData(t *testing.T, c *framework.Clients, td map[int]interface{}) *v1alpha1.TaskList {
371+
func GetTaskListWithTestData(t *testing.T, c *framework.Clients, td map[int]interface{}) *v1beta1.TaskList {
371372
t.Helper()
372373

373374
tasklist := GetTaskList(c)
@@ -393,7 +394,7 @@ func GetTaskListWithTestData(t *testing.T, c *framework.Clients, td map[int]inte
393394
return tasklist
394395
}
395396

396-
func GetClusterTaskListWithTestData(t *testing.T, c *framework.Clients, td map[int]interface{}) *v1alpha1.ClusterTaskList {
397+
func GetClusterTaskListWithTestData(t *testing.T, c *framework.Clients, td map[int]interface{}) *v1beta1.ClusterTaskList {
397398
t.Helper()
398399

399400
clustertasklist := GetClusterTaskList(c)
@@ -445,7 +446,7 @@ NAME STARTED DURATION STATUS{{- if $.AllNamespaces }} NAMESPACE{{- end }}
445446
SortByStartTimeTaskRun(taskrun.Items)
446447
}
447448
var data = struct {
448-
TaskRuns *v1alpha1.TaskRunList
449+
TaskRuns *v1beta1.TaskRunList
449450
Time clockwork.Clock
450451
AllNamespaces bool
451452
}{
@@ -473,7 +474,7 @@ NAME STARTED DURATION STATUS{{- if $.AllNamespaces }} NAMESPACE{{- end }}
473474
return tmplBytes.String()
474475
}
475476

476-
func GetTaskRunListWithTestData(t *testing.T, c *framework.Clients, td map[int]interface{}) *v1alpha1.TaskRunList {
477+
func GetTaskRunListWithTestData(t *testing.T, c *framework.Clients, td map[int]interface{}) *v1beta1.TaskRunList {
477478
taskRunlist := GetTaskRunList(c)
478479
if len(taskRunlist.Items) != len(td) {
479480
t.Errorf("Length of taskrun list and Testdata provided not matching")
@@ -502,7 +503,7 @@ func GetTaskRunListWithTestData(t *testing.T, c *framework.Clients, td map[int]i
502503
return taskRunlist
503504
}
504505

505-
type pipelineruns map[string]v1alpha1.PipelineRun
506+
type pipelineruns map[string]v1beta1.PipelineRun
506507

507508
type PipelinesListData struct {
508509
Name string
@@ -533,7 +534,7 @@ func ListAllPipelinesOutput(t *testing.T, cs *framework.Clients, td map[int]inte
533534
t.Error("Failed to list pipelines")
534535
}
535536
var data = struct {
536-
Pipelines *v1alpha1.PipelineList
537+
Pipelines *v1beta1.PipelineList
537538
PipelineRuns pipelineruns
538539
Params clockwork.Clock
539540
}{
@@ -543,7 +544,7 @@ func ListAllPipelinesOutput(t *testing.T, cs *framework.Clients, td map[int]inte
543544
}
544545

545546
funcMap := template.FuncMap{
546-
"accessMap": func(prs pipelineruns, name string) *v1alpha1.PipelineRun {
547+
"accessMap": func(prs pipelineruns, name string) *v1beta1.PipelineRun {
547548
if pr, ok := prs[name]; ok {
548549
return &pr
549550
}
@@ -570,7 +571,7 @@ func ListAllPipelinesOutput(t *testing.T, cs *framework.Clients, td map[int]inte
570571
return tmplBytes.String()
571572
}
572573

573-
func listPipelineDetailsWithTestData(t *testing.T, cs *framework.Clients, td map[int]interface{}) (*v1alpha1.PipelineList, pipelineruns, error) {
574+
func listPipelineDetailsWithTestData(t *testing.T, cs *framework.Clients, td map[int]interface{}) (*v1beta1.PipelineList, pipelineruns, error) {
574575
t.Helper()
575576
ps := GetPipelineListWithTestData(t, cs, td)
576577
runs := GetPipelineRunList(cs)
@@ -596,7 +597,7 @@ func listPipelineDetailsWithTestData(t *testing.T, cs *framework.Clients, td map
596597
return ps, latestRuns, nil
597598
}
598599

599-
func GetPipelineListWithTestData(t *testing.T, c *framework.Clients, td map[int]interface{}) *v1alpha1.PipelineList {
600+
func GetPipelineListWithTestData(t *testing.T, c *framework.Clients, td map[int]interface{}) *v1beta1.PipelineList {
600601
t.Helper()
601602
ps := GetPipelineList(c)
602603

@@ -718,8 +719,8 @@ func GetPipelineDescribeOutput(t *testing.T, cs *framework.Clients, pname string
718719
pipelineRuns := GetPipelineRunListWithNameAndTestData(t, cs, pname, td)
719720

720721
var data = struct {
721-
Pipeline *v1alpha1.Pipeline
722-
PipelineRuns *v1alpha1.PipelineRunList
722+
Pipeline *v1beta1.Pipeline
723+
PipelineRuns *v1beta1.PipelineRunList
723724
PipelineName string
724725
Params clockwork.Clock
725726
}{
@@ -756,7 +757,7 @@ func GetPipelineDescribeOutput(t *testing.T, cs *framework.Clients, pname string
756757

757758
}
758759

759-
func GetPipelineWithTestData(t *testing.T, c *framework.Clients, name string, td map[int]interface{}) *v1alpha1.Pipeline {
760+
func GetPipelineWithTestData(t *testing.T, c *framework.Clients, name string, td map[int]interface{}) *v1beta1.Pipeline {
760761
t.Helper()
761762
pipeline := GetPipeline(c, name)
762763

@@ -770,19 +771,17 @@ func GetPipelineWithTestData(t *testing.T, c *framework.Clients, name string, td
770771
pipeline.Spec.Resources[count].Name = k
771772
switch v {
772773
case "git":
773-
pipeline.Spec.Resources[count].Type = v1alpha1.PipelineResourceTypeGit
774+
pipeline.Spec.Resources[count].Type = v1beta1.PipelineResourceTypeGit
774775
case "storage":
775-
pipeline.Spec.Resources[count].Type = v1alpha1.PipelineResourceTypeStorage
776+
pipeline.Spec.Resources[count].Type = v1beta1.PipelineResourceTypeStorage
776777
case "image":
777-
pipeline.Spec.Resources[count].Type = v1alpha1.PipelineResourceTypeImage
778+
pipeline.Spec.Resources[count].Type = v1beta1.PipelineResourceTypeImage
778779
case "cluster":
779-
pipeline.Spec.Resources[count].Type = v1alpha1.PipelineResourceTypeCluster
780+
pipeline.Spec.Resources[count].Type = v1beta1.PipelineResourceTypeCluster
780781
case "pullRequest":
781-
pipeline.Spec.Resources[count].Type = v1alpha1.PipelineResourceTypePullRequest
782-
case "gcs":
783-
pipeline.Spec.Resources[count].Type = v1alpha1.PipelineResourceTypeGCS
782+
pipeline.Spec.Resources[count].Type = v1beta1.PipelineResourceTypePullRequest
784783
default:
785-
t.Errorf("Provided PipelineResourcesData is not Valid Type : Need to Provide (%s, %s, %s, %s)", v1alpha1.PipelineResourceTypeGit, v1alpha1.PipelineResourceTypeImage, v1alpha1.PipelineResourceTypePullRequest, v1alpha1.PipelineResourceTypeCluster)
784+
t.Errorf("Provided PipelineResourcesData is not Valid Type : Need to Provide (%s, %s, %s, %s)", v1beta1.PipelineResourceTypeGit, v1beta1.PipelineResourceTypeImage, v1beta1.PipelineResourceTypePullRequest, v1beta1.PipelineResourceTypeCluster)
786785
}
787786

788787
count++
@@ -818,7 +817,7 @@ func GetPipelineWithTestData(t *testing.T, c *framework.Clients, name string, td
818817
return pipeline
819818
}
820819

821-
func GetPipelineRunListWithNameAndTestData(t *testing.T, c *framework.Clients, pname string, td map[int]interface{}) *v1alpha1.PipelineRunList {
820+
func GetPipelineRunListWithNameAndTestData(t *testing.T, c *framework.Clients, pname string, td map[int]interface{}) *v1beta1.PipelineRunList {
822821
t.Helper()
823822
opts := metav1.ListOptions{
824823
LabelSelector: fmt.Sprintf("tekton.dev/pipeline=%s", pname),

test/builder/sort.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ package builder
1717
import (
1818
"sort"
1919

20-
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
20+
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
2121
)
2222

23-
func SortByStartTimeTaskRun(trs []v1alpha1.TaskRun) {
23+
func SortByStartTimeTaskRun(trs []v1beta1.TaskRun) {
2424
sort.Sort(byStartTimeTR(trs))
2525
}
2626

27-
func SortByStartTimePipelineRun(prs []v1alpha1.PipelineRun) {
27+
func SortByStartTimePipelineRun(prs []v1beta1.PipelineRun) {
2828
sort.Sort(byStartTimePR(prs))
2929
}
3030

31-
type byStartTimeTR []v1alpha1.TaskRun
31+
type byStartTimeTR []v1beta1.TaskRun
3232

3333
func (trs byStartTimeTR) Len() int { return len(trs) }
3434
func (trs byStartTimeTR) Swap(i, j int) { trs[i], trs[j] = trs[j], trs[i] }
@@ -42,7 +42,7 @@ func (trs byStartTimeTR) Less(i, j int) bool {
4242
return trs[j].Status.StartTime.Before(trs[i].Status.StartTime)
4343
}
4444

45-
type byStartTimePR []v1alpha1.PipelineRun
45+
type byStartTimePR []v1beta1.PipelineRun
4646

4747
func (prs byStartTimePR) Len() int { return len(prs) }
4848
func (prs byStartTimePR) Swap(i, j int) { prs[i], prs[j] = prs[j], prs[i] }

test/builder/validate.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ import (
1919
"sort"
2020
"strings"
2121

22-
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
22+
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
23+
"github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
2324
corev1 "k8s.io/api/core/v1"
2425
)
2526

2627
func Details(pre v1alpha1.PipelineResource) string {
2728
var key = "url"
28-
if pre.Spec.Type == v1alpha1.PipelineResourceTypeStorage {
29+
if pre.Spec.Type == v1beta1.PipelineResourceTypeStorage {
2930
key = "location"
3031
}
31-
if pre.Spec.Type == v1alpha1.PipelineResourceTypeCloudEvent {
32+
if pre.Spec.Type == v1beta1.PipelineResourceTypeCloudEvent {
3233
key = "targeturi"
3334
}
3435

@@ -41,7 +42,7 @@ func Details(pre v1alpha1.PipelineResource) string {
4142
return "---"
4243
}
4344

44-
func TaskRunHasFailed(tr *v1alpha1.TaskRun) string {
45+
func TaskRunHasFailed(tr *v1beta1.TaskRun) string {
4546
if len(tr.Status.Conditions) == 0 {
4647
return ""
4748
}
@@ -53,7 +54,7 @@ func TaskRunHasFailed(tr *v1alpha1.TaskRun) string {
5354
}
5455

5556
// this will sort the Resource by Type and then by Name
56-
func SortResourcesByTypeAndName(pres []v1alpha1.PipelineDeclaredResource) []v1alpha1.PipelineDeclaredResource {
57+
func SortResourcesByTypeAndName(pres []v1beta1.PipelineDeclaredResource) []v1beta1.PipelineDeclaredResource {
5758
sort.Slice(pres, func(i, j int) bool {
5859
if pres[j].Type < pres[i].Type {
5960
return false
@@ -71,7 +72,7 @@ func SortResourcesByTypeAndName(pres []v1alpha1.PipelineDeclaredResource) []v1al
7172

7273
// Pipeline Run Describe command
7374

74-
func PipelineRunHasFailed(pr *v1alpha1.PipelineRun) string {
75+
func PipelineRunHasFailed(pr *v1beta1.PipelineRun) string {
7576
if len(pr.Status.Conditions) == 0 {
7677
return ""
7778
}
@@ -95,7 +96,7 @@ type TaskrunList []tkr
9596

9697
type tkr struct {
9798
TaskrunName string
98-
*v1alpha1.PipelineRunTaskRunStatus
99+
*v1beta1.PipelineRunTaskRunStatus
99100
}
100101

101102
func (s TaskrunList) Len() int { return len(s) }

0 commit comments

Comments
 (0)