Skip to content

Commit

Permalink
feat: use tekton v1 instead of v1beta1
Browse files Browse the repository at this point in the history
Adjust code to use github.com/tektoncd/pipeline/pkg/apis/pipeline/v1
instead of v1beta1

Signed-off-by: Karel Simon <ksimon@redhat.com>
  • Loading branch information
ksimon1 committed Jan 2, 2024
1 parent 528af66 commit 9e2cc06
Show file tree
Hide file tree
Showing 17 changed files with 284 additions and 284 deletions.
6 changes: 3 additions & 3 deletions modules/tests/test/framework/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/kubevirt/kubevirt-tekton-tasks/modules/tests/test/framework/testoptions"
templatev1 "github.com/openshift/client-go/template/clientset/versioned/typed/template/v1"
tknclientversioned "github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
tknclientv1beta1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1"
tknclientv1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1"
"k8s.io/client-go/kubernetes"
kubeclient "k8s.io/client-go/kubernetes"
kubeclientcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
Expand All @@ -22,7 +22,7 @@ type Clients struct {

K8sClient *kubernetes.Clientset
CoreV1Client kubeclientcorev1.CoreV1Interface
TknClient tknclientv1beta1.TektonV1beta1Interface
TknClient tknclientv1.TektonV1Interface
TemplateClient *templatev1.TemplateV1Client
CdiClient *cdicliv1beta1.CdiV1beta1Client
KubevirtClient kubevirtcliv1.KubevirtClient
Expand Down Expand Up @@ -71,7 +71,7 @@ func InitClients(clients *Clients, testOptions *testoptions.TestOptions) error {
clients.RestConfig = restConf
clients.K8sClient = k8sClient
clients.CoreV1Client = k8sClient.CoreV1()
clients.TknClient = tknClientset.TektonV1beta1()
clients.TknClient = tknClientset.TektonV1()
clients.TemplateClient = templateClient
clients.CdiClient = cdiClient
clients.KubevirtClient = kubevirtClient
Expand Down
14 changes: 7 additions & 7 deletions modules/tests/test/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/kubevirt/kubevirt-tekton-tasks/modules/tests/test/tekton"
. "github.com/onsi/ginkgo/v2"
templatev1 "github.com/openshift/api/template/v1"
pipev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubevirtv1 "kubevirt.io/api/core/v1"
Expand All @@ -22,9 +22,9 @@ var TestOptionsInstance = &testoptions.TestOptions{}
var ClientsInstance = &clients.Clients{}

type ManagedResources struct {
taskRuns []*pipev1beta1.TaskRun
pipelineRuns []*pipev1beta1.PipelineRun
pipelines []*pipev1beta1.Pipeline
taskRuns []*pipev1.TaskRun
pipelineRuns []*pipev1.PipelineRun
pipelines []*pipev1.Pipeline
dataVolumes []*cdiv1beta1.DataVolume
dataSources []*cdiv1beta1.DataSource
vms []*kubevirtv1.VirtualMachine
Expand Down Expand Up @@ -150,17 +150,17 @@ func (f *Framework) AfterEach() {
}
}

func (f *Framework) ManageTaskRuns(taskRuns ...*pipev1beta1.TaskRun) *Framework {
func (f *Framework) ManageTaskRuns(taskRuns ...*pipev1.TaskRun) *Framework {
f.managedResources.taskRuns = append(f.managedResources.taskRuns, taskRuns...)
return f
}

func (f *Framework) ManagePipelineRuns(pipelineRuns ...*pipev1beta1.PipelineRun) *Framework {
func (f *Framework) ManagePipelineRuns(pipelineRuns ...*pipev1.PipelineRun) *Framework {
f.managedResources.pipelineRuns = append(f.managedResources.pipelineRuns, pipelineRuns...)
return f
}

func (f *Framework) ManagePipelines(pipelines ...*pipev1beta1.Pipeline) *Framework {
func (f *Framework) ManagePipelines(pipelines ...*pipev1.Pipeline) *Framework {
f.managedResources.pipelines = append(f.managedResources.pipelines, pipelines...)
return f
}
Expand Down
64 changes: 32 additions & 32 deletions modules/tests/test/pipelines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/kubevirt/kubevirt-tekton-tasks/modules/tests/test/testconfigs"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
Expand All @@ -23,31 +23,31 @@ var _ = Describe("Pipelines tests", func() {
ServiceAccount: ModifyDataObjectServiceAccountName,
Timeout: Timeouts.PipelineRunExtraWaitDelay,
},
Pipeline: &v1beta1.Pipeline{
Pipeline: &pipev1.Pipeline{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pipeline-dvs",
},
Spec: v1beta1.PipelineSpec{
Tasks: []v1beta1.PipelineTask{
Spec: pipev1.PipelineSpec{
Tasks: []pipev1.PipelineTask{
{
Name: "create-dv",
TaskRef: &v1beta1.TaskRef{
Kind: v1beta1.NamespacedTaskKind,
TaskRef: &pipev1.TaskRef{
Kind: pipev1.NamespacedTaskKind,
Name: "modify-data-object",
},
Params: []v1beta1.Param{
Params: []pipev1.Param{
{
Name: "waitForSuccess",
Value: v1beta1.ArrayOrString{
Type: v1beta1.ParamTypeString,
Value: pipev1.ParamValue{
Type: pipev1.ParamTypeString,
StringVal: "true",
},
}, {
Name: "manifest",
Value: v1beta1.ArrayOrString{
Type: v1beta1.ParamTypeString,
Value: pipev1.ParamValue{
Type: pipev1.ParamTypeString,
StringVal: `
apiVersion: cdi.kubevirt.io/v1beta1
apiVersion: cdi.kubevirt.io/pipev1
kind: DataVolume
metadata:
name: test-dv
Expand All @@ -69,40 +69,40 @@ spec:
},
}, {
Name: "sysprep-dv",
TaskRef: &v1beta1.TaskRef{
Kind: v1beta1.NamespacedTaskKind,
TaskRef: &pipev1.TaskRef{
Kind: pipev1.NamespacedTaskKind,
Name: "disk-virt-sysprep",
},
Params: []v1beta1.Param{
Params: []pipev1.Param{
{
Name: "sysprepCommands",
Value: v1beta1.ArrayOrString{
Type: v1beta1.ParamTypeString,
Value: pipev1.ParamValue{
Type: pipev1.ParamTypeString,
StringVal: "run-command echo 'krtek' > new",
},
}, {
Name: "pvc",
Value: v1beta1.ArrayOrString{
Type: v1beta1.ParamTypeString,
Value: pipev1.ParamValue{
Type: pipev1.ParamTypeString,
StringVal: "$(tasks.create-dv.results.name)",
},
},
},
RunAfter: []string{"create-dv"},
}, {
Name: "create-updated-dv",
TaskRef: &v1beta1.TaskRef{
Kind: v1beta1.NamespacedTaskKind,
TaskRef: &pipev1.TaskRef{
Kind: pipev1.NamespacedTaskKind,
Name: "modify-data-object",
},
Params: []v1beta1.Param{
Params: []pipev1.Param{
{

Name: "manifest",
Value: v1beta1.ArrayOrString{
Type: v1beta1.ParamTypeString,
Value: pipev1.ParamValue{
Type: pipev1.ParamTypeString,
StringVal: `
apiVersion: cdi.kubevirt.io/v1beta1
apiVersion: cdi.kubevirt.io/pipev1
kind: DataVolume
metadata:
name: test-dv-updated
Expand Down Expand Up @@ -131,17 +131,17 @@ spec:
},
PipelineRunData: testconfigs.PipelineRunData{
Name: "test-dv-hardening",
Params: []v1beta1.Param{},
PipelineRef: &v1beta1.PipelineRef{
Params: []pipev1.Param{},
PipelineRef: &pipev1.PipelineRef{
Name: "test-pipeline-dvs",
},
TaskRunSpecs: []v1beta1.PipelineTaskRunSpec{
TaskRunSpecs: []pipev1.PipelineTaskRunSpec{
{
PipelineTaskName: "create-dv",
TaskServiceAccountName: "modify-data-object-task",
PipelineTaskName: "create-dv",
ServiceAccountName: "modify-data-object-task",
}, {
PipelineTaskName: "create-updated-dv",
TaskServiceAccountName: "modify-data-object-task",
PipelineTaskName: "create-updated-dv",
ServiceAccountName: "modify-data-object-task",
},
},
},
Expand Down
10 changes: 5 additions & 5 deletions modules/tests/test/runner/pipelinerunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ import (
framework2 "github.com/kubevirt/kubevirt-tekton-tasks/modules/tests/test/framework"
"github.com/kubevirt/kubevirt-tekton-tasks/modules/tests/test/tekton"
. "github.com/onsi/gomega"
pipev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
tkntest "github.com/tektoncd/pipeline/test"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
)

type PipelineRunRunner struct {
framework *framework2.Framework
pipelineRun *pipev1beta1.PipelineRun
pipelineRun *pipev1.PipelineRun
logs string
}

func NewPipelineRunRunner(framework *framework2.Framework, pipelineRun *pipev1beta1.PipelineRun) *PipelineRunRunner {
func NewPipelineRunRunner(framework *framework2.Framework, pipelineRun *pipev1.PipelineRun) *PipelineRunRunner {
Expect(pipelineRun).ShouldNot(BeNil())
return &PipelineRunRunner{
framework: framework,
pipelineRun: pipelineRun,
}
}

func (r *PipelineRunRunner) GetPipelineRun() *pipev1beta1.PipelineRun {
func (r *PipelineRunRunner) GetPipelineRun() *pipev1.PipelineRun {
return r.pipelineRun
}

Expand Down Expand Up @@ -82,7 +82,7 @@ func (r *PipelineRunRunner) ExpectLogs(logs ...string) *PipelineRunRunner {
}

func (r *PipelineRunRunner) GetResults() map[string]string {
return tekton.PipelineResultsToMap(r.pipelineRun.Status.PipelineResults)
return tekton.PipelineResultsToMap(r.pipelineRun.Status.Results)
}

func (r *PipelineRunRunner) ExpectResults(results map[string]string) *PipelineRunRunner {
Expand Down
10 changes: 5 additions & 5 deletions modules/tests/test/runner/taskrunrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ import (
"github.com/kubevirt/kubevirt-tekton-tasks/modules/tests/test/tekton"
"github.com/kubevirt/kubevirt-tekton-tasks/modules/tests/test/testconfigs"
. "github.com/onsi/gomega"
pipev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
tkntest "github.com/tektoncd/pipeline/test"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
)

type TaskRunRunner struct {
framework *framework2.Framework
taskRun *pipev1beta1.TaskRun
taskRun *pipev1.TaskRun
logs string
}

func NewTaskRunRunner(framework *framework2.Framework, taskRun *pipev1beta1.TaskRun) *TaskRunRunner {
func NewTaskRunRunner(framework *framework2.Framework, taskRun *pipev1.TaskRun) *TaskRunRunner {
Expect(taskRun).ShouldNot(BeNil())
return &TaskRunRunner{
framework: framework,
taskRun: taskRun,
}
}

func (r *TaskRunRunner) GetTaskRun() *pipev1beta1.TaskRun {
func (r *TaskRunRunner) GetTaskRun() *pipev1.TaskRun {
return r.taskRun
}

Expand Down Expand Up @@ -91,7 +91,7 @@ func (r *TaskRunRunner) ExpectTermination(termination *testconfigs.TaskRunExpect
}

func (r *TaskRunRunner) GetResults() map[string]string {
return tekton.TaskResultsToMap(r.taskRun.Status.TaskRunResults)
return tekton.TaskResultsToMap(r.taskRun.Status.Results)
}

func (r *TaskRunRunner) ExpectResults(results map[string]string) *TaskRunRunner {
Expand Down
8 changes: 4 additions & 4 deletions modules/tests/test/tekton/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

. "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
tkntest "github.com/tektoncd/pipeline/test"

v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -48,7 +48,7 @@ func (l *taskRunsLogs) getAllLogs() string {
return logs
}

func WaitForPipelineRunState(clients *clients.Clients, namespace, name string, timeout time.Duration, inState tkntest.ConditionAccessorFn) (*v1beta1.PipelineRun, string) {
func WaitForPipelineRunState(clients *clients.Clients, namespace, name string, timeout time.Duration, inState tkntest.ConditionAccessorFn) (*pipev1.PipelineRun, string) {
pipelinePodsLogs := taskRunsLogs{}
pipelinePodsLogs.logs = make(map[string]string)
var wg sync.WaitGroup
Expand All @@ -58,8 +58,8 @@ func WaitForPipelineRunState(clients *clients.Clients, namespace, name string, t
return true, err
}

for _, taskRun := range pipelineRun.Status.TaskRuns {
podName := taskRun.Status.PodName
for _, reference := range pipelineRun.Status.ChildReferences {
podName := reference.Name
if pipelinePodsLogs.getLog(podName) == "" && podName != "" {
wg.Add(1)
go func() {
Expand Down
8 changes: 4 additions & 4 deletions modules/tests/test/tekton/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/kubevirt/kubevirt-tekton-tasks/modules/tests/test/framework/clients"
. "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
tkntest "github.com/tektoncd/pipeline/test"
v1 "k8s.io/api/core/v1"

Expand All @@ -20,10 +20,10 @@ import (
"sigs.k8s.io/yaml"
)

func WaitForTaskRunState(clients *clients.Clients, namespace, name string, timeout time.Duration, inState tkntest.ConditionAccessorFn) (*v1beta1.TaskRun, string) {
func WaitForTaskRunState(clients *clients.Clients, namespace, name string, timeout time.Duration, inState tkntest.ConditionAccessorFn) (*pipev1.TaskRun, string) {
isCapturing := false
logs := make(chan string, 1)
var taskRun *v1beta1.TaskRun
var taskRun *pipev1.TaskRun
err := wait.PollImmediate(constants.PollInterval, timeout, func() (bool, error) {
var err error
taskRun, err = clients.TknClient.TaskRuns(namespace).Get(context.Background(), name, metav1.GetOptions{})
Expand Down Expand Up @@ -77,7 +77,7 @@ func PrintTaskRunDebugInfo(clients *clients.Clients, taskRunNamespace, taskRunNa
}
}

func getTaskRunLogs(coreClient clientv1.CoreV1Interface, taskRun *v1beta1.TaskRun) string {
func getTaskRunLogs(coreClient clientv1.CoreV1Interface, taskRun *pipev1.TaskRun) string {
if taskRun.Status.PodName == "" {
return ""
}
Expand Down
8 changes: 4 additions & 4 deletions modules/tests/test/tekton/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"strings"

beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
)

func TaskResultsToMap(results []beta1.TaskRunResult) map[string]string {
func TaskResultsToMap(results []pipev1.TaskRunResult) map[string]string {
mappedResult := make(map[string]string, len(results))

for _, result := range results {
Expand All @@ -17,7 +17,7 @@ func TaskResultsToMap(results []beta1.TaskRunResult) map[string]string {
return mappedResult
}

func PipelineResultsToMap(results []beta1.PipelineRunResult) map[string]string {
func PipelineResultsToMap(results []pipev1.PipelineRunResult) map[string]string {
mappedResult := make(map[string]string, len(results))

for _, result := range results {
Expand All @@ -27,7 +27,7 @@ func PipelineResultsToMap(results []beta1.PipelineRunResult) map[string]string {
return mappedResult
}

func resultToString(value beta1.ParamValue) string {
func resultToString(value pipev1.ParamValue) string {
if value.StringVal != "" {
return value.StringVal
}
Expand Down
Loading

0 comments on commit 9e2cc06

Please sign in to comment.