Skip to content

Commit

Permalink
Update from Tekton v1beta1 to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsauter committed Oct 5, 2023
1 parent 5bd4f73 commit 21db0e3
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 48 deletions.
23 changes: 10 additions & 13 deletions internal/manager/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

tektonClient "github.com/opendevstack/ods-pipeline/internal/tekton"
"github.com/opendevstack/ods-pipeline/pkg/config"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -55,12 +55,10 @@ func createPipelineRun(
Kind: "PipelineRun",
},
Spec: tekton.PipelineRunSpec{
PipelineSpec: assemblePipelineSpec(cfg),
Params: extractPipelineParams(cfg.Params),
ServiceAccountName: "pipeline", // TODO
PodTemplate: cfg.PipelineSpec.PodTemplate,
TaskRunSpecs: cfg.PipelineSpec.TaskRunSpecs,
Timeouts: cfg.PipelineSpec.Timeouts,
PipelineSpec: assemblePipelineSpec(cfg),
Params: extractPipelineParams(cfg.Params),
TaskRunSpecs: cfg.PipelineSpec.TaskRunSpecs,
Timeouts: cfg.PipelineSpec.Timeouts,
Workspaces: []tekton.WorkspaceBinding{
{
Name: sharedWorkspaceName,
Expand Down Expand Up @@ -188,17 +186,16 @@ func pipelineRunIsProgressing(pr tekton.PipelineRun) bool {

// tektonStringParam returns a Tekton task parameter.
func tektonStringParam(name, val string) tekton.Param {
return tekton.Param{Name: name, Value: tekton.ArrayOrString{Type: "string", StringVal: val}}
return tekton.Param{Name: name, Value: tekton.ParamValue{Type: "string", StringVal: val}}
}

// tektonStringParam returns a Tekton task parameter spec.
func tektonStringParamSpec(name, defaultVal string) tekton.ParamSpec {
return tekton.ParamSpec{
Name: name,
Type: "string",
Default: &tekton.ArrayOrString{
Type: tekton.ParamTypeString, StringVal: defaultVal,
}}
Name: name,
Type: "string",
Default: &tekton.ParamValue{Type: tekton.ParamTypeString, StringVal: defaultVal},
}
}

// tektonDefaultWorkspaceBindings returns the default workspace bindings for a task.
Expand Down
2 changes: 1 addition & 1 deletion internal/manager/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/google/go-cmp/cmp"
tektonClient "github.com/opendevstack/ods-pipeline/internal/tekton"
"github.com/opendevstack/ods-pipeline/pkg/config"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
)

func TestShortenString(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/manager/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

tektonClient "github.com/opendevstack/ods-pipeline/internal/tekton"
"github.com/opendevstack/ods-pipeline/pkg/logging"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/manager/prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/google/go-cmp/cmp"
tektonClient "github.com/opendevstack/ods-pipeline/internal/tekton"
"github.com/opendevstack/ods-pipeline/pkg/logging"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
8 changes: 4 additions & 4 deletions internal/manager/receive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/opendevstack/ods-pipeline/pkg/bitbucket"
"github.com/opendevstack/ods-pipeline/pkg/config"
"github.com/opendevstack/ods-pipeline/pkg/logging"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
)

func TestIsCiSkipInCommitMessage(t *testing.T) {
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestFetchODSConfig(t *testing.T) {
"ods.yml": []byte("pipelines: [{tasks: [{name: yml}]}]"),
},
wantErr: "",
wantODS: &config.ODS{Pipelines: []config.Pipeline{{Tasks: []v1beta1.PipelineTask{{Name: "yaml"}}}}},
wantODS: &config.ODS{Pipelines: []config.Pipeline{{Tasks: []tekton.PipelineTask{{Name: "yaml"}}}}},
},
}

Expand Down Expand Up @@ -728,11 +728,11 @@ func verifyMatchingPipelineInfo(pInfo *PipelineInfo, odsConfig *config.ODS, want
// Annotate wanted pipeline/trigger so that
// we can check later if it was selected.
// no matching pipeline, as wanted by the test case.
odsConfig.Pipelines[wantPipelineIndex].Tasks = []v1beta1.PipelineTask{
odsConfig.Pipelines[wantPipelineIndex].Tasks = []tekton.PipelineTask{
{Name: "match this"},
}
if wantTriggerIndex > -1 {
odsConfig.Pipelines[wantPipelineIndex].Triggers[wantTriggerIndex].Params = []v1beta1.Param{
odsConfig.Pipelines[wantPipelineIndex].Triggers[wantTriggerIndex].Params = []tekton.Param{
tektonStringParam("match", "this"),
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/manager/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
kubernetesClient "github.com/opendevstack/ods-pipeline/internal/kubernetes"
tektonClient "github.com/opendevstack/ods-pipeline/internal/tekton"
"github.com/opendevstack/ods-pipeline/pkg/logging"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
)

type StorageConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/manager/schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
kubernetesClient "github.com/opendevstack/ods-pipeline/internal/kubernetes"
tektonClient "github.com/opendevstack/ods-pipeline/internal/tekton"
"github.com/opendevstack/ods-pipeline/pkg/logging"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/manager/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

tektonClient "github.com/opendevstack/ods-pipeline/internal/tekton"
"github.com/opendevstack/ods-pipeline/pkg/logging"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
6 changes: 4 additions & 2 deletions internal/manager/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

tektonClient "github.com/opendevstack/ods-pipeline/internal/tekton"
"github.com/opendevstack/ods-pipeline/pkg/logging"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/clock"
)
Expand Down Expand Up @@ -145,7 +145,9 @@ func timedOutPipelineRun(t *testing.T, name string, creationTime time.Time) *tek
CreationTimestamp: metav1.Time{Time: creationTime},
},
Spec: tekton.PipelineRunSpec{
Timeout: &metav1.Duration{Duration: time.Second},
Timeouts: &tekton.TimeoutFields{
Pipeline: &metav1.Duration{Duration: time.Second},
},
},
Status: tekton.PipelineRunStatus{
PipelineRunStatusFields: tekton.PipelineRunStatusFields{
Expand Down
10 changes: 5 additions & 5 deletions internal/tekton/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/opendevstack/ods-pipeline/pkg/logging"
tektonClient "github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
v1beta1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1"
tektonv1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1"
"k8s.io/client-go/rest"
)

Expand Down Expand Up @@ -72,10 +72,10 @@ func (c *Client) namespace() string {
return c.clientConfig.Namespace
}

func (c *Client) tektonV1beta1Client() v1beta1.TektonV1beta1Interface {
return c.clientConfig.TektonClient.TektonV1beta1()
func (c *Client) tektonV1Client() tektonv1.TektonV1Interface {
return c.clientConfig.TektonClient.TektonV1()
}

func (c *Client) pipelineRunsClient() v1beta1.PipelineRunInterface {
return c.tektonV1beta1Client().PipelineRuns(c.namespace())
func (c *Client) pipelineRunsClient() tektonv1.PipelineRunInterface {
return c.tektonV1Client().PipelineRuns(c.namespace())
}
2 changes: 1 addition & 1 deletion internal/tekton/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"net/url"

tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/tekton/test_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"fmt"

tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
4 changes: 1 addition & 3 deletions pkg/config/ods.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
"path/filepath"
"strings"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/pod"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"sigs.k8s.io/yaml"
)

Expand Down Expand Up @@ -55,7 +54,6 @@ type Pipeline struct {
Tasks []tekton.PipelineTask `json:"tasks,omitempty"`
Finally []tekton.PipelineTask `json:"finally,omitempty"`
Timeouts *tekton.TimeoutFields `json:"timeouts,omitempty"`
PodTemplate *pod.PodTemplate `json:"podTemplate,omitempty"`
TaskRunSpecs []tekton.PipelineTaskRunSpec `json:"taskRunSpecs,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/taskdoc/taskdoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
"text/template"

tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"sigs.k8s.io/yaml"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/tektontaskrun/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

k "github.com/opendevstack/ods-pipeline/internal/kubernetes"
"github.com/opendevstack/ods-pipeline/pkg/taskmanifest"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/yaml"
)
Expand All @@ -30,7 +30,7 @@ func installTask(path, namespace string, data map[string]string) (*tekton.Task,
}
clients := k.NewClients()
tc := clients.TektonClientSet
it, err := tc.TektonV1beta1().Tasks(namespace).Create(context.TODO(), &t, metav1.CreateOptions{})
it, err := tc.TektonV1().Tasks(namespace).Create(context.TODO(), &t, metav1.CreateOptions{})
if err != nil {
return nil, fmt.Errorf("create task: %w", err)
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/tektontaskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

k "github.com/opendevstack/ods-pipeline/internal/kubernetes"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
pipelineclientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -71,7 +71,7 @@ func createTaskRunWithParams(tknClient *pipelineclientset.Clientset, tc *TaskRun
})
}

tr, err := tknClient.TektonV1beta1().TaskRuns(tc.Namespace).Create(context.TODO(),
tr, err := tknClient.TektonV1().TaskRuns(tc.Namespace).Create(context.TODO(),
&tekton.TaskRun{
ObjectMeta: metav1.ObjectMeta{
Name: makeRandomTaskrunName(tc.Name),
Expand Down Expand Up @@ -143,7 +143,7 @@ func waitForTaskRunPod(

var taskRunPod *corev1.Pod

podsInformer.AddEventHandler(
_, err := podsInformer.AddEventHandler(
cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
// when a new task is created, watch its events
Expand All @@ -156,6 +156,9 @@ func waitForTaskRunPod(

},
})
if err != nil {
log.Printf("Unable to install the event handler: %s", err)
}

defer close(stop)
kubeInformerFactory.Start(stop)
Expand Down
2 changes: 1 addition & 1 deletion pkg/tektontaskrun/taskrun_opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/opendevstack/ods-pipeline/internal/directory"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
)

const (
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/pipeline_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/opendevstack/ods-pipeline/internal/tasktesting"
"github.com/opendevstack/ods-pipeline/pkg/bitbucket"
"github.com/opendevstack/ods-pipeline/pkg/tektontaskrun"
tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
tekton "github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -176,14 +176,14 @@ func waitForServiceToBeReady(t *testing.T, clientset *k8s.Clientset, ns, name st
return nil
}

func waitForPipelineRunToBeTriggered(clientset *tekton.Clientset, ns string, timeout time.Duration) (*tektonv1beta1.PipelineRun, error) {
func waitForPipelineRunToBeTriggered(clientset *tekton.Clientset, ns string, timeout time.Duration) (*tektonv1.PipelineRun, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

var pipelineRunList *tektonv1beta1.PipelineRunList
var pipelineRunList *tektonv1.PipelineRunList
for {
time.Sleep(2 * time.Second)
prs, err := clientset.TektonV1beta1().PipelineRuns(ns).List(ctx, metav1.ListOptions{})
prs, err := clientset.TektonV1().PipelineRuns(ns).List(ctx, metav1.ListOptions{})
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/task_finish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/opendevstack/ods-pipeline/pkg/bitbucket"
"github.com/opendevstack/ods-pipeline/pkg/nexus"
"github.com/opendevstack/ods-pipeline/pkg/pipelinectxt"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"k8s.io/client-go/kubernetes"

ott "github.com/opendevstack/ods-pipeline/pkg/odstasktest"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/task_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/opendevstack/ods-pipeline/pkg/config"
"github.com/opendevstack/ods-pipeline/pkg/nexus"
"github.com/opendevstack/ods-pipeline/pkg/pipelinectxt"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/yaml"

Expand Down

0 comments on commit 21db0e3

Please sign in to comment.