From e08bd8de55d925ad4ed05c75176de95aacc37399 Mon Sep 17 00:00:00 2001 From: Jerome Ju Date: Tue, 28 Mar 2023 08:14:39 -0400 Subject: [PATCH] [WIP] Swap v1 storage version --- .../cmd/demoresolver/main.go | 8 +- pkg/apis/pipeline/v1alpha1/run_types.go | 12 +- pkg/apis/pipeline/v1alpha1/run_types_test.go | 34 +- pkg/apis/pipeline/v1alpha1/run_validation.go | 6 +- .../pipeline/v1alpha1/run_validation_test.go | 44 +- .../v1beta1/resolution_request_types.go | 6 +- pkg/container/container_replacements.go | 6 +- pkg/container/sidecar_replacements.go | 4 +- pkg/container/sidecar_replacements_test.go | 6 +- pkg/container/step_replacements.go | 8 +- pkg/container/step_replacements_test.go | 14 +- pkg/controller/filter.go | 5 +- pkg/controller/filter_test.go | 19 +- pkg/internal/resolution/resolved_meta.go | 4 +- pkg/pod/entrypoint.go | 14 +- pkg/pod/entrypoint_lookup_impl_test.go | 7 +- pkg/pod/entrypoint_test.go | 42 +- pkg/pod/pod.go | 26 +- pkg/pod/pod_test.go | 336 +- pkg/pod/script.go | 12 +- pkg/pod/script_test.go | 36 +- pkg/pod/status.go | 84 +- pkg/pod/status_test.go | 510 +-- pkg/reconciler/events/cache/cache_test.go | 2 +- .../cloudevent/cloud_event_controller_test.go | 29 +- .../events/cloudevent/cloudevent.go | 33 +- pkg/reconciler/events/event_test.go | 8 +- pkg/reconciler/events/k8sevent/event_test.go | 8 +- pkg/reconciler/pipeline/dag/dag_test.go | 296 +- .../pipelinerun/affinity_assistant.go | 22 +- .../pipelinerun/affinity_assistant_test.go | 52 +- pkg/reconciler/pipelinerun/cancel.go | 17 +- pkg/reconciler/pipelinerun/cancel_test.go | 158 +- pkg/reconciler/pipelinerun/controller.go | 16 +- pkg/reconciler/pipelinerun/pipelinerun.go | 149 +- .../pipelinerun/pipelinerun_test.go | 1538 ++++----- .../pipelinerun_updatestatus_test.go | 221 +- .../pipelinerun/pipelinespec/pipelinespec.go | 10 +- .../pipelinespec/pipelinespec_test.go | 122 +- pkg/reconciler/pipelinerun/resources/apply.go | 67 +- .../pipelinerun/resources/apply_test.go | 2936 +++++++++-------- .../pipelinerun/resources/pipelineref.go | 26 +- .../pipelinerun/resources/pipelineref_test.go | 172 +- .../resources/pipelinerunresolution.go | 133 +- .../resources/pipelinerunresolution_test.go | 941 +++--- .../pipelinerun/resources/pipelinerunstate.go | 89 +- .../resources/pipelinerunstate_test.go | 699 ++-- .../resources/resultrefresolution.go | 59 +- .../resources/resultrefresolution_test.go | 271 +- .../resources/validate_dependencies.go | 14 +- .../resources/validate_dependencies_test.go | 170 +- .../pipelinerun/resources/validate_params.go | 10 +- .../resources/validate_params_test.go | 170 +- pkg/reconciler/pipelinerun/timeout.go | 15 +- pkg/reconciler/pipelinerun/timeout_test.go | 118 +- pkg/reconciler/pipelinerun/tracing.go | 4 +- pkg/reconciler/pipelinerun/tracing_test.go | 12 +- pkg/reconciler/taskrun/controller.go | 10 +- pkg/reconciler/taskrun/resources/apply.go | 32 +- .../taskrun/resources/apply_test.go | 434 +-- pkg/reconciler/taskrun/resources/taskref.go | 94 +- .../taskrun/resources/taskref_test.go | 256 +- pkg/reconciler/taskrun/resources/taskspec.go | 24 +- .../taskrun/resources/taskspec_test.go | 82 +- pkg/reconciler/taskrun/taskrun.go | 96 +- pkg/reconciler/taskrun/taskrun_test.go | 802 ++--- pkg/reconciler/taskrun/tracing.go | 4 +- pkg/reconciler/taskrun/tracing_test.go | 12 +- pkg/reconciler/taskrun/validate_taskrun.go | 91 +- .../taskrun/validate_taskrun_test.go | 467 ++- pkg/reconciler/testing/logger.go | 6 +- pkg/reconciler/volumeclaim/pvchandler.go | 10 +- pkg/reconciler/volumeclaim/pvchandler_test.go | 8 +- pkg/remote/oci/resolver.go | 4 +- pkg/remote/resolution/resolver.go | 10 +- pkg/remote/resolver.go | 4 +- pkg/resolution/resolver/bundle/bundle.go | 9 +- pkg/resolution/resolver/bundle/params.go | 6 +- pkg/resolution/resolver/bundle/resolver.go | 6 +- .../resolver/bundle/resolver_test.go | 69 +- pkg/resolution/resolver/cluster/resolver.go | 14 +- .../resolver/cluster/resolver_test.go | 75 +- .../resolver/framework/fakeresolver.go | 14 +- .../resolver/framework/interface.go | 8 +- .../resolver/framework/reconciler.go | 8 +- .../resolver/framework/reconciler_test.go | 22 +- pkg/resolution/resolver/git/resolver.go | 12 +- pkg/resolution/resolver/git/resolver_test.go | 32 +- pkg/resolution/resolver/hub/resolver.go | 12 +- pkg/resolution/resolver/hub/resolver_test.go | 10 +- pkg/resolution/resource/crd_resource.go | 4 +- pkg/resolution/resource/name.go | 3 +- pkg/resolution/resource/request.go | 10 +- pkg/resolution/resource/resource.go | 6 +- pkg/taskrunmetrics/metrics.go | 16 +- pkg/trustedresources/verify_test.go | 7 +- pkg/workspace/apply.go | 26 +- pkg/workspace/apply_test.go | 359 +- pkg/workspace/validate.go | 6 +- pkg/workspace/validate_test.go | 70 +- test/controller.go | 34 +- test/resolution.go | 13 +- test/trustedresources.go | 33 +- 103 files changed, 6785 insertions(+), 6375 deletions(-) diff --git a/docs/resolver-template/cmd/demoresolver/main.go b/docs/resolver-template/cmd/demoresolver/main.go index b2e1caad3dc..45d289a3b68 100644 --- a/docs/resolver-template/cmd/demoresolver/main.go +++ b/docs/resolver-template/cmd/demoresolver/main.go @@ -17,7 +17,7 @@ import ( "context" "errors" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" @@ -52,7 +52,7 @@ func (r *resolver) GetSelector(context.Context) map[string]string { } // ValidateParams ensures parameters from a request are as expected. -func (r *resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { +func (r *resolver) ValidateParams(ctx context.Context, params []pipelinev1.Param) error { if len(params) > 0 { return errors.New("no params allowed") } @@ -60,7 +60,7 @@ func (r *resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1. } // Resolve uses the given params to resolve the requested file or resource. -func (r *resolver) Resolve(ctx context.Context, params []pipelinev1beta1.Param) (framework.ResolvedResource, error) { +func (r *resolver) Resolve(ctx context.Context, params []pipelinev1.Param) (framework.ResolvedResource, error) { return &myResolvedResource{}, nil } @@ -95,6 +95,6 @@ func (*myResolvedResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. None atm. -func (*myResolvedResource) Source() *pipelinev1beta1.ConfigSource { +func (*myResolvedResource) Source() *pipelinev1.ConfigSource { return nil } diff --git a/pkg/apis/pipeline/v1alpha1/run_types.go b/pkg/apis/pipeline/v1alpha1/run_types.go index 0806ef6cb1b..84058ce6fc5 100644 --- a/pkg/apis/pipeline/v1alpha1/run_types.go +++ b/pkg/apis/pipeline/v1alpha1/run_types.go @@ -23,7 +23,7 @@ import ( apisconfig "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" pod "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" runv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -38,7 +38,7 @@ type EmbeddedRunSpec struct { runtime.TypeMeta `json:",inline"` // +optional - Metadata v1beta1.PipelineTaskMetadata `json:"metadata,omitempty"` + Metadata v1.PipelineTaskMetadata `json:"metadata,omitempty"` // Spec is a specification of a custom task // +optional @@ -48,14 +48,14 @@ type EmbeddedRunSpec struct { // RunSpec defines the desired state of Run type RunSpec struct { // +optional - Ref *v1beta1.TaskRef `json:"ref,omitempty"` + Ref *v1.TaskRef `json:"ref,omitempty"` // Spec is a specification of a custom task // +optional Spec *EmbeddedRunSpec `json:"spec,omitempty"` // +optional - Params []v1beta1.Param `json:"params,omitempty"` + Params []v1.Param `json:"params,omitempty"` // Used for cancelling a run (and maybe more later on) // +optional @@ -83,7 +83,7 @@ type RunSpec struct { // Workspaces is a list of WorkspaceBindings from volumes to workspaces. // +optional - Workspaces []v1beta1.WorkspaceBinding `json:"workspaces,omitempty"` + Workspaces []v1.WorkspaceBinding `json:"workspaces,omitempty"` } // RunSpecStatus defines the taskrun spec status the user can provide @@ -108,7 +108,7 @@ const ( // GetParam gets the Param from the RunSpec with the given name // TODO(jasonhall): Move this to a Params type so other code can use it? -func (rs RunSpec) GetParam(name string) *v1beta1.Param { +func (rs RunSpec) GetParam(name string) *v1.Param { for _, p := range rs.Params { if p.Name == name { return &p diff --git a/pkg/apis/pipeline/v1alpha1/run_types_test.go b/pkg/apis/pipeline/v1alpha1/run_types_test.go index 377b2e34039..0436cd6539b 100644 --- a/pkg/apis/pipeline/v1alpha1/run_types_test.go +++ b/pkg/apis/pipeline/v1alpha1/run_types_test.go @@ -22,8 +22,8 @@ import ( "github.com/google/go-cmp/cmp" apisconfig "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme" "github.com/tektoncd/pipeline/test/diff" corev1 "k8s.io/api/core/v1" @@ -42,7 +42,7 @@ func TestGetParams(t *testing.T) { desc string spec v1alpha1.RunSpec name string - want *v1beta1.Param + want *v1.Param }{{ desc: "no params", spec: v1alpha1.RunSpec{}, @@ -51,28 +51,28 @@ func TestGetParams(t *testing.T) { }, { desc: "found", spec: v1alpha1.RunSpec{ - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "first", - Value: *v1beta1.NewStructuredValues("blah"), + Value: *v1.NewStructuredValues("blah"), }, { Name: "foo", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }}, }, name: "foo", - want: &v1beta1.Param{ + want: &v1.Param{ Name: "foo", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }, }, { desc: "not found", spec: v1alpha1.RunSpec{ - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "first", - Value: *v1beta1.NewStructuredValues("blah"), + Value: *v1.NewStructuredValues("blah"), }, { Name: "foo", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }}, }, name: "bar", @@ -83,21 +83,21 @@ func TestGetParams(t *testing.T) { // the specified name. desc: "multiple with same name", spec: v1alpha1.RunSpec{ - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "first", - Value: *v1beta1.NewStructuredValues("blah"), + Value: *v1.NewStructuredValues("blah"), }, { Name: "foo", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }, { Name: "foo", - Value: *v1beta1.NewStructuredValues("second bar"), + Value: *v1.NewStructuredValues("second bar"), }}, }, name: "foo", - want: &v1beta1.Param{ + want: &v1.Param{ Name: "foo", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }, }} { t.Run(c.desc, func(t *testing.T) { @@ -234,7 +234,7 @@ status: }, Spec: v1alpha1.RunSpec{ Retries: 3, - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", }, diff --git a/pkg/apis/pipeline/v1alpha1/run_validation.go b/pkg/apis/pipeline/v1alpha1/run_validation.go index c8e2a7ca7f8..0e776a529b4 100644 --- a/pkg/apis/pipeline/v1alpha1/run_validation.go +++ b/pkg/apis/pipeline/v1alpha1/run_validation.go @@ -20,7 +20,7 @@ import ( "context" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/validate" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" "k8s.io/apimachinery/pkg/api/equality" @@ -78,9 +78,9 @@ func (rs *RunSpec) Validate(ctx context.Context) *apis.FieldError { return apis.ErrInvalidValue(fmt.Sprintf("statusMessage should not be set if status is not set, but it is currently set to %s", rs.StatusMessage), "statusMessage") } } - if err := v1beta1.ValidateParameters(ctx, rs.Params).ViaField("spec.params"); err != nil { + if err := v1.ValidateParameters(ctx, rs.Params).ViaField("spec.params"); err != nil { return err } - return v1beta1.ValidateWorkspaceBindings(ctx, rs.Workspaces).ViaField("spec.workspaces") + return v1.ValidateWorkspaceBindings(ctx, rs.Workspaces).ViaField("spec.workspaces") } diff --git a/pkg/apis/pipeline/v1alpha1/run_validation_test.go b/pkg/apis/pipeline/v1alpha1/run_validation_test.go index c417936b303..8875328483b 100644 --- a/pkg/apis/pipeline/v1alpha1/run_validation_test.go +++ b/pkg/apis/pipeline/v1alpha1/run_validation_test.go @@ -22,8 +22,8 @@ import ( "testing" "github.com/google/go-cmp/cmp" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/test/diff" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -74,7 +74,7 @@ func TestRun_Invalid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "apiVersion", Kind: "kind", }, @@ -94,7 +94,7 @@ func TestRun_Invalid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "", }, }, @@ -107,7 +107,7 @@ func TestRun_Invalid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "", }, @@ -152,7 +152,7 @@ func TestRun_Invalid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "blah", }, @@ -167,16 +167,16 @@ func TestRun_Invalid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "blah", }, - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("foo"), + Value: *v1.NewStructuredValues("foo"), }, { Name: "foo", - Value: *v1beta1.NewStructuredValues("foo"), + Value: *v1.NewStructuredValues("foo"), }}, }, }, @@ -202,7 +202,7 @@ func TestRun_Valid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "blah", Name: "blah", @@ -216,7 +216,7 @@ func TestRun_Valid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "blah", }, @@ -229,7 +229,7 @@ func TestRun_Valid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "blah", }, @@ -259,16 +259,16 @@ func TestRun_Valid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "blah", }, - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("foo"), + Value: *v1.NewStructuredValues("foo"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }}, }, }, @@ -279,11 +279,11 @@ func TestRun_Valid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "blah", }, - Workspaces: []v1beta1.WorkspaceBinding{{ + Workspaces: []v1.WorkspaceBinding{{ Name: "workspace", EmptyDir: &corev1.EmptyDirVolumeSource{}, }}, @@ -310,11 +310,11 @@ func TestRun_Workspaces_Invalid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "blah", }, - Workspaces: []v1beta1.WorkspaceBinding{{ + Workspaces: []v1.WorkspaceBinding{{ Name: "workspace", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "", @@ -330,11 +330,11 @@ func TestRun_Workspaces_Invalid(t *testing.T) { Name: "temp", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "blah", Kind: "blah", }, - Workspaces: []v1beta1.WorkspaceBinding{{ + Workspaces: []v1.WorkspaceBinding{{ Name: "workspace", EmptyDir: &corev1.EmptyDirVolumeSource{}, }, { diff --git a/pkg/apis/resolution/v1beta1/resolution_request_types.go b/pkg/apis/resolution/v1beta1/resolution_request_types.go index da507b70845..b7ad103f6c7 100644 --- a/pkg/apis/resolution/v1beta1/resolution_request_types.go +++ b/pkg/apis/resolution/v1beta1/resolution_request_types.go @@ -17,7 +17,7 @@ limitations under the License. package v1beta1 import ( - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" duckv1 "knative.dev/pkg/apis/duck/v1" ) @@ -63,7 +63,7 @@ type ResolutionRequestSpec struct { // path to file, the kind of authentication to leverage, etc. // +optional // +listType=atomic - Params []pipelinev1beta1.Param `json:"params,omitempty"` + Params []pipelinev1.Param `json:"params,omitempty"` } // ResolutionRequestStatus are all the fields in a ResolutionRequest's @@ -82,7 +82,7 @@ type ResolutionRequestStatusFields struct { Data string `json:"data"` // Source is the source reference of the remote data that records the url, digest // and the entrypoint. - Source *pipelinev1beta1.ConfigSource `json:"source"` + Source *pipelinev1.ConfigSource `json:"source"` } // GetStatus implements KRShaped. diff --git a/pkg/container/container_replacements.go b/pkg/container/container_replacements.go index 64d92d2485a..6a6d66c5b8d 100644 --- a/pkg/container/container_replacements.go +++ b/pkg/container/container_replacements.go @@ -17,20 +17,20 @@ package container import ( - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/substitution" corev1 "k8s.io/api/core/v1" ) // applyStepReplacements returns a StepContainer with variable interpolation applied. -func applyStepReplacements(step *v1beta1.Step, stringReplacements map[string]string, arrayReplacements map[string][]string) { +func applyStepReplacements(step *v1.Step, stringReplacements map[string]string, arrayReplacements map[string][]string) { c := step.ToK8sContainer() applyContainerReplacements(c, stringReplacements, arrayReplacements) step.SetContainerFields(*c) } // applySidecarReplacements returns a SidecarContainer with variable interpolation applied. -func applySidecarReplacements(sidecar *v1beta1.Sidecar, stringReplacements map[string]string, arrayReplacements map[string][]string) { +func applySidecarReplacements(sidecar *v1.Sidecar, stringReplacements map[string]string, arrayReplacements map[string][]string) { c := sidecar.ToK8sContainer() applyContainerReplacements(c, stringReplacements, arrayReplacements) sidecar.SetContainerFields(*c) diff --git a/pkg/container/sidecar_replacements.go b/pkg/container/sidecar_replacements.go index 908677a11f4..2054d858a4b 100644 --- a/pkg/container/sidecar_replacements.go +++ b/pkg/container/sidecar_replacements.go @@ -17,12 +17,12 @@ package container import ( - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/substitution" ) // ApplySidecarReplacements applies variable interpolation on a Sidecar. -func ApplySidecarReplacements(sidecar *v1beta1.Sidecar, stringReplacements map[string]string, arrayReplacements map[string][]string) { +func ApplySidecarReplacements(sidecar *v1.Sidecar, stringReplacements map[string]string, arrayReplacements map[string][]string) { sidecar.Script = substitution.ApplyReplacements(sidecar.Script, stringReplacements) applySidecarReplacements(sidecar, stringReplacements, arrayReplacements) } diff --git a/pkg/container/sidecar_replacements_test.go b/pkg/container/sidecar_replacements_test.go index e93bdcc955f..1e29bede487 100644 --- a/pkg/container/sidecar_replacements_test.go +++ b/pkg/container/sidecar_replacements_test.go @@ -20,7 +20,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/container" corev1 "k8s.io/api/core/v1" ) @@ -34,7 +34,7 @@ func TestApplySidecarReplacements(t *testing.T) { "array.replace.me": {"val1", "val2"}, } - s := v1beta1.Sidecar{ + s := v1.Sidecar{ Script: "$(replace.me)", Name: "$(replace.me)", Image: "$(replace.me)", @@ -78,7 +78,7 @@ func TestApplySidecarReplacements(t *testing.T) { }}, } - expected := v1beta1.Sidecar{ + expected := v1.Sidecar{ Script: "replaced!", Name: "replaced!", Image: "replaced!", diff --git a/pkg/container/step_replacements.go b/pkg/container/step_replacements.go index 1640e749ce9..921995157a2 100644 --- a/pkg/container/step_replacements.go +++ b/pkg/container/step_replacements.go @@ -17,14 +17,14 @@ package container import ( - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/substitution" ) // ApplyStepReplacements applies variable interpolation on a Step. -func ApplyStepReplacements(step *v1beta1.Step, stringReplacements map[string]string, arrayReplacements map[string][]string) { +func ApplyStepReplacements(step *v1.Step, stringReplacements map[string]string, arrayReplacements map[string][]string) { step.Script = substitution.ApplyReplacements(step.Script, stringReplacements) - step.OnError = (v1beta1.OnErrorType)(substitution.ApplyReplacements(string(step.OnError), stringReplacements)) + step.OnError = (v1.OnErrorType)(substitution.ApplyReplacements(string(step.OnError), stringReplacements)) if step.StdoutConfig != nil { step.StdoutConfig.Path = substitution.ApplyReplacements(step.StdoutConfig.Path, stringReplacements) } @@ -35,7 +35,7 @@ func ApplyStepReplacements(step *v1beta1.Step, stringReplacements map[string]str } // ApplyStepTemplateReplacements applies variable interpolation on a StepTemplate (aka a container) -func ApplyStepTemplateReplacements(stepTemplate *v1beta1.StepTemplate, stringReplacements map[string]string, arrayReplacements map[string][]string) { +func ApplyStepTemplateReplacements(stepTemplate *v1.StepTemplate, stringReplacements map[string]string, arrayReplacements map[string][]string) { container := stepTemplate.ToK8sContainer() applyContainerReplacements(container, stringReplacements, arrayReplacements) stepTemplate.SetContainerFields(*container) diff --git a/pkg/container/step_replacements_test.go b/pkg/container/step_replacements_test.go index 05a7b805fb7..4da6e4acf70 100644 --- a/pkg/container/step_replacements_test.go +++ b/pkg/container/step_replacements_test.go @@ -20,7 +20,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/container" corev1 "k8s.io/api/core/v1" ) @@ -35,7 +35,7 @@ func TestApplyStepReplacements(t *testing.T) { "array.replace.me": {"val1", "val2"}, } - s := v1beta1.Step{ + s := v1.Step{ Script: "$(replace.me)", Name: "$(replace.me)", Image: "$(replace.me)", @@ -78,15 +78,15 @@ func TestApplyStepReplacements(t *testing.T) { MountPath: "$(replace.me)", SubPath: "$(replace.me)", }}, - StdoutConfig: &v1beta1.StepOutputConfig{ + StdoutConfig: &v1.StepOutputConfig{ Path: "$(workspaces.data.path)/stdout.txt", }, - StderrConfig: &v1beta1.StepOutputConfig{ + StderrConfig: &v1.StepOutputConfig{ Path: "$(workspaces.data.path)/stderr.txt", }, } - expected := v1beta1.Step{ + expected := v1.Step{ Script: "replaced!", Name: "replaced!", Image: "replaced!", @@ -129,10 +129,10 @@ func TestApplyStepReplacements(t *testing.T) { MountPath: "replaced!", SubPath: "replaced!", }}, - StdoutConfig: &v1beta1.StepOutputConfig{ + StdoutConfig: &v1.StepOutputConfig{ Path: "/workspace/data/stdout.txt", }, - StderrConfig: &v1beta1.StepOutputConfig{ + StderrConfig: &v1.StepOutputConfig{ Path: "/workspace/data/stderr.txt", }, } diff --git a/pkg/controller/filter.go b/pkg/controller/filter.go index 2a3674b40c9..70e9250e46a 100644 --- a/pkg/controller/filter.go +++ b/pkg/controller/filter.go @@ -20,6 +20,7 @@ package controller import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" listersalpha "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" @@ -53,7 +54,7 @@ func FilterRunRef(apiVersion, kind string) func(interface{}) bool { } result := false if r.Spec.Ref != nil { - result = r.Spec.Ref.APIVersion == apiVersion && r.Spec.Ref.Kind == v1beta1.TaskKind(kind) + result = r.Spec.Ref.APIVersion == apiVersion && r.Spec.Ref.Kind == v1.TaskKind(kind) } else if r.Spec.Spec != nil { result = r.Spec.Spec.APIVersion == apiVersion && r.Spec.Spec.Kind == kind } @@ -99,7 +100,7 @@ func FilterOwnerRunRef(runLister listersalpha.RunLister, apiVersion, kind string } result := false if run.Spec.Ref != nil { - result = run.Spec.Ref.APIVersion == apiVersion && run.Spec.Ref.Kind == v1beta1.TaskKind(kind) + result = run.Spec.Ref.APIVersion == apiVersion && run.Spec.Ref.Kind == v1.TaskKind(kind) } else if run.Spec.Spec != nil { result = run.Spec.Spec.APIVersion == apiVersion && run.Spec.Spec.Kind == kind } diff --git a/pkg/controller/filter_test.go b/pkg/controller/filter_test.go index fb9729958ae..9e4fdc7b24c 100644 --- a/pkg/controller/filter_test.go +++ b/pkg/controller/filter_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/tektoncd/pipeline/pkg/apis/pipeline" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" fakeruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/run/fake" @@ -65,7 +66,7 @@ func TestFilterRunRef(t *testing.T) { desc: "both ref and spec", in: &v1alpha1.Run{ Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "not-matching", Kind: kind, }, @@ -82,7 +83,7 @@ func TestFilterRunRef(t *testing.T) { desc: "Run without matching apiVersion in taskRef", in: &v1alpha1.Run{ Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: "not-matching", Kind: kind, }, @@ -93,7 +94,7 @@ func TestFilterRunRef(t *testing.T) { desc: "Run without matching kind in taskRef", in: &v1alpha1.Run{ Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: apiVersion, Kind: "not-matching", }, @@ -104,7 +105,7 @@ func TestFilterRunRef(t *testing.T) { desc: "Run with matching apiVersion and kind in taskRef", in: &v1alpha1.Run{ Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: apiVersion, Kind: kind, }, @@ -154,7 +155,7 @@ func TestFilterRunRef(t *testing.T) { desc: "Run with matching apiVersion and kind and name for taskRef", in: &v1alpha1.Run{ Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: apiVersion, Kind: kind, Name: "some-name", @@ -202,7 +203,7 @@ func TestFilterOwnerRunRef(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: apiVersion, Kind: kind, }, @@ -266,7 +267,7 @@ func TestFilterOwnerRunRef(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: apiVersion2, // different apiversion Kind: kind, }, @@ -330,7 +331,7 @@ func TestFilterOwnerRunRef(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: apiVersion, Kind: kind2, // different kind }, @@ -420,7 +421,7 @@ func TestFilterOwnerRunRef(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.RunSpec{ - Ref: &v1beta1.TaskRef{ + Ref: &v1.TaskRef{ APIVersion: apiVersion, Kind: kind, }, diff --git a/pkg/internal/resolution/resolved_meta.go b/pkg/internal/resolution/resolved_meta.go index e3776347155..969266a9341 100644 --- a/pkg/internal/resolution/resolved_meta.go +++ b/pkg/internal/resolution/resolved_meta.go @@ -17,7 +17,7 @@ limitations under the License. package resolution import ( - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -25,5 +25,5 @@ import ( type ResolvedObjectMeta struct { *metav1.ObjectMeta `json:",omitempty"` // ConfigSource identifies where the spec came from. - ConfigSource *v1beta1.ConfigSource `json:",omitempty"` + ConfigSource *v1.ConfigSource `json:",omitempty"` } diff --git a/pkg/pod/entrypoint.go b/pkg/pod/entrypoint.go index e62b04b6fc3..aebd06cafbd 100644 --- a/pkg/pod/entrypoint.go +++ b/pkg/pod/entrypoint.go @@ -28,7 +28,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "gomodules.xyz/jsonpatch/v2" corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" @@ -114,7 +114,7 @@ var ( // command, we must have fetched the image's ENTRYPOINT before calling this // method, using entrypoint_lookup.go. // Additionally, Step timeouts are added as entrypoint flag. -func orderContainers(commonExtraEntrypointArgs []string, steps []corev1.Container, taskSpec *v1beta1.TaskSpec, breakpointConfig *v1beta1.TaskRunDebug, waitForReadyAnnotation bool) ([]corev1.Container, error) { +func orderContainers(commonExtraEntrypointArgs []string, steps []corev1.Container, taskSpec *v1.TaskSpec, breakpointConfig *v1.TaskRunDebug, waitForReadyAnnotation bool) ([]corev1.Container, error) { if len(steps) == 0 { return nil, errors.New("No steps specified") } @@ -143,9 +143,9 @@ func orderContainers(commonExtraEntrypointArgs []string, steps []corev1.Containe if taskSpec != nil { if taskSpec.Steps != nil && len(taskSpec.Steps) >= i+1 { if taskSpec.Steps[i].OnError != "" { - if taskSpec.Steps[i].OnError != v1beta1.Continue && taskSpec.Steps[i].OnError != v1beta1.StopAndFail { + if taskSpec.Steps[i].OnError != v1.Continue && taskSpec.Steps[i].OnError != v1.StopAndFail { return nil, fmt.Errorf("task step onError must be either \"%s\" or \"%s\" but it is set to an invalid value \"%s\"", - v1beta1.Continue, v1beta1.StopAndFail, taskSpec.Steps[i].OnError) + v1.Continue, v1.StopAndFail, taskSpec.Steps[i].OnError) } argsForEntrypoint = append(argsForEntrypoint, "-on_error", string(taskSpec.Steps[i].OnError)) } @@ -194,14 +194,14 @@ func orderContainers(commonExtraEntrypointArgs []string, steps []corev1.Containe return steps, nil } -func resultArgument(steps []corev1.Container, results []v1beta1.TaskResult) []string { +func resultArgument(steps []corev1.Container, results []v1.TaskResult) []string { if len(results) == 0 { return nil } return []string{"-results", collectResultsName(results)} } -func collectResultsName(results []v1beta1.TaskResult) string { +func collectResultsName(results []v1.TaskResult) string { var resultNames []string for _, r := range results { resultNames = append(resultNames, r.Name) @@ -283,7 +283,7 @@ func StopSidecars(ctx context.Context, nopImage string, kubeclient kubernetes.In // IsSidecarStatusRunning determines if any SidecarStatus on a TaskRun // is still running. -func IsSidecarStatusRunning(tr *v1beta1.TaskRun) bool { +func IsSidecarStatusRunning(tr *v1.TaskRun) bool { for _, sidecar := range tr.Status.Sidecars { if sidecar.Terminated == nil { return true diff --git a/pkg/pod/entrypoint_lookup_impl_test.go b/pkg/pod/entrypoint_lookup_impl_test.go index f18e4a8fced..8d02746bbae 100644 --- a/pkg/pod/entrypoint_lookup_impl_test.go +++ b/pkg/pod/entrypoint_lookup_impl_test.go @@ -29,11 +29,10 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/registry" - v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/empty" "github.com/google/go-containerregistry/pkg/v1/mutate" "github.com/google/go-containerregistry/pkg/v1/random" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" remotetest "github.com/tektoncd/pipeline/test" "github.com/tektoncd/pipeline/test/diff" corev1 "k8s.io/api/core/v1" @@ -111,9 +110,9 @@ func TestGetImageWithImagePullSecrets(t *testing.T) { t.Errorf("Parsing url with an error: %v", err) } - task := &v1beta1.Task{ + task := &v1.Task{ TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task"}, ObjectMeta: metav1.ObjectMeta{ Name: "test-create-image"}, diff --git a/pkg/pod/entrypoint_test.go b/pkg/pod/entrypoint_test.go index 261862f1360..38ac79b68ba 100644 --- a/pkg/pod/entrypoint_test.go +++ b/pkg/pod/entrypoint_test.go @@ -25,7 +25,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/test/diff" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -240,7 +240,7 @@ func TestOrderContainersWithDebugOnFailure(t *testing.T) { VolumeMounts: []corev1.VolumeMount{downwardMount}, TerminationMessagePath: "/tekton/termination", }} - taskRunDebugConfig := &v1beta1.TaskRunDebug{ + taskRunDebugConfig := &v1.TaskRunDebug{ Breakpoint: []string{"onFailure"}, } got, err := orderContainers([]string{}, steps, nil, taskRunDebugConfig, true) @@ -253,8 +253,8 @@ func TestOrderContainersWithDebugOnFailure(t *testing.T) { } func TestEntryPointResults(t *testing.T) { - taskSpec := v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + taskSpec := v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "sum", Description: "This is the sum result of the task", }, { @@ -331,8 +331,8 @@ func TestEntryPointResults(t *testing.T) { } func TestEntryPointResultsSingleStep(t *testing.T) { - taskSpec := v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + taskSpec := v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "sum", Description: "This is the sum result of the task", }, { @@ -371,8 +371,8 @@ func TestEntryPointResultsSingleStep(t *testing.T) { } } func TestEntryPointSingleResultsSingleStep(t *testing.T) { - taskSpec := v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + taskSpec := v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "sum", Description: "This is the sum result of the task", }}, @@ -421,15 +421,15 @@ func TestEntryPointOnError(t *testing.T) { for _, tc := range []struct { desc string - taskSpec v1beta1.TaskSpec + taskSpec v1.TaskSpec wantContainers []corev1.Container err error }{{ - taskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - OnError: v1beta1.Continue, + taskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ + OnError: v1.Continue, }, { - OnError: v1beta1.StopAndFail, + OnError: v1.StopAndFail, }}, }, wantContainers: []corev1.Container{{ @@ -462,8 +462,8 @@ func TestEntryPointOnError(t *testing.T) { TerminationMessagePath: "/tekton/termination", }}, }, { - taskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + taskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ OnError: "invalid-on-error", }}, }, @@ -491,20 +491,20 @@ func TestEntryPointOnError(t *testing.T) { } func TestEntryPointStepOutputConfigs(t *testing.T) { - taskSpec := v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - StdoutConfig: &v1beta1.StepOutputConfig{ + taskSpec := v1.TaskSpec{ + Steps: []v1.Step{{ + StdoutConfig: &v1.StepOutputConfig{ Path: "step-1-out", }, }, { - StderrConfig: &v1beta1.StepOutputConfig{ + StderrConfig: &v1.StepOutputConfig{ Path: "step-2-err", }, }, { - StdoutConfig: &v1beta1.StepOutputConfig{ + StdoutConfig: &v1.StepOutputConfig{ Path: "step-3-out", }, - StderrConfig: &v1beta1.StepOutputConfig{ + StderrConfig: &v1.StepOutputConfig{ Path: "step-3-err", }, }}, diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index 820aac62663..c74284a9c47 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -28,7 +28,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/internal/computeresources/tasklevel" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" @@ -60,8 +60,8 @@ var ( ReleaseAnnotation = "pipeline.tekton.dev/release" groupVersionKind = schema.GroupVersionKind{ - Group: v1beta1.SchemeGroupVersion.Group, - Version: v1beta1.SchemeGroupVersion.Version, + Group: v1.SchemeGroupVersion.Group, + Version: v1.SchemeGroupVersion.Version, Kind: "TaskRun", } // These are injected into all of the source/step containers. @@ -111,7 +111,7 @@ type Transformer func(*corev1.Pod) (*corev1.Pod, error) // Build creates a Pod using the configuration options set on b and the TaskRun // and TaskSpec provided in its arguments. An error is returned if there are // any problems during the conversion. -func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec v1beta1.TaskSpec, transformers ...Transformer) (*corev1.Pod, error) { +func (b *Builder) Build(ctx context.Context, taskRun *v1.TaskRun, taskSpec v1.TaskSpec, transformers ...Transformer) (*corev1.Pod, error) { var ( scriptsInit *corev1.Container initContainers, stepContainers, sidecarContainers []corev1.Container @@ -142,11 +142,11 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec // Merge step template with steps. // TODO(#1605): Move MergeSteps to pkg/pod - steps, err := v1beta1.MergeStepsWithStepTemplate(taskSpec.StepTemplate, taskSpec.Steps) + steps, err := v1.MergeStepsWithStepTemplate(taskSpec.StepTemplate, taskSpec.Steps) if err != nil { return nil, err } - steps, err = v1beta1.MergeStepsWithOverrides(steps, taskRun.Spec.StepOverrides) + steps, err = v1.MergeStepsWithOverrides(steps, taskRun.Spec.StepOverrides) if err != nil { return nil, err } @@ -159,7 +159,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec taskSpec.Sidecars = append(taskSpec.Sidecars, resultsSidecar) commonExtraEntrypointArgs = append(commonExtraEntrypointArgs, "-result_from", config.ResultExtractionMethodSidecarLogs) } - sidecars, err := v1beta1.MergeSidecarsWithOverrides(taskSpec.Sidecars, taskRun.Spec.SidecarOverrides) + sidecars, err := v1.MergeSidecarsWithOverrides(taskSpec.Sidecars, taskRun.Spec.SidecarOverrides) if err != nil { return nil, err } @@ -318,7 +318,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec volumes = append(volumes, taskSpec.Volumes...) volumes = append(volumes, podTemplate.Volumes...) - if err := v1beta1.ValidateVolumes(volumes); err != nil { + if err := v1.ValidateVolumes(volumes); err != nil { return nil, err } @@ -410,7 +410,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec } // makeLabels constructs the labels we will propagate from TaskRuns to Pods. -func makeLabels(s *v1beta1.TaskRun) map[string]string { +func makeLabels(s *v1.TaskRun) map[string]string { labels := make(map[string]string, len(s.ObjectMeta.Labels)+1) // NB: Set this *before* passing through TaskRun labels. If the TaskRun // has a managed-by label, it should override this default. @@ -430,7 +430,7 @@ func makeLabels(s *v1beta1.TaskRun) map[string]string { // controller should consider the Pod "Ready" as soon as it's deployed. // This will add the `Ready` annotation when creating the Pod, // and prevent the first step from waiting for the annotation to appear before starting. -func isPodReadyImmediately(featureFlags config.FeatureFlags, sidecars []v1beta1.Sidecar) bool { +func isPodReadyImmediately(featureFlags config.FeatureFlags, sidecars []v1.Sidecar) bool { // If the TaskRun has sidecars, we must wait for them if len(sidecars) > 0 || featureFlags.RunningInEnvWithInjectedSidecars { if featureFlags.AwaitSidecarReadiness { @@ -458,7 +458,7 @@ func runVolume(i int) corev1.Volume { // entrypointInitContainer generates a few init containers based of a set of command (in images) and volumes to run // This should effectively merge multiple command and volumes together. -func entrypointInitContainer(image string, steps []v1beta1.Step) corev1.Container { +func entrypointInitContainer(image string, steps []v1.Step) corev1.Container { // Invoke the entrypoint binary in "cp mode" to copy itself // into the correct location for later steps and initialize steps folder command := []string{"/ko-app/entrypoint", "init", "/ko-app/entrypoint", entrypointBinary} @@ -484,14 +484,14 @@ func entrypointInitContainer(image string, steps []v1beta1.Step) corev1.Containe } // createResultsSidecar creates a sidecar that will run the sidecarlogresults binary. -func createResultsSidecar(taskSpec v1beta1.TaskSpec, image string) v1beta1.Sidecar { +func createResultsSidecar(taskSpec v1.TaskSpec, image string) v1.Sidecar { names := make([]string, 0, len(taskSpec.Results)) for _, r := range taskSpec.Results { names = append(names, r.Name) } resultsStr := strings.Join(names, ",") command := []string{"/ko-app/sidecarlogresults", "-results-dir", pipeline.DefaultResultPath, "-result-names", resultsStr} - return v1beta1.Sidecar{ + return v1.Sidecar{ Name: pipeline.ReservedResultsSidecarName, Image: image, Command: command, diff --git a/pkg/pod/pod_test.go b/pkg/pod/pod_test.go index 37f62924c00..b07f48a06bc 100644 --- a/pkg/pod/pod_test.go +++ b/pkg/pod/pod_test.go @@ -29,7 +29,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" @@ -87,11 +87,11 @@ func TestPodBuild(t *testing.T) { for _, c := range []struct { desc string - trs v1beta1.TaskRunSpec + trs v1.TaskRunSpec trAnnotation map[string]string - trStatus v1beta1.TaskRunStatus + trStatus v1.TaskRunStatus trName string - ts v1beta1.TaskSpec + ts v1.TaskSpec configDefaults map[string]string featureFlags map[string]string want *corev1.PodSpec @@ -99,8 +99,8 @@ func TestPodBuild(t *testing.T) { wantPodName string }{{ desc: "simple", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -108,7 +108,7 @@ func TestPodBuild(t *testing.T) { }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -141,13 +141,13 @@ func TestPodBuild(t *testing.T) { }, }, { desc: "simple with breakpoint onFailure enabled, alpha api fields disabled", - trs: v1beta1.TaskRunSpec{ - Debug: &v1beta1.TaskRunDebug{ + trs: v1.TaskRunSpec{ + Debug: &v1.TaskRunDebug{ Breakpoint: []string{breakpointOnFailure}, }, }, - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -155,7 +155,7 @@ func TestPodBuild(t *testing.T) { }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -188,8 +188,8 @@ func TestPodBuild(t *testing.T) { }, }, { desc: "simple with running-in-environment-with-injected-sidecar set to false", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -200,7 +200,7 @@ func TestPodBuild(t *testing.T) { }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -233,20 +233,20 @@ func TestPodBuild(t *testing.T) { }, }, { desc: "with service account", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ ServiceAccountName: "service-account", }, want: &corev1.PodSpec{ ServiceAccountName: "service-account", RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -286,14 +286,14 @@ func TestPodBuild(t *testing.T) { }, }, { desc: "with-pod-template", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ PodTemplate: &pod.Template{ SecurityContext: &corev1.PodSecurityContext{ Sysctls: []corev1.Sysctl{ @@ -313,7 +313,7 @@ func TestPodBuild(t *testing.T) { }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -361,8 +361,8 @@ func TestPodBuild(t *testing.T) { }, }, { desc: "very long step name", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "a-very-very-long-character-step-name-to-trigger-max-len----and-invalid-characters", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -370,7 +370,7 @@ func TestPodBuild(t *testing.T) { }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "a-very-very-long-character-step-name-to-trigger-max-len----and-invalid-characters"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "a-very-very-long-character-step-name-to-trigger-max-len----and-invalid-characters"}})}, Containers: []corev1.Container{{ Name: "step-a-very-very-long-character-step-name-to-trigger-max-len", // step name trimmed. Image: "image", @@ -403,8 +403,8 @@ func TestPodBuild(t *testing.T) { }, }, { desc: "step name ends with non alphanumeric", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ends-with-invalid-%%__$$", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -412,7 +412,7 @@ func TestPodBuild(t *testing.T) { }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "ends-with-invalid-%%__$$"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "ends-with-invalid-%%__$$"}})}, Containers: []corev1.Container{{ Name: "step-ends-with-invalid", // invalid suffix removed. Image: "image", @@ -445,8 +445,8 @@ func TestPodBuild(t *testing.T) { }, }, { desc: "workingDir in workspace", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -456,7 +456,7 @@ func TestPodBuild(t *testing.T) { want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{ - entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}}), + entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}}), { Name: "working-dir-initializer", Image: images.WorkingDirInitImage, @@ -499,13 +499,13 @@ func TestPodBuild(t *testing.T) { }, }, { desc: "sidecar container", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "primary-name", Image: "primary-image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ Name: "sc-name", Image: "sidecar-image", }}, @@ -513,7 +513,7 @@ func TestPodBuild(t *testing.T) { wantAnnotations: map[string]string{}, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "primary-name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "primary-name"}})}, Containers: []corev1.Container{{ Name: "step-primary-name", Image: "primary-image", @@ -552,13 +552,13 @@ func TestPodBuild(t *testing.T) { }, }, { desc: "sidecar container with script", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "primary-name", Image: "primary-image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ Name: "sc-name", Image: "sidecar-image", Script: "#!/bin/sh\necho hello from sidecar", @@ -568,7 +568,7 @@ func TestPodBuild(t *testing.T) { want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{ - entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "primary-name"}}), + entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "primary-name"}}), { Name: "place-scripts", Image: "busybox", @@ -620,13 +620,13 @@ _EOF_ }, }, { desc: "sidecar container with enable-ready-annotation-on-pod-create", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "primary-name", Image: "primary-image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ Name: "sc-name", Image: "sidecar-image", }}, @@ -637,7 +637,7 @@ _EOF_ wantAnnotations: map[string]string{}, // no ready annotations on pod create since sidecars are present want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "primary-name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "primary-name"}})}, Containers: []corev1.Container{{ Name: "step-primary-name", Image: "primary-image", @@ -673,8 +673,8 @@ _EOF_ }, }, { desc: "resource request", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. Resources: corev1.ResourceRequirements{ @@ -696,7 +696,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{ + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{ {Name: "unnamed-0"}, {Name: "unnamed-1"}, })}, @@ -769,8 +769,8 @@ _EOF_ }, }, { desc: "with stepOverrides", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "image", Command: []string{"cmd"}, @@ -782,8 +782,8 @@ _EOF_ }, }}, }, - trs: v1beta1.TaskRunSpec{ - StepOverrides: []v1beta1.TaskRunStepOverride{{ + trs: v1.TaskRunSpec{ + StepOverrides: []v1.TaskRunStepOverride{{ Name: "step1", Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ @@ -795,7 +795,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{ + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{ {Name: "step1"}, })}, Containers: []corev1.Container{{ @@ -836,8 +836,8 @@ _EOF_ }, }, { desc: "with stepOverrides and stepTemplate", - ts: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + ts: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("8"), @@ -845,14 +845,14 @@ _EOF_ }, }, }, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "image", Command: []string{"cmd"}, }}, }, - trs: v1beta1.TaskRunSpec{ - StepOverrides: []v1beta1.TaskRunStepOverride{{ + trs: v1.TaskRunSpec{ + StepOverrides: []v1.TaskRunStepOverride{{ Name: "step1", Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ @@ -864,7 +864,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{ + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{ {Name: "step1"}, })}, Containers: []corev1.Container{{ @@ -905,13 +905,13 @@ _EOF_ }, }, { desc: "with sidecarOverrides", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "primary-name", Image: "primary-image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ Name: "sc-name", Image: "sidecar-image", Resources: corev1.ResourceRequirements{ @@ -922,8 +922,8 @@ _EOF_ }, }}, }, - trs: v1beta1.TaskRunSpec{ - SidecarOverrides: []v1beta1.TaskRunSidecarOverride{{ + trs: v1.TaskRunSpec{ + SidecarOverrides: []v1.TaskRunSidecarOverride{{ Name: "sc-name", Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ @@ -936,7 +936,7 @@ _EOF_ wantAnnotations: map[string]string{}, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "primary-name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "primary-name"}})}, Containers: []corev1.Container{{ Name: "step-primary-name", Image: "primary-image", @@ -978,12 +978,12 @@ _EOF_ }, }, { desc: "step with script and stepTemplate", - ts: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + ts: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ Env: []corev1.EnvVar{{Name: "FOO", Value: "bar"}}, Args: []string{"template", "args"}, }, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "one", Image: "image", Script: "#!/bin/sh\necho hello from step one", @@ -1002,7 +1002,7 @@ print("Hello from Python")`, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{ - entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{ + entrypointInitContainer(images.EntrypointImage, []v1.Step{ {Name: "one"}, {Name: "two"}, {Name: "regular-step"}, @@ -1119,8 +1119,8 @@ _EOF_ }, }, { desc: "step with script that uses two dollar signs", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "one", Image: "image", Script: "#!/bin/sh\n$$", @@ -1128,7 +1128,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "one"}}), + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "one"}}), { Name: "place-scripts", Image: images.ShellImage, @@ -1175,8 +1175,8 @@ _EOF_ }, }, { desc: "using another scheduler", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{ + ts: v1.TaskSpec{ + Steps: []v1.Step{ { Name: "schedule-me", Image: "image", @@ -1184,14 +1184,14 @@ _EOF_ }, }, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ PodTemplate: &pod.Template{ SchedulerName: "there-scheduler", }, }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "schedule-me"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "schedule-me"}})}, SchedulerName: "there-scheduler", Volumes: append(implicitVolumes, binVolume, runVolume(0), downwardVolume, corev1.Volume{ Name: "tekton-creds-init-home-0", @@ -1226,8 +1226,8 @@ _EOF_ }, }, { desc: "setting image pull secret", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{ + ts: v1.TaskSpec{ + Steps: []v1.Step{ { Name: "image-pull", Image: "image", @@ -1235,14 +1235,14 @@ _EOF_ }, }, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ PodTemplate: &pod.Template{ ImagePullSecrets: []corev1.LocalObjectReference{{Name: "imageSecret"}}, }, }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "image-pull"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "image-pull"}})}, Volumes: append(implicitVolumes, binVolume, runVolume(0), downwardVolume, corev1.Volume{ Name: "tekton-creds-init-home-0", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{Medium: corev1.StorageMediumMemory}}, @@ -1276,8 +1276,8 @@ _EOF_ }}, { desc: "setting host aliases", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{ + ts: v1.TaskSpec{ + Steps: []v1.Step{ { Name: "host-aliases", Image: "image", @@ -1285,14 +1285,14 @@ _EOF_ }, }, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ PodTemplate: &pod.Template{ HostAliases: []corev1.HostAlias{{IP: "127.0.0.1", Hostnames: []string{"foo.bar"}}}, }, }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "host-aliases"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "host-aliases"}})}, Volumes: append(implicitVolumes, binVolume, runVolume(0), downwardVolume, corev1.Volume{ Name: "tekton-creds-init-home-0", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{Medium: corev1.StorageMediumMemory}}, @@ -1325,8 +1325,8 @@ _EOF_ ActiveDeadlineSeconds: &defaultActiveDeadlineSeconds, }}, { desc: "using hostNetwork", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{ + ts: v1.TaskSpec{ + Steps: []v1.Step{ { Name: "use-my-hostNetwork", Image: "image", @@ -1334,14 +1334,14 @@ _EOF_ }, }, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ PodTemplate: &pod.Template{ HostNetwork: true, }, }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "use-my-hostNetwork"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "use-my-hostNetwork"}})}, HostNetwork: true, Volumes: append(implicitVolumes, binVolume, runVolume(0), downwardVolume, corev1.Volume{ Name: "tekton-creds-init-home-0", @@ -1375,8 +1375,8 @@ _EOF_ }, }, { desc: "step-with-timeout", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -1385,7 +1385,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -1420,20 +1420,20 @@ _EOF_ }, }, { desc: "step-with-no-timeout-equivalent-to-0-second-timeout", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. Timeout: &metav1.Duration{Duration: 0 * time.Second}, }}, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ Timeout: &metav1.Duration{Duration: 0 * time.Second}, }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -1471,8 +1471,8 @@ _EOF_ featureFlags: map[string]string{ "disable-creds-init": "true", }, - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -1480,7 +1480,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -1507,8 +1507,8 @@ _EOF_ }, }, { desc: "default-forbidden-env - disallowed via podTemplate.", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -1517,7 +1517,7 @@ _EOF_ }}, }, configDefaults: map[string]string{"default-forbidden-env": "FORBIDDEN_ENV, TEST_ENV"}, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ PodTemplate: &pod.Template{ Env: []corev1.EnvVar{{Name: "FORBIDDEN_ENV", Value: "overridden_val"}, {Name: "TEST_ENV", Value: "new_val"}}, @@ -1525,7 +1525,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -1562,15 +1562,15 @@ _EOF_ }, }, { desc: "override env var using podTemplate", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. Env: []corev1.EnvVar{{Name: "SOME_ENV", Value: "some_val"}}, }}, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ PodTemplate: &pod.Template{ Env: []corev1.EnvVar{{Name: "SOME_ENV", Value: "overridden_val"}, {Name: "SOME_ENV2", Value: "new_val"}}, @@ -1578,7 +1578,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -1617,8 +1617,8 @@ _EOF_ }, { desc: "hermetic env var", featureFlags: map[string]string{"enable-api-fields": "alpha"}, - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -1629,7 +1629,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -1666,8 +1666,8 @@ _EOF_ }, { desc: "override hermetic env var", featureFlags: map[string]string{"enable-api-fields": "alpha"}, - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -1679,7 +1679,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -1717,16 +1717,16 @@ _EOF_ }, }, { desc: "pod for a taskRun with retries", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}, }, - trStatus: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - RetriesStatus: []v1beta1.TaskRunStatus{{ + trStatus: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + RetriesStatus: []v1.TaskRunStatus{{ Status: duckv1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -1745,7 +1745,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -1779,8 +1779,8 @@ _EOF_ wantPodName: fmt.Sprintf("%s-pod-retry2", taskRunName), }, { desc: "long-taskrun-name", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -1790,7 +1790,7 @@ _EOF_ wantPodName: "task-run-0123456789-01234560d38957287bb0283c59440df14069f59-pod", want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}})}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -1823,8 +1823,8 @@ _EOF_ }, }, { desc: "using TopologySpreadConstraints", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{ + ts: v1.TaskSpec{ + Steps: []v1.Step{ { Name: "use-topologySpreadConstraints", Image: "image", @@ -1832,7 +1832,7 @@ _EOF_ }, }, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ PodTemplate: &pod.Template{ TopologySpreadConstraints: []corev1.TopologySpreadConstraint{ { @@ -1850,7 +1850,7 @@ _EOF_ }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "use-topologySpreadConstraints"}})}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "use-topologySpreadConstraints"}})}, TopologySpreadConstraints: []corev1.TopologySpreadConstraint{ { MaxSkew: 1, @@ -1896,12 +1896,12 @@ _EOF_ }, { desc: "sidecar logs enabled", featureFlags: map[string]string{"results-from": "sidecar-logs"}, - ts: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + ts: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "foo", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -1910,7 +1910,7 @@ _EOF_ want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{ - entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}}), + entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}}), }, Containers: []corev1.Container{{ Name: "step-name", @@ -2016,7 +2016,7 @@ _EOF_ if c.trName != "" { testTaskRunName = c.trName } - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: testTaskRunName, Namespace: "default", @@ -2124,20 +2124,20 @@ debug-fail-continue-heredoc-randomly-generated-mz4c7 for _, c := range []struct { desc string - trs v1beta1.TaskRunSpec + trs v1.TaskRunSpec trAnnotation map[string]string - ts v1beta1.TaskSpec + ts v1.TaskSpec want *corev1.PodSpec wantAnnotations map[string]string }{{ desc: "simple with debug breakpoint onFailure", - trs: v1beta1.TaskRunSpec{ - Debug: &v1beta1.TaskRunDebug{ + trs: v1.TaskRunSpec{ + Debug: &v1.TaskRunDebug{ Breakpoint: []string{breakpointOnFailure}, }, }, - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. @@ -2145,7 +2145,7 @@ debug-fail-continue-heredoc-randomly-generated-mz4c7 }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, - InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1beta1.Step{{Name: "name"}}), placeScriptsContainer}, + InitContainers: []corev1.Container{entrypointInitContainer(images.EntrypointImage, []v1.Step{{Name: "name"}}), placeScriptsContainer}, Containers: []corev1.Container{{ Name: "step-name", Image: "image", @@ -2220,7 +2220,7 @@ debug-fail-continue-heredoc-randomly-generated-mz4c7 trAnnotations = c.trAnnotation trAnnotations[ReleaseAnnotation] = fakeVersion } - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "taskrun-name", Namespace: "default", @@ -2268,13 +2268,13 @@ type ExpectedComputeResources struct { func TestPodBuild_TaskLevelResourceRequirements(t *testing.T) { testcases := []struct { desc string - ts v1beta1.TaskSpec - trs v1beta1.TaskRunSpec + ts v1.TaskSpec + trs v1.TaskRunSpec expectedComputeResources []ExpectedComputeResources }{{ desc: "overwrite stepTemplate resources requirements", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "1st-step", Image: "image", Command: []string{"cmd"}, @@ -2283,7 +2283,7 @@ func TestPodBuild_TaskLevelResourceRequirements(t *testing.T) { Image: "image", Command: []string{"cmd"}, }}, - StepTemplate: &v1beta1.StepTemplate{ + StepTemplate: &v1.StepTemplate{ Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("500m"), @@ -2292,7 +2292,7 @@ func TestPodBuild_TaskLevelResourceRequirements(t *testing.T) { }, }, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ ComputeResources: &corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("2"), @@ -2319,8 +2319,8 @@ func TestPodBuild_TaskLevelResourceRequirements(t *testing.T) { }}, }, { desc: "overwrite step resources requirements", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "1st-step", Image: "image", Command: []string{"cmd"}, @@ -2342,7 +2342,7 @@ func TestPodBuild_TaskLevelResourceRequirements(t *testing.T) { }, }}, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ ComputeResources: &corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("2"), @@ -2369,13 +2369,13 @@ func TestPodBuild_TaskLevelResourceRequirements(t *testing.T) { }}, }, { desc: "with sidecar resource requirements", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "1st-step", Image: "image", Command: []string{"cmd"}, }}, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ Name: "sidecar", Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ @@ -2387,7 +2387,7 @@ func TestPodBuild_TaskLevelResourceRequirements(t *testing.T) { }, }}, }, - trs: v1beta1.TaskRunSpec{ + trs: v1.TaskRunSpec{ ComputeResources: &corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("2"), @@ -2435,7 +2435,7 @@ func TestPodBuild_TaskLevelResourceRequirements(t *testing.T) { Images: images, KubeClient: kubeclient, } - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "foo-taskrun", Namespace: "default", @@ -2478,7 +2478,7 @@ func TestMakeLabels(t *testing.T) { "foo": "bar", "hello": "world", } - got := makeLabels(&v1beta1.TaskRun{ + got := makeLabels(&v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: taskRunName, Labels: map[string]string{ @@ -2493,7 +2493,7 @@ func TestMakeLabels(t *testing.T) { } func TestIsPodReadyImmediately(t *testing.T) { - sd := v1beta1.Sidecar{ + sd := v1.Sidecar{ Name: "a-sidecar", } @@ -2507,22 +2507,22 @@ func TestIsPodReadyImmediately(t *testing.T) { tcs := []struct { description string - sidecars []v1beta1.Sidecar + sidecars []v1.Sidecar featureFlags *config.FeatureFlags expected bool }{{ description: "Default behavior with sidecars present: Pod is not ready on create", - sidecars: []v1beta1.Sidecar{sd}, + sidecars: []v1.Sidecar{sd}, featureFlags: getFeatureFlags(map[string]string{}), expected: false, }, { description: "Default behavior with no sidecars present: Pod is not ready on create", - sidecars: []v1beta1.Sidecar{}, + sidecars: []v1.Sidecar{}, featureFlags: getFeatureFlags(map[string]string{}), expected: false, }, { description: "Setting await-sidecar-readiness to true and running-in-environment-with-injected-sidecars to true with sidecars present results in false", - sidecars: []v1beta1.Sidecar{sd}, + sidecars: []v1.Sidecar{sd}, featureFlags: getFeatureFlags(map[string]string{ featureAwaitSidecarReadiness: "true", featureInjectedSidecar: "true", @@ -2530,7 +2530,7 @@ func TestIsPodReadyImmediately(t *testing.T) { expected: false, }, { description: "Setting await-sidecar-readiness to true and running-in-environment-with-injected-sidecars to true with no sidecars present results in false", - sidecars: []v1beta1.Sidecar{}, + sidecars: []v1.Sidecar{}, featureFlags: getFeatureFlags(map[string]string{ featureAwaitSidecarReadiness: "true", featureInjectedSidecar: "true", @@ -2538,7 +2538,7 @@ func TestIsPodReadyImmediately(t *testing.T) { expected: false, }, { description: "Setting await-sidecar-readiness to true and running-in-environment-with-injected-sidecars to false with sidecars present results in false", - sidecars: []v1beta1.Sidecar{sd}, + sidecars: []v1.Sidecar{sd}, featureFlags: getFeatureFlags(map[string]string{ featureAwaitSidecarReadiness: "true", featureInjectedSidecar: "false", @@ -2546,7 +2546,7 @@ func TestIsPodReadyImmediately(t *testing.T) { expected: false, }, { description: "Setting await-sidecar-readiness to true and running-in-environment-with-injected-sidecars to false with no sidecars present results in true", - sidecars: []v1beta1.Sidecar{}, + sidecars: []v1.Sidecar{}, featureFlags: getFeatureFlags(map[string]string{ featureAwaitSidecarReadiness: "true", featureInjectedSidecar: "false", @@ -2554,7 +2554,7 @@ func TestIsPodReadyImmediately(t *testing.T) { expected: true, }, { description: "Setting await-sidecar-readiness to false and running-in-environment-with-injected-sidecars to true with sidecars present results in true", - sidecars: []v1beta1.Sidecar{sd}, + sidecars: []v1.Sidecar{sd}, featureFlags: getFeatureFlags(map[string]string{ featureAwaitSidecarReadiness: "false", featureInjectedSidecar: "true", @@ -2562,7 +2562,7 @@ func TestIsPodReadyImmediately(t *testing.T) { expected: true, }, { description: "Setting await-sidecar-readiness to false and running-in-environment-with-injected-sidecars to true with no sidecars present results in true", - sidecars: []v1beta1.Sidecar{}, + sidecars: []v1.Sidecar{}, featureFlags: getFeatureFlags(map[string]string{ featureAwaitSidecarReadiness: "false", featureInjectedSidecar: "true", @@ -2570,7 +2570,7 @@ func TestIsPodReadyImmediately(t *testing.T) { expected: true, }, { description: "Setting await-sidecar-readiness to false and running-in-environment-with-injected-sidecars to false with sidecars present results in true", - sidecars: []v1beta1.Sidecar{sd}, + sidecars: []v1.Sidecar{sd}, featureFlags: getFeatureFlags(map[string]string{ featureAwaitSidecarReadiness: "false", featureInjectedSidecar: "false", @@ -2578,7 +2578,7 @@ func TestIsPodReadyImmediately(t *testing.T) { expected: true, }, { description: "Setting await-sidecar-readiness to false and running-in-environment-with-injected-sidecars to false with no sidecars present results in true", - sidecars: []v1beta1.Sidecar{}, + sidecars: []v1.Sidecar{}, featureFlags: getFeatureFlags(map[string]string{ featureAwaitSidecarReadiness: "false", featureInjectedSidecar: "false", @@ -2598,12 +2598,12 @@ func TestIsPodReadyImmediately(t *testing.T) { func TestPrepareInitContainers(t *testing.T) { tcs := []struct { name string - steps []v1beta1.Step + steps []v1.Step want corev1.Container featureFlags map[string]string }{{ name: "nothing-special", - steps: []v1beta1.Step{{ + steps: []v1.Step{{ Name: "foo", }}, want: corev1.Container{ @@ -2615,7 +2615,7 @@ func TestPrepareInitContainers(t *testing.T) { }, }, { name: "nothing-special-two-steps", - steps: []v1beta1.Step{{ + steps: []v1.Step{{ Name: "foo", }, { Name: "bar", diff --git a/pkg/pod/script.go b/pkg/pod/script.go index 23498a0b0d9..0816329b2a4 100644 --- a/pkg/pod/script.go +++ b/pkg/pod/script.go @@ -22,7 +22,7 @@ import ( "path/filepath" "strings" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -70,7 +70,7 @@ var ( ) // convertScripts converts any steps and sidecars that specify a Script field into a normal Container. -func convertScripts(shellImageLinux string, shellImageWin string, steps []v1beta1.Step, sidecars []v1beta1.Sidecar, debugConfig *v1beta1.TaskRunDebug) (*corev1.Container, []corev1.Container, []corev1.Container) { +func convertScripts(shellImageLinux string, shellImageWin string, steps []v1.Step, sidecars []v1.Sidecar, debugConfig *v1.TaskRunDebug) (*corev1.Container, []corev1.Container, []corev1.Container) { placeScripts := false // Place scripts is an init container used for creating scripts in the // /tekton/scripts directory which would be later used by the step containers @@ -96,10 +96,10 @@ func convertScripts(shellImageLinux string, shellImageWin string, steps []v1beta } breakpoints := []string{} - sideCarSteps := []v1beta1.Step{} + sideCarSteps := []v1.Step{} for _, sidecar := range sidecars { c := sidecar.ToK8sContainer() - sidecarStep := v1beta1.Step{ + sidecarStep := v1.Step{ Script: sidecar.Script, Timeout: &metav1.Duration{}, } @@ -127,7 +127,7 @@ func convertScripts(shellImageLinux string, shellImageWin string, steps []v1beta // // It iterates through the list of steps (or sidecars), generates the script file name and heredoc termination string, // adds an entry to the init container args, sets up the step container to run the script, and sets the volume mounts. -func convertListOfSteps(steps []v1beta1.Step, initContainer *corev1.Container, placeScripts *bool, breakpoints []string, namePrefix string) []corev1.Container { +func convertListOfSteps(steps []v1.Step, initContainer *corev1.Container, placeScripts *bool, breakpoints []string, namePrefix string) []corev1.Container { containers := []corev1.Container{} for i, s := range steps { // Add debug mounts if breakpoints are present @@ -236,7 +236,7 @@ func encodeScript(script string) string { return base64.StdEncoding.EncodeToString([]byte(script)) } -func checkWindowsRequirement(steps []v1beta1.Step, sidecars []v1beta1.Sidecar) bool { +func checkWindowsRequirement(steps []v1.Step, sidecars []v1.Sidecar) bool { // Detect windows shebangs for _, step := range steps { cleaned := strings.TrimSpace(step.Script) diff --git a/pkg/pod/script_test.go b/pkg/pod/script_test.go index f341be86d42..8400bd6633e 100644 --- a/pkg/pod/script_test.go +++ b/pkg/pod/script_test.go @@ -20,18 +20,18 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" ) func TestConvertScripts_NothingToConvert_EmptySidecars(t *testing.T) { - gotInit, gotScripts, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1beta1.Step{{ + gotInit, gotScripts, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1.Step{{ Image: "step-1", }, { Image: "step-2", - }}, []v1beta1.Sidecar{}, nil) + }}, []v1.Sidecar{}, nil) want := []corev1.Container{{ Image: "step-1", }, { @@ -50,7 +50,7 @@ func TestConvertScripts_NothingToConvert_EmptySidecars(t *testing.T) { } func TestConvertScripts_NothingToConvert_NilSidecars(t *testing.T) { - gotInit, gotScripts, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1beta1.Step{{ + gotInit, gotScripts, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1.Step{{ Image: "step-1", }, { Image: "step-2", @@ -73,11 +73,11 @@ func TestConvertScripts_NothingToConvert_NilSidecars(t *testing.T) { } func TestConvertScripts_NothingToConvert_WithSidecar(t *testing.T) { - gotInit, gotScripts, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1beta1.Step{{ + gotInit, gotScripts, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1.Step{{ Image: "step-1", }, { Image: "step-2", - }}, []v1beta1.Sidecar{{ + }}, []v1.Sidecar{{ Image: "sidecar-1", }}, nil) want := []corev1.Container{{ @@ -116,7 +116,7 @@ func TestConvertScripts(t *testing.T) { MountPath: "/another/one", }} - gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1beta1.Step{{ + gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1.Step{{ Script: `#!/bin/sh script-1`, Image: "step-1", @@ -135,7 +135,7 @@ script-3`, Image: "step-3", VolumeMounts: preExistingVolumeMounts, Args: []string{"my", "args"}, - }}, []v1beta1.Sidecar{}, nil) + }}, []v1.Sidecar{}, nil) wantInit := &corev1.Container{ Name: "place-scripts", Image: images.ShellImage, @@ -205,7 +205,7 @@ func TestConvertScripts_WithBreakpoint_OnFailure(t *testing.T) { MountPath: "/another/one", }} - gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1beta1.Step{{ + gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1.Step{{ Script: `#!/bin/sh script-1`, Image: "step-1", @@ -224,7 +224,7 @@ script-3`, Image: "step-3", VolumeMounts: preExistingVolumeMounts, Args: []string{"my", "args"}, - }}, []v1beta1.Sidecar{}, &v1beta1.TaskRunDebug{ + }}, []v1.Sidecar{}, &v1.TaskRunDebug{ Breakpoint: []string{breakpointOnFailure}, }) @@ -352,7 +352,7 @@ func TestConvertScripts_WithSidecar(t *testing.T) { MountPath: "/another/one", }} - gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1beta1.Step{{ + gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1.Step{{ Script: `#!/bin/sh script-1`, Image: "step-1", @@ -365,7 +365,7 @@ script-3`, Image: "step-3", VolumeMounts: preExistingVolumeMounts, Args: []string{"my", "args"}, - }}, []v1beta1.Sidecar{{ + }}, []v1.Sidecar{{ Script: `#!/bin/sh sidecar-1`, Image: "sidecar-1", @@ -443,7 +443,7 @@ func TestConvertScripts_Windows(t *testing.T) { MountPath: "/another/one", }} - gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1beta1.Step{{ + gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1.Step{{ Script: `#!win pwsh -File script-1`, Image: "step-1", @@ -462,7 +462,7 @@ no-shebang`, Image: "step-3", VolumeMounts: preExistingVolumeMounts, Args: []string{"my", "args"}, - }}, []v1beta1.Sidecar{}, nil) + }}, []v1.Sidecar{}, nil) wantInit := &corev1.Container{ Name: "place-scripts", Image: images.ShellImageWin, @@ -526,7 +526,7 @@ func TestConvertScripts_Windows_WithSidecar(t *testing.T) { MountPath: "/another/one", }} - gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1beta1.Step{{ + gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1.Step{{ Script: `#!win pwsh -File script-1`, Image: "step-1", @@ -539,7 +539,7 @@ script-3`, Image: "step-3", VolumeMounts: preExistingVolumeMounts, Args: []string{"my", "args"}, - }}, []v1beta1.Sidecar{{ + }}, []v1.Sidecar{{ Script: `#!win pwsh -File sidecar-1`, Image: "sidecar-1", @@ -605,10 +605,10 @@ sidecar-1 func TestConvertScripts_Windows_SidecarOnly(t *testing.T) { names.TestingSeed() - gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1beta1.Step{{ + gotInit, gotSteps, gotSidecars := convertScripts(images.ShellImage, images.ShellImageWin, []v1.Step{{ // No script to convert here.: Image: "step-1", - }}, []v1beta1.Sidecar{{ + }}, []v1.Sidecar{{ Script: `#!win python sidecar-1`, Image: "sidecar-1", diff --git a/pkg/pod/status.go b/pkg/pod/status.go index 04cb7af755c..ff53c50d979 100644 --- a/pkg/pod/status.go +++ b/pkg/pod/status.go @@ -28,7 +28,7 @@ import ( "github.com/tektoncd/pipeline/internal/sidecarlogresults" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/termination" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" @@ -115,11 +115,11 @@ func SidecarsReady(podStatus corev1.PodStatus) bool { } // MakeTaskRunStatus returns a TaskRunStatus based on the Pod's status. -func MakeTaskRunStatus(ctx context.Context, logger *zap.SugaredLogger, tr v1beta1.TaskRun, pod *corev1.Pod, kubeclient kubernetes.Interface, ts *v1beta1.TaskSpec) (v1beta1.TaskRunStatus, error) { +func MakeTaskRunStatus(ctx context.Context, logger *zap.SugaredLogger, tr v1.TaskRun, pod *corev1.Pod, kubeclient kubernetes.Interface, ts *v1.TaskSpec) (v1.TaskRunStatus, error) { trs := &tr.Status if trs.GetCondition(apis.ConditionSucceeded) == nil || trs.GetCondition(apis.ConditionSucceeded).Status == corev1.ConditionUnknown { // If the taskRunStatus doesn't exist yet, it's because we just started running - markStatusRunning(trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") + markStatusRunning(trs, v1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") } sortPodContainerStatuses(pod.Status.ContainerStatuses, pod.Spec.Containers) @@ -133,8 +133,8 @@ func MakeTaskRunStatus(ctx context.Context, logger *zap.SugaredLogger, tr v1beta } trs.PodName = pod.Name - trs.Steps = []v1beta1.StepState{} - trs.Sidecars = []v1beta1.SidecarState{} + trs.Steps = []v1.StepState{} + trs.Sidecars = []v1.SidecarState{} var stepStatuses []corev1.ContainerStatus var sidecarStatuses []corev1.ContainerStatus @@ -158,12 +158,12 @@ func MakeTaskRunStatus(ctx context.Context, logger *zap.SugaredLogger, tr v1beta return *trs, merr.ErrorOrNil() } -func setTaskRunStatusBasedOnStepStatus(ctx context.Context, logger *zap.SugaredLogger, stepStatuses []corev1.ContainerStatus, tr *v1beta1.TaskRun, podPhase corev1.PodPhase, kubeclient kubernetes.Interface, ts *v1beta1.TaskSpec) *multierror.Error { +func setTaskRunStatusBasedOnStepStatus(ctx context.Context, logger *zap.SugaredLogger, stepStatuses []corev1.ContainerStatus, tr *v1.TaskRun, podPhase corev1.PodPhase, kubeclient kubernetes.Interface, ts *v1.TaskSpec) *multierror.Error { trs := &tr.Status var merr *multierror.Error // collect results from taskrun spec and taskspec - specResults := []v1beta1.TaskResult{} + specResults := []v1.TaskResult{} if tr.Spec.TaskSpec != nil { specResults = append(specResults, tr.Spec.TaskSpec.Results...) } @@ -228,7 +228,7 @@ func setTaskRunStatusBasedOnStepStatus(ctx context.Context, logger *zap.SugaredL } } } - trs.Steps = append(trs.Steps, v1beta1.StepState{ + trs.Steps = append(trs.Steps, v1.StepState{ ContainerState: *s.State.DeepCopy(), Name: trimStepPrefix(s.Name), ContainerName: s.Name, @@ -239,9 +239,9 @@ func setTaskRunStatusBasedOnStepStatus(ctx context.Context, logger *zap.SugaredL return merr } -func setTaskRunStatusBasedOnSidecarStatus(sidecarStatuses []corev1.ContainerStatus, trs *v1beta1.TaskRunStatus) { +func setTaskRunStatusBasedOnSidecarStatus(sidecarStatuses []corev1.ContainerStatus, trs *v1.TaskRunStatus) { for _, s := range sidecarStatuses { - trs.Sidecars = append(trs.Sidecars, v1beta1.SidecarState{ + trs.Sidecars = append(trs.Sidecars, v1.SidecarState{ ContainerState: *s.State.DeepCopy(), Name: TrimSidecarPrefix(s.Name), ContainerName: s.Name, @@ -250,7 +250,7 @@ func setTaskRunStatusBasedOnSidecarStatus(sidecarStatuses []corev1.ContainerStat } } -func createMessageFromResults(results []v1beta1.PipelineResourceResult) (string, error) { +func createMessageFromResults(results []v1.PipelineResourceResult) (string, error) { if len(results) == 0 { return "", nil } @@ -261,41 +261,43 @@ func createMessageFromResults(results []v1beta1.PipelineResourceResult) (string, return string(bytes), nil } -func filterResultsAndResources(results []v1beta1.PipelineResourceResult, specResults []v1beta1.TaskResult) ([]v1beta1.TaskRunResult, []v1beta1.PipelineResourceResult, []v1beta1.PipelineResourceResult) { - var taskResults []v1beta1.TaskRunResult - var pipelineResourceResults []v1beta1.PipelineResourceResult - var filteredResults []v1beta1.PipelineResourceResult - neededTypes := make(map[string]v1beta1.ResultsType) +func filterResultsAndResources(results []v1.PipelineResourceResult, specResults []v1.TaskResult) ([]v1.TaskRunResult, []v1.PipelineResourceResult, []v1.PipelineResourceResult) { + var taskResults []v1.TaskRunResult + var pipelineResourceResults []v1.PipelineResourceResult + var filteredResults []v1.PipelineResourceResult + neededTypes := make(map[string]v1.ResultsType) for _, r := range specResults { neededTypes[r.Name] = r.Type } for _, r := range results { switch r.ResultType { - case v1beta1.TaskRunResultType: - var taskRunResult v1beta1.TaskRunResult - if neededTypes[r.Key] == v1beta1.ResultsTypeString { - taskRunResult = v1beta1.TaskRunResult{ + case v1.TaskRunResultType: + taskRunResult := v1.TaskRunResult{} + if neededTypes[r.Key] == v1.ResultsTypeString { + taskRunResult = v1.TaskRunResult{ Name: r.Key, - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues(r.Value), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues(r.Value), } } else { - v := v1beta1.ResultValue{} + v := v1.ResultValue{} err := v.UnmarshalJSON([]byte(r.Value)) if err != nil { continue } - taskRunResult = v1beta1.TaskRunResult{ + taskRunResult = v1.TaskRunResult{ Name: r.Key, - Type: v1beta1.ResultsType(v.Type), + Type: v1.ResultsType(v.Type), Value: v, } } taskResults = append(taskResults, taskRunResult) filteredResults = append(filteredResults, r) - case v1beta1.InternalTektonResultType: + case v1.InternalTektonResultType: // Internal messages are ignored because they're not used as external result continue + case v1.PipelineResourceResultType: + fallthrough default: pipelineResourceResults = append(pipelineResourceResults, r) filteredResults = append(filteredResults, r) @@ -305,13 +307,13 @@ func filterResultsAndResources(results []v1beta1.PipelineResourceResult, specRes return taskResults, pipelineResourceResults, filteredResults } -func removeDuplicateResults(taskRunResult []v1beta1.TaskRunResult) []v1beta1.TaskRunResult { +func removeDuplicateResults(taskRunResult []v1.TaskRunResult) []v1.TaskRunResult { if len(taskRunResult) == 0 { return nil } - uniq := make([]v1beta1.TaskRunResult, 0) - latest := make(map[string]v1beta1.TaskRunResult, 0) + uniq := make([]v1.TaskRunResult, 0) + latest := make(map[string]v1.TaskRunResult, 0) for _, res := range taskRunResult { if _, seen := latest[res.Name]; !seen { uniq = append(uniq, res) @@ -324,7 +326,7 @@ func removeDuplicateResults(taskRunResult []v1beta1.TaskRunResult) []v1beta1.Tas return uniq } -func extractStartedAtTimeFromResults(results []v1beta1.PipelineResourceResult) (*metav1.Time, error) { +func extractStartedAtTimeFromResults(results []v1.PipelineResourceResult) (*metav1.Time, error) { for _, result := range results { if result.Key == "StartedAt" { t, err := time.Parse(timeFormat, result.Value) @@ -338,7 +340,7 @@ func extractStartedAtTimeFromResults(results []v1beta1.PipelineResourceResult) ( return nil, nil } -func extractExitCodeFromResults(results []v1beta1.PipelineResourceResult) (*int32, error) { +func extractExitCodeFromResults(results []v1.PipelineResourceResult) (*int32, error) { for _, result := range results { if result.Key == "ExitCode" { // We could just pass the string through but this provides extra validation @@ -353,10 +355,10 @@ func extractExitCodeFromResults(results []v1beta1.PipelineResourceResult) (*int3 return nil, nil } -func updateCompletedTaskRunStatus(logger *zap.SugaredLogger, trs *v1beta1.TaskRunStatus, pod *corev1.Pod) { +func updateCompletedTaskRunStatus(logger *zap.SugaredLogger, trs *v1.TaskRunStatus, pod *corev1.Pod) { if DidTaskRunFail(pod) { msg := getFailureMessage(logger, pod) - markStatusFailure(trs, v1beta1.TaskRunReasonFailed.String(), msg) + markStatusFailure(trs, v1.TaskRunReasonFailed.String(), msg) } else { markStatusSuccess(trs) } @@ -365,10 +367,10 @@ func updateCompletedTaskRunStatus(logger *zap.SugaredLogger, trs *v1beta1.TaskRu trs.CompletionTime = &metav1.Time{Time: time.Now()} } -func updateIncompleteTaskRunStatus(trs *v1beta1.TaskRunStatus, pod *corev1.Pod) { +func updateIncompleteTaskRunStatus(trs *v1.TaskRunStatus, pod *corev1.Pod) { switch pod.Status.Phase { case corev1.PodRunning: - markStatusRunning(trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") + markStatusRunning(trs, v1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") case corev1.PodPending: switch { case IsPodExceedingNodeResources(pod): @@ -402,7 +404,7 @@ func DidTaskRunFail(pod *corev1.Pod) bool { } // IsPodArchived indicates if a pod is archived in the retriesStatus. -func IsPodArchived(pod *corev1.Pod, trs *v1beta1.TaskRunStatus) bool { +func IsPodArchived(pod *corev1.Pod, trs *v1.TaskRunStatus) bool { for _, retryStatus := range trs.RetriesStatus { if retryStatus.PodName == pod.GetName() { return true @@ -471,7 +473,7 @@ func extractContainerFailureMessage(logger *zap.SugaredLogger, status corev1.Con msg := status.State.Terminated.Message r, _ := termination.ParseMessage(logger, msg) for _, result := range r { - if result.ResultType == v1beta1.InternalTektonResultType && result.Key == "Reason" && result.Value == "TimeoutExceeded" { + if result.ResultType == v1.InternalTektonResultType && result.Key == "Reason" && result.Value == "TimeoutExceeded" { // Newline required at end to prevent yaml parser from breaking the log help text at 80 chars return fmt.Sprintf("%q exited because the step exceeded the specified timeout limit; for logs run: kubectl -n %s logs %s -c %s\n", status.Name, @@ -566,7 +568,7 @@ func getWaitingMessage(pod *corev1.Pod) string { } // markStatusRunning sets taskrun status to running -func markStatusRunning(trs *v1beta1.TaskRunStatus, reason, message string) { +func markStatusRunning(trs *v1.TaskRunStatus, reason, message string) { trs.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionUnknown, @@ -576,7 +578,7 @@ func markStatusRunning(trs *v1beta1.TaskRunStatus, reason, message string) { } // markStatusFailure sets taskrun status to failure with specified reason -func markStatusFailure(trs *v1beta1.TaskRunStatus, reason string, message string) { +func markStatusFailure(trs *v1.TaskRunStatus, reason string, message string) { trs.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, @@ -586,11 +588,11 @@ func markStatusFailure(trs *v1beta1.TaskRunStatus, reason string, message string } // markStatusSuccess sets taskrun status to success -func markStatusSuccess(trs *v1beta1.TaskRunStatus) { +func markStatusSuccess(trs *v1.TaskRunStatus) { trs.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, - Reason: v1beta1.TaskRunReasonSuccessful.String(), + Reason: v1.TaskRunReasonSuccessful.String(), Message: "All Steps have completed executing", }) } diff --git a/pkg/pod/status_test.go b/pkg/pod/status_test.go index 78065ac6e14..baf6375d011 100644 --- a/pkg/pod/status_test.go +++ b/pkg/pod/status_test.go @@ -74,13 +74,13 @@ func TestSetTaskRunStatusBasedOnStepStatus(t *testing.T) { }} { t.Run(c.desc, func(t *testing.T) { startTime := time.Date(2010, 1, 1, 1, 1, 1, 1, time.UTC) - tr := v1beta1.TaskRun{ + tr := v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "task-run", Namespace: "foo", }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ StartTime: &metav1.Time{Time: startTime}, }, }, @@ -88,7 +88,7 @@ func TestSetTaskRunStatusBasedOnStepStatus(t *testing.T) { logger, _ := logging.NewLogger("", "status") kubeclient := fakek8s.NewSimpleClientset() - merr := setTaskRunStatusBasedOnStepStatus(context.Background(), logger, c.ContainerStatuses, &tr, corev1.PodRunning, kubeclient, &v1beta1.TaskSpec{}) + merr := setTaskRunStatusBasedOnStepStatus(context.Background(), logger, c.ContainerStatuses, &tr, corev1.PodRunning, kubeclient, &v1.TaskSpec{}) if merr != nil { t.Errorf("setTaskRunStatusBasedOnStepStatus: %s", merr) } @@ -111,15 +111,15 @@ func TestSetTaskRunStatusBasedOnStepStatus_sidecar_logs(t *testing.T) { wantErr: fmt.Errorf("%s", "Invalid result invalid character 'k' in literal false (expecting 'l')"), }} { t.Run(c.desc, func(t *testing.T) { - tr := v1beta1.TaskRun{ + tr := v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "task-run", Namespace: "foo", }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result1", }}, }, @@ -163,7 +163,7 @@ func TestSetTaskRunStatusBasedOnStepStatus_sidecar_logs(t *testing.T) { }) var wantErr *multierror.Error wantErr = multierror.Append(wantErr, c.wantErr) - merr := setTaskRunStatusBasedOnStepStatus(ctx, logger, []corev1.ContainerStatus{{}}, &tr, pod.Status.Phase, kubeclient, &v1beta1.TaskSpec{}) + merr := setTaskRunStatusBasedOnStepStatus(ctx, logger, []corev1.ContainerStatus{{}}, &tr, pod.Status.Phase, kubeclient, &v1.TaskSpec{}) if d := cmp.Diff(wantErr.Error(), merr.Error()); d != "" { t.Errorf("Got unexpected error %s", diff.PrintWantGot(d)) @@ -177,16 +177,16 @@ func TestMakeTaskRunStatus(t *testing.T) { desc string podStatus corev1.PodStatus pod corev1.Pod - want v1beta1.TaskRunStatus + want v1.TaskRunStatus }{{ desc: "empty", podStatus: corev1.PodStatus{}, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusRunning(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{}, - Sidecars: []v1beta1.SidecarState{}, + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -206,10 +206,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusRunning(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 123, @@ -217,7 +217,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "state-name", ContainerName: "step-state-name", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -240,10 +240,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusRunning(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 123, @@ -252,7 +252,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-state-name", ImageID: "image-id", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -269,10 +269,10 @@ func TestMakeTaskRunStatus(t *testing.T) { ImageID: "image-id", }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 0, @@ -281,7 +281,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-step-push", ImageID: "image-id", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -297,17 +297,17 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusRunning(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, Name: "running-step", ContainerName: "step-running-step", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -328,10 +328,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ - Status: statusFailure(v1beta1.TaskRunReasonFailed.String(), "\"step-failure\" exited with code 123 (image: \"image-id\"); for logs run: kubectl -n foo logs pod -c step-failure\n"), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + want: v1.TaskRunStatus{ + Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-failure\" exited with code 123 (image: \"image-id\"); for logs run: kubectl -n foo logs pod -c step-failure\n"), + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 123, @@ -341,7 +341,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-failure", ImageID: "image-id", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -352,11 +352,11 @@ func TestMakeTaskRunStatus(t *testing.T) { Phase: corev1.PodFailed, Message: "boom", }, - want: v1beta1.TaskRunStatus{ - Status: statusFailure(v1beta1.TaskRunReasonFailed.String(), "boom"), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{}, - Sidecars: []v1beta1.SidecarState{}, + want: v1.TaskRunStatus{ + Status: statusFailure(v1.TaskRunReasonFailed.String(), "boom"), + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -376,10 +376,10 @@ func TestMakeTaskRunStatus(t *testing.T) { ImageID: "image-id", }}, }, - want: v1beta1.TaskRunStatus{ - Status: statusFailure(v1beta1.TaskRunReasonFailed.String(), "OOMKilled"), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + want: v1.TaskRunStatus{ + Status: statusFailure(v1.TaskRunReasonFailed.String(), "OOMKilled"), + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Reason: "OOMKilled", @@ -389,7 +389,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-step-push", ImageID: "image-id", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -397,11 +397,11 @@ func TestMakeTaskRunStatus(t *testing.T) { }, { desc: "failure-unspecified", podStatus: corev1.PodStatus{Phase: corev1.PodFailed}, - want: v1beta1.TaskRunStatus{ - Status: statusFailure(v1beta1.TaskRunReasonFailed.String(), "build failed for unspecified reasons."), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{}, - Sidecars: []v1beta1.SidecarState{}, + want: v1.TaskRunStatus{ + Status: statusFailure(v1.TaskRunReasonFailed.String(), "build failed for unspecified reasons."), + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -422,10 +422,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusPending("Pending", `build step "step-status-name" is pending with reason "i'm pending"`), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Waiting: &corev1.ContainerStateWaiting{ Message: "i'm pending", @@ -434,7 +434,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "status-name", ContainerName: "step-status-name", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -447,11 +447,11 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "the message", }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusPending("Pending", `pod status "the type":"Unknown"; message: "the message"`), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{}, - Sidecars: []v1beta1.SidecarState{}, + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -460,21 +460,21 @@ func TestMakeTaskRunStatus(t *testing.T) { Phase: corev1.PodPending, Message: "pod status message", }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusPending("Pending", "pod status message"), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{}, - Sidecars: []v1beta1.SidecarState{}, + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { desc: "pending-no-message", podStatus: corev1.PodStatus{Phase: corev1.PodPending}, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusPending("Pending", "Pending"), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{}, - Sidecars: []v1beta1.SidecarState{}, + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -486,11 +486,11 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "0/1 nodes are available: 1 Insufficient cpu.", }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusPending(ReasonExceededNodeResources, "TaskRun Pod exceeded available resources"), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{}, - Sidecars: []v1beta1.SidecarState{}, + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -505,11 +505,11 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusFailure(ReasonCreateContainerConfigError, "Failed to create pod due to config error"), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{}, - Sidecars: []v1beta1.SidecarState{}, + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -530,17 +530,17 @@ func TestMakeTaskRunStatus(t *testing.T) { Ready: true, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusRunning(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, Name: "running-step", ContainerName: "step-running-step", }}, - Sidecars: []v1beta1.SidecarState{{ + Sidecars: []v1.SidecarState{{ ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, @@ -574,10 +574,10 @@ func TestMakeTaskRunStatus(t *testing.T) { Ready: true, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusRunning(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Waiting: &corev1.ContainerStateWaiting{ Reason: "PodInitializing", @@ -587,7 +587,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "waiting-step", ContainerName: "step-waiting-step", }}, - Sidecars: []v1beta1.SidecarState{{ + Sidecars: []v1.SidecarState{{ ContainerState: corev1.ContainerState{ Waiting: &corev1.ContainerStateWaiting{ Reason: "PodInitializing", @@ -622,17 +622,17 @@ func TestMakeTaskRunStatus(t *testing.T) { Ready: true, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusRunning(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, Name: "running-step", ContainerName: "step-running-step", }}, - Sidecars: []v1beta1.SidecarState{{ + Sidecars: []v1.SidecarState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, @@ -659,10 +659,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"digest","value":"sha256:12345","resourceName":"source-image"}]`, @@ -670,8 +670,8 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "foo", ContainerName: "step-foo", }}, - Sidecars: []v1beta1.SidecarState{}, - ResourcesResult: []v1beta1.PipelineResourceResult{{ + Sidecars: []v1.SidecarState{}, + ResourcesResult: []v1.PipelineResourceResult{{ Key: "digest", Value: "sha256:12345", ResourceName: "source-image", @@ -693,10 +693,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"digest","value":"sha256:1234","resourceName":"source-image"},{"key":"resultName","value":"resultValue","type":1}]`, @@ -704,16 +704,16 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "bar", ContainerName: "step-bar", }}, - Sidecars: []v1beta1.SidecarState{}, - ResourcesResult: []v1beta1.PipelineResourceResult{{ + Sidecars: []v1.SidecarState{}, + ResourcesResult: []v1.PipelineResourceResult{{ Key: "digest", Value: "sha256:1234", ResourceName: "source-image", }}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Results: []v1.TaskRunResult{{ Name: "resultName", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("resultValue"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("resultValue"), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -732,10 +732,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"digest","value":"sha256:1234","resourceName":"source-image"},{"key":"resultName","value":"resultValue","type":1}]`, @@ -743,16 +743,16 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "banana", ContainerName: "step-banana", }}, - Sidecars: []v1beta1.SidecarState{}, - ResourcesResult: []v1beta1.PipelineResourceResult{{ + Sidecars: []v1.SidecarState{}, + ResourcesResult: []v1.PipelineResourceResult{{ Key: "digest", Value: "sha256:1234", ResourceName: "source-image", }}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Results: []v1.TaskRunResult{{ Name: "resultName", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("resultValue"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("resultValue"), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -778,10 +778,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"resultNameOne","value":"resultValueOne","type":1},{"key":"resultNameTwo","value":"resultValueTwo","type":1}]`, @@ -796,15 +796,15 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "two", ContainerName: "step-two", }}, - Sidecars: []v1beta1.SidecarState{}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Sidecars: []v1.SidecarState{}, + Results: []v1.TaskRunResult{{ Name: "resultNameOne", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("resultValueThree"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("resultValueThree"), }, { Name: "resultNameTwo", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("resultValueTwo"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("resultValueTwo"), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -821,16 +821,16 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ - Status: statusFailure(v1beta1.TaskRunReasonFailed.String(), "build failed for unspecified reasons."), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + want: v1.TaskRunStatus{ + Status: statusFailure(v1.TaskRunReasonFailed.String(), "build failed for unspecified reasons."), + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{}}, Name: "mango", ContainerName: "step-mango", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -848,16 +848,16 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{}}, Name: "pineapple", ContainerName: "step-pineapple", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -874,10 +874,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"resultNameThree","value":"","type":1}]`, @@ -885,11 +885,16 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "pear", ContainerName: "step-pear", }}, - Sidecars: []v1beta1.SidecarState{}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Sidecars: []v1.SidecarState{}, + ResourcesResult: []v1.PipelineResourceResult{{ + Key: "resultNameOne", + Value: "", + ResultType: v1.PipelineResourceResultType, + }}, + Results: []v1.TaskRunResult{{ Name: "resultNameThree", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues(""), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues(""), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -908,10 +913,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"resultNameThree","value":"","type":1}]`, @@ -919,11 +924,16 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "pear", ContainerName: "step-pear", }}, - Sidecars: []v1beta1.SidecarState{}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Sidecars: []v1.SidecarState{}, + ResourcesResult: []v1.PipelineResourceResult{{ + Key: "resultNameOne", + Value: "", + ResultType: v1.PipelineResourceResultType, + }}, + Results: []v1.TaskRunResult{{ Name: "resultNameThree", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues(""), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues(""), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -978,10 +988,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }}, }, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{}, }, @@ -1008,7 +1018,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "fourth", ContainerName: "step-fourth", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -1043,10 +1053,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }}, }, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 11, @@ -1062,7 +1072,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "second", ContainerName: "step-second", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -1091,10 +1101,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }}, }, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusPending("PullImageFailed", `build step "step-first" is pending with reason "Back-off pulling image xxxxxxx"`), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Waiting: &corev1.ContainerStateWaiting{ Reason: "ImagePullBackOff", @@ -1104,7 +1114,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "first", ContainerName: "step-first", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, }, }, }, { @@ -1143,10 +1153,10 @@ func TestMakeTaskRunStatus(t *testing.T) { }}, }, }, - want: v1beta1.TaskRunStatus{ - Status: statusFailure(v1beta1.TaskRunReasonFailed.String(), "init container failed, \"init-A\" exited with code 1 (image: \"init-image-id-A\"); for logs run: kubectl -n foo logs pod -c init-A\n"), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + want: v1.TaskRunStatus{ + Status: statusFailure(v1.TaskRunReasonFailed.String(), "init container failed, \"init-A\" exited with code 1 (image: \"init-image-id-A\"); for logs run: kubectl -n foo logs pod -c init-A\n"), + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Waiting: &corev1.ContainerStateWaiting{ Reason: "PodInitializing", @@ -1156,7 +1166,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-A", ImageID: "image-id-A", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, CompletionTime: &metav1.Time{Time: time.Now()}, }, }, @@ -1219,20 +1229,20 @@ func TestMakeTaskRunStatus(t *testing.T) { } startTime := time.Date(2010, 1, 1, 1, 1, 1, 1, time.UTC) - tr := v1beta1.TaskRun{ + tr := v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "task-run", Namespace: "foo", }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ StartTime: &metav1.Time{Time: startTime}, }, }, } logger, _ := logging.NewLogger("", "status") kubeclient := fakek8s.NewSimpleClientset() - got, err := MakeTaskRunStatus(context.Background(), logger, tr, &c.pod, kubeclient, &v1beta1.TaskSpec{}) + got, err := MakeTaskRunStatus(context.Background(), logger, tr, &c.pod, kubeclient, &v1.TaskSpec{}) if err != nil { t.Errorf("MakeTaskRunResult: %s", err) } @@ -1262,8 +1272,8 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { desc string podStatus corev1.PodStatus pod corev1.Pod - taskSpec v1beta1.TaskSpec - want v1beta1.TaskRunStatus + taskSpec v1.TaskSpec + want v1.TaskRunStatus }{{ desc: "test empty result", podStatus: corev1.PodStatus{ @@ -1277,18 +1287,18 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { }, }}, }, - taskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + taskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "resultName", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }, }, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"digest","value":"sha256:1234","resourceName":"source-image"},{"key":"resultName","value":"","type":1}]`, @@ -1296,16 +1306,16 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { Name: "bar", ContainerName: "step-bar", }}, - Sidecars: []v1beta1.SidecarState{}, - ResourcesResult: []v1beta1.PipelineResourceResult{{ + Sidecars: []v1.SidecarState{}, + ResourcesResult: []v1.PipelineResourceResult{{ Key: "digest", Value: "sha256:1234", ResourceName: "source-image", }}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Results: []v1.TaskRunResult{{ Name: "resultName", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues(""), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues(""), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -1324,18 +1334,18 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { }, }}, }, - taskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + taskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "resultName", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }, }, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"digest","value":"sha256:1234","resourceName":"source-image"},{"key":"resultName","value":"hello","type":1}]`, @@ -1343,16 +1353,16 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { Name: "bar", ContainerName: "step-bar", }}, - Sidecars: []v1beta1.SidecarState{}, - ResourcesResult: []v1beta1.PipelineResourceResult{{ + Sidecars: []v1.SidecarState{}, + ResourcesResult: []v1.PipelineResourceResult{{ Key: "digest", Value: "sha256:1234", ResourceName: "source-image", }}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Results: []v1.TaskRunResult{{ Name: "resultName", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("hello"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("hello"), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -1371,18 +1381,18 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { }, }}, }, - taskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + taskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "resultName", - Type: v1beta1.ResultsTypeArray, + Type: v1.ResultsTypeArray, }, }, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"digest","value":"sha256:1234","resourceName":"source-image"},{"key":"resultName","value":"[\"hello\",\"world\"]","type":1}]`, @@ -1390,16 +1400,16 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { Name: "bar", ContainerName: "step-bar", }}, - Sidecars: []v1beta1.SidecarState{}, - ResourcesResult: []v1beta1.PipelineResourceResult{{ + Sidecars: []v1.SidecarState{}, + ResourcesResult: []v1.PipelineResourceResult{{ Key: "digest", Value: "sha256:1234", ResourceName: "source-image", }}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Results: []v1.TaskRunResult{{ Name: "resultName", - Type: v1beta1.ResultsTypeArray, - Value: *v1beta1.NewStructuredValues("hello", "world"), + Type: v1.ResultsTypeArray, + Value: *v1.NewStructuredValues("hello", "world"), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -1418,18 +1428,18 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { }, }}, }, - taskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + taskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "resultName", - Type: v1beta1.ResultsTypeObject, + Type: v1.ResultsTypeObject, }, }, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"digest","value":"sha256:1234","resourceName":"source-image"},{"key":"resultName","value":"{\"hello\":\"world\"}","type":1}]`, @@ -1437,16 +1447,16 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { Name: "bar", ContainerName: "step-bar", }}, - Sidecars: []v1beta1.SidecarState{}, - ResourcesResult: []v1beta1.PipelineResourceResult{{ + Sidecars: []v1.SidecarState{}, + ResourcesResult: []v1.PipelineResourceResult{{ Key: "digest", Value: "sha256:1234", ResourceName: "source-image", }}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Results: []v1.TaskRunResult{{ Name: "resultName", - Type: v1beta1.ResultsTypeObject, - Value: *v1beta1.NewObject(map[string]string{"hello": "world"}), + Type: v1.ResultsTypeObject, + Value: *v1.NewObject(map[string]string{"hello": "world"}), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -1465,22 +1475,22 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { }, }}, }, - taskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + taskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "resultName", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }, { Name: "resultName2", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }, }, }, - want: v1beta1.TaskRunStatus{ + want: v1.TaskRunStatus{ Status: statusSuccess(), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - Steps: []v1beta1.StepState{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Message: `[{"key":"resultName","value":"{\"hello\":\"world\"}","type":1},{"key":"resultName2","value":"[\"hello\",\"world\"]","type":1}]`, @@ -1488,15 +1498,15 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { Name: "bar", ContainerName: "step-bar", }}, - Sidecars: []v1beta1.SidecarState{}, - TaskRunResults: []v1beta1.TaskRunResult{{ + Sidecars: []v1.SidecarState{}, + Results: []v1.TaskRunResult{{ Name: "resultName", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("{\"hello\":\"world\"}"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("{\"hello\":\"world\"}"), }, { Name: "resultName2", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("[\"hello\",\"world\"]"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("[\"hello\",\"world\"]"), }}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, @@ -1517,13 +1527,13 @@ func TestMakeTaskRunStatusAlpha(t *testing.T) { } startTime := time.Date(2010, 1, 1, 1, 1, 1, 1, time.UTC) - tr := v1beta1.TaskRun{ + tr := v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "task-run", Namespace: "foo", }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ StartTime: &metav1.Time{Time: startTime}, }, }, @@ -1604,11 +1614,11 @@ func TestMakeRunStatusJSONError(t *testing.T) { }}, }, } - wantTr := v1beta1.TaskRunStatus{ - Status: statusFailure(v1beta1.TaskRunReasonFailed.String(), "\"step-non-json\" exited with code 1 (image: \"image\"); for logs run: kubectl -n foo logs pod -c step-non-json\n"), - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + wantTr := v1.TaskRunStatus{ + Status: statusFailure(v1.TaskRunReasonFailed.String(), "\"step-non-json\" exited with code 1 (image: \"image\"); for logs run: kubectl -n foo logs pod -c step-non-json\n"), + TaskRunStatusFields: v1.TaskRunStatusFields{ PodName: "pod", - Steps: []v1beta1.StepState{{ + Steps: []v1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, @@ -1636,12 +1646,12 @@ func TestMakeRunStatusJSONError(t *testing.T) { ContainerName: "step-foo", ImageID: "image", }}, - Sidecars: []v1beta1.SidecarState{}, + Sidecars: []v1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, } - tr := v1beta1.TaskRun{ + tr := v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "task-run", Namespace: "foo", @@ -1650,7 +1660,7 @@ func TestMakeRunStatusJSONError(t *testing.T) { logger, _ := logging.NewLogger("", "status") kubeclient := fakek8s.NewSimpleClientset() - gotTr, err := MakeTaskRunStatus(context.Background(), logger, tr, pod, kubeclient, &v1beta1.TaskSpec{}) + gotTr, err := MakeTaskRunStatus(context.Background(), logger, tr, pod, kubeclient, &v1.TaskSpec{}) if err == nil { t.Error("Expected error, got nil") } @@ -1757,13 +1767,13 @@ func TestSidecarsReady(t *testing.T) { } func TestMarkStatusRunning(t *testing.T) { - trs := v1beta1.TaskRunStatus{} - markStatusRunning(&trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") + trs := v1.TaskRunStatus{} + markStatusRunning(&trs, v1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") expected := &apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionUnknown, - Reason: v1beta1.TaskRunReasonRunning.String(), + Reason: v1.TaskRunReasonRunning.String(), Message: "Not all Steps in the Task have finished executing", } @@ -1773,13 +1783,13 @@ func TestMarkStatusRunning(t *testing.T) { } func TestMarkStatusFailure(t *testing.T) { - trs := v1beta1.TaskRunStatus{} - markStatusFailure(&trs, v1beta1.TaskRunReasonFailed.String(), "failure message") + trs := v1.TaskRunStatus{} + markStatusFailure(&trs, v1.TaskRunReasonFailed.String(), "failure message") expected := &apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.TaskRunReasonFailed.String(), + Reason: v1.TaskRunReasonFailed.String(), Message: "failure message", } @@ -1789,13 +1799,13 @@ func TestMarkStatusFailure(t *testing.T) { } func TestMarkStatusSuccess(t *testing.T) { - trs := v1beta1.TaskRunStatus{} + trs := v1.TaskRunStatus{} markStatusSuccess(&trs) expected := &apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, - Reason: v1beta1.TaskRunReasonSuccessful.String(), + Reason: v1.TaskRunReasonSuccessful.String(), Message: "All Steps have completed executing", } @@ -1808,18 +1818,18 @@ func TestIsPodArchived(t *testing.T) { for _, tc := range []struct { name string podName string - retriesStatus []v1beta1.TaskRunStatus + retriesStatus []v1.TaskRunStatus want bool }{{ name: "Pod is not in the empty retriesStatus", podName: "pod", - retriesStatus: []v1beta1.TaskRunStatus{}, + retriesStatus: []v1.TaskRunStatus{}, want: false, }, { name: "Pod is not in the non-empty retriesStatus", podName: "pod-retry1", - retriesStatus: []v1beta1.TaskRunStatus{{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + retriesStatus: []v1.TaskRunStatus{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ PodName: "pod", }, }}, @@ -1827,16 +1837,16 @@ func TestIsPodArchived(t *testing.T) { }, { name: "Pod is in the retriesStatus", podName: "pod", - retriesStatus: []v1beta1.TaskRunStatus{{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + retriesStatus: []v1.TaskRunStatus{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ PodName: "pod", }}, }, want: true, }} { t.Run(tc.name, func(t *testing.T) { - trs := v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + trs := v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ PodName: "pod", RetriesStatus: tc.retriesStatus, }, @@ -1850,19 +1860,19 @@ func TestIsPodArchived(t *testing.T) { } func statusRunning() duckv1.Status { - var trs v1beta1.TaskRunStatus - markStatusRunning(&trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") + var trs v1.TaskRunStatus + markStatusRunning(&trs, v1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") return trs.Status } func statusFailure(reason, message string) duckv1.Status { - var trs v1beta1.TaskRunStatus + var trs v1.TaskRunStatus markStatusFailure(&trs, reason, message) return trs.Status } func statusSuccess() duckv1.Status { - var trs v1beta1.TaskRunStatus + var trs v1.TaskRunStatus markStatusSuccess(&trs) return trs.Status } diff --git a/pkg/reconciler/events/cache/cache_test.go b/pkg/reconciler/events/cache/cache_test.go index 4ae12beab5f..aaccb526128 100644 --- a/pkg/reconciler/events/cache/cache_test.go +++ b/pkg/reconciler/events/cache/cache_test.go @@ -80,7 +80,7 @@ func getCustomRunByMeta(name string, namespace string) *v1beta1.CustomRun { return &v1beta1.CustomRun{ TypeMeta: metav1.TypeMeta{ Kind: "CustomRun", - APIVersion: "v1beta1", + APIVersion: "v1", }, ObjectMeta: metav1.ObjectMeta{ Name: name, diff --git a/pkg/reconciler/events/cloudevent/cloud_event_controller_test.go b/pkg/reconciler/events/cloudevent/cloud_event_controller_test.go index d9771670038..686daceac0b 100644 --- a/pkg/reconciler/events/cloudevent/cloud_event_controller_test.go +++ b/pkg/reconciler/events/cloudevent/cloud_event_controller_test.go @@ -22,6 +22,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" @@ -56,11 +57,11 @@ func TestSendCloudEventWithRetries(t *testing.T) { clientBehaviour: cloudevent.FakeClientBehaviour{ SendSuccessfully: true, }, - object: &v1beta1.TaskRun{ + object: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ SelfLink: "/taskruns/test1", }, - Status: v1beta1.TaskRunStatus{Status: objectStatus}, + Status: v1.TaskRunStatus{Status: objectStatus}, }, wantCEvents: []string{"Context Attributes,"}, wantEvents: []string{}, @@ -69,11 +70,11 @@ func TestSendCloudEventWithRetries(t *testing.T) { clientBehaviour: cloudevent.FakeClientBehaviour{ SendSuccessfully: true, }, - object: &v1beta1.PipelineRun{ + object: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ SelfLink: "/pipelineruns/test1", }, - Status: v1beta1.PipelineRunStatus{Status: objectStatus}, + Status: v1.PipelineRunStatus{Status: objectStatus}, }, wantCEvents: []string{"Context Attributes,"}, wantEvents: []string{}, @@ -82,8 +83,8 @@ func TestSendCloudEventWithRetries(t *testing.T) { clientBehaviour: cloudevent.FakeClientBehaviour{ SendSuccessfully: false, }, - object: &v1beta1.PipelineRun{ - Status: v1beta1.PipelineRunStatus{Status: objectStatus}, + object: &v1.PipelineRun{ + Status: v1.PipelineRunStatus{Status: objectStatus}, }, wantCEvents: []string{}, wantEvents: []string{"Warning Cloud Event Failure"}, @@ -128,15 +129,15 @@ func TestSendCloudEventWithRetriesInvalid(t *testing.T) { wantEvent string }{{ name: "test-send-cloud-event-invalid-taskrun", - object: &v1beta1.TaskRun{ - Status: v1beta1.TaskRunStatus{}, + object: &v1.TaskRun{ + Status: v1.TaskRunStatus{}, }, wantCEvent: "Context Attributes,", wantEvent: "", }, { name: "test-send-cloud-event-pipelinerun", - object: &v1beta1.PipelineRun{ - Status: v1beta1.PipelineRunStatus{}, + object: &v1.PipelineRun{ + Status: v1.PipelineRunStatus{}, }, wantCEvent: "Context Attributes,", wantEvent: "", @@ -158,7 +159,7 @@ func TestSendCloudEventWithRetriesInvalid(t *testing.T) { func TestSendCloudEventWithRetriesNoClient(t *testing.T) { ctx := setupFakeContext(t, cloudevent.FakeClientBehaviour{}, false, 0) - err := cloudevent.SendCloudEventWithRetries(ctx, &v1beta1.TaskRun{Status: v1beta1.TaskRunStatus{}}) + err := cloudevent.SendCloudEventWithRetries(ctx, &v1.TaskRun{Status: v1.TaskRunStatus{}}) if err == nil { t.Fatalf("Expected an error sending cloud events with no client in the context, got none") } @@ -225,14 +226,14 @@ func TestEmitCloudEventsWhenConditionChange(t *testing.T) { Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionUnknown, - Reason: v1beta1.PipelineRunReasonStarted.String(), + Reason: v1.PipelineRunReasonStarted.String(), }}, } - object := &v1beta1.PipelineRun{ + object := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ SelfLink: "/pipelineruns/test1", }, - Status: v1beta1.PipelineRunStatus{Status: objectStatus}, + Status: v1.PipelineRunStatus{Status: objectStatus}, } after := &apis.Condition{ Type: apis.ConditionSucceeded, diff --git a/pkg/reconciler/events/cloudevent/cloudevent.go b/pkg/reconciler/events/cloudevent/cloudevent.go index 8cefaf54392..9d17c3c8d20 100644 --- a/pkg/reconciler/events/cloudevent/cloudevent.go +++ b/pkg/reconciler/events/cloudevent/cloudevent.go @@ -25,6 +25,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "knative.dev/pkg/apis" @@ -99,19 +100,19 @@ type CEClient interface { // TektonCloudEventData type is used to marshal and unmarshal the payload of // a Tekton cloud event. It can include a TaskRun or a PipelineRun type TektonCloudEventData struct { - TaskRun *v1beta1.TaskRun `json:"taskRun,omitempty"` - PipelineRun *v1beta1.PipelineRun `json:"pipelineRun,omitempty"` - Run *v1alpha1.Run `json:"run,omitempty"` - CustomRun *v1beta1.CustomRun `json:"customRun,omitempty"` + TaskRun *v1.TaskRun `json:"taskRun,omitempty"` + PipelineRun *v1.PipelineRun `json:"pipelineRun,omitempty"` + Run *v1alpha1.Run `json:"run,omitempty"` + CustomRun *v1beta1.CustomRun `json:"customRun,omitempty"` } // newTektonCloudEventData returns a new instance of TektonCloudEventData func newTektonCloudEventData(runObject objectWithCondition) TektonCloudEventData { tektonCloudEventData := TektonCloudEventData{} switch v := runObject.(type) { - case *v1beta1.TaskRun: + case *v1.TaskRun: tektonCloudEventData.TaskRun = v - case *v1beta1.PipelineRun: + case *v1.PipelineRun: tektonCloudEventData.PipelineRun = v case *v1alpha1.Run: tektonCloudEventData.Run = v @@ -175,20 +176,20 @@ func getEventType(runObject objectWithCondition) (*TektonEventType, error) { switch { case c.IsUnknown(): switch runObject.(type) { - case *v1beta1.TaskRun: + case *v1.TaskRun: switch c.Reason { - case v1beta1.TaskRunReasonStarted.String(): + case v1.TaskRunReasonStarted.String(): eventType = TaskRunStartedEventV1 - case v1beta1.TaskRunReasonRunning.String(): + case v1.TaskRunReasonRunning.String(): eventType = TaskRunRunningEventV1 default: eventType = TaskRunUnknownEventV1 } - case *v1beta1.PipelineRun: + case *v1.PipelineRun: switch c.Reason { - case v1beta1.PipelineRunReasonStarted.String(): + case v1.PipelineRunReasonStarted.String(): eventType = PipelineRunStartedEventV1 - case v1beta1.PipelineRunReasonRunning.String(): + case v1.PipelineRunReasonRunning.String(): eventType = PipelineRunRunningEventV1 default: eventType = PipelineRunUnknownEventV1 @@ -206,9 +207,9 @@ func getEventType(runObject objectWithCondition) (*TektonEventType, error) { } case c.IsFalse(): switch runObject.(type) { - case *v1beta1.TaskRun: + case *v1.TaskRun: eventType = TaskRunFailedEventV1 - case *v1beta1.PipelineRun: + case *v1.PipelineRun: eventType = PipelineRunFailedEventV1 case *v1alpha1.Run: eventType = RunFailedEventV1 @@ -217,9 +218,9 @@ func getEventType(runObject objectWithCondition) (*TektonEventType, error) { } case c.IsTrue(): switch runObject.(type) { - case *v1beta1.TaskRun: + case *v1.TaskRun: eventType = TaskRunSuccessfulEventV1 - case *v1beta1.PipelineRun: + case *v1.PipelineRun: eventType = PipelineRunSuccessfulEventV1 case *v1alpha1.Run: eventType = RunSuccessfulEventV1 diff --git a/pkg/reconciler/events/event_test.go b/pkg/reconciler/events/event_test.go index ba350a20259..8bba01a2ad5 100644 --- a/pkg/reconciler/events/event_test.go +++ b/pkg/reconciler/events/event_test.go @@ -20,7 +20,7 @@ import ( "testing" "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" "github.com/tektoncd/pipeline/pkg/reconciler/events/k8sevent" corev1 "k8s.io/api/core/v1" @@ -37,14 +37,14 @@ func TestEmit(t *testing.T) { Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionUnknown, - Reason: v1beta1.PipelineRunReasonStarted.String(), + Reason: v1.PipelineRunReasonStarted.String(), }}, } - object := &v1beta1.PipelineRun{ + object := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ SelfLink: "/pipelineruns/test1", }, - Status: v1beta1.PipelineRunStatus{Status: objectStatus}, + Status: v1.PipelineRunStatus{Status: objectStatus}, } after := &apis.Condition{ Type: apis.ConditionSucceeded, diff --git a/pkg/reconciler/events/k8sevent/event_test.go b/pkg/reconciler/events/k8sevent/event_test.go index f5c446696b5..b051447e5cc 100644 --- a/pkg/reconciler/events/k8sevent/event_test.go +++ b/pkg/reconciler/events/k8sevent/event_test.go @@ -22,7 +22,7 @@ import ( "time" "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/record" @@ -189,14 +189,14 @@ func TestEmitK8sEvents(t *testing.T) { Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionUnknown, - Reason: v1beta1.PipelineRunReasonStarted.String(), + Reason: v1.PipelineRunReasonStarted.String(), }}, } - object := &v1beta1.PipelineRun{ + object := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ SelfLink: "/pipelineruns/test1", }, - Status: v1beta1.PipelineRunStatus{Status: objectStatus}, + Status: v1.PipelineRunStatus{Status: objectStatus}, } after := &apis.Condition{ Type: apis.ConditionSucceeded, diff --git a/pkg/reconciler/pipeline/dag/dag_test.go b/pkg/reconciler/pipeline/dag/dag_test.go index d798455ff62..2eca1a57e1e 100644 --- a/pkg/reconciler/pipeline/dag/dag_test.go +++ b/pkg/reconciler/pipeline/dag/dag_test.go @@ -23,7 +23,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/list" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" "github.com/tektoncd/pipeline/test/diff" @@ -80,7 +80,7 @@ func TestGetSchedulable(t *testing.T) { if err != nil { t.Fatalf("Didn't expect error when getting next tasks for %v but got %v", tc.finished, err) } - if d := cmp.Diff(tasks, tc.expectedTasks, cmpopts.IgnoreFields(v1beta1.PipelineTask{}, "RunAfter")); d != "" { + if d := cmp.Diff(tasks, tc.expectedTasks, cmpopts.IgnoreFields(v1.PipelineTask{}, "RunAfter")); d != "" { t.Errorf("expected that with %v done, %v would be ready to schedule but was different: %s", tc.finished, tc.expectedTasks, diff.PrintWantGot(d)) } }) @@ -125,17 +125,17 @@ func TestGetSchedulable_Invalid(t *testing.T) { } func TestBuild_Parallel(t *testing.T) { - a := v1beta1.PipelineTask{Name: "a"} - b := v1beta1.PipelineTask{Name: "b"} - c := v1beta1.PipelineTask{Name: "c"} + a := v1.PipelineTask{Name: "a"} + b := v1.PipelineTask{Name: "b"} + c := v1.PipelineTask{Name: "c"} // This test make sure we can create a Pipeline with no links between any Tasks // (all tasks run in parallel) // a b c - p := &v1beta1.Pipeline{ + p := &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{a, b, c}, + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{a, b, c}, }, } expectedDAG := &dag.Graph{ @@ -145,7 +145,7 @@ func TestBuild_Parallel(t *testing.T) { "c": {Key: "c"}, }, } - g, err := dag.Build(v1beta1.PipelineTaskList(p.Spec.Tasks), v1beta1.PipelineTaskList(p.Spec.Tasks).Deps()) + g, err := dag.Build(v1.PipelineTaskList(p.Spec.Tasks), v1.PipelineTaskList(p.Spec.Tasks).Deps()) if err != nil { t.Fatalf("didn't expect error creating valid Pipeline %v but got %v", p, err) } @@ -153,41 +153,41 @@ func TestBuild_Parallel(t *testing.T) { } func TestBuild_JoinMultipleRoots(t *testing.T) { - a := v1beta1.PipelineTask{ + a := v1.PipelineTask{ Name: "a", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result", }}, }}, } - b := v1beta1.PipelineTask{Name: "b"} - c := v1beta1.PipelineTask{ + b := v1.PipelineTask{Name: "b"} + c := v1.PipelineTask{ Name: "c", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result", }}, }}, } - xDependsOnA := v1beta1.PipelineTask{ + xDependsOnA := v1.PipelineTask{ Name: "x", - Params: []v1beta1.Param{ + Params: []v1.Param{ { - Value: *v1beta1.NewStructuredValues("$(tasks.a.results.result)"), + Value: *v1.NewStructuredValues("$(tasks.a.results.result)"), }, }, } - yDependsOnARunsAfterB := v1beta1.PipelineTask{ + yDependsOnARunsAfterB := v1.PipelineTask{ Name: "y", RunAfter: []string{"b"}, - Params: []v1beta1.Param{ + Params: []v1.Param{ { - Value: *v1beta1.NewStructuredValues("$(tasks.a.results.result)"), + Value: *v1.NewStructuredValues("$(tasks.a.results.result)"), }, }, } - zRunsAfterx := v1beta1.PipelineTask{ + zRunsAfterx := v1.PipelineTask{ Name: "z", RunAfter: []string{"x"}, } @@ -221,13 +221,13 @@ func TestBuild_JoinMultipleRoots(t *testing.T) { "y": nodeY, "z": nodeZ}, } - p := &v1beta1.Pipeline{ + p := &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{a, xDependsOnA, yDependsOnARunsAfterB, zRunsAfterx, b, c}, + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{a, xDependsOnA, yDependsOnARunsAfterB, zRunsAfterx, b, c}, }, } - g, err := dag.Build(v1beta1.PipelineTaskList(p.Spec.Tasks), v1beta1.PipelineTaskList(p.Spec.Tasks).Deps()) + g, err := dag.Build(v1.PipelineTaskList(p.Spec.Tasks), v1.PipelineTaskList(p.Spec.Tasks).Deps()) if err != nil { t.Fatalf("didn't expect error creating valid Pipeline %v but got %v", p, err) } @@ -235,45 +235,45 @@ func TestBuild_JoinMultipleRoots(t *testing.T) { } func TestBuild_FanInFanOut(t *testing.T) { - a := v1beta1.PipelineTask{ + a := v1.PipelineTask{ Name: "a", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result", }}, }}, } - dDependsOnA := v1beta1.PipelineTask{ + dDependsOnA := v1.PipelineTask{ Name: "d", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "resultFromD", }}, }}, - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.a.results.result)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.a.results.result)"), }}, } - eDependsOnA := v1beta1.PipelineTask{ + eDependsOnA := v1.PipelineTask{ Name: "e", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "resultFromE", }}, }}, - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.a.results.result)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.a.results.result)"), }}, } - fDependsOnDAndE := v1beta1.PipelineTask{ + fDependsOnDAndE := v1.PipelineTask{ Name: "f", - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.d.results.resultFromD)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.d.results.resultFromD)"), }, { - Value: *v1beta1.NewStructuredValues("$(tasks.e.results.resultFromE)"), + Value: *v1.NewStructuredValues("$(tasks.e.results.resultFromE)"), }}, } - gRunsAfterF := v1beta1.PipelineTask{ + gRunsAfterF := v1.PipelineTask{ Name: "g", RunAfter: []string{"f"}, } @@ -311,13 +311,13 @@ func TestBuild_FanInFanOut(t *testing.T) { "g": nodeG, }, } - p := &v1beta1.Pipeline{ + p := &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{a, dDependsOnA, eDependsOnA, fDependsOnDAndE, gRunsAfterF}, + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{a, dDependsOnA, eDependsOnA, fDependsOnDAndE, gRunsAfterF}, }, } - g, err := dag.Build(v1beta1.PipelineTaskList(p.Spec.Tasks), v1beta1.PipelineTaskList(p.Spec.Tasks).Deps()) + g, err := dag.Build(v1.PipelineTaskList(p.Spec.Tasks), v1.PipelineTaskList(p.Spec.Tasks).Deps()) if err != nil { t.Fatalf("didn't expect error creating valid Pipeline %v but got %v", p, err) } @@ -325,39 +325,39 @@ func TestBuild_FanInFanOut(t *testing.T) { } func TestBuild_TaskParamsFromTaskResults(t *testing.T) { - a := v1beta1.PipelineTask{Name: "a"} - b := v1beta1.PipelineTask{Name: "b"} - c := v1beta1.PipelineTask{Name: "c"} - d := v1beta1.PipelineTask{Name: "d"} - e := v1beta1.PipelineTask{Name: "e"} - f := v1beta1.PipelineTask{Name: "f"} - xDependsOnA := v1beta1.PipelineTask{ + a := v1.PipelineTask{Name: "a"} + b := v1.PipelineTask{Name: "b"} + c := v1.PipelineTask{Name: "c"} + d := v1.PipelineTask{Name: "d"} + e := v1.PipelineTask{Name: "e"} + f := v1.PipelineTask{Name: "f"} + xDependsOnA := v1.PipelineTask{ Name: "x", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "paramX", - Value: *v1beta1.NewStructuredValues("$(tasks.a.results.resultA)"), + Value: *v1.NewStructuredValues("$(tasks.a.results.resultA)"), }}, } - yDependsOnBRunsAfterC := v1beta1.PipelineTask{ + yDependsOnBRunsAfterC := v1.PipelineTask{ Name: "y", RunAfter: []string{"c"}, - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "paramB", - Value: *v1beta1.NewStructuredValues("$(tasks.b.results.resultB)"), + Value: *v1.NewStructuredValues("$(tasks.b.results.resultB)"), }}, } - zDependsOnDAndE := v1beta1.PipelineTask{ + zDependsOnDAndE := v1.PipelineTask{ Name: "z", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "paramZ", - Value: *v1beta1.NewStructuredValues("$(tasks.d.results.resultD) $(tasks.e.results.resultE)"), + Value: *v1.NewStructuredValues("$(tasks.d.results.resultD) $(tasks.e.results.resultE)"), }}, } - wDependsOnF := v1beta1.PipelineTask{ + wDependsOnF := v1.PipelineTask{ Name: "w", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "paramw", - Value: *v1beta1.NewStructuredValues("$(tasks.f.results.resultF[*])"), + Value: *v1.NewStructuredValues("$(tasks.f.results.resultF[*])"), }}, } @@ -400,13 +400,13 @@ func TestBuild_TaskParamsFromTaskResults(t *testing.T) { "w": nodeW, }, } - p := &v1beta1.Pipeline{ + p := &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{a, b, c, d, e, f, xDependsOnA, yDependsOnBRunsAfterC, zDependsOnDAndE, wDependsOnF}, + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{a, b, c, d, e, f, xDependsOnA, yDependsOnBRunsAfterC, zDependsOnDAndE, wDependsOnF}, }, } - tasks := v1beta1.PipelineTaskList(p.Spec.Tasks) + tasks := v1.PipelineTaskList(p.Spec.Tasks) g, err := dag.Build(tasks, tasks.Deps()) if err != nil { t.Fatalf("didn't expect error creating valid Pipeline %v but got %v", p, err) @@ -415,148 +415,148 @@ func TestBuild_TaskParamsFromTaskResults(t *testing.T) { } func TestBuild_InvalidDAG(t *testing.T) { - a := v1beta1.PipelineTask{ + a := v1.PipelineTask{ Name: "a", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result", }}, }}, } - xDependsOnA := v1beta1.PipelineTask{ + xDependsOnA := v1.PipelineTask{ Name: "x", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "resultX", }}, }}, - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.a.results.result)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.a.results.result)"), }}, } - zRunsAfterx := v1beta1.PipelineTask{ + zDependsOnX := v1.PipelineTask{ Name: "z", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "resultZ", }}, }}, - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.x.results.resultX)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.x.results.resultX)"), }}, } - aDependsOnZ := v1beta1.PipelineTask{ + aDependsOnZ := v1.PipelineTask{ Name: "a", - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.z.results.resultZ)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.z.results.resultZ)"), }}, } - xAfterA := v1beta1.PipelineTask{ + xAfterA := v1.PipelineTask{ Name: "x", RunAfter: []string{"a"}, } - zAfterX := v1beta1.PipelineTask{ + zAfterX := v1.PipelineTask{ Name: "z", RunAfter: []string{"x"}, } - aAfterZ := v1beta1.PipelineTask{ + aAfterZ := v1.PipelineTask{ Name: "a", RunAfter: []string{"z"}, } - selfLinkResult := v1beta1.PipelineTask{ + selfLinkResult := v1.PipelineTask{ Name: "a", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result", }}, }}, - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.a.results.result)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.a.results.result)"), }}, } - invalidTaskResult := v1beta1.PipelineTask{ + invalidTaskResult := v1.PipelineTask{ Name: "a", - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.invalid.results.none)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.invalid.results.none)"), }}, } - selfLinkAfter := v1beta1.PipelineTask{ + selfLinkAfter := v1.PipelineTask{ Name: "a", RunAfter: []string{"a"}, } - invalidTaskAfter := v1beta1.PipelineTask{ + invalidTaskAfter := v1.PipelineTask{ Name: "a", RunAfter: []string{"none"}, } - aRunsAfterE := v1beta1.PipelineTask{ + aRunsAfterE := v1.PipelineTask{ Name: "a", RunAfter: []string{"e"}, - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result", }}, }}, } - bDependsOnA := v1beta1.PipelineTask{ + bDependsOnA := v1.PipelineTask{ Name: "b", - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.a.results.result)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.a.results.result)"), }}, - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "resultb", }}, }}, } - cDependsOnA := v1beta1.PipelineTask{ + cRunsAfterA := v1.PipelineTask{ Name: "c", - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.a.results.result)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.a.results.result)"), }}, - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "resultc", }}, }}, } - dDependsOnBAndC := v1beta1.PipelineTask{ + dDependsOnBAndC := v1.PipelineTask{ Name: "d", - Params: []v1beta1.Param{{ - Value: *v1beta1.NewStructuredValues("$(tasks.b.results.resultb)"), + Params: []v1.Param{{ + Value: *v1.NewStructuredValues("$(tasks.b.results.resultb)"), }, { - Value: *v1beta1.NewStructuredValues("$(tasks.c.results.resultc)"), + Value: *v1.NewStructuredValues("$(tasks.c.results.resultc)"), }}, } - eRunsAfterD := v1beta1.PipelineTask{ + eRunsAfterD := v1.PipelineTask{ Name: "e", RunAfter: []string{"d"}, } - fRunsAfterD := v1beta1.PipelineTask{ + fRunsAfterD := v1.PipelineTask{ Name: "f", RunAfter: []string{"d"}, } - gRunAfterF := v1beta1.PipelineTask{ + gDependsOnF := v1.PipelineTask{ Name: "g", RunAfter: []string{"f"}, } tcs := []struct { name string - spec v1beta1.PipelineSpec + spec v1.PipelineSpec err string }{{ // a // | // a ("a" uses result of "a" as params) name: "self-link-result", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{selfLinkResult}}, + spec: v1.PipelineSpec{Tasks: []v1.PipelineTask{selfLinkResult}}, err: "cycle detected", }, { // a // | // a ("a" runAfter "a") name: "self-link-after", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{selfLinkAfter}}, + spec: v1.PipelineSpec{Tasks: []v1.PipelineTask{selfLinkAfter}}, err: "cycle detected", }, { // a (also "a" depends on resource from "z") @@ -565,7 +565,7 @@ func TestBuild_InvalidDAG(t *testing.T) { // | // z ("z" depends on resource from "x") name: "cycle-from", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{xDependsOnA, zRunsAfterx, aDependsOnZ}}, + spec: v1.PipelineSpec{Tasks: []v1.PipelineTask{xDependsOnA, zDependsOnX, aDependsOnZ}}, err: "cycle detected", }, { // a (also "a" runAfter "z") @@ -574,7 +574,7 @@ func TestBuild_InvalidDAG(t *testing.T) { // | // z ("z" runAfter "x") name: "cycle-runAfter", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{xAfterA, zAfterX, aAfterZ}}, + spec: v1.PipelineSpec{Tasks: []v1.PipelineTask{xAfterA, zAfterX, aAfterZ}}, err: "cycle detected", }, { // a (also "a" depends on resource from "z") @@ -583,7 +583,7 @@ func TestBuild_InvalidDAG(t *testing.T) { // | // z ("z" runAfter "x") name: "cycle-both", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{xDependsOnA, zAfterX, aDependsOnZ}}, + spec: v1.PipelineSpec{Tasks: []v1.PipelineTask{xDependsOnA, zAfterX, aDependsOnZ}}, err: "cycle detected", }, { // This test make sure we detect a cyclic branch in a DAG with multiple branches. @@ -598,29 +598,29 @@ func TestBuild_InvalidDAG(t *testing.T) { // | // g name: "multiple-branches-with-one-cyclic-branch", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{aRunsAfterE, bDependsOnA, cDependsOnA, dDependsOnBAndC, eRunsAfterD, fRunsAfterD, gRunAfterF}}, + spec: v1.PipelineSpec{Tasks: []v1.PipelineTask{aRunsAfterE, bDependsOnA, cRunsAfterA, dDependsOnBAndC, eRunsAfterD, fRunsAfterD, gDependsOnF}}, err: "cycle detected", }, { name: "duplicate-tasks", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{a, a}}, + spec: v1.PipelineSpec{Tasks: []v1.PipelineTask{a, a}}, err: "duplicate pipeline task", }, { name: "invalid-task-result", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{invalidTaskResult}}, + spec: v1.PipelineSpec{Tasks: []v1.PipelineTask{invalidTaskResult}}, err: "wasn't present in Pipeline", }, { name: "invalid-task-name-after", - spec: v1beta1.PipelineSpec{Tasks: []v1beta1.PipelineTask{invalidTaskAfter}}, + spec: v1.PipelineSpec{Tasks: []v1.PipelineTask{invalidTaskAfter}}, err: "wasn't present in Pipeline", }, } for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { - p := &v1beta1.Pipeline{ + p := &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{Name: tc.name}, Spec: tc.spec, } - _, err := dag.Build(v1beta1.PipelineTaskList(p.Spec.Tasks), v1beta1.PipelineTaskList(p.Spec.Tasks).Deps()) + _, err := dag.Build(v1.PipelineTaskList(p.Spec.Tasks), v1.PipelineTaskList(p.Spec.Tasks).Deps()) if err == nil || !strings.Contains(err.Error(), tc.err) { t.Errorf("expected to see an error for invalid DAG in pipeline %v but had none", tc.spec) } @@ -629,7 +629,7 @@ func TestBuild_InvalidDAG(t *testing.T) { } func TestBuildGraphWithHundredsOfTasks_Success(t *testing.T) { - var tasks []v1beta1.PipelineTask + var tasks []v1.PipelineTask // separate branches with sequential tasks and redundant links (each task explicitly depends on all predecessors) // b00 - 000 - 001 - ... - 100 // b01 - 000 - 001 - ... - 100 @@ -639,18 +639,18 @@ func TestBuildGraphWithHundredsOfTasks_Success(t *testing.T) { for branchIdx := 0; branchIdx < nBranches; branchIdx++ { var taskDeps []string firstTaskName := fmt.Sprintf("b%02d", branchIdx) - firstTask := v1beta1.PipelineTask{ + firstTask := v1.PipelineTask{ Name: firstTaskName, - TaskRef: &v1beta1.TaskRef{Name: firstTaskName + "-task"}, + TaskRef: &v1.TaskRef{Name: firstTaskName + "-task"}, RunAfter: taskDeps, } tasks = append(tasks, firstTask) taskDeps = append(taskDeps, firstTaskName) for taskIdx := 0; taskIdx < nTasks; taskIdx++ { taskName := fmt.Sprintf("%s-%03d", firstTaskName, taskIdx) - task := v1beta1.PipelineTask{ + task := v1.PipelineTask{ Name: taskName, - TaskRef: &v1beta1.TaskRef{Name: taskName + "-task"}, + TaskRef: &v1.TaskRef{Name: taskName + "-task"}, RunAfter: taskDeps, } tasks = append(tasks, task) @@ -658,14 +658,14 @@ func TestBuildGraphWithHundredsOfTasks_Success(t *testing.T) { } } - _, err := dag.Build(v1beta1.PipelineTaskList(tasks), v1beta1.PipelineTaskList(tasks).Deps()) + _, err := dag.Build(v1.PipelineTaskList(tasks), v1.PipelineTaskList(tasks).Deps()) if err != nil { t.Error(err) } } func TestBuildGraphWithHundredsOfTasks_InvalidDAG(t *testing.T) { - var tasks []v1beta1.PipelineTask + var tasks []v1.PipelineTask // branches with circular interdependencies nBranches, nTasks := 5, 100 for branchIdx := 0; branchIdx < nBranches; branchIdx++ { @@ -675,18 +675,18 @@ func TestBuildGraphWithHundredsOfTasks_InvalidDAG(t *testing.T) { } taskDeps := []string{fmt.Sprintf("b%02d", depBranchIdx)} firstTaskName := fmt.Sprintf("b%02d", branchIdx) - firstTask := v1beta1.PipelineTask{ + firstTask := v1.PipelineTask{ Name: firstTaskName, - TaskRef: &v1beta1.TaskRef{Name: firstTaskName + "-task"}, + TaskRef: &v1.TaskRef{Name: firstTaskName + "-task"}, RunAfter: taskDeps, } tasks = append(tasks, firstTask) taskDeps = append(taskDeps, firstTaskName) for taskIdx := 0; taskIdx < nTasks; taskIdx++ { taskName := fmt.Sprintf("%s-%03d", firstTaskName, taskIdx) - task := v1beta1.PipelineTask{ + task := v1.PipelineTask{ Name: taskName, - TaskRef: &v1beta1.TaskRef{Name: taskName + "-task"}, + TaskRef: &v1.TaskRef{Name: taskName + "-task"}, RunAfter: taskDeps, } tasks = append(tasks, task) @@ -694,7 +694,7 @@ func TestBuildGraphWithHundredsOfTasks_InvalidDAG(t *testing.T) { } } - _, err := dag.Build(v1beta1.PipelineTaskList(tasks), v1beta1.PipelineTaskList(tasks).Deps()) + _, err := dag.Build(v1.PipelineTaskList(tasks), v1.PipelineTaskList(tasks).Deps()) if err == nil { t.Errorf("Pipeline.Validate() did not return error for invalid pipeline with cycles") } @@ -709,15 +709,15 @@ func testGraph(t *testing.T) *dag.Graph { // \ / z // w t.Helper() - tasks := []v1beta1.PipelineTask{{ + tasks := []v1.PipelineTask{{ Name: "a", }, { Name: "b", }, { Name: "w", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("$(tasks.y.results.bar)"), + Value: *v1.NewStructuredValues("$(tasks.y.results.bar)"), }}, RunAfter: []string{"b"}, }, { @@ -730,7 +730,7 @@ func testGraph(t *testing.T) *dag.Graph { Name: "z", RunAfter: []string{"x"}, }} - g, err := dag.Build(v1beta1.PipelineTaskList(tasks), v1beta1.PipelineTaskList(tasks).Deps()) + g, err := dag.Build(v1.PipelineTaskList(tasks), v1.PipelineTaskList(tasks).Deps()) if err != nil { t.Fatal(err) } diff --git a/pkg/reconciler/pipelinerun/affinity_assistant.go b/pkg/reconciler/pipelinerun/affinity_assistant.go index 7433313740f..1b110539eb7 100644 --- a/pkg/reconciler/pipelinerun/affinity_assistant.go +++ b/pkg/reconciler/pipelinerun/affinity_assistant.go @@ -24,7 +24,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/reconciler/volumeclaim" "github.com/tektoncd/pipeline/pkg/workspace" appsv1 "k8s.io/api/apps/v1" @@ -48,7 +48,7 @@ const ( // createAffinityAssistants creates an Affinity Assistant StatefulSet for every workspace in the PipelineRun that // use a PersistentVolumeClaim volume. This is done to achieve Node Affinity for all TaskRuns that // share the workspace volume and make it possible for the tasks to execute parallel while sharing volume. -func (c *Reconciler) createAffinityAssistants(ctx context.Context, wb []v1beta1.WorkspaceBinding, pr *v1beta1.PipelineRun, namespace string) error { +func (c *Reconciler) createAffinityAssistants(ctx context.Context, wb []v1.WorkspaceBinding, pr *v1.PipelineRun, namespace string) error { logger := logging.FromContext(ctx) cfg := config.FromContextOrDefaults(ctx) @@ -76,7 +76,7 @@ func (c *Reconciler) createAffinityAssistants(ctx context.Context, wb []v1beta1. return errorutils.NewAggregate(errs) } -func getClaimName(w v1beta1.WorkspaceBinding, ownerReference metav1.OwnerReference) string { +func getClaimName(w v1.WorkspaceBinding, ownerReference metav1.OwnerReference) string { if w.PersistentVolumeClaim != nil { return w.PersistentVolumeClaim.ClaimName } else if w.VolumeClaimTemplate != nil { @@ -86,7 +86,7 @@ func getClaimName(w v1beta1.WorkspaceBinding, ownerReference metav1.OwnerReferen return "" } -func (c *Reconciler) cleanupAffinityAssistants(ctx context.Context, pr *v1beta1.PipelineRun) error { +func (c *Reconciler) cleanupAffinityAssistants(ctx context.Context, pr *v1.PipelineRun) error { // omit cleanup if the feature is disabled if c.isAffinityAssistantDisabled(ctx) { return nil @@ -110,7 +110,7 @@ func getAffinityAssistantName(pipelineWorkspaceName string, pipelineRunName stri return fmt.Sprintf("%s-%s", "affinity-assistant", hashString[:10]) } -func getStatefulSetLabels(pr *v1beta1.PipelineRun, affinityAssistantName string) map[string]string { +func getStatefulSetLabels(pr *v1.PipelineRun, affinityAssistantName string) map[string]string { // Propagate labels from PipelineRun to StatefulSet. labels := make(map[string]string, len(pr.ObjectMeta.Labels)+1) for key, val := range pr.ObjectMeta.Labels { @@ -125,14 +125,14 @@ func getStatefulSetLabels(pr *v1beta1.PipelineRun, affinityAssistantName string) return labels } -func affinityAssistantStatefulSet(name string, pr *v1beta1.PipelineRun, claimName string, affinityAssistantImage string, defaultAATpl *pod.AffinityAssistantTemplate) *appsv1.StatefulSet { +func affinityAssistantStatefulSet(name string, pr *v1.PipelineRun, claimName string, affinityAssistantImage string, defaultAATpl *pod.AffinityAssistantTemplate) *appsv1.StatefulSet { // We want a singleton pod replicas := int32(1) tpl := &pod.AffinityAssistantTemplate{} // merge pod template from spec and default if any of them are defined - if pr.Spec.PodTemplate != nil || defaultAATpl != nil { - tpl = pod.MergeAAPodTemplateWithDefault(pr.Spec.PodTemplate.ToAffinityAssistantTemplate(), defaultAATpl) + if pr.Spec.TaskRunTemplate.PodTemplate != nil || defaultAATpl != nil { + tpl = pod.MergeAAPodTemplateWithDefault(pr.Spec.TaskRunTemplate.PodTemplate.ToAffinityAssistantTemplate(), defaultAATpl) } containers := []corev1.Container{{ @@ -213,7 +213,7 @@ func (c *Reconciler) isAffinityAssistantDisabled(ctx context.Context) bool { } // getAssistantAffinityMergedWithPodTemplateAffinity return the affinity that merged with PipelineRun PodTemplate affinity. -func getAssistantAffinityMergedWithPodTemplateAffinity(pr *v1beta1.PipelineRun) *corev1.Affinity { +func getAssistantAffinityMergedWithPodTemplateAffinity(pr *v1.PipelineRun) *corev1.Affinity { // use podAntiAffinity to repel other affinity assistants repelOtherAffinityAssistantsPodAffinityTerm := corev1.WeightedPodAffinityTerm{ Weight: 100, @@ -228,8 +228,8 @@ func getAssistantAffinityMergedWithPodTemplateAffinity(pr *v1beta1.PipelineRun) } affinityAssistantsAffinity := &corev1.Affinity{} - if pr.Spec.PodTemplate != nil && pr.Spec.PodTemplate.Affinity != nil { - affinityAssistantsAffinity = pr.Spec.PodTemplate.Affinity + if pr.Spec.TaskRunTemplate.PodTemplate != nil && pr.Spec.TaskRunTemplate.PodTemplate.Affinity != nil { + affinityAssistantsAffinity = pr.Spec.TaskRunTemplate.PodTemplate.Affinity } if affinityAssistantsAffinity.PodAntiAffinity == nil { affinityAssistantsAffinity.PodAntiAffinity = &corev1.PodAntiAffinity{} diff --git a/pkg/reconciler/pipelinerun/affinity_assistant_test.go b/pkg/reconciler/pipelinerun/affinity_assistant_test.go index ff7fb6fad98..ecf16086849 100644 --- a/pkg/reconciler/pipelinerun/affinity_assistant_test.go +++ b/pkg/reconciler/pipelinerun/affinity_assistant_test.go @@ -24,7 +24,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/workspace" "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/parse" @@ -51,13 +51,13 @@ func TestCreateAndDeleteOfAffinityAssistant(t *testing.T) { workspaceName := "testws" pipelineRunName := "pipelinerun-1" - testPipelineRun := &v1beta1.PipelineRun{ + testPipelineRun := &v1.PipelineRun{ TypeMeta: metav1.TypeMeta{Kind: "PipelineRun"}, ObjectMeta: metav1.ObjectMeta{ Name: pipelineRunName, }, - Spec: v1beta1.PipelineRunSpec{ - Workspaces: []v1beta1.WorkspaceBinding{{ + Spec: v1.PipelineRunSpec{ + Workspaces: []v1.WorkspaceBinding{{ Name: workspaceName, PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "myclaim", @@ -89,13 +89,13 @@ func TestCreateAndDeleteOfAffinityAssistant(t *testing.T) { } func TestPipelineRunPodTemplatesArePropagatedToAffinityAssistant(t *testing.T) { - prWithCustomPodTemplate := &v1beta1.PipelineRun{ + prWithCustomPodTemplate := &v1.PipelineRun{ TypeMeta: metav1.TypeMeta{Kind: "PipelineRun"}, ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun-with-custom-podtemplate", }, - Spec: v1beta1.PipelineRunSpec{ - PodTemplate: &pod.Template{ + Spec: v1.PipelineRunSpec{ + TaskRunTemplate: v1.PipelineTaskRunTemplate{PodTemplate: &pod.Template{ Tolerations: []corev1.Toleration{{ Key: "key", Operator: "Equal", @@ -108,7 +108,7 @@ func TestPipelineRunPodTemplatesArePropagatedToAffinityAssistant(t *testing.T) { ImagePullSecrets: []corev1.LocalObjectReference{{ Name: "reg-creds", }}, - }, + }}, }, } @@ -128,7 +128,7 @@ func TestPipelineRunPodTemplatesArePropagatedToAffinityAssistant(t *testing.T) { } func TestDefaultPodTemplatesArePropagatedToAffinityAssistant(t *testing.T) { - prWithCustomPodTemplate := &v1beta1.PipelineRun{ + prWithCustomPodTemplate := &v1.PipelineRun{ TypeMeta: metav1.TypeMeta{Kind: "PipelineRun"}, ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun-with-custom-podtemplate", @@ -166,13 +166,13 @@ func TestDefaultPodTemplatesArePropagatedToAffinityAssistant(t *testing.T) { } func TestMergedPodTemplatesArePropagatedToAffinityAssistant(t *testing.T) { - prWithCustomPodTemplate := &v1beta1.PipelineRun{ + prWithCustomPodTemplate := &v1.PipelineRun{ TypeMeta: metav1.TypeMeta{Kind: "PipelineRun"}, ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun-with-custom-podtemplate", }, - Spec: v1beta1.PipelineRunSpec{ - PodTemplate: &pod.Template{ + Spec: v1.PipelineRunSpec{ + TaskRunTemplate: v1.PipelineTaskRunTemplate{PodTemplate: &pod.Template{ Tolerations: []corev1.Toleration{{ Key: "key", Operator: "Equal", @@ -183,7 +183,7 @@ func TestMergedPodTemplatesArePropagatedToAffinityAssistant(t *testing.T) { {Name: "reg-creds"}, {Name: "alt-creds"}, }, - }, + }}, }, } @@ -212,13 +212,13 @@ func TestMergedPodTemplatesArePropagatedToAffinityAssistant(t *testing.T) { } func TestOnlySelectPodTemplateFieldsArePropagatedToAffinityAssistant(t *testing.T) { - prWithCustomPodTemplate := &v1beta1.PipelineRun{ + prWithCustomPodTemplate := &v1.PipelineRun{ TypeMeta: metav1.TypeMeta{Kind: "PipelineRun"}, ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun-with-custom-podtemplate", }, - Spec: v1beta1.PipelineRunSpec{ - PodTemplate: &pod.Template{ + Spec: v1.PipelineRunSpec{ + TaskRunTemplate: v1.PipelineTaskRunTemplate{PodTemplate: &pod.Template{ Tolerations: []corev1.Toleration{{ Key: "key", Operator: "Equal", @@ -229,7 +229,7 @@ func TestOnlySelectPodTemplateFieldsArePropagatedToAffinityAssistant(t *testing. IP: "1.2.3.4", Hostnames: []string{"localhost"}, }}, - }, + }}, }, } @@ -245,12 +245,12 @@ func TestOnlySelectPodTemplateFieldsArePropagatedToAffinityAssistant(t *testing. } func TestThatTheAffinityAssistantIsWithoutNodeSelectorAndTolerations(t *testing.T) { - prWithoutCustomPodTemplate := &v1beta1.PipelineRun{ + prWithoutCustomPodTemplate := &v1.PipelineRun{ TypeMeta: metav1.TypeMeta{Kind: "PipelineRun"}, ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun-without-custom-podtemplate", }, - Spec: v1beta1.PipelineRunSpec{}, + Spec: v1.PipelineRunSpec{}, } stsWithoutTolerationsAndNodeSelector := affinityAssistantStatefulSet("test-assistant", prWithoutCustomPodTemplate, "mypvc", "nginx", nil) @@ -284,13 +284,13 @@ func TestThatAffinityAssistantNameIsNoLongerThan53(t *testing.T) { // cleanup of Affinity Assistants is omitted when the // Affinity Assistant is disabled func TestThatCleanupIsAvoidedIfAssistantIsDisabled(t *testing.T) { - testPipelineRun := &v1beta1.PipelineRun{ + testPipelineRun := &v1.PipelineRun{ TypeMeta: metav1.TypeMeta{Kind: "PipelineRun"}, ObjectMeta: metav1.ObjectMeta{ Name: "test-pipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ - Workspaces: []v1beta1.WorkspaceBinding{{ + Spec: v1.PipelineRunSpec{ + Workspaces: []v1.WorkspaceBinding{{ Name: "test-workspace", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "myclaim", @@ -384,7 +384,7 @@ func TestGetAssistantAffinityMergedWithPodTemplateAffinity(t *testing.T) { }, } - prWithEmptyAffinityPodTemplate := parse.MustParseV1beta1PipelineRun(t, ` + prWithEmptyAffinityPodTemplate := parse.MustParseV1PipelineRun(t, ` metadata: name: pr-with-no-podTemplate `) @@ -396,7 +396,7 @@ metadata: }, } - prWithPodTemplatePodAffinity := parse.MustParseV1beta1PipelineRun(t, ` + prWithPodTemplatePodAffinity := parse.MustParseV1PipelineRun(t, ` metadata: name: pr-with-podTemplate-podAffinity spec: @@ -445,7 +445,7 @@ spec: }, } - prWithPodTemplateNodeAffinity := parse.MustParseV1beta1PipelineRun(t, ` + prWithPodTemplateNodeAffinity := parse.MustParseV1PipelineRun(t, ` metadata: name: pr-with-podTemplate-nodeAffinity spec: @@ -487,7 +487,7 @@ spec: for _, tc := range []struct { description string - pr *v1beta1.PipelineRun + pr *v1.PipelineRun expect *corev1.Affinity }{ { diff --git a/pkg/reconciler/pipelinerun/cancel.go b/pkg/reconciler/pipelinerun/cancel.go index 4416b79bcfe..24b2dcdd528 100644 --- a/pkg/reconciler/pipelinerun/cancel.go +++ b/pkg/reconciler/pipelinerun/cancel.go @@ -24,6 +24,7 @@ import ( "strings" "time" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" @@ -45,12 +46,12 @@ func init() { { Operation: "add", Path: "/spec/status", - Value: v1beta1.TaskRunSpecStatusCancelled, + Value: v1.TaskRunSpecStatusCancelled, }, { Operation: "add", Path: "/spec/statusMessage", - Value: v1beta1.TaskRunCancelledByPipelineMsg, + Value: v1.TaskRunCancelledByPipelineMsg, }}) if err != nil { log.Fatalf("failed to marshal TaskRun cancel patch bytes: %v", err) @@ -106,7 +107,7 @@ func cancelRun(ctx context.Context, runName string, namespace string, clientSet } func cancelTaskRun(ctx context.Context, taskRunName string, namespace string, clientSet clientset.Interface) error { - _, err := clientSet.TektonV1beta1().TaskRuns(namespace).Patch(ctx, taskRunName, types.JSONPatchType, cancelTaskRunPatchBytes, metav1.PatchOptions{}, "") + _, err := clientSet.TektonV1().TaskRuns(namespace).Patch(ctx, taskRunName, types.JSONPatchType, cancelTaskRunPatchBytes, metav1.PatchOptions{}, "") if errors.IsNotFound(err) { // The resource may have been deleted in the meanwhile, but we should // still be able to cancel the PipelineRun @@ -116,7 +117,7 @@ func cancelTaskRun(ctx context.Context, taskRunName string, namespace string, cl } // cancelPipelineRun marks the PipelineRun as cancelled and any resolved TaskRun(s) too. -func cancelPipelineRun(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, clientSet clientset.Interface) error { +func cancelPipelineRun(ctx context.Context, logger *zap.SugaredLogger, pr *v1.PipelineRun, clientSet clientset.Interface) error { errs := cancelPipelineTaskRuns(ctx, logger, pr, clientSet) // If we successfully cancelled all the TaskRuns and Runs, we can consider the PipelineRun cancelled. @@ -146,12 +147,12 @@ func cancelPipelineRun(ctx context.Context, logger *zap.SugaredLogger, pr *v1bet } // cancelPipelineTaskRuns patches `TaskRun` and `Run` with canceled status -func cancelPipelineTaskRuns(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, clientSet clientset.Interface) []string { +func cancelPipelineTaskRuns(ctx context.Context, logger *zap.SugaredLogger, pr *v1.PipelineRun, clientSet clientset.Interface) []string { return cancelPipelineTaskRunsForTaskNames(ctx, logger, pr, clientSet, sets.NewString()) } // cancelPipelineTaskRunsForTaskNames patches `TaskRun`s and `Run`s for the given task names, or all if no task names are given, with canceled status -func cancelPipelineTaskRunsForTaskNames(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, clientSet clientset.Interface, taskNames sets.String) []string { +func cancelPipelineTaskRunsForTaskNames(ctx context.Context, logger *zap.SugaredLogger, pr *v1.PipelineRun, clientSet clientset.Interface, taskNames sets.String) []string { errs := []string{} trNames, customRunNames, runNames, err := getChildObjectsFromPRStatusForTaskNames(ctx, pr.Status, taskNames) @@ -191,7 +192,7 @@ func cancelPipelineTaskRunsForTaskNames(ctx context.Context, logger *zap.Sugared // getChildObjectsFromPRStatusForTaskNames returns taskruns, customruns, and runs in the PipelineRunStatus's ChildReferences, // based on the given set of PipelineTask names. If that set is empty, all are returned. -func getChildObjectsFromPRStatusForTaskNames(ctx context.Context, prs v1beta1.PipelineRunStatus, taskNames sets.String) ([]string, []string, []string, error) { +func getChildObjectsFromPRStatusForTaskNames(ctx context.Context, prs v1.PipelineRunStatus, taskNames sets.String) ([]string, []string, []string, error) { var trNames []string var customRunNames []string var runNames []string @@ -221,7 +222,7 @@ func getChildObjectsFromPRStatusForTaskNames(ctx context.Context, prs v1beta1.Pi } // gracefullyCancelPipelineRun marks any non-final resolved TaskRun(s) as cancelled and runs finally. -func gracefullyCancelPipelineRun(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, clientSet clientset.Interface) error { +func gracefullyCancelPipelineRun(ctx context.Context, logger *zap.SugaredLogger, pr *v1.PipelineRun, clientSet clientset.Interface) error { errs := cancelPipelineTaskRuns(ctx, logger, pr, clientSet) // If we successfully cancelled all the TaskRuns and Runs, we can proceed with the PipelineRun reconciliation to trigger finally. diff --git a/pkg/reconciler/pipelinerun/cancel_test.go b/pkg/reconciler/pipelinerun/cancel_test.go index c15a5c59011..0ac3072d373 100644 --- a/pkg/reconciler/pipelinerun/cancel_test.go +++ b/pkg/reconciler/pipelinerun/cancel_test.go @@ -22,6 +22,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/config" + "github.com/tektoncd/pipeline/pkg/apis/pipeline" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" _ "github.com/tektoncd/pipeline/pkg/pipelinerunmetrics/fake" // Make sure the pipelinerunmetrics are setup @@ -39,47 +41,47 @@ func TestCancelPipelineRun(t *testing.T) { testCases := []struct { name string - pipelineRun *v1beta1.PipelineRun - taskRuns []*v1beta1.TaskRun + pipelineRun *v1.PipelineRun + taskRuns []*v1.TaskRun runs []*v1alpha1.Run customRuns []*v1beta1.CustomRun wantErr bool }{{ name: "no-resolved-taskrun", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, }, }, { name: "one-taskrun", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{Kind: taskRun}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{Kind: "TaskRun"}, Name: "t1", PipelineTaskName: "task-1", }}, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t1"}}, }, }, { name: "multiple-taskruns-one-missing", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{Kind: taskRun}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{Kind: "TaskRun"}, Name: "t1", PipelineTaskName: "task-1", }, { @@ -89,19 +91,19 @@ func TestCancelPipelineRun(t *testing.T) { }}, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t2"}}, }, }, { name: "multiple-taskruns", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{Kind: taskRun}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{Kind: "TaskRun"}, Name: "t1", PipelineTaskName: "task-1", }, { @@ -111,20 +113,20 @@ func TestCancelPipelineRun(t *testing.T) { }}, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t1"}}, {ObjectMeta: metav1.ObjectMeta{Name: "t2"}}, }, }, { name: "multiple-runs", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{Kind: customRun}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{Kind: "CustomRun"}, Name: "t1", PipelineTaskName: "task-1", }, { @@ -140,14 +142,14 @@ func TestCancelPipelineRun(t *testing.T) { }, }, { name: "multiple-runs-one-missing", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{Kind: customRun}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{Kind: "CustomRun"}, Name: "t1", PipelineTaskName: "task-1", }, { @@ -162,13 +164,13 @@ func TestCancelPipelineRun(t *testing.T) { }, }, { name: "multiple-taskruns-and-runs", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{ + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{ { TypeMeta: runtime.TypeMeta{Kind: taskRun}, Name: "t1", @@ -192,7 +194,7 @@ func TestCancelPipelineRun(t *testing.T) { }, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t1"}}, {ObjectMeta: metav1.ObjectMeta{Name: "t2"}}, }, @@ -202,13 +204,13 @@ func TestCancelPipelineRun(t *testing.T) { }, }, { name: "child-references-some-missing", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{ + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{ { TypeMeta: runtime.TypeMeta{Kind: taskRun}, Name: "t1", @@ -232,7 +234,7 @@ func TestCancelPipelineRun(t *testing.T) { }, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t2"}}, }, runs: []*v1alpha1.Run{ @@ -240,13 +242,13 @@ func TestCancelPipelineRun(t *testing.T) { }, }, { name: "child-references-with-customruns", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{ + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{ { TypeMeta: runtime.TypeMeta{Kind: taskRun}, Name: "t1", @@ -270,7 +272,7 @@ func TestCancelPipelineRun(t *testing.T) { }, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t1"}}, {ObjectMeta: metav1.ObjectMeta{Name: "t2"}}, }, @@ -280,13 +282,13 @@ func TestCancelPipelineRun(t *testing.T) { }, }, { name: "unknown-kind-on-child-references", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, - Spec: v1beta1.PipelineRunSpec{ - Status: v1beta1.PipelineRunSpecStatusCancelled, + Spec: v1.PipelineRunSpec{ + Status: v1.PipelineRunSpecStatusCancelled, }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{Kind: "InvalidKind"}, Name: "t1", PipelineTaskName: "task-1", @@ -299,7 +301,7 @@ func TestCancelPipelineRun(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{tc.pipelineRun}, + PipelineRuns: []*v1.PipelineRun{tc.pipelineRun}, TaskRuns: tc.taskRuns, Runs: tc.runs, CustomRuns: tc.customRuns, @@ -327,14 +329,14 @@ func TestCancelPipelineRun(t *testing.T) { } if tc.taskRuns != nil { for _, expectedTR := range tc.taskRuns { - tr, err := c.Pipeline.TektonV1beta1().TaskRuns("").Get(ctx, expectedTR.Name, metav1.GetOptions{}) + tr, err := c.Pipeline.TektonV1().TaskRuns("").Get(ctx, expectedTR.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("couldn't get expected TaskRun %s, got error %s", expectedTR.Name, err) } - if tr.Spec.Status != v1beta1.TaskRunSpecStatusCancelled { + if tr.Spec.Status != v1.TaskRunSpecStatusCancelled { t.Errorf("expected task %q to be marked as cancelled, was %q", tr.Name, tr.Spec.Status) } - expectedStatusMessage := v1beta1.TaskRunCancelledByPipelineMsg + expectedStatusMessage := v1.TaskRunCancelledByPipelineMsg if tr.Spec.StatusMessage != expectedStatusMessage { t.Errorf("expected task %q to have status message %s but was %s", tr.Name, expectedStatusMessage, tr.Spec.StatusMessage) } @@ -378,8 +380,8 @@ func TestCancelPipelineRun(t *testing.T) { func TestGetChildObjectsFromPRStatusForTaskNames(t *testing.T) { testCases := []struct { name string - useV1Beta1CustomTask bool - prStatus v1beta1.PipelineRunStatus + usev1CustomTask bool + prStatus v1.PipelineRunStatus taskNames sets.String expectedTRNames []string expectedRunNames []string @@ -388,8 +390,8 @@ func TestGetChildObjectsFromPRStatusForTaskNames(t *testing.T) { }{ { name: "runs", - prStatus: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ + prStatus: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ APIVersion: v1alpha1.SchemeGroupVersion.String(), Kind: run, @@ -402,13 +404,13 @@ func TestGetChildObjectsFromPRStatusForTaskNames(t *testing.T) { expectedRunNames: []string{"r1"}, hasError: false, }, { - name: "beta custom tasks", - useV1Beta1CustomTask: true, - prStatus: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ + name: "beta custom tasks", + usev1CustomTask: true, + prStatus: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: customRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: pipeline.CustomRunControllerName, }, Name: "r1", PipelineTaskName: "run-1", @@ -418,8 +420,8 @@ func TestGetChildObjectsFromPRStatusForTaskNames(t *testing.T) { hasError: false, }, { name: "unknown kind", - prStatus: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ + prStatus: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ APIVersion: "v1", Kind: "UnknownKind", @@ -440,7 +442,7 @@ func TestGetChildObjectsFromPRStatusForTaskNames(t *testing.T) { ctx, _ := ttesting.SetupFakeContext(t) cfg := config.NewStore(logtesting.TestLogger(t)) cm := newFeatureFlagsConfigMap() - if tc.useV1Beta1CustomTask { + if tc.usev1CustomTask { cm = withCustomTaskVersion(cm, config.CustomTaskVersionBeta) } cfg.OnConfigChanged(cm) diff --git a/pkg/reconciler/pipelinerun/controller.go b/pkg/reconciler/pipelinerun/controller.go index 17d6866c74c..5ce50dfd204 100644 --- a/pkg/reconciler/pipelinerun/controller.go +++ b/pkg/reconciler/pipelinerun/controller.go @@ -21,14 +21,14 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" pipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client" + pipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/pipelinerun" + taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/taskrun" runinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/run" verificationpolicyinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/verificationpolicy" customruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/customrun" - pipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/pipelinerun" - taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun" - pipelinerunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun" + pipelinerunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1/pipelinerun" resolutionclient "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" resolutioninformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest" "github.com/tektoncd/pipeline/pkg/pipelinerunmetrics" @@ -85,19 +85,19 @@ func NewController(opts *pipeline.Options, clock clock.PassiveClock, tracerProvi pipelineRunInformer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue)) taskRunInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ - FilterFunc: controller.FilterController(&v1beta1.PipelineRun{}), + FilterFunc: controller.FilterController(&v1.PipelineRun{}), Handler: controller.HandleAll(impl.EnqueueControllerOf), }) customRunInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ - FilterFunc: controller.FilterController(&v1beta1.PipelineRun{}), + FilterFunc: controller.FilterController(&v1.PipelineRun{}), Handler: controller.HandleAll(impl.EnqueueControllerOf), }) resolutionInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ - FilterFunc: controller.FilterController(&v1beta1.PipelineRun{}), + FilterFunc: controller.FilterController(&v1.PipelineRun{}), Handler: controller.HandleAll(impl.EnqueueControllerOf), }) runInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ - FilterFunc: controller.FilterController(&v1beta1.PipelineRun{}), + FilterFunc: controller.FilterController(&v1.PipelineRun{}), Handler: controller.HandleAll(impl.EnqueueControllerOf), }) diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 54824f05c1a..178b9cef64d 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -28,13 +28,15 @@ import ( "github.com/hashicorp/go-multierror" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" runv1beta1 "github.com/tektoncd/pipeline/pkg/apis/run/v1beta1" clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - pipelinerunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun" + pipelinerunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1/pipelinerun" + listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1" alpha1listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" - listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" + beta1listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" resolutionutil "github.com/tektoncd/pipeline/pkg/internal/resolution" "github.com/tektoncd/pipeline/pkg/pipelinerunmetrics" tknreconciler "github.com/tektoncd/pipeline/pkg/reconciler" @@ -48,7 +50,6 @@ import ( "github.com/tektoncd/pipeline/pkg/reconciler/volumeclaim" "github.com/tektoncd/pipeline/pkg/remote" resolution "github.com/tektoncd/pipeline/pkg/resolution/resource" - "github.com/tektoncd/pipeline/pkg/substitution" "github.com/tektoncd/pipeline/pkg/trustedresources" "github.com/tektoncd/pipeline/pkg/workspace" "go.opentelemetry.io/otel/attribute" @@ -96,6 +97,9 @@ const ( // ReasonCouldntGetTask indicates that the reason for the failure status is that the // associated Pipeline's Tasks couldn't all be retrieved ReasonCouldntGetTask = "CouldntGetTask" + // ReasonCouldntGetResource indicates that the reason for the failure status is that the + // associated PipelineRun's bound PipelineResources couldn't all be retrieved + ReasonCouldntGetResource = "CouldntGetResource" // ReasonParameterMissing indicates that the reason for the failure status is that the // associated PipelineRun didn't provide all the required parameters ReasonParameterMissing = "ParameterMissing" @@ -151,7 +155,7 @@ type Reconciler struct { // listers index properties about resources pipelineRunLister listers.PipelineRunLister taskRunLister listers.TaskRunLister - customRunLister listers.CustomRunLister + customRunLister beta1listers.CustomRunLister runLister alpha1listers.RunLister verificationPolicyLister alpha1listers.VerificationPolicyLister cloudEventClient cloudevent.CEClient @@ -169,7 +173,7 @@ var ( // ReconcileKind compares the actual state with the desired, and attempts to // converge the two. It then updates the Status block of the Pipeline Run // resource with the current status of the resource. -func (c *Reconciler) ReconcileKind(ctx context.Context, pr *v1beta1.PipelineRun) pkgreconciler.Event { +func (c *Reconciler) ReconcileKind(ctx context.Context, pr *v1.PipelineRun) pkgreconciler.Event { logger := logging.FromContext(ctx) ctx = cloudevent.ToContext(ctx, c.cloudEventClient) ctx = initTracing(ctx, c.tracerProvider, pr) @@ -266,7 +270,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, pr *v1beta1.PipelineRun) return nil } -func (c *Reconciler) durationAndCountMetrics(ctx context.Context, pr *v1beta1.PipelineRun, beforeCondition *apis.Condition) { +func (c *Reconciler) durationAndCountMetrics(ctx context.Context, pr *v1.PipelineRun, beforeCondition *apis.Condition) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "durationAndCountMetrics") defer span.End() logger := logging.FromContext(ctx) @@ -278,7 +282,7 @@ func (c *Reconciler) durationAndCountMetrics(ctx context.Context, pr *v1beta1.Pi } } -func (c *Reconciler) finishReconcileUpdateEmitEvents(ctx context.Context, pr *v1beta1.PipelineRun, beforeCondition *apis.Condition, previousError error) error { +func (c *Reconciler) finishReconcileUpdateEmitEvents(ctx context.Context, pr *v1.PipelineRun, beforeCondition *apis.Condition, previousError error) error { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "finishReconcileUpdateEmitEvents") defer span.End() logger := logging.FromContext(ctx) @@ -302,9 +306,9 @@ func (c *Reconciler) finishReconcileUpdateEmitEvents(ctx context.Context, pr *v1 // specified by those tasks. func (c *Reconciler) resolvePipelineState( ctx context.Context, - tasks []v1beta1.PipelineTask, + tasks []v1.PipelineTask, pipelineMeta *metav1.ObjectMeta, - pr *v1beta1.PipelineRun) (resources.PipelineRunState, error) { + pr *v1.PipelineRun) (resources.PipelineRunState, error) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "resolvePipelineState") defer span.End() pst := resources.PipelineRunState{} @@ -319,7 +323,8 @@ func (c *Reconciler) resolvePipelineState( if err != nil { return nil, fmt.Errorf("failed to list VerificationPolicies from namespace %s with error %v", pr.Namespace, err) } - fn := tresources.GetVerifiedTaskFunc(ctx, c.KubeClientSet, c.PipelineClientSet, c.resolutionRequester, pr, task.TaskRef, trName, pr.Namespace, pr.Spec.ServiceAccountName, vp) + + fn := tresources.GetVerifiedTaskFunc(ctx, c.KubeClientSet, c.PipelineClientSet, c.resolutionRequester, pr, task.TaskRef, trName, pr.Namespace, pr.Spec.TaskRunTemplate.ServiceAccountName, vp) getRunObjectFunc := func(name string) (v1beta1.RunObject, error) { r, err := c.customRunLister.CustomRuns(pr.Namespace).Get(name) @@ -352,7 +357,7 @@ func (c *Reconciler) resolvePipelineState( resolvedTask, err := resources.ResolvePipelineTask(ctx, *pr, fn, - func(name string) (*v1beta1.TaskRun, error) { + func(name string) (*v1.TaskRun, error) { return c.taskRunLister.TaskRuns(pr.Namespace).Get(name) }, getRunObjectFunc, @@ -387,7 +392,7 @@ func (c *Reconciler) resolvePipelineState( return pst, nil } -func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, getPipelineFunc rprp.GetPipeline, beforeCondition *apis.Condition) error { +func (c *Reconciler) reconcile(ctx context.Context, pr *v1.PipelineRun, getPipelineFunc rprp.GetPipeline, beforeCondition *apis.Condition) error { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "reconcile") defer span.End() defer c.durationAndCountMetrics(ctx, pr, beforeCondition) @@ -423,7 +428,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, get } } - d, err := dag.Build(v1beta1.PipelineTaskList(pipelineSpec.Tasks), v1beta1.PipelineTaskList(pipelineSpec.Tasks).Deps()) + d, err := dag.Build(v1.PipelineTaskList(pipelineSpec.Tasks), v1.PipelineTaskList(pipelineSpec.Tasks).Deps()) if err != nil { // This Run has failed, so we need to mark it as failed and stop reconciling it pr.Status.MarkFailed(ReasonInvalidGraph, @@ -436,7 +441,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, get // if a task in PipelineRunState is final task or not // the finally section is optional and might not exist // dfinally holds an empty Graph in the absence of finally clause - dfinally, err := dag.Build(v1beta1.PipelineTaskList(pipelineSpec.Finally), map[string][]string{}) + dfinally, err := dag.Build(v1.PipelineTaskList(pipelineSpec.Finally), map[string][]string{}) if err != nil { // This Run has failed, so we need to mark it as failed and stop reconciling it pr.Status.MarkFailed(ReasonInvalidGraph, @@ -528,7 +533,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, get switch { case errors.Is(err, remote.ErrRequestInProgress): message := fmt.Sprintf("PipelineRun %s/%s awaiting remote resource", pr.Namespace, pr.Name) - pr.Status.MarkRunning(v1beta1.TaskRunReasonResolvingTaskRef, message) + pr.Status.MarkRunning(v1.TaskRunReasonResolvingTaskRef, message) return nil case err != nil: return err @@ -691,7 +696,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, get pr.Status.SkippedTasks = pipelineRunFacts.GetSkippedTasks() if after.Status == corev1.ConditionTrue || after.Status == corev1.ConditionFalse { - pr.Status.PipelineResults, err = resources.ApplyTaskResultsToPipelineResults(ctx, pipelineSpec.Results, + pr.Status.Results, err = resources.ApplyTaskResultsToPipelineResults(ctx, pipelineSpec.Results, pipelineRunFacts.State.GetTaskRunsResults(), pipelineRunFacts.State.GetRunsResults(), pr.Status.SkippedTasks) if err != nil { pr.Status.MarkFailed(ReasonFailedValidation, err.Error()) @@ -706,7 +711,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, get // runNextSchedulableTask gets the next schedulable Tasks from the dag based on the current // pipeline run state, and starts them // after all DAG tasks are done, it's responsible for scheduling final tasks and start executing them -func (c *Reconciler) runNextSchedulableTask(ctx context.Context, pr *v1beta1.PipelineRun, pipelineRunFacts *resources.PipelineRunFacts) error { +func (c *Reconciler) runNextSchedulableTask(ctx context.Context, pr *v1.PipelineRun, pipelineRunFacts *resources.PipelineRunFacts) error { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "runNextSchedulableTask") defer span.End() @@ -801,7 +806,7 @@ func (c *Reconciler) runNextSchedulableTask(ctx context.Context, pr *v1beta1.Pip } // setFinallyStartedTimeIfNeeded sets the PipelineRun.Status.FinallyStartedTime to the current time if it's nil. -func (c *Reconciler) setFinallyStartedTimeIfNeeded(pr *v1beta1.PipelineRun, facts *resources.PipelineRunFacts) { +func (c *Reconciler) setFinallyStartedTimeIfNeeded(pr *v1.PipelineRun, facts *resources.PipelineRunFacts) { if pr.Status.FinallyStartTime == nil { pr.Status.FinallyStartTime = &metav1.Time{Time: c.Clock.Now()} } @@ -810,10 +815,10 @@ func (c *Reconciler) setFinallyStartedTimeIfNeeded(pr *v1beta1.PipelineRun, fact } } -func (c *Reconciler) createTaskRuns(ctx context.Context, rpt *resources.ResolvedPipelineTask, pr *v1beta1.PipelineRun) ([]*v1beta1.TaskRun, error) { +func (c *Reconciler) createTaskRuns(ctx context.Context, rpt *resources.ResolvedPipelineTask, pr *v1.PipelineRun) ([]*v1.TaskRun, error) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createTaskRuns") defer span.End() - var taskRuns []*v1beta1.TaskRun + var taskRuns []*v1.TaskRun matrixCombinations := rpt.PipelineTask.Matrix.FanOut() for i, taskRunName := range rpt.TaskRunNames { params := matrixCombinations[i] @@ -826,7 +831,7 @@ func (c *Reconciler) createTaskRuns(ctx context.Context, rpt *resources.Resolved return taskRuns, nil } -func (c *Reconciler) createTaskRun(ctx context.Context, taskRunName string, params []v1beta1.Param, rpt *resources.ResolvedPipelineTask, pr *v1beta1.PipelineRun) (*v1beta1.TaskRun, error) { +func (c *Reconciler) createTaskRun(ctx context.Context, taskRunName string, params []v1.Param, rpt *resources.ResolvedPipelineTask, pr *v1.PipelineRun) (*v1.TaskRun, error) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createTaskRun") defer span.End() logger := logging.FromContext(ctx) @@ -834,7 +839,7 @@ func (c *Reconciler) createTaskRun(ctx context.Context, taskRunName string, para rpt.PipelineTask = resources.ApplyPipelineTaskContexts(rpt.PipelineTask) taskRunSpec := pr.GetTaskRunSpec(rpt.PipelineTask.Name) params = append(params, rpt.PipelineTask.Params...) - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: taskRunName, Namespace: pr.Namespace, @@ -842,13 +847,13 @@ func (c *Reconciler) createTaskRun(ctx context.Context, taskRunName string, para Labels: combineTaskRunAndTaskSpecLabels(pr, rpt.PipelineTask), Annotations: combineTaskRunAndTaskSpecAnnotations(pr, rpt.PipelineTask), }, - Spec: v1beta1.TaskRunSpec{ + Spec: v1.TaskRunSpec{ Retries: rpt.PipelineTask.Retries, Params: params, - ServiceAccountName: taskRunSpec.TaskServiceAccountName, - PodTemplate: taskRunSpec.TaskPodTemplate, - StepOverrides: taskRunSpec.StepOverrides, - SidecarOverrides: taskRunSpec.SidecarOverrides, + ServiceAccountName: taskRunSpec.ServiceAccountName, + PodTemplate: taskRunSpec.PodTemplate, + StepSpecs: taskRunSpec.StepSpecs, + SidecarSpecs: taskRunSpec.SidecarSpecs, ComputeResources: taskRunSpec.ComputeResources, }} @@ -881,10 +886,10 @@ func (c *Reconciler) createTaskRun(ctx context.Context, taskRunName string, para } logger.Infof("Creating a new TaskRun object %s for pipeline task %s", taskRunName, rpt.PipelineTask.Name) - return c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).Create(ctx, tr, metav1.CreateOptions{}) + return c.PipelineClientSet.TektonV1().TaskRuns(pr.Namespace).Create(ctx, tr, metav1.CreateOptions{}) } -func (c *Reconciler) createRunObjects(ctx context.Context, rpt *resources.ResolvedPipelineTask, pr *v1beta1.PipelineRun) ([]v1beta1.RunObject, error) { +func (c *Reconciler) createRunObjects(ctx context.Context, rpt *resources.ResolvedPipelineTask, pr *v1.PipelineRun) ([]v1beta1.RunObject, error) { var runObjects []v1beta1.RunObject ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createRunObjects") defer span.End() @@ -900,7 +905,7 @@ func (c *Reconciler) createRunObjects(ctx context.Context, rpt *resources.Resolv return runObjects, nil } -func (c *Reconciler) createRunObject(ctx context.Context, runName string, params []v1beta1.Param, rpt *resources.ResolvedPipelineTask, pr *v1beta1.PipelineRun) (v1beta1.RunObject, error) { +func (c *Reconciler) createRunObject(ctx context.Context, runName string, params []v1.Param, rpt *resources.ResolvedPipelineTask, pr *v1.PipelineRun) (v1beta1.RunObject, error) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createRunObject") defer span.End() logger := logging.FromContext(ctx) @@ -911,7 +916,7 @@ func (c *Reconciler) createRunObject(ctx context.Context, runName string, params taskTimeout := rpt.PipelineTask.Timeout var pipelinePVCWorkspaceName string var err error - var workspaces []v1beta1.WorkspaceBinding + var workspaces []v1.WorkspaceBinding workspaces, pipelinePVCWorkspaceName, err = getTaskrunWorkspaces(ctx, pr, rpt) if err != nil { return nil, err @@ -932,7 +937,7 @@ func (c *Reconciler) createRunObject(ctx context.Context, runName string, params Retries: rpt.PipelineTask.Retries, Ref: rpt.PipelineTask.TaskRef, Params: params, - ServiceAccountName: taskRunSpec.TaskServiceAccountName, + ServiceAccountName: taskRunSpec.ServiceAccountName, Timeout: taskTimeout, Workspaces: workspaces, }, @@ -969,7 +974,7 @@ func (c *Reconciler) createRunObject(ctx context.Context, runName string, params Retries: rpt.PipelineTask.Retries, CustomRef: rpt.PipelineTask.TaskRef, Params: params, - ServiceAccountName: taskRunSpec.TaskServiceAccountName, + ServiceAccountName: taskRunSpec.ServiceAccountName, Timeout: taskTimeout, Workspaces: workspaces, }, @@ -1018,17 +1023,17 @@ func propagateWorkspaces(rpt *resources.ResolvedPipelineTask) (*resources.Resolv for wSpace := range workspacesUsedInSteps { if !ptw.Has(wSpace) { - rpt.PipelineTask.Workspaces = append(rpt.PipelineTask.Workspaces, v1beta1.WorkspacePipelineTaskBinding{Name: wSpace}) + rpt.PipelineTask.Workspaces = append(rpt.PipelineTask.Workspaces, v1.WorkspacePipelineTaskBinding{Name: wSpace}) } } return rpt, nil } -func getTaskrunWorkspaces(ctx context.Context, pr *v1beta1.PipelineRun, rpt *resources.ResolvedPipelineTask) ([]v1beta1.WorkspaceBinding, string, error) { +func getTaskrunWorkspaces(ctx context.Context, pr *v1.PipelineRun, rpt *resources.ResolvedPipelineTask) ([]v1.WorkspaceBinding, string, error) { var err error - var workspaces []v1beta1.WorkspaceBinding + var workspaces []v1.WorkspaceBinding var pipelinePVCWorkspaceName string - pipelineRunWorkspaces := make(map[string]v1beta1.WorkspaceBinding) + pipelineRunWorkspaces := make(map[string]v1.WorkspaceBinding) for _, binding := range pr.Spec.Workspaces { pipelineRunWorkspaces[binding.Name] = binding } @@ -1074,22 +1079,12 @@ func getTaskrunWorkspaces(ctx context.Context, pr *v1beta1.PipelineRun, rpt *res } } } - - // replace pipelineRun context variables in workspace subPath in the workspace binding - var p string - if pr.Spec.PipelineRef != nil { - p = pr.Spec.PipelineRef.Name - } - for j := range workspaces { - workspaces[j].SubPath = substitution.ApplyReplacements(workspaces[j].SubPath, resources.GetContextReplacements(p, pr)) - } - return workspaces, pipelinePVCWorkspaceName, nil } // taskWorkspaceByWorkspaceVolumeSource is returning the WorkspaceBinding with the TaskRun specified name. // If the volume source is a volumeClaimTemplate, the template is applied and passed to TaskRun as a persistentVolumeClaim -func taskWorkspaceByWorkspaceVolumeSource(wb v1beta1.WorkspaceBinding, taskWorkspaceName string, pipelineTaskSubPath string, owner metav1.OwnerReference) v1beta1.WorkspaceBinding { +func taskWorkspaceByWorkspaceVolumeSource(wb v1.WorkspaceBinding, taskWorkspaceName string, pipelineTaskSubPath string, owner metav1.OwnerReference) v1.WorkspaceBinding { if wb.VolumeClaimTemplate == nil { binding := *wb.DeepCopy() binding.Name = taskWorkspaceName @@ -1098,7 +1093,7 @@ func taskWorkspaceByWorkspaceVolumeSource(wb v1beta1.WorkspaceBinding, taskWorks } // apply template - binding := v1beta1.WorkspaceBinding{ + binding := v1.WorkspaceBinding{ SubPath: combinedSubPath(wb.SubPath, pipelineTaskSubPath), PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: volumeclaim.GetPersistentVolumeClaimName(wb.VolumeClaimTemplate, wb, owner), @@ -1119,7 +1114,7 @@ func combinedSubPath(workspaceSubPath string, pipelineTaskSubPath string) string return filepath.Join(workspaceSubPath, pipelineTaskSubPath) } -func getTaskrunAnnotations(pr *v1beta1.PipelineRun) map[string]string { +func getTaskrunAnnotations(pr *v1.PipelineRun) map[string]string { // Propagate annotations from PipelineRun to TaskRun. annotations := make(map[string]string, len(pr.ObjectMeta.Annotations)+1) for key, val := range pr.ObjectMeta.Annotations { @@ -1128,7 +1123,7 @@ func getTaskrunAnnotations(pr *v1beta1.PipelineRun) map[string]string { return annotations } -func propagatePipelineNameLabelToPipelineRun(pr *v1beta1.PipelineRun) error { +func propagatePipelineNameLabelToPipelineRun(pr *v1.PipelineRun) error { if pr.ObjectMeta.Labels == nil { pr.ObjectMeta.Labels = make(map[string]string) } @@ -1145,7 +1140,7 @@ func propagatePipelineNameLabelToPipelineRun(pr *v1beta1.PipelineRun) error { return nil } -func getTaskrunLabels(pr *v1beta1.PipelineRun, pipelineTaskName string, includePipelineLabels bool) map[string]string { +func getTaskrunLabels(pr *v1.PipelineRun, pipelineTaskName string, includePipelineLabels bool) map[string]string { // Propagate labels from PipelineRun to TaskRun. labels := make(map[string]string, len(pr.ObjectMeta.Labels)+1) if includePipelineLabels { @@ -1161,14 +1156,14 @@ func getTaskrunLabels(pr *v1beta1.PipelineRun, pipelineTaskName string, includeP // check if a task is part of the "tasks" section, add a label to identify it during the runtime for _, f := range pr.Status.PipelineSpec.Tasks { if pipelineTaskName == f.Name { - labels[pipeline.MemberOfLabelKey] = v1beta1.PipelineTasks + labels[pipeline.MemberOfLabelKey] = v1.PipelineTasks break } } // check if a task is part of the "finally" section, add a label to identify it during the runtime for _, f := range pr.Status.PipelineSpec.Finally { if pipelineTaskName == f.Name { - labels[pipeline.MemberOfLabelKey] = v1beta1.PipelineFinallyTasks + labels[pipeline.MemberOfLabelKey] = v1.PipelineFinallyTasks break } } @@ -1176,7 +1171,7 @@ func getTaskrunLabels(pr *v1beta1.PipelineRun, pipelineTaskName string, includeP return labels } -func combineTaskRunAndTaskSpecLabels(pr *v1beta1.PipelineRun, pipelineTask *v1beta1.PipelineTask) map[string]string { +func combineTaskRunAndTaskSpecLabels(pr *v1.PipelineRun, pipelineTask *v1.PipelineTask) map[string]string { labels := make(map[string]string) taskRunSpec := pr.GetTaskRunSpec(pipelineTask.Name) @@ -1193,7 +1188,7 @@ func combineTaskRunAndTaskSpecLabels(pr *v1beta1.PipelineRun, pipelineTask *v1be return labels } -func combineTaskRunAndTaskSpecAnnotations(pr *v1beta1.PipelineRun, pipelineTask *v1beta1.PipelineTask) map[string]string { +func combineTaskRunAndTaskSpecAnnotations(pr *v1.PipelineRun, pipelineTask *v1.PipelineTask) map[string]string { annotations := make(map[string]string) taskRunSpec := pr.GetTaskRunSpec(pipelineTask.Name) @@ -1220,7 +1215,7 @@ func addMetadataByPrecedence(metadata map[string]string, addedMetadata map[strin } } -func (c *Reconciler) updateLabelsAndAnnotations(ctx context.Context, pr *v1beta1.PipelineRun) (*v1beta1.PipelineRun, error) { +func (c *Reconciler) updateLabelsAndAnnotations(ctx context.Context, pr *v1.PipelineRun) (*v1.PipelineRun, error) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "updateLabelsAndAnnotations") defer span.End() newPr, err := c.pipelineRunLister.PipelineRuns(pr.Namespace).Get(pr.Name) @@ -1235,12 +1230,12 @@ func (c *Reconciler) updateLabelsAndAnnotations(ctx context.Context, pr *v1beta1 // Properly merge labels and annotations, as the labels *might* have changed during the reconciliation newPr.Labels = kmap.Union(newPr.Labels, pr.Labels) newPr.Annotations = kmap.Union(newPr.Annotations, pr.Annotations) - return c.PipelineClientSet.TektonV1beta1().PipelineRuns(pr.Namespace).Update(ctx, newPr, metav1.UpdateOptions{}) + return c.PipelineClientSet.TektonV1().PipelineRuns(pr.Namespace).Update(ctx, newPr, metav1.UpdateOptions{}) } return newPr, nil } -func storePipelineSpecAndMergeMeta(ctx context.Context, pr *v1beta1.PipelineRun, ps *v1beta1.PipelineSpec, meta *resolutionutil.ResolvedObjectMeta) error { +func storePipelineSpecAndMergeMeta(ctx context.Context, pr *v1.PipelineRun, ps *v1.PipelineSpec, meta *resolutionutil.ResolvedObjectMeta) error { // Only store the PipelineSpec once, if it has never been set before. if pr.Status.PipelineSpec == nil { pr.Status.PipelineSpec = ps @@ -1261,7 +1256,7 @@ func storePipelineSpecAndMergeMeta(ctx context.Context, pr *v1beta1.PipelineRun, cfg := config.FromContextOrDefaults(ctx) if cfg.FeatureFlags.EnableProvenanceInStatus { if pr.Status.Provenance == nil { - pr.Status.Provenance = &v1beta1.Provenance{} + pr.Status.Provenance = &v1.Provenance{} } // Store FeatureFlags in the Provenance. pr.Status.Provenance.FeatureFlags = cfg.FeatureFlags @@ -1274,7 +1269,7 @@ func storePipelineSpecAndMergeMeta(ctx context.Context, pr *v1beta1.PipelineRun, return nil } -func (c *Reconciler) updatePipelineRunStatusFromInformer(ctx context.Context, pr *v1beta1.PipelineRun) error { +func (c *Reconciler) updatePipelineRunStatusFromInformer(ctx context.Context, pr *v1.PipelineRun) error { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "updatePipelineRunStatusFromInformer") defer span.End() logger := logging.FromContext(ctx) @@ -1314,13 +1309,13 @@ func (c *Reconciler) updatePipelineRunStatusFromInformer(ctx context.Context, pr return updatePipelineRunStatusFromChildObjects(ctx, logger, pr, taskRuns, runObjects) } -func updatePipelineRunStatusFromChildObjects(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, taskRuns []*v1beta1.TaskRun, runObjects []v1beta1.RunObject) error { +func updatePipelineRunStatusFromChildObjects(ctx context.Context, logger *zap.SugaredLogger, pr *v1.PipelineRun, taskRuns []*v1.TaskRun, runObjects []v1beta1.RunObject) error { updatePipelineRunStatusFromChildRefs(logger, pr, taskRuns, runObjects) return validateChildObjectsInPipelineRunStatus(ctx, pr.Status) } -func validateChildObjectsInPipelineRunStatus(ctx context.Context, prs v1beta1.PipelineRunStatus) error { +func validateChildObjectsInPipelineRunStatus(ctx context.Context, prs v1.PipelineRunStatus) error { var err error for _, cr := range prs.ChildReferences { @@ -1336,8 +1331,8 @@ func validateChildObjectsInPipelineRunStatus(ctx context.Context, prs v1beta1.Pi } // filterTaskRunsForPipelineRunStatus returns TaskRuns owned by the PipelineRun. -func filterTaskRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun) []*v1beta1.TaskRun { - var ownedTaskRuns []*v1beta1.TaskRun +func filterTaskRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1.PipelineRun, trs []*v1.TaskRun) []*v1.TaskRun { + var ownedTaskRuns []*v1.TaskRun for _, tr := range trs { // Only process TaskRuns that are owned by this PipelineRun. @@ -1353,7 +1348,7 @@ func filterTaskRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1beta1.P } // filterRunsForPipelineRunStatus filters the given slice of run objects, returning information only those owned by the given PipelineRun. -func filterRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, runObjects []v1beta1.RunObject) ([]string, []string, []schema.GroupVersionKind, []*v1beta1.CustomRunStatus) { +func filterRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1.PipelineRun, runObjects []v1beta1.RunObject) ([]string, []string, []schema.GroupVersionKind, []*v1beta1.CustomRunStatus) { var names []string var taskLabels []string var gvks []schema.GroupVersionKind @@ -1371,13 +1366,13 @@ func filterRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1beta1.Pipel names = append(names, runObj.GetObjectMeta().GetName()) taskLabels = append(taskLabels, runObj.GetObjectMeta().GetLabels()[pipeline.PipelineTaskLabelKey]) - switch r := runObj.(type) { + switch run := runObj.(type) { case *v1beta1.CustomRun: - statuses = append(statuses, &r.Status) + statuses = append(statuses, &run.Status) // We can't just get the gvk from the run's TypeMeta because that isn't populated for resources created through the fake client. - gvks = append(gvks, v1beta1.SchemeGroupVersion.WithKind(customRun)) + gvks = append(gvks, v1.SchemeGroupVersion.WithKind(pipeline.CustomRunControllerName)) case *v1alpha1.Run: - crStatus := runv1beta1.FromRunStatus(r.Status) + crStatus := runv1beta1.FromRunStatus(run.Status) statuses = append(statuses, &crStatus) // We can't just get the gvk from the run's TypeMeta because that isn't populated for resources created through the fake client. gvks = append(gvks, v1alpha1.SchemeGroupVersion.WithKind(run)) @@ -1387,7 +1382,7 @@ func filterRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1beta1.Pipel return names, taskLabels, gvks, statuses } -func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun, runObjects []v1beta1.RunObject) { +func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1.PipelineRun, trs []*v1.TaskRun, runObjects []v1beta1.RunObject) { // If no TaskRun or RunObject was found, nothing to be done. We never remove child references from the status. // We do still return an empty map of TaskRun/Run names keyed by PipelineTask name for later functions. if len(trs) == 0 && len(runObjects) == 0 { @@ -1395,7 +1390,7 @@ func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1 } // Map PipelineTask names to TaskRun child references that were already in the status - childRefByName := make(map[string]*v1beta1.ChildStatusReference) + childRefByName := make(map[string]*v1.ChildStatusReference) for i := range pr.Status.ChildReferences { childRefByName[pr.Status.ChildReferences[i].Name] = &pr.Status.ChildReferences[i] @@ -1414,10 +1409,10 @@ func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1 logger.Infof("Found a TaskRun %s that was missing from the PipelineRun status", tr.Name) // Since this was recovered now, add it to the map, or it might be overwritten - childRefByName[tr.Name] = &v1beta1.ChildStatusReference{ + childRefByName[tr.Name] = &v1.ChildStatusReference{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: pipeline.TaskRunControllerName, }, Name: tr.Name, PipelineTaskName: pipelineTaskName, @@ -1440,7 +1435,7 @@ func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1 logger.Infof("Found a %s %s that was missing from the PipelineRun status", gvk.Kind, name) // Since this was recovered now, add it to the map, or it might be overwritten - childRefByName[name] = &v1beta1.ChildStatusReference{ + childRefByName[name] = &v1.ChildStatusReference{ TypeMeta: runtime.TypeMeta{ APIVersion: gvk.GroupVersion().String(), Kind: gvk.Kind, @@ -1451,7 +1446,7 @@ func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1 } } - var newChildRefs []v1beta1.ChildStatusReference + var newChildRefs []v1.ChildStatusReference for k := range childRefByName { newChildRefs = append(newChildRefs, *childRefByName[k]) } diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 2462224bbc3..67fe556300f 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -33,6 +33,7 @@ import ( "github.com/google/go-containerregistry/pkg/registry" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resolutionutil "github.com/tektoncd/pipeline/pkg/internal/resolution" @@ -79,18 +80,18 @@ var ( ignoreResourceVersion = cmpopts.IgnoreFields(metav1.ObjectMeta{}, "ResourceVersion") ignoreTypeMeta = cmpopts.IgnoreFields(metav1.TypeMeta{}, "Kind", "APIVersion") ignoreLastTransitionTime = cmpopts.IgnoreFields(apis.Condition{}, "LastTransitionTime.Inner.Time") - ignoreStartTime = cmpopts.IgnoreFields(v1beta1.PipelineRunStatusFields{}, "StartTime") - ignoreCompletionTime = cmpopts.IgnoreFields(v1beta1.PipelineRunStatusFields{}, "CompletionTime") - ignoreFinallyStartTime = cmpopts.IgnoreFields(v1beta1.PipelineRunStatusFields{}, "FinallyStartTime") + ignoreStartTime = cmpopts.IgnoreFields(v1.PipelineRunStatusFields{}, "StartTime") + ignoreCompletionTime = cmpopts.IgnoreFields(v1.PipelineRunStatusFields{}, "CompletionTime") + ignoreFinallyStartTime = cmpopts.IgnoreFields(v1.PipelineRunStatusFields{}, "FinallyStartTime") trueb = true - simpleHelloWorldTask = &v1beta1.Task{ObjectMeta: baseObjectMeta("hello-world", "foo")} - simpleSomeTask = &v1beta1.Task{ObjectMeta: baseObjectMeta("some-task", "foo")} - simpleHelloWorldPipeline = &v1beta1.Pipeline{ + simpleHelloWorldTask = &v1.Task{ObjectMeta: baseObjectMeta("hello-world", "foo")} + simpleSomeTask = &v1.Task{ObjectMeta: baseObjectMeta("some-task", "foo")} + simpleHelloWorldPipeline = &v1.Pipeline{ ObjectMeta: baseObjectMeta("test-pipeline", "foo"), - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "hello-world-1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "hello-world", }, }}, @@ -153,16 +154,16 @@ func initializePipelineRunControllerAssets(t *testing.T, d test.Data, opts pipel // getTaskRunCreations will look through a set of actions to find all task run creation actions and return the set of // them. It will fatal the test if none are found, or if less actions were found than expected. -func getTaskRunCreations(t *testing.T, actions []ktesting.Action, minActionCount int) []*v1beta1.TaskRun { +func getTaskRunCreations(t *testing.T, actions []ktesting.Action, minActionCount int) []*v1.TaskRun { t.Helper() if len(actions) < minActionCount { t.Fatalf("Expected client to have at least %d action implementation but it has %d", minActionCount, len(actions)) } - var outputs []*v1beta1.TaskRun + var outputs []*v1.TaskRun for _, a := range actions { if action, ok := a.(ktesting.CreateAction); ok { - if output, ok := action.GetObject().(*v1beta1.TaskRun); ok { + if output, ok := action.GetObject().(*v1.TaskRun); ok { outputs = append(outputs, output) } } @@ -178,12 +179,12 @@ func getTaskRunCreations(t *testing.T, actions []ktesting.Action, minActionCount // getPipelineRunUpdates will look through a set of actions to find all PipelineRun creation actions and return the // set of them. It will fatal the test if none are found. -func getPipelineRunUpdates(t *testing.T, actions []ktesting.Action) []*v1beta1.PipelineRun { +func getPipelineRunUpdates(t *testing.T, actions []ktesting.Action) []*v1.PipelineRun { t.Helper() - var outputs []*v1beta1.PipelineRun + var outputs []*v1.PipelineRun for _, a := range actions { if action, ok := a.(ktesting.UpdateAction); ok { - if output, ok := action.GetObject().(*v1beta1.PipelineRun); ok { + if output, ok := action.GetObject().(*v1.PipelineRun); ok { outputs = append(outputs, output) } } @@ -201,7 +202,7 @@ func getPipelineRunUpdates(t *testing.T, actions []ktesting.Action) []*v1beta1.P // it checks the resulting API actions, status and events. func TestReconcile(t *testing.T) { names.TestingSeed() - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-success namespace: foo @@ -213,7 +214,7 @@ spec: name: test-pipeline serviceAccountName: test-sa `)} - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -273,8 +274,8 @@ spec: kind: ClusterTask name: unit-test-cluster-task `)} - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: unit-test-task namespace: foo @@ -357,7 +358,7 @@ spec: } // This PipelineRun is in progress now and the status should reflect that - checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) tr1Name := "test-pipeline-run-success-unit-test-1" tr2Name := "test-pipeline-run-success-unit-test-cluster-task" @@ -399,7 +400,7 @@ spec: name: test-pipelinerun-custom-task namespace: namespace ownerReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 blockOwnerDeletion: true controller: true kind: PipelineRun @@ -417,15 +418,15 @@ spec: tcs := []struct { name string - pr *v1beta1.PipelineRun + pr *v1.PipelineRun wantRun *v1alpha1.Run }{{ name: "simple custom task with taskRef", - pr: parse.MustParseV1beta1PipelineRun(t, simpleCustomTaskPRYAML), + pr: parse.MustParseV1PipelineRun(t, simpleCustomTaskPRYAML), wantRun: parse.MustParseRun(t, simpleCustomTaskWantRunYAML), }, { name: "simple custom task with taskSpec", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipelinerun namespace: namespace @@ -466,7 +467,7 @@ spec: `), }, { name: "custom task with workspace", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipelinerun namespace: namespace @@ -513,7 +514,7 @@ spec: cms := []*corev1.ConfigMap{withCustomTaskVersion(newFeatureFlagsConfigMap(), "v1alpha1")} d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{tc.pr}, + PipelineRuns: []*v1.PipelineRun{tc.pr}, ConfigMaps: cms, } prt := newPipelineRunTest(t, d) @@ -538,7 +539,7 @@ spec: } // This PipelineRun is in progress now and the status should reflect that - checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) verifyCustomRunOrRunStatusesCount(t, run, reconciledRun.Status, 1) verifyCustomRunOrRunStatusesNames(t, run, reconciledRun.Status, tc.wantRun.Name) @@ -546,10 +547,10 @@ spec: } } -// TestReconcile_V1Beta1CustomTask runs "Reconcile" on a PipelineRun with one Custom -// Task reference that has not been run yet, with the custom-task-version feature flag set to "v1beta1". +// TestReconcile_v1CustomTask runs "Reconcile" on a PipelineRun with one Custom +// Task reference that has not been run yet, with the custom-task-version feature flag set to "v1". // It verifies that the CustomRun is created, it checks the resulting API actions, status and events. -func TestReconcile_V1Beta1CustomTask(t *testing.T) { +func TestReconcile_v1CustomTask(t *testing.T) { names.TestingSeed() const pipelineRunName = "test-pipelinerun" const namespace = "namespace" @@ -579,7 +580,7 @@ spec: name: test-pipelinerun-custom-task namespace: namespace ownerReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 blockOwnerDeletion: true controller: true kind: PipelineRun @@ -597,15 +598,15 @@ spec: tcs := []struct { name string - pr *v1beta1.PipelineRun + pr *v1.PipelineRun wantRun *v1beta1.CustomRun }{{ name: "simple custom task with taskRef", - pr: parse.MustParseV1beta1PipelineRun(t, simpleCustomTaskPRYAML), + pr: parse.MustParseV1PipelineRun(t, simpleCustomTaskPRYAML), wantRun: parse.MustParseCustomRun(t, simpleCustomTaskWantRunYAML), }, { name: "simple custom task with taskSpec", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipelinerun namespace: namespace @@ -646,7 +647,7 @@ spec: `), }, { name: "custom task with workspace", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipelinerun namespace: namespace @@ -690,10 +691,10 @@ spec: for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { - cms := []*corev1.ConfigMap{withCustomTaskVersion(newFeatureFlagsConfigMap(), "v1beta1")} + cms := []*corev1.ConfigMap{withCustomTaskVersion(newFeatureFlagsConfigMap(), "v1")} d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{tc.pr}, + PipelineRuns: []*v1.PipelineRun{tc.pr}, ConfigMaps: cms, } prt := newPipelineRunTest(t, d) @@ -718,7 +719,7 @@ spec: } // This PipelineRun is in progress now and the status should reflect that - checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) verifyCustomRunOrRunStatusesCount(t, customRun, reconciledRun.Status, 1) verifyCustomRunOrRunStatusesNames(t, customRun, reconciledRun.Status, tc.wantRun.Name) @@ -731,8 +732,8 @@ func TestReconcile_PipelineSpecTaskSpec(t *testing.T) { // It verifies that a TaskRun is created, it checks the resulting API actions, status and events. names.TestingSeed() - prs := []*v1beta1.PipelineRun{ - parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{ + parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-success namespace: foo @@ -741,8 +742,8 @@ spec: name: test-pipeline `), } - ps := []*v1beta1.Pipeline{ - parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{ + parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -772,7 +773,7 @@ spec: // Check that the expected TaskRun was created actual := getTaskRunCreations(t, clients.Pipeline.Actions(), 2)[0] - expectedTaskRun := parse.MustParseV1beta1TaskRun(t, fmt.Sprintf(` + expectedTaskRun := parse.MustParseV1TaskRun(t, fmt.Sprintf(` spec: taskSpec: steps: @@ -784,7 +785,7 @@ spec: expectedTaskRun.ObjectMeta = taskRunObjectMeta("test-pipeline-run-success-unit-test-task-spec", "foo", "test-pipeline-run-success", "test-pipeline", "unit-test-task-spec", false) // ignore IgnoreUnexported ignore both after and before steps fields - if d := cmp.Diff(expectedTaskRun, actual, ignoreTypeMeta, cmpopts.SortSlices(func(x, y v1beta1.TaskSpec) bool { return len(x.Steps) == len(y.Steps) })); d != "" { + if d := cmp.Diff(expectedTaskRun, actual, ignoreTypeMeta, cmpopts.SortSlices(func(x, y v1.TaskSpec) bool { return len(x.Steps) == len(y.Steps) })); d != "" { t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRun, diff.PrintWantGot(d)) } @@ -800,13 +801,13 @@ spec: // TestReconcile_InvalidPipelineRuns runs "Reconcile" on several PipelineRuns that are invalid in different ways. // It verifies that reconcile fails, how it fails and which events are triggered. func TestReconcile_InvalidPipelineRuns(t *testing.T) { - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: a-task-that-exists namespace: foo `), - parse.MustParseV1beta1Task(t, ` + parse.MustParseV1Task(t, ` metadata: name: a-task-that-needs-params namespace: foo @@ -814,7 +815,7 @@ spec: params: - name: some-param `), - parse.MustParseV1beta1Task(t, fmt.Sprintf(` + parse.MustParseV1Task(t, fmt.Sprintf(` metadata: name: a-task-that-needs-array-params namespace: foo @@ -822,8 +823,8 @@ spec: params: - name: some-param type: %s -`, v1beta1.ParamTypeArray)), - parse.MustParseV1beta1Task(t, fmt.Sprintf(` +`, v1.ParamTypeArray)), + parse.MustParseV1Task(t, fmt.Sprintf(` metadata: name: a-task-that-needs-object-params namespace: foo @@ -834,10 +835,10 @@ spec: properties: key1: {} key2: {} -`, v1beta1.ParamTypeObject)), +`, v1.ParamTypeObject)), } - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: pipeline-missing-tasks namespace: foo @@ -847,7 +848,7 @@ spec: taskRef: name: sometask `), - parse.MustParseV1beta1Pipeline(t, ` + parse.MustParseV1Pipeline(t, ` metadata: name: a-pipeline-without-params namespace: foo @@ -857,7 +858,7 @@ spec: taskRef: name: a-task-that-needs-params `), - parse.MustParseV1beta1Pipeline(t, ` + parse.MustParseV1Pipeline(t, ` metadata: name: a-pipeline-that-should-be-caught-by-admission-control namespace: foo @@ -867,7 +868,7 @@ spec: taskRef: name: a-task-that-exists `), - parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` + parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: a-pipeline-with-array-params namespace: foo @@ -879,8 +880,8 @@ spec: - name: some-task taskRef: name: a-task-that-needs-array-params -`, v1beta1.ParamTypeArray)), - parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` +`, v1.ParamTypeArray)), + parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: a-pipeline-with-array-indexing-params namespace: foo @@ -895,8 +896,8 @@ spec: params: - name: param value: "$(params.some-param[2])" -`, v1beta1.ParamTypeArray)), - parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` +`, v1.ParamTypeArray)), + parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: a-pipeline-with-object-params namespace: foo @@ -911,19 +912,19 @@ spec: - name: some-task taskRef: name: a-task-that-needs-object-params -`, v1beta1.ParamTypeObject)), +`, v1.ParamTypeObject)), } for _, tc := range []struct { name string - pipelineRun *v1beta1.PipelineRun + pipelineRun *v1.PipelineRun reason string hasNoDefaultLabels bool permanentError bool wantEvents []string }{{ name: "invalid-pipeline-shd-be-stop-reconciling", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: invalid-pipeline namespace: foo @@ -940,7 +941,7 @@ spec: }, }, { name: "invalid-pipeline-run-missing-tasks-shd-stop-reconciling", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pipelinerun-missing-tasks namespace: foo @@ -956,7 +957,7 @@ spec: }, }, { name: "invalid-pipeline-run-params-dont-exist-shd-stop-reconciling", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline-params-dont-exist namespace: foo @@ -972,7 +973,7 @@ spec: }, }, { name: "invalid-pipeline-mismatching-parameter-types", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline-mismatching-param-type namespace: foo @@ -991,7 +992,7 @@ spec: }, }, { name: "invalid-pipeline-missing-object-keys", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline-missing-object-param-keys namespace: foo @@ -1011,7 +1012,7 @@ spec: }, }, { name: "invalid-pipeline-array-index-out-of-bound", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline-param-array-out-of-bound namespace: foo @@ -1032,7 +1033,7 @@ spec: }, }, { name: "invalid-embedded-pipeline-bad-name-shd-stop-reconciling", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: embedded-pipeline-invalid namespace: foo @@ -1051,7 +1052,7 @@ spec: }, }, { name: "invalid-embedded-pipeline-mismatching-parameter-types", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + pipelineRun: parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: embedded-pipeline-mismatching-param-type namespace: foo @@ -1067,7 +1068,7 @@ spec: params: - name: some-param value: stringval -`, v1beta1.ParamTypeArray)), +`, v1.ParamTypeArray)), reason: ReasonParameterTypeMismatch, permanentError: true, wantEvents: []string{ @@ -1076,7 +1077,7 @@ spec: }, }, { name: "invalid-pipeline-run-missing-params-shd-stop-reconciling", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + pipelineRun: parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: pipelinerun-missing-params namespace: foo @@ -1089,7 +1090,7 @@ spec: - name: some-task taskRef: name: a-task-that-needs-params -`, v1beta1.ParamTypeString)), +`, v1.ParamTypeString)), reason: ReasonParameterMissing, permanentError: true, wantEvents: []string{ @@ -1098,7 +1099,7 @@ spec: }, }, { name: "invalid-pipeline-with-invalid-dag-graph", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline-invalid-dag-graph namespace: foo @@ -1118,7 +1119,7 @@ spec: }, }, { name: "invalid-pipeline-with-invalid-final-tasks-graph", - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline-invalid-final-graph namespace: foo @@ -1147,7 +1148,7 @@ spec: cms := []*corev1.ConfigMap{withEnabledAlphaAPIFields(newFeatureFlagsConfigMap())} d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{tc.pipelineRun}, + PipelineRuns: []*v1.PipelineRun{tc.pipelineRun}, Pipelines: ps, Tasks: ts, ConfigMaps: cms, @@ -1241,7 +1242,7 @@ status: - status: "False" type: Succeeded `, runName))} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -1260,40 +1261,40 @@ status: - name: test-pipeline-run-completed-hello-world-task-run pipelineTaskName: hello-world-1 kind: TaskRun - apiVersion: tekton.dev/v1beta1 + apiVersion: tekton.dev/v1 - name: test-pipeline-run-completed-hello-world-run pipelineTaskName: hello-world-1 kind: Run - apiVersion: tekton.dev/v1beta1 + apiVersion: tekton.dev/v1 `, pipelineRunName))} - ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline} - ts := []*v1beta1.Task{simpleHelloWorldTask} - trs := []*v1beta1.TaskRun{createHelloWorldTaskRunWithStatus(t, taskRunName, "foo", + ps := []*v1.Pipeline{simpleHelloWorldPipeline} + ts := []*v1.Task{simpleHelloWorldTask} + trs := []*v1.TaskRun{createHelloWorldTaskRunWithStatus(t, taskRunName, "foo", pipelineRunName, "test-pipeline", "", apis.Condition{ Type: apis.ConditionSucceeded, })} - expectedChildReferences := []v1beta1.ChildStatusReference{{ + expectedChildReferences := []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: taskRunName, PipelineTaskName: "hello-world-1", }, { TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: run, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "Run", }, Name: runName, PipelineTaskName: "hello-world-1", }} - expectedTaskRunsStatus := make(map[string]*v1beta1.PipelineRunTaskRunStatus) - expectedTaskRunsStatus[taskRunName] = &v1beta1.PipelineRunTaskRunStatus{ + expectedTaskRunsStatus := make(map[string]*v1.PipelineRunTaskRunStatus) + expectedTaskRunsStatus[taskRunName] = &v1.PipelineRunTaskRunStatus{ PipelineTaskName: "hello-world-1", - Status: &v1beta1.TaskRunStatus{ + Status: &v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded}}, }, @@ -1395,22 +1396,22 @@ func withMaxMatrixCombinationsCount(cm *corev1.ConfigMap, count int) *corev1.Con func TestReconcileOnCancelledPipelineRun(t *testing.T) { testCases := []struct { name string - specStatus v1beta1.PipelineRunSpecStatus + specStatus v1.PipelineRunSpecStatus reason string }{ { name: "cancelled", - specStatus: v1beta1.PipelineRunSpecStatusCancelled, + specStatus: v1.PipelineRunSpecStatusCancelled, reason: ReasonCancelled, }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - prs := []*v1beta1.PipelineRun{createCancelledPipelineRun(t, "test-pipeline-run-cancelled", tc.specStatus)} - ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline} - ts := []*v1beta1.Task{simpleHelloWorldTask} - trs := []*v1beta1.TaskRun{createHelloWorldTaskRun(t, "test-pipeline-run-cancelled-hello-world", "foo", + prs := []*v1.PipelineRun{createCancelledPipelineRun(t, "test-pipeline-run-cancelled", tc.specStatus)} + ps := []*v1.Pipeline{simpleHelloWorldPipeline} + ts := []*v1.Task{simpleHelloWorldTask} + trs := []*v1.TaskRun{createHelloWorldTaskRun(t, "test-pipeline-run-cancelled-hello-world", "foo", "test-pipeline-run-cancelled", "test-pipeline")} cms := []*corev1.ConfigMap{newFeatureFlagsConfigMap()} @@ -1453,7 +1454,7 @@ func TestReconcileForCustomTaskWithPipelineTaskTimedOut(t *testing.T) { // TestReconcileForCustomTaskWithPipelineTaskTimedOut runs "Reconcile" on a PipelineRun. // It verifies that reconcile is successful, and the individual // custom task which has timed out, is patched as cancelled. - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: test @@ -1465,7 +1466,7 @@ spec: kind: Example `)} prName := "test-pipeline-run-custom-task-with-timeout" - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-custom-task-with-timeout namespace: test @@ -1539,16 +1540,16 @@ func TestReconcileForCustomTaskWithPipelineRunTimedOut(t *testing.T) { for _, tc := range []struct { name string timeout *metav1.Duration - timeouts *v1beta1.TimeoutFields + timeouts *v1.TimeoutFields }{{ name: "spec.Timeout", timeout: &metav1.Duration{Duration: 12 * time.Hour}, }, { name: "spec.Timeouts.Pipeline", - timeouts: &v1beta1.TimeoutFields{Pipeline: &metav1.Duration{Duration: 12 * time.Hour}}, + timeouts: &v1.TimeoutFields{Pipeline: &metav1.Duration{Duration: 12 * time.Hour}}, }} { t.Run(tc.name, func(*testing.T) { - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: test @@ -1561,7 +1562,7 @@ spec: `)} prName := "test-pipeline-run-custom-task" - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-custom-task namespace: test @@ -1582,7 +1583,6 @@ status: kind: CustomRun apiVersion: example.dev/v0 `)} - prs[0].Spec.Timeout = tc.timeout prs[0].Spec.Timeouts = tc.timeouts customRuns := []*v1beta1.CustomRun{mustParseCustomRunWithObjectMeta(t, @@ -1665,9 +1665,9 @@ status: func TestReconcileOnCancelledRunFinallyPipelineRun(t *testing.T) { // TestReconcileOnCancelledRunFinallyPipelineRun runs "Reconcile" on a PipelineRun that has been gracefully cancelled. // It verifies that reconcile is successful, the pipeline status updated and events generated. - prs := []*v1beta1.PipelineRun{createCancelledPipelineRun(t, "test-pipeline-run-cancelled-run-finally", v1beta1.PipelineRunSpecStatusCancelledRunFinally)} - ps := []*v1beta1.Pipeline{helloWorldPipelineWithRunAfter(t)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + prs := []*v1.PipelineRun{createCancelledPipelineRun(t, "test-pipeline-run-cancelled-run-finally", v1.PipelineRunSpecStatusCancelledRunFinally)} + ps := []*v1.Pipeline{helloWorldPipelineWithRunAfter(t)} + ts := []*v1.Task{simpleHelloWorldTask} cms := []*corev1.ConfigMap{newFeatureFlagsConfigMap()} d := test.Data{ PipelineRuns: prs, @@ -1695,12 +1695,12 @@ func TestReconcileOnCancelledRunFinallyPipelineRun(t *testing.T) { // There should be no task runs triggered for the pipeline tasks verifyTaskRunStatusesCount(t, reconciledRun.Status, 0) - expectedSkippedTasks := []v1beta1.SkippedTask{{ + expectedSkippedTasks := []v1.SkippedTask{{ Name: "hello-world-1", - Reason: v1beta1.GracefullyCancelledSkip, + Reason: v1.GracefullyCancelledSkip, }, { Name: "hello-world-2", - Reason: v1beta1.GracefullyCancelledSkip, + Reason: v1.GracefullyCancelledSkip, }} if d := cmp.Diff(expectedSkippedTasks, reconciledRun.Status.SkippedTasks); d != "" { @@ -1713,9 +1713,9 @@ func TestReconcileOnCancelledRunFinallyPipelineRun(t *testing.T) { // that reconcile is successful, final tasks run, the pipeline status updated // and events generated. func TestReconcileOnCancelledRunFinallyPipelineRunWithFinalTask(t *testing.T) { - prs := []*v1beta1.PipelineRun{createCancelledPipelineRun(t, "test-pipeline-run-cancelled-run-finally", v1beta1.PipelineRunSpecStatusCancelledRunFinally)} - ps := []*v1beta1.Pipeline{ - parse.MustParseV1beta1Pipeline(t, ` + prs := []*v1.PipelineRun{createCancelledPipelineRun(t, "test-pipeline-run-cancelled-run-finally", v1.PipelineRunSpecStatusCancelledRunFinally)} + ps := []*v1.Pipeline{ + parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -1735,7 +1735,7 @@ spec: name: some-task `), } - ts := []*v1beta1.Task{ + ts := []*v1.Task{ simpleHelloWorldTask, simpleSomeTask, } @@ -1772,7 +1772,7 @@ spec: func TestReconcileOnCancelledRunFinallyPipelineRunWithRunningFinalTask(t *testing.T) { // TestReconcileOnCancelledRunFinallyPipelineRunWithRunningFinalTask runs "Reconcile" on a PipelineRun that has been gracefully cancelled. // It verifies that reconcile is successful and completed tasks and running final tasks are left untouched. - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-cancelled-run-finally namespace: foo @@ -1784,11 +1784,11 @@ spec: status: startTime: "2022-01-01T00:00:00Z" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: test-pipeline-run-cancelled-run-finally-final-task pipelineTaskName: final-task-1 - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: test-pipeline-run-cancelled-run-finally-hello-world pipelineTaskName: hello-world-1 @@ -1798,7 +1798,7 @@ status: status: "True" type: Succeeded `)} - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -1812,11 +1812,11 @@ spec: taskRef: name: hello-world `)} - ts := []*v1beta1.Task{ + ts := []*v1.Task{ simpleHelloWorldTask, simpleSomeTask, } - trs := []*v1beta1.TaskRun{ + trs := []*v1.TaskRun{ createHelloWorldTaskRunWithStatus(t, "test-pipeline-run-cancelled-run-finally-hello-world", "foo", "test-pipeline-run-cancelled-run-finally", "test-pipeline", "my-pod-name", apis.Condition{ @@ -1870,19 +1870,19 @@ func TestReconcileOnCancelledRunFinallyPipelineRunWithFinalTaskAndRetries(t *tes // TestReconcileOnCancelledRunFinallyPipelineRunWithFinalTaskAndRetries runs "Reconcile" on a PipelineRun that has // been gracefully cancelled. It verifies that reconcile is successful, the pipeline status updated and events generated. // Pipeline has a DAG task "hello-world-1" and Finally task "hello-world-2" - ps := []*v1beta1.Pipeline{{ + ps := []*v1.Pipeline{{ ObjectMeta: baseObjectMeta("test-pipeline", "foo"), - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "hello-world-1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "hello-world", }, Retries: 2, }}, - Finally: []v1beta1.PipelineTask{{ + Finally: []v1.PipelineTask{{ Name: "hello-world-2", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "hello-world", }, }}, @@ -1891,37 +1891,39 @@ func TestReconcileOnCancelledRunFinallyPipelineRunWithFinalTaskAndRetries(t *tes // PipelineRun has been gracefully cancelled, and it has a TaskRun for DAG task "hello-world-1" that has failed // with reason of cancellation - prs := []*v1beta1.PipelineRun{{ + prs := []*v1.PipelineRun{{ ObjectMeta: baseObjectMeta("test-pipeline-run-cancelled-run-finally", "foo"), - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{Name: "test-pipeline"}, - ServiceAccountName: "test-sa", - Status: v1beta1.PipelineRunSpecStatusCancelledRunFinally, + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{Name: "test-pipeline"}, + TaskRunTemplate: v1.PipelineTaskRunTemplate{ + ServiceAccountName: "test-sa", + }, + Status: v1.PipelineRunSpecStatusCancelledRunFinally, }, - Status: v1beta1.PipelineRunStatus{ - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{}, + Status: v1.PipelineRunStatus{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{}, }, }} - prs[0].Status.ChildReferences = append(prs[0].Status.ChildReferences, v1beta1.ChildStatusReference{ + prs[0].Status.ChildReferences = append(prs[0].Status.ChildReferences, v1.ChildStatusReference{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "test-pipeline-run-cancelled-run-finally-hello-world", PipelineTaskName: "hello-world-1", }) // TaskRun exists for DAG task "hello-world-1" that has failed with reason of cancellation - trs := []*v1beta1.TaskRun{createHelloWorldTaskRunWithStatus(t, "test-pipeline-run-cancelled-run-finally-hello-world", "foo", + trs := []*v1.TaskRun{createHelloWorldTaskRunWithStatus(t, "test-pipeline-run-cancelled-run-finally-hello-world", "foo", "test-pipeline-run-cancelled-run-finally", "test-pipeline", "my-pod-name", apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.TaskRunSpecStatusCancelled, + Reason: v1.TaskRunSpecStatusCancelled, })} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} cms := []*corev1.ConfigMap{newFeatureFlagsConfigMap()} d := test.Data{ @@ -1951,13 +1953,13 @@ func TestReconcileOnCancelledRunFinallyPipelineRunWithFinalTaskAndRetries(t *tes } func TestReconcileTaskResolutionError(t *testing.T) { - ts := []*v1beta1.Task{ + ts := []*v1.Task{ simpleHelloWorldTask, } ptName := "hello-world-1" prName := "test-pipeline-fails-task-resolution" - prs := []*v1beta1.PipelineRun{ - parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + prs := []*v1.PipelineRun{ + parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -1975,10 +1977,10 @@ status: - name: %s%s pipelineTaskName: %s kind: TaskRun -`, prName, v1beta1.PipelineRunSpecStatusCancelledRunFinally, ptName, prName, ptName)), +`, prName, v1.PipelineRunSpecStatusCancelledRunFinally, ptName, prName, ptName)), } - trs := []*v1beta1.TaskRun{ + trs := []*v1.TaskRun{ getTaskRun( t, "test-pipeline-fails-task-resolutionhello-world-1", @@ -1990,7 +1992,7 @@ status: } d := test.Data{ PipelineRuns: prs, - Pipelines: []*v1beta1.Pipeline{simpleHelloWorldPipeline}, + Pipelines: []*v1.Pipeline{simpleHelloWorldPipeline}, Tasks: ts, TaskRuns: trs, ConfigMaps: []*corev1.ConfigMap{}, @@ -2015,7 +2017,7 @@ status: } // Check that the PipelineRun is still running with correct error message - reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(testAssets.Ctx, "test-pipeline-fails-task-resolution", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1().PipelineRuns("foo").Get(testAssets.Ctx, "test-pipeline-fails-task-resolution", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } @@ -2050,18 +2052,18 @@ spec: serviceAccountName: test-sa status: %s status: - startTime: %s`, v1beta1.PipelineRunSpecStatusStoppedRunFinally, now.Format(time.RFC3339)) + startTime: %s`, v1.PipelineRunSpecStatusStoppedRunFinally, now.Format(time.RFC3339)) testCases := []struct { name string - pipeline *v1beta1.Pipeline - taskRuns []*v1beta1.TaskRun - initialChildReferences []v1beta1.ChildStatusReference + pipeline *v1.Pipeline + taskRuns []*v1.TaskRun + initialChildReferences []v1.ChildStatusReference expectedEvents []string hasNilCompletionTime bool isFailed bool childRefInStatusCount int - skippedTasks []v1beta1.SkippedTask + skippedTasks []v1.SkippedTask }{ { name: "stopped PipelineRun", @@ -2072,11 +2074,11 @@ status: hasNilCompletionTime: false, isFailed: true, childRefInStatusCount: 0, - skippedTasks: []v1beta1.SkippedTask{{Name: "hello-world-1", Reason: v1beta1.GracefullyStoppedSkip}}, + skippedTasks: []v1.SkippedTask{{Name: "hello-world-1", Reason: v1.GracefullyStoppedSkip}}, }, { name: "with running task", pipeline: simpleHelloWorldPipeline, - taskRuns: []*v1beta1.TaskRun{getTaskRun( + taskRuns: []*v1.TaskRun{getTaskRun( t, "test-pipeline-run-stopped-run-finally-hello-world", "test-pipeline-run-stopped-run-finally", @@ -2084,10 +2086,10 @@ status: "hello-world", corev1.ConditionUnknown, )}, - initialChildReferences: []v1beta1.ChildStatusReference{{ + initialChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "test-pipeline-run-stopped-run-finally-hello-world", PipelineTaskName: "hello-world-1", @@ -2100,7 +2102,7 @@ status: }, { name: "with completed task", pipeline: helloWorldPipelineWithRunAfter(t), - taskRuns: []*v1beta1.TaskRun{getTaskRun( + taskRuns: []*v1.TaskRun{getTaskRun( t, "test-pipeline-run-stopped-run-finally-hello-world", "test-pipeline-run-stopped-run-finally", @@ -2108,10 +2110,10 @@ status: "hello-world", corev1.ConditionTrue, )}, - initialChildReferences: []v1beta1.ChildStatusReference{{ + initialChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "test-pipeline-run-stopped-run-finally-hello-world", PipelineTaskName: "hello-world-1", @@ -2121,20 +2123,20 @@ status: hasNilCompletionTime: false, isFailed: true, childRefInStatusCount: 1, - skippedTasks: []v1beta1.SkippedTask{{Name: "hello-world-2", Reason: v1beta1.GracefullyStoppedSkip}}, + skippedTasks: []v1.SkippedTask{{Name: "hello-world-2", Reason: v1.GracefullyStoppedSkip}}, }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - pr := parse.MustParseV1beta1PipelineRun(t, basePRYAML) + pr := parse.MustParseV1PipelineRun(t, basePRYAML) if tc.initialChildReferences != nil { pr.Status.ChildReferences = tc.initialChildReferences } - ps := []*v1beta1.Pipeline{tc.pipeline} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ps := []*v1.Pipeline{tc.pipeline} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{pr}, + PipelineRuns: []*v1.PipelineRun{pr}, Pipelines: ps, Tasks: ts, TaskRuns: tc.taskRuns, @@ -2181,7 +2183,7 @@ status: func TestReconcileOnPendingPipelineRun(t *testing.T) { // TestReconcileOnPendingPipelineRun runs "Reconcile" on a PipelineRun that is pending. // It verifies that reconcile is successful, the pipeline status updated and events generated. - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-pending namespace: foo @@ -2191,9 +2193,9 @@ spec: serviceAccountName: test-sa status: PipelineRunPending `)} - ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline} - var ts []*v1beta1.Task - var trs []*v1beta1.TaskRun + ps := []*v1.Pipeline{simpleHelloWorldPipeline} + var ts []*v1.Task + var trs []*v1.TaskRun d := test.Data{ PipelineRuns: prs, @@ -2207,7 +2209,7 @@ spec: var wantEvents []string reconciledRun, _ := prt.reconcileRun("foo", "test-pipeline-run-pending", wantEvents, false) - checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonPending.String()) + checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1.PipelineRunReasonPending.String()) if reconciledRun.Status.StartTime != nil { t.Errorf("Start time should be nil, not: %s", reconciledRun.Status.StartTime) @@ -2218,8 +2220,8 @@ func TestReconcileWithTimeoutDeprecated(t *testing.T) { // TestReconcileWithTimeoutDeprecated runs "Reconcile" on a PipelineRun that has timed out. // It verifies that reconcile is successful, no TaskRun is created, the PipelineTask is marked as skipped, and the // pipeline status updated and events generated. - ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + ps := []*v1.Pipeline{simpleHelloWorldPipeline} + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-with-timeout namespace: foo @@ -2231,7 +2233,7 @@ spec: status: startTime: "2021-12-31T00:00:00Z" `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ PipelineRuns: prs, @@ -2258,8 +2260,8 @@ status: // Check that there is a skipped task for the expected reason if len(reconciledRun.Status.SkippedTasks) != 1 { t.Errorf("expected one skipped task, found %d", len(reconciledRun.Status.SkippedTasks)) - } else if reconciledRun.Status.SkippedTasks[0].Reason != v1beta1.PipelineTimedOutSkip { - t.Errorf("expected skipped reason to be '%s', but was '%s", v1beta1.PipelineTimedOutSkip, reconciledRun.Status.SkippedTasks[0].Reason) + } else if reconciledRun.Status.SkippedTasks[0].Reason != v1.PipelineTimedOutSkip { + t.Errorf("expected skipped reason to be '%s', but was '%s", v1.PipelineTimedOutSkip, reconciledRun.Status.SkippedTasks[0].Reason) } } @@ -2267,7 +2269,7 @@ func TestReconcileWithTimeouts_Pipeline(t *testing.T) { // TestReconcileWithTimeouts_Pipeline runs "Reconcile" on a PipelineRun that has timed out. // It verifies that reconcile is successful, no TaskRun is created, the PipelineTask is marked as skipped, and the // pipeline status updated and events generated. - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -2280,7 +2282,7 @@ spec: taskRef: name: hello-world `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-with-timeout namespace: foo @@ -2297,9 +2299,9 @@ status: pipelineTaskName: hello-world-1 kind: TaskRun `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} - trs := []*v1beta1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-with-timeout-hello-world-1", "foo", "test-pipeline-run-with-timeout", + trs := []*v1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-with-timeout-hello-world-1", "foo", "test-pipeline-run-with-timeout", "test-pipeline", "hello-world-1", false), ` spec: serviceAccountName: test-sa @@ -2334,20 +2336,20 @@ spec: // Check that there is a skipped task for the expected reason if len(reconciledRun.Status.SkippedTasks) != 1 { t.Errorf("expected one skipped task, found %d", len(reconciledRun.Status.SkippedTasks)) - } else if reconciledRun.Status.SkippedTasks[0].Reason != v1beta1.PipelineTimedOutSkip { - t.Errorf("expected skipped reason to be '%s', but was '%s", v1beta1.PipelineTimedOutSkip, reconciledRun.Status.SkippedTasks[0].Reason) + } else if reconciledRun.Status.SkippedTasks[0].Reason != v1.PipelineTimedOutSkip { + t.Errorf("expected skipped reason to be '%s', but was '%s", v1.PipelineTimedOutSkip, reconciledRun.Status.SkippedTasks[0].Reason) } - updatedTaskRun, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").Get(context.Background(), trs[0].Name, metav1.GetOptions{}) + updatedTaskRun, err := clients.Pipeline.TektonV1().TaskRuns("foo").Get(context.Background(), trs[0].Name, metav1.GetOptions{}) if err != nil { t.Fatalf("error getting updated TaskRun: %#v", err) } - if updatedTaskRun.Spec.Status != v1beta1.TaskRunSpecStatusCancelled { - t.Errorf("expected existing TaskRun Spec.Status to be set to %s, but was %s", v1beta1.TaskRunSpecStatusCancelled, updatedTaskRun.Spec.Status) + if updatedTaskRun.Spec.Status != v1.TaskRunSpecStatusCancelled { + t.Errorf("expected existing TaskRun Spec.Status to be set to %s, but was %s", v1.TaskRunSpecStatusCancelled, updatedTaskRun.Spec.Status) } - if updatedTaskRun.Spec.StatusMessage != v1beta1.TaskRunCancelledByPipelineTimeoutMsg { - t.Errorf("expected existing TaskRun Spec.StatusMessage to be set to %s, but was %s", v1beta1.TaskRunCancelledByPipelineTimeoutMsg, updatedTaskRun.Spec.StatusMessage) + if updatedTaskRun.Spec.StatusMessage != v1.TaskRunCancelledByPipelineTimeoutMsg { + t.Errorf("expected existing TaskRun Spec.StatusMessage to be set to %s, but was %s", v1.TaskRunCancelledByPipelineTimeoutMsg, updatedTaskRun.Spec.StatusMessage) } } @@ -2355,7 +2357,7 @@ func TestReconcileWithTimeouts_Tasks(t *testing.T) { // TestReconcileWithTimeouts_Tasks runs "Reconcile" on a PipelineRun with timeouts.tasks configured. // It verifies that reconcile is successful, no TaskRun is created, the PipelineTask is marked as skipped, and the // pipeline status updated and events generated. - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -2368,7 +2370,7 @@ spec: taskRef: name: hello-world `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-with-timeout namespace: foo @@ -2385,9 +2387,9 @@ status: pipelineTaskName: hello-world-1 kind: TaskRun `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} - trs := []*v1beta1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-with-timeout-hello-world-1", "foo", "test-pipeline-run-with-timeout", + trs := []*v1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-with-timeout-hello-world-1", "foo", "test-pipeline-run-with-timeout", "test-pipeline", "hello-world-1", false), ` spec: serviceAccountName: test-sa @@ -2420,27 +2422,27 @@ status: } // The PipelineRun should be running. - if reconciledRun.Status.GetCondition(apis.ConditionSucceeded).Reason != v1beta1.PipelineRunReasonRunning.String() { + if reconciledRun.Status.GetCondition(apis.ConditionSucceeded).Reason != v1.PipelineRunReasonRunning.String() { t.Errorf("Expected PipelineRun to be running, but condition reason is %s", reconciledRun.Status.GetCondition(apis.ConditionSucceeded).Reason) } // Check that there is a skipped task for the expected reason if len(reconciledRun.Status.SkippedTasks) != 1 { t.Errorf("expected one skipped task, found %d", len(reconciledRun.Status.SkippedTasks)) - } else if reconciledRun.Status.SkippedTasks[0].Reason != v1beta1.TasksTimedOutSkip { - t.Errorf("expected skipped reason to be '%s', but was '%s", v1beta1.TasksTimedOutSkip, reconciledRun.Status.SkippedTasks[0].Reason) + } else if reconciledRun.Status.SkippedTasks[0].Reason != v1.TasksTimedOutSkip { + t.Errorf("expected skipped reason to be '%s', but was '%s", v1.TasksTimedOutSkip, reconciledRun.Status.SkippedTasks[0].Reason) } - updatedTaskRun, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").Get(context.Background(), trs[0].Name, metav1.GetOptions{}) + updatedTaskRun, err := clients.Pipeline.TektonV1().TaskRuns("foo").Get(context.Background(), trs[0].Name, metav1.GetOptions{}) if err != nil { t.Fatalf("error getting updated TaskRun: %#v", err) } - if updatedTaskRun.Spec.Status != v1beta1.TaskRunSpecStatusCancelled { - t.Errorf("expected existing TaskRun Spec.Status to be set to %s, but was %s", v1beta1.TaskRunSpecStatusCancelled, updatedTaskRun.Spec.Status) + if updatedTaskRun.Spec.Status != v1.TaskRunSpecStatusCancelled { + t.Errorf("expected existing TaskRun Spec.Status to be set to %s, but was %s", v1.TaskRunSpecStatusCancelled, updatedTaskRun.Spec.Status) } - if updatedTaskRun.Spec.StatusMessage != v1beta1.TaskRunCancelledByPipelineTimeoutMsg { - t.Errorf("expected existing TaskRun Spec.StatusMessage to be set to %s, but was %s", v1beta1.TaskRunCancelledByPipelineTimeoutMsg, updatedTaskRun.Spec.StatusMessage) + if updatedTaskRun.Spec.StatusMessage != v1.TaskRunCancelledByPipelineTimeoutMsg { + t.Errorf("expected existing TaskRun Spec.StatusMessage to be set to %s, but was %s", v1.TaskRunCancelledByPipelineTimeoutMsg, updatedTaskRun.Spec.StatusMessage) } } @@ -2448,7 +2450,7 @@ func TestReconcileWithTimeouts_Finally(t *testing.T) { // TestReconcileWithTimeouts_Finally runs "Reconcile" on a PipelineRun with timeouts.finally configured. // It verifies that reconcile is successful, no TaskRun is created, the PipelineTask is marked as skipped, and the // pipeline status updated and events generated. - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline-with-finally namespace: foo @@ -2465,7 +2467,7 @@ spec: taskRef: name: hello-world `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-with-timeout namespace: foo @@ -2480,7 +2482,7 @@ status: startTime: "2021-12-31T23:40:00Z" childReferences: - name: test-pipeline-run-with-timeout-hello-world - apiVersion: tekton.dev/v1beta1 + apiVersion: tekton.dev/v1 kind: TaskRun pipelineTaskName: task1 status: @@ -2489,7 +2491,7 @@ status: status: "True" type: Succeeded - name: test-pipeline-run-with-timeout-finaltask-1 - apiVersion: tekton.dev/v1beta1 + apiVersion: tekton.dev/v1 kind: TaskRun pipelineTaskName: finaltask-1 status: @@ -2498,8 +2500,8 @@ status: status: "Unknown" type: Succeeded `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} - trs := []*v1beta1.TaskRun{ + ts := []*v1.Task{simpleHelloWorldTask} + trs := []*v1.TaskRun{ getTaskRun( t, "test-pipeline-run-with-timeout-hello-world", @@ -2537,34 +2539,34 @@ spec: } // The PipelineRun should be running. - if reconciledRun.Status.GetCondition(apis.ConditionSucceeded).Reason != v1beta1.PipelineRunReasonRunning.String() { + if reconciledRun.Status.GetCondition(apis.ConditionSucceeded).Reason != v1.PipelineRunReasonRunning.String() { t.Errorf("Expected PipelineRun to be running, but condition reason is %s", reconciledRun.Status.GetCondition(apis.ConditionSucceeded).Reason) } // Check that there is a skipped task for the expected reason if len(reconciledRun.Status.SkippedTasks) != 1 { t.Errorf("expected one skipped task, found %d", len(reconciledRun.Status.SkippedTasks)) - } else if reconciledRun.Status.SkippedTasks[0].Reason != v1beta1.FinallyTimedOutSkip { - t.Errorf("expected skipped reason to be '%s', but was '%s", v1beta1.FinallyTimedOutSkip, reconciledRun.Status.SkippedTasks[0].Reason) + } else if reconciledRun.Status.SkippedTasks[0].Reason != v1.FinallyTimedOutSkip { + t.Errorf("expected skipped reason to be '%s', but was '%s", v1.FinallyTimedOutSkip, reconciledRun.Status.SkippedTasks[0].Reason) } - updatedTaskRun, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").Get(context.Background(), trs[1].Name, metav1.GetOptions{}) + updatedTaskRun, err := clients.Pipeline.TektonV1().TaskRuns("foo").Get(context.Background(), trs[1].Name, metav1.GetOptions{}) if err != nil { t.Fatalf("error getting updated TaskRun: %#v", err) } - if updatedTaskRun.Spec.Status != v1beta1.TaskRunSpecStatusCancelled { - t.Errorf("expected existing TaskRun Spec.Status to be set to %s, but was %s", v1beta1.TaskRunSpecStatusCancelled, updatedTaskRun.Spec.Status) + if updatedTaskRun.Spec.Status != v1.TaskRunSpecStatusCancelled { + t.Errorf("expected existing TaskRun Spec.Status to be set to %s, but was %s", v1.TaskRunSpecStatusCancelled, updatedTaskRun.Spec.Status) } - if updatedTaskRun.Spec.StatusMessage != v1beta1.TaskRunCancelledByPipelineTimeoutMsg { - t.Errorf("expected existing TaskRun Spec.StatusMessage to be set to %s, but was %s", v1beta1.TaskRunCancelledByPipelineTimeoutMsg, updatedTaskRun.Spec.StatusMessage) + if updatedTaskRun.Spec.StatusMessage != v1.TaskRunCancelledByPipelineTimeoutMsg { + t.Errorf("expected existing TaskRun Spec.StatusMessage to be set to %s, but was %s", v1.TaskRunCancelledByPipelineTimeoutMsg, updatedTaskRun.Spec.StatusMessage) } } func TestReconcileWithoutPVC(t *testing.T) { // TestReconcileWithoutPVC runs "Reconcile" on a PipelineRun that has two unrelated tasks. // It verifies that reconcile is successful and that no PVC is created - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -2578,7 +2580,7 @@ spec: name: hello-world `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run namespace: foo @@ -2586,7 +2588,7 @@ spec: pipelineRef: name: test-pipeline `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ PipelineRuns: prs, @@ -2619,15 +2621,15 @@ func TestReconcileCancelledFailsTaskRunCancellation(t *testing.T) { testCases := []struct { name string - specStatus v1beta1.PipelineRunSpecStatus + specStatus v1.PipelineRunSpecStatus }{ { name: "cancelled", - specStatus: v1beta1.PipelineRunSpecStatusCancelled, + specStatus: v1.PipelineRunSpecStatusCancelled, }, { name: "cancelled run finally", - specStatus: v1beta1.PipelineRunSpecStatusCancelledRunFinally, + specStatus: v1.PipelineRunSpecStatusCancelledRunFinally, }, } @@ -2637,7 +2639,7 @@ func TestReconcileCancelledFailsTaskRunCancellation(t *testing.T) { // The TaskRun cannot be cancelled. Check that the pipelinerun cancel fails, that reconcile fails and // an event is generated names.TestingSeed() - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: test-pipeline-fails-to-cancel namespace: foo @@ -2653,12 +2655,12 @@ status: type: Succeeded startTime: "2022-01-01T00:00:00Z" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: test-pipeline-fails-to-cancelhello-world-1 pipelineTaskName: hello-world-1 `, tc.specStatus))} - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -2671,8 +2673,8 @@ spec: taskRef: name: hello-world `)} - tasks := []*v1beta1.Task{simpleHelloWorldTask} - taskRuns := []*v1beta1.TaskRun{ + tasks := []*v1.Task{simpleHelloWorldTask} + taskRuns := []*v1.TaskRun{ getTaskRun( t, "test-pipeline-fails-to-cancelhello-world-1", @@ -2710,7 +2712,7 @@ spec: } // Check that the PipelineRun is still running with correct error message - reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(testAssets.Ctx, "test-pipeline-fails-to-cancel", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1().PipelineRuns("foo").Get(testAssets.Ctx, "test-pipeline-fails-to-cancel", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } @@ -2755,7 +2757,7 @@ func TestReconcileFailsTaskRunTimeOut(t *testing.T) { // The TaskRun cannot be timed out. Check that the pipelinerun timeout fails, that reconcile fails and // an event is generated names.TestingSeed() - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-fails-to-timeout namespace: foo @@ -2771,12 +2773,12 @@ status: type: Succeeded startTime: "2021-12-31T22:59:00Z" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: test-pipeline-fails-to-timeouthello-world-1 pipelineTaskName: hello-world-1 `)} - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -2789,8 +2791,8 @@ spec: taskRef: name: hello-world `)} - tasks := []*v1beta1.Task{simpleHelloWorldTask} - taskRuns := []*v1beta1.TaskRun{ + tasks := []*v1.Task{simpleHelloWorldTask} + taskRuns := []*v1.TaskRun{ getTaskRun( t, "test-pipeline-fails-to-timeouthello-world-1", @@ -2828,7 +2830,7 @@ spec: } // Check that the PipelineRun is still running with correct error message - reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(testAssets.Ctx, "test-pipeline-fails-to-timeout", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1().PipelineRuns("foo").Get(testAssets.Ctx, "test-pipeline-fails-to-timeout", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } @@ -2867,8 +2869,8 @@ spec: func TestReconcilePropagateLabelsAndAnnotations(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + ps := []*v1.Pipeline{simpleHelloWorldPipeline} + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: annotations: PipelineRunAnnotation: PipelineRunValue @@ -2882,7 +2884,7 @@ spec: name: test-pipeline serviceAccountName: test-sa `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} expectedObjectMeta := taskRunObjectMeta("test-pipeline-run-with-labels-hello-world-1", "foo", "test-pipeline-run-with-labels", "test-pipeline", "hello-world-1", false) @@ -2908,7 +2910,7 @@ spec: // Check that the expected TaskRun was created actual := getTaskRunCreations(t, clients.Pipeline.Actions(), 2)[0] - // We're ignoring TypeMeta here because parse.MustParseV1beta1TaskRun populates that, but ktesting does not, so actual does not have it. + // We're ignoring TypeMeta here because parse.MustParseV1TaskRun populates that, but ktesting does not, so actual does not have it. if d := cmp.Diff(expected, actual, cmpopts.IgnoreTypes(metav1.TypeMeta{})); d != "" { t.Errorf("expected to see TaskRun %v created. Diff %s", expected, diff.PrintWantGot(d)) } @@ -2917,14 +2919,14 @@ spec: func TestReconcilePropagateLabelsWithSpecStatus(t *testing.T) { testCases := []struct { name string - specStatus v1beta1.PipelineRunSpecStatus + specStatus v1.PipelineRunSpecStatus }{ { name: "pending", - specStatus: v1beta1.PipelineRunSpecStatusPending, + specStatus: v1.PipelineRunSpecStatusPending, }, { name: "cancelled", - specStatus: v1beta1.PipelineRunSpecStatusCancelled, + specStatus: v1.PipelineRunSpecStatusCancelled, }, } @@ -2932,8 +2934,8 @@ func TestReconcilePropagateLabelsWithSpecStatus(t *testing.T) { t.Run(tc.name, func(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + ps := []*v1.Pipeline{simpleHelloWorldPipeline} + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: annotations: PipelineRunAnnotation: PipelineRunValue @@ -2949,7 +2951,7 @@ spec: status: %s `, tc.specStatus))} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ PipelineRuns: prs, @@ -2961,7 +2963,7 @@ spec: _, clients := prt.reconcileRun("foo", "test-pipeline-run-with-labels", []string{}, false) - reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "test-pipeline-run-with-labels", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "test-pipeline-run-with-labels", metav1.GetOptions{}) if err != nil { t.Fatalf("unexpected error when updating status: %v", err) } @@ -2978,7 +2980,7 @@ spec: func TestReconcileWithDifferentServiceAccounts(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -2991,7 +2993,7 @@ spec: taskRef: name: hello-world-task `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-different-service-accs namespace: foo @@ -3003,7 +3005,7 @@ spec: - taskServiceAccountName: test-sa-1 pipelineTaskName: hello-world-1 `)} - ts := []*v1beta1.Task{parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{parse.MustParseV1Task(t, ` metadata: name: hello-world-task namespace: foo @@ -3021,7 +3023,7 @@ metadata: taskRunNames := []string{"test-pipeline-run-different-service-accs-hello-world-0", "test-pipeline-run-different-service-accs-hello-world-1"} - expectedTaskRuns := []*v1beta1.TaskRun{ + expectedTaskRuns := []*v1.TaskRun{ mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta(taskRunNames[0], "foo", "test-pipeline-run-different-service-accs", "test-pipeline", "hello-world-0", false), ` @@ -3044,7 +3046,7 @@ spec: for i := range ps[0].Spec.Tasks { // Check that the expected TaskRun was created - actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").Get(prt.TestAssets.Ctx, taskRunNames[i], metav1.GetOptions{}) + actual, err := clients.Pipeline.TektonV1().TaskRuns("foo").Get(prt.TestAssets.Ctx, taskRunNames[i], metav1.GetOptions{}) if err != nil { t.Fatalf("Expected a TaskRun to be created, but it wasn't: %s", err) } @@ -3057,7 +3059,7 @@ spec: func TestReconcileCustomTasksWithDifferentServiceAccounts(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -3073,7 +3075,7 @@ spec: kind: Example `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-different-service-accs namespace: foo @@ -3117,8 +3119,8 @@ spec: func TestReconcileAndPropagateCustomPipelineTaskRunSpec(t *testing.T) { names.TestingSeed() prName := "test-pipeline-run" - ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + ps := []*v1.Pipeline{simpleHelloWorldPipeline} + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: annotations: PipelineRunAnnotation: PipelineRunValue @@ -3139,7 +3141,7 @@ spec: workloadtype: tekton taskServiceAccountName: custom-sa `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ PipelineRuns: prs, @@ -3178,7 +3180,7 @@ spec: func TestReconcileCustomTasksWithTaskRunSpec(t *testing.T) { names.TestingSeed() prName := "test-pipeline-run" - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -3191,7 +3193,7 @@ spec: `)} serviceAccount := "custom-sa" - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run namespace: foo @@ -3231,7 +3233,7 @@ spec: func TestReconcileWithWhenExpressionsWithTaskResultsAndParams(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -3277,7 +3279,7 @@ spec: taskRef: name: d-task `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-different-service-accs namespace: foo @@ -3289,13 +3291,13 @@ spec: name: test-pipeline serviceAccountName: test-sa-0 `)} - ts := []*v1beta1.Task{ + ts := []*v1.Task{ {ObjectMeta: baseObjectMeta("a-task", "foo")}, {ObjectMeta: baseObjectMeta("b-task", "foo")}, {ObjectMeta: baseObjectMeta("c-task", "foo")}, {ObjectMeta: baseObjectMeta("d-task", "foo")}, } - trs := []*v1beta1.TaskRun{mustParseTaskRunWithObjectMeta(t, + trs := []*v1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-different-service-accs-a-task-xxyyy", "foo", "test-pipeline-run-different-service-accs", "test-pipeline", "a-task", true), ` @@ -3340,7 +3342,7 @@ spec: kind: Task `) // Check that the expected TaskRun was created - actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + actual, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: "tekton.dev/pipelineTask=b-task,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs", Limit: 1, }) @@ -3356,7 +3358,7 @@ spec: t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRunName, diff.PrintWantGot(d)) } - expectedWhenExpressionsInTaskRun := []v1beta1.WhenExpression{{ + expectedWhenExpressionsInTaskRun := []v1.WhenExpression{{ Input: "aResultValue", Operator: "in", Values: []string{"aResultValue"}, @@ -3372,10 +3374,10 @@ spec: verifyTaskRunStatusesWhenExpressions(t, pipelineRun.Status, expectedTaskRunName, expectedWhenExpressionsInTaskRun) actualSkippedTasks := pipelineRun.Status.SkippedTasks - expectedSkippedTasks := []v1beta1.SkippedTask{{ + expectedSkippedTasks := []v1.SkippedTask{{ Name: "c-task", - Reason: v1beta1.WhenExpressionsSkip, - WhenExpressions: v1beta1.WhenExpressions{{ + Reason: v1.WhenExpressionsSkip, + WhenExpressions: v1.WhenExpressions{{ Input: "aResultValue", Operator: "in", Values: []string{"missing"}, @@ -3392,7 +3394,7 @@ spec: skippedTasks := []string{"c-task"} for _, skippedTask := range skippedTasks { labelSelector := fmt.Sprintf("tekton.dev/pipelineTask=%s,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs", skippedTask) - actualSkippedTask, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + actualSkippedTask, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: labelSelector, Limit: 1, }) @@ -3412,7 +3414,7 @@ func TestReconcileWithWhenExpressions(t *testing.T) { // \ // (e) ———— (f) names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -3469,7 +3471,7 @@ spec: name: f-task `)} // initialize the pipelinerun with the skipped a-task - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-different-service-accs namespace: foo @@ -3487,8 +3489,8 @@ status: - bar `)} // initialize the tasks used in the pipeline - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: a-task namespace: foo @@ -3530,7 +3532,7 @@ spec: kind: Task `, taskName)) - actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + actual, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: fmt.Sprintf("tekton.dev/pipelineTask=%s,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs", taskName), Limit: 1, }) @@ -3551,11 +3553,11 @@ spec: taskRunExists("d-task", "test-pipeline-run-different-service-accs-d-task") actualSkippedTasks := pipelineRun.Status.SkippedTasks - expectedSkippedTasks := []v1beta1.SkippedTask{{ + expectedSkippedTasks := []v1.SkippedTask{{ // its when expressions evaluate to false Name: "a-task", - Reason: v1beta1.WhenExpressionsSkip, - WhenExpressions: v1beta1.WhenExpressions{{ + Reason: v1.WhenExpressionsSkip, + WhenExpressions: v1.WhenExpressions{{ Input: "foo", Operator: "in", Values: []string{"bar"}, @@ -3563,8 +3565,8 @@ spec: }, { // its when expressions evaluate to false Name: "c-task", - Reason: v1beta1.WhenExpressionsSkip, - WhenExpressions: v1beta1.WhenExpressions{{ + Reason: v1.WhenExpressionsSkip, + WhenExpressions: v1.WhenExpressions{{ Input: "foo", Operator: "in", Values: []string{"bar"}, @@ -3572,15 +3574,15 @@ spec: }, { // was attempted, but has missing results references Name: "e-task", - Reason: v1beta1.MissingResultsSkip, - WhenExpressions: v1beta1.WhenExpressions{{ + Reason: v1.MissingResultsSkip, + WhenExpressions: v1.WhenExpressions{{ Input: "$(tasks.a-task.results.aResult)", Operator: "in", Values: []string{"aResultValue"}, }}, }, { Name: "f-task", - Reason: v1beta1.ParentTasksSkip, + Reason: v1.ParentTasksSkip, }} if d := cmp.Diff(expectedSkippedTasks, actualSkippedTasks); d != "" { t.Errorf("expected to find Skipped Tasks %v. Diff %s", expectedSkippedTasks, diff.PrintWantGot(d)) @@ -3590,7 +3592,7 @@ spec: skippedTasks := []string{"a-task", "c-task", "e-task", "f-task"} for _, skippedTask := range skippedTasks { labelSelector := fmt.Sprintf("tekton.dev/pipelineTask=%s,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs", skippedTask) - actualSkippedTask, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + actualSkippedTask, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: labelSelector, Limit: 1, }) @@ -3605,7 +3607,7 @@ spec: func TestReconcileWithWhenExpressionsWithResultRefs(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -3631,7 +3633,7 @@ spec: taskRef: name: c-task `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-different-service-accs namespace: foo @@ -3640,8 +3642,8 @@ spec: name: test-pipeline serviceAccountName: test-sa-0 `)} - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: a-task namespace: foo @@ -3653,7 +3655,7 @@ spec: {ObjectMeta: baseObjectMeta("b-task", "foo")}, {ObjectMeta: baseObjectMeta("c-task", "foo")}, } - trs := []*v1beta1.TaskRun{mustParseTaskRunWithObjectMeta(t, + trs := []*v1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-different-service-accs-a-task-xxyyy", "foo", "test-pipeline-run-different-service-accs", "test-pipeline", "a-task", true), @@ -3687,7 +3689,7 @@ status: } pipelineRun, clients := prt.reconcileRun("foo", "test-pipeline-run-different-service-accs", wantEvents, false) - actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + actual, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: "tekton.dev/pipelineTask=c-task,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs", Limit: 1, }) @@ -3700,11 +3702,11 @@ status: } actualSkippedTasks := pipelineRun.Status.SkippedTasks - expectedSkippedTasks := []v1beta1.SkippedTask{{ + expectedSkippedTasks := []v1.SkippedTask{{ // its when expressions evaluate to false Name: "b-task", - Reason: v1beta1.WhenExpressionsSkip, - WhenExpressions: v1beta1.WhenExpressions{{ + Reason: v1.WhenExpressionsSkip, + WhenExpressions: v1.WhenExpressions{{ Input: "aResultValue", Operator: "in", Values: []string{"notResultValue"}, @@ -3718,7 +3720,7 @@ status: skippedTasks := []string{"b-task"} for _, skippedTask := range skippedTasks { labelSelector := fmt.Sprintf("tekton.dev/pipelineTask=%s,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs", skippedTask) - actualSkippedTask, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + actualSkippedTask, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: labelSelector, Limit: 1, }) @@ -3738,7 +3740,7 @@ func TestReconcileWithAffinityAssistantStatefulSet(t *testing.T) { workspaceName := "ws1" workspaceName2 := "ws2" pipelineRunName := "test-pipeline-run" - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -3768,7 +3770,7 @@ spec: - name: emptyDirWorkspace `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run namespace: foo @@ -3789,7 +3791,7 @@ spec: - emptyDir: {} name: emptyDirWorkspace `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ PipelineRuns: prs, @@ -3828,7 +3830,7 @@ spec: } } - taskRuns, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{}) + taskRuns, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error when listing TaskRuns: %v", err) } @@ -3869,7 +3871,7 @@ spec: // a PVC is created and that the workspace appears as a PersistentVolumeClaim workspace for TaskRuns. func TestReconcileWithVolumeClaimTemplateWorkspace(t *testing.T) { pipelineRunName := "test-pipeline-run" - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -3888,7 +3890,7 @@ spec: - name: ws1 `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run namespace: foo @@ -3902,7 +3904,7 @@ spec: creationTimestamp: null name: myclaim `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ PipelineRuns: prs, @@ -3943,7 +3945,7 @@ spec: } } - taskRuns, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{}) + taskRuns, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error when listing TaskRuns: %v", err) } @@ -3972,7 +3974,7 @@ func TestReconcileWithVolumeClaimTemplateWorkspaceUsingSubPaths(t *testing.T) { subPath2 := "otherdirecory" pipelineRunWsSubPath := "mypath" pipelineRunName := "test-pipeline-run" - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -4030,7 +4032,7 @@ spec: - name: ws3 `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -4056,7 +4058,7 @@ spec: creationTimestamp: null name: myclaim `, pipelineRunName))} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ PipelineRuns: prs, @@ -4068,7 +4070,7 @@ spec: reconciledRun, clients := prt.reconcileRun("foo", pipelineRunName, []string{}, false) - taskRuns, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{}) + taskRuns, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error when listing TaskRuns: %v", err) } @@ -4155,7 +4157,7 @@ spec: func TestReconcileWithTaskResults(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -4171,7 +4173,7 @@ spec: taskRef: name: b-task `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-different-service-accs namespace: foo @@ -4180,14 +4182,14 @@ spec: name: test-pipeline serviceAccountName: test-sa-0 `)} - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: a-task namespace: foo spec: {} `), - parse.MustParseV1beta1Task(t, ` + parse.MustParseV1Task(t, ` metadata: name: b-task namespace: foo @@ -4197,7 +4199,7 @@ spec: type: string `), } - trs := []*v1beta1.TaskRun{mustParseTaskRunWithObjectMeta(t, + trs := []*v1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-different-service-accs-a-task-xxyyy", "foo", "test-pipeline-run-different-service-accs", "test-pipeline", "a-task", true), ` @@ -4242,7 +4244,7 @@ spec: kind: Task `) // Check that the expected TaskRun was created - actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + actual, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: "tekton.dev/pipelineTask=b-task,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs", Limit: 1, }) @@ -4261,7 +4263,7 @@ spec: func TestReconcileWithTaskResultsEmbeddedNoneStarted(t *testing.T) { names.TestingSeed() - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-different-service-accs namespace: foo @@ -4285,8 +4287,8 @@ spec: name: b-task serviceAccountName: test-sa-0 `)} - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: a-task namespace: foo @@ -4294,7 +4296,7 @@ spec: results: - name: A_RESULT `), - parse.MustParseV1beta1Task(t, ` + parse.MustParseV1Task(t, ` metadata: name: b-task namespace: foo @@ -4330,7 +4332,7 @@ spec: name: a-task `) // Check that the expected TaskRun was created (only) - actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{}) + actual, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("Failure to list TaskRun's %s", err) } @@ -4345,7 +4347,7 @@ spec: func TestReconcileWithFinallyResults(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -4371,7 +4373,7 @@ spec: kind: Example name: b-task `)} - trs := []*v1beta1.TaskRun{mustParseTaskRunWithObjectMeta(t, + trs := []*v1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-finally-results-task-run-a", "foo", "test-pipeline-run-finally-results", "test-pipeline", "a-task", true), ` @@ -4413,7 +4415,7 @@ status: - name: b-Result value: bResultValue `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-finally-results namespace: foo @@ -4426,8 +4428,8 @@ status: type: Succeeded reason: Succeeded `)} - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: a-task namespace: foo @@ -4435,7 +4437,7 @@ spec: results: - name: a-Result `), - parse.MustParseV1beta1Task(t, ` + parse.MustParseV1Task(t, ` metadata: name: c-task namespace: foo @@ -4461,7 +4463,7 @@ spec: defer prt.Cancel() reconciledRun, _ := prt.reconcileRun("foo", "test-pipeline-run-finally-results", []string{}, false) - expectedPrStatus := parse.MustParseV1beta1PipelineRun(t, ` + expectedPrStatus := parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-finally-results namespace: foo @@ -4506,15 +4508,15 @@ status: - name: custom-result value: bResultValue childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: test-pipeline-run-finally-results-task-run-c pipelineTaskName: c-task - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: test-pipeline-run-finally-results-task-run-a pipelineTaskName: a-task - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: test-pipeline-run-finally-results-task-run-b pipelineTaskName: b-task @@ -4529,7 +4531,7 @@ status: func TestReconcileWithPipelineResults(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -4551,7 +4553,7 @@ spec: taskRef: name: a-task `)} - trs := []*v1beta1.TaskRun{mustParseTaskRunWithObjectMeta(t, + trs := []*v1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-results-task-run-a", "foo", "test-pipeline-run-results", "test-pipeline", "a-task", true), ` @@ -4582,7 +4584,7 @@ status: - name: b-Result value: bResultValue `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-results namespace: foo @@ -4594,8 +4596,8 @@ status: - status: "Unknown" type: Succeeded `)} - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: a-task namespace: foo @@ -4618,7 +4620,7 @@ spec: defer prt.Cancel() reconciledRun, _ := prt.reconcileRun("foo", "test-pipeline-run-results", []string{}, false) - expectedPrStatus := parse.MustParseV1beta1PipelineRun(t, ` + expectedPrStatus := parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-results namespace: foo @@ -4658,11 +4660,11 @@ status: - name: custom-result value: bResultValue childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: test-pipeline-run-results-task-run-b pipelineTaskName: b-task - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: test-pipeline-run-results-task-run-a pipelineTaskName: a-task @@ -4677,7 +4679,7 @@ status: func TestReconcileWithPipelineResults_OnFailedPipelineRun(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -4697,7 +4699,7 @@ spec: taskRef: name: b-task `)} - trs := []*v1beta1.TaskRun{mustParseTaskRunWithObjectMeta(t, + trs := []*v1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-failed-pr-with-task-results-a-task", "foo", "test-failed-pr-with-task-results", "test-pipeline", "a-task", true), ` @@ -4730,7 +4732,7 @@ status: - name: bResult value: bResultValue `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-failed-pr-with-task-results namespace: foo @@ -4748,9 +4750,9 @@ status: type: Succeeded startTime: "2021-12-31T00:00:00Z" `)} - ts := []*v1beta1.Task{ + ts := []*v1.Task{ {ObjectMeta: baseObjectMeta("a-task", "foo")}, - parse.MustParseV1beta1Task(t, ` + parse.MustParseV1Task(t, ` metadata: name: b-task namespace: foo @@ -4760,7 +4762,7 @@ spec: type: string `), } - wantPrs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + wantPrs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-failed-pr-with-task-results namespace: foo @@ -4796,13 +4798,13 @@ status: if d := cmp.Diff(reconciledRun.Status.Conditions, wantPrs[0].Status.Conditions, ignoreResourceVersion, ignoreLastTransitionTime); d != "" { t.Errorf("expected to see pipeline run marked as failed. Diff %s", diff.PrintWantGot(d)) } - if d := cmp.Diff(reconciledRun.Status.PipelineResults, wantPrs[0].Status.PipelineResults, ignoreResourceVersion, ignoreLastTransitionTime); d != "" { + if d := cmp.Diff(reconciledRun.Status.Results, wantPrs[0].Status.Results, ignoreResourceVersion, ignoreLastTransitionTime); d != "" { t.Errorf("expected to see pipeline run results created. Diff %s", diff.PrintWantGot(d)) } } func Test_storePipelineSpecAndConfigSource(t *testing.T) { - pr := parse.MustParseV1beta1PipelineRun(t, ` + pr := parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-success labels: @@ -4810,7 +4812,7 @@ metadata: annotations: io.annotation: value `) - configSource := &v1beta1.ConfigSource{ + configSource := &v1.ConfigSource{ URI: "abc.com", Digest: map[string]string{ "sha1": "a123", @@ -4818,14 +4820,14 @@ metadata: EntryPoint: "foo/bar", } - ps := v1beta1.PipelineSpec{Description: "foo-pipeline"} - ps1 := v1beta1.PipelineSpec{Description: "bar-pipeline"} + ps := v1.PipelineSpec{Description: "foo-pipeline"} + ps1 := v1.PipelineSpec{Description: "bar-pipeline"} want := pr.DeepCopy() - want.Status = v1beta1.PipelineRunStatus{ - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + want.Status = v1.PipelineRunStatus{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ PipelineSpec: ps.DeepCopy(), - Provenance: &v1beta1.Provenance{ + Provenance: &v1.Provenance{ ConfigSource: configSource.DeepCopy(), FeatureFlags: &config.FeatureFlags{ RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars, @@ -4843,7 +4845,7 @@ metadata: want.ObjectMeta.Labels["tekton.dev/pipeline"] = pr.ObjectMeta.Name type args struct { - pipelineSpec *v1beta1.PipelineSpec + pipelineSpec *v1.PipelineSpec resolvedObjectMeta *resolutionutil.ResolvedObjectMeta } @@ -4851,7 +4853,7 @@ metadata: name string reconcile1Args *args reconcile2Args *args - wantPipelineRun *v1beta1.PipelineRun + wantPipelineRun *v1.PipelineRun }{ { name: "spec and source are available in the same reconcile", @@ -4915,11 +4917,11 @@ func Test_storePipelineSpec_metadata(t *testing.T) { wantedlabels := map[string]string{"lbl1": "value1", "lbl2": "value2", "lbl3": "value3", pipeline.PipelineLabelKey: "bar"} wantedannotations := map[string]string{"io.annotation.1": "value1", "io.annotation.2": "value2", "io.annotation.3": "value3"} - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Labels: pipelinerunlabels, Annotations: pipelinerunannotations}, } meta := metav1.ObjectMeta{Name: "bar", Labels: pipelinelabels, Annotations: pipelineannotations} - if err := storePipelineSpecAndMergeMeta(context.Background(), pr, &v1beta1.PipelineSpec{}, &resolutionutil.ResolvedObjectMeta{ + if err := storePipelineSpecAndMergeMeta(context.Background(), pr, &v1.PipelineSpec{}, &resolutionutil.ResolvedObjectMeta{ ObjectMeta: &meta, }); err != nil { t.Errorf("storePipelineSpecAndMergeMeta error = %v", err) @@ -4943,7 +4945,7 @@ func TestReconcileOutOfSyncPipelineRun(t *testing.T) { prOutOfSyncName := "test-pipeline-run-out-of-sync" helloWorldTask := simpleHelloWorldTask - testPipeline := parse.MustParseV1beta1Pipeline(t, ` + testPipeline := parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -5001,7 +5003,7 @@ status: type: Succeeded `) - prOutOfSync := parse.MustParseV1beta1PipelineRun(t, ` + prOutOfSync := parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-out-of-sync namespace: foo @@ -5015,21 +5017,21 @@ status: type: Succeeded `) - prOutOfSync.Status.ChildReferences = []v1beta1.ChildStatusReference{ + prOutOfSync.Status.ChildReferences = []v1.ChildStatusReference{ { TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: taskRunDone.Name, PipelineTaskName: "hello-world-1", }, } - prs := []*v1beta1.PipelineRun{prOutOfSync} - ps := []*v1beta1.Pipeline{testPipeline} - ts := []*v1beta1.Task{helloWorldTask} - trs := []*v1beta1.TaskRun{taskRunDone, taskRunOrphaned} + prs := []*v1.PipelineRun{prOutOfSync} + ps := []*v1.Pipeline{testPipeline} + ts := []*v1.Task{helloWorldTask} + trs := []*v1.TaskRun{taskRunDone, taskRunOrphaned} customRuns := []*v1beta1.CustomRun{orphanedCustomRun} cms := []*corev1.ConfigMap{newFeatureFlagsConfigMap()} @@ -5084,12 +5086,12 @@ status: t.Errorf("Expected PipelineRun status to be running, but was %v", reconciledRun.Status.GetCondition(apis.ConditionSucceeded)) } - expectedTaskRunsStatus := make(map[string]*v1beta1.PipelineRunTaskRunStatus) - expectedRunsStatus := make(map[string]*v1beta1.PipelineRunRunStatus) + expectedTaskRunsStatus := make(map[string]*v1.PipelineRunTaskRunStatus) + expectedRunsStatus := make(map[string]*v1.PipelineRunRunStatus) // taskRunDone did not change - expectedTaskRunsStatus[taskRunDone.Name] = &v1beta1.PipelineRunTaskRunStatus{ + expectedTaskRunsStatus[taskRunDone.Name] = &v1.PipelineRunTaskRunStatus{ PipelineTaskName: "hello-world-1", - Status: &v1beta1.TaskRunStatus{ + Status: &v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{ { @@ -5101,9 +5103,9 @@ status: }, } // taskRunOrphaned was recovered into the status - expectedTaskRunsStatus[taskRunOrphaned.Name] = &v1beta1.PipelineRunTaskRunStatus{ + expectedTaskRunsStatus[taskRunOrphaned.Name] = &v1.PipelineRunTaskRunStatus{ PipelineTaskName: "hello-world-2", - Status: &v1beta1.TaskRunStatus{ + Status: &v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{ { @@ -5115,7 +5117,7 @@ status: }, } // orphanedCustomRun was recovered into the status - expectedRunsStatus[orphanedCustomRun.Name] = &v1beta1.PipelineRunRunStatus{ + expectedRunsStatus[orphanedCustomRun.Name] = &v1.PipelineRunRunStatus{ PipelineTaskName: "hello-world-5", Status: &v1beta1.CustomRunStatus{ Status: duckv1.Status{ @@ -5129,24 +5131,24 @@ status: }, } - taskRunsStatus := make(map[string]*v1beta1.PipelineRunTaskRunStatus) - runsStatus := make(map[string]*v1beta1.PipelineRunRunStatus) + taskRunsStatus := make(map[string]*v1.PipelineRunTaskRunStatus) + runsStatus := make(map[string]*v1.PipelineRunRunStatus) for _, cr := range reconciledRun.Status.ChildReferences { - if cr.Kind == taskRun { - trStatusForPipelineRun := &v1beta1.PipelineRunTaskRunStatus{ + if cr.Kind == "TaskRun" { + trStatusForPipelineRun := &v1.PipelineRunTaskRunStatus{ PipelineTaskName: cr.PipelineTaskName, WhenExpressions: cr.WhenExpressions, } - tr, _ := clients.Pipeline.TektonV1beta1().TaskRuns("foo").Get(ctx, cr.Name, metav1.GetOptions{}) + tr, _ := clients.Pipeline.TektonV1().TaskRuns("foo").Get(ctx, cr.Name, metav1.GetOptions{}) if tr != nil { trStatusForPipelineRun.Status = &tr.Status } taskRunsStatus[cr.Name] = trStatusForPipelineRun - } else if cr.Kind == customRun { - rStatusForPipelineRun := &v1beta1.PipelineRunRunStatus{ + } else if cr.Kind == "CustomRun" { + rStatusForPipelineRun := &v1.PipelineRunRunStatus{ PipelineTaskName: cr.PipelineTaskName, WhenExpressions: cr.WhenExpressions, } @@ -5168,7 +5170,7 @@ status: func TestUpdatePipelineRunStatusFromInformer(t *testing.T) { names.TestingSeed() - pr := parse.MustParseV1beta1PipelineRun(t, ` + pr := parse.MustParseV1PipelineRun(t, ` metadata: labels: mylabel: myvale @@ -5192,7 +5194,7 @@ spec: cms := []*corev1.ConfigMap{newFeatureFlagsConfigMap()} d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{pr}, + PipelineRuns: []*v1.PipelineRun{pr}, ConfigMaps: cms, } prt := newPipelineRunTest(t, d) @@ -5232,7 +5234,7 @@ spec: // Add a label to the PipelineRun. This tests a scenario in issue 3126 which could prevent the reconciler // from finding TaskRuns that are missing from the status. reconciledRun.ObjectMeta.Labels["bah"] = "humbug" - reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Update(prt.TestAssets.Ctx, reconciledRun, metav1.UpdateOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1().PipelineRuns("foo").Update(prt.TestAssets.Ctx, reconciledRun, metav1.UpdateOptions{}) if err != nil { t.Fatalf("unexpected error when updating status: %v", err) } @@ -5240,8 +5242,8 @@ spec: // The label update triggers another reconcile. Depending on timing, the PipelineRun passed to the reconcile may or may not // have the updated status with the name of the created TaskRun. Clear the status because we want to test the case where the // status does not have the TaskRun. - reconciledRun.Status = v1beta1.PipelineRunStatus{} - if _, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").UpdateStatus(prt.TestAssets.Ctx, reconciledRun, metav1.UpdateOptions{}); err != nil { + reconciledRun.Status = v1.PipelineRunStatus{} + if _, err := clients.Pipeline.TektonV1().PipelineRuns("foo").UpdateStatus(prt.TestAssets.Ctx, reconciledRun, metav1.UpdateOptions{}); err != nil { t.Fatalf("unexpected error when updating status: %v", err) } @@ -5258,12 +5260,12 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { tests := []struct { name string pipelineRunName string - prs []*v1beta1.PipelineRun - ps []*v1beta1.Pipeline - ts []*v1beta1.Task - trs []*v1beta1.TaskRun - expectedTaskRuns map[string]*v1beta1.PipelineRunTaskRunStatus - expectedChildReferences []v1beta1.ChildStatusReference + prs []*v1.PipelineRun + ps []*v1.Pipeline + ts []*v1.Task + trs []*v1.TaskRun + expectedTaskRuns map[string]*v1.PipelineRunTaskRunStatus + expectedChildReferences []v1.ChildStatusReference pipelineRunStatusUnknown bool pipelineRunStatusFalse bool }{{ @@ -5283,7 +5285,7 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { "pipeline-run-dag-task-failing", "pipeline-dag-task-failing", corev1.ConditionFalse, - v1beta1.PipelineRunReasonFailed.String(), + v1.PipelineRunReasonFailed.String(), "Tasks Completed: 2 (Failed: 1, Cancelled 0), Skipped: 0", map[string]string{ "dag-task-1": "task-run-dag-task", @@ -5293,20 +5295,20 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ps: getPipeline( "pipeline-dag-task-failing", - v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "dag-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }}, - Finally: []v1beta1.PipelineTask{{ + Finally: []v1.PipelineTask{{ Name: "final-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }}, }), - ts: []*v1beta1.Task{simpleHelloWorldTask}, + ts: []*v1.Task{simpleHelloWorldTask}, - trs: []*v1beta1.TaskRun{ + trs: []*v1.TaskRun{ getTaskRun( t, "task-run-dag-task", @@ -5325,22 +5327,22 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ), }, - expectedTaskRuns: map[string]*v1beta1.PipelineRunTaskRunStatus{ + expectedTaskRuns: map[string]*v1.PipelineRunTaskRunStatus{ "task-run-dag-task": getTaskRunStatus("dag-task-1", corev1.ConditionFalse), "task-run-final-task": getTaskRunStatus("final-task-1", ""), }, - expectedChildReferences: []v1beta1.ChildStatusReference{{ + expectedChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "task-run-dag-task", PipelineTaskName: "dag-task-1", }, { TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "task-run-final-task", PipelineTaskName: "final-task-1", @@ -5362,7 +5364,7 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { "pipeline-run-with-dag-successful-but-final-failing", "pipeline-with-dag-successful-but-final-failing", corev1.ConditionFalse, - v1beta1.PipelineRunReasonFailed.String(), + v1.PipelineRunReasonFailed.String(), "Tasks Completed: 2 (Failed: 1, Cancelled 0), Skipped: 0", map[string]string{ "dag-task-1": "task-run-dag-task", @@ -5372,20 +5374,20 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ps: getPipeline( "pipeline-with-dag-successful-but-final-failing", - v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "dag-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }}, - Finally: []v1beta1.PipelineTask{{ + Finally: []v1.PipelineTask{{ Name: "final-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }}, }), - ts: []*v1beta1.Task{simpleHelloWorldTask}, + ts: []*v1.Task{simpleHelloWorldTask}, - trs: []*v1beta1.TaskRun{ + trs: []*v1.TaskRun{ getTaskRun( t, "task-run-dag-task", @@ -5404,22 +5406,22 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ), }, - expectedTaskRuns: map[string]*v1beta1.PipelineRunTaskRunStatus{ + expectedTaskRuns: map[string]*v1.PipelineRunTaskRunStatus{ "task-run-dag-task": getTaskRunStatus("dag-task-1", ""), "task-run-final-task": getTaskRunStatus("final-task-1", corev1.ConditionFalse), }, - expectedChildReferences: []v1beta1.ChildStatusReference{{ + expectedChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "task-run-dag-task", PipelineTaskName: "dag-task-1", }, { TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "task-run-final-task", PipelineTaskName: "final-task-1", @@ -5443,7 +5445,7 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { "pipeline-run-with-dag-and-final-failing", "pipeline-with-dag-and-final-failing", corev1.ConditionFalse, - v1beta1.PipelineRunReasonFailed.String(), + v1.PipelineRunReasonFailed.String(), "Tasks Completed: 2 (Failed: 2, Cancelled 0), Skipped: 0", map[string]string{ "dag-task-1": "task-run-dag-task", @@ -5453,20 +5455,20 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ps: getPipeline( "pipeline-with-dag-and-final-failing", - v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "dag-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }}, - Finally: []v1beta1.PipelineTask{{ + Finally: []v1.PipelineTask{{ Name: "final-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }}, }), - ts: []*v1beta1.Task{simpleHelloWorldTask}, + ts: []*v1.Task{simpleHelloWorldTask}, - trs: []*v1beta1.TaskRun{ + trs: []*v1.TaskRun{ getTaskRun( t, "task-run-dag-task", @@ -5485,22 +5487,22 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ), }, - expectedTaskRuns: map[string]*v1beta1.PipelineRunTaskRunStatus{ + expectedTaskRuns: map[string]*v1.PipelineRunTaskRunStatus{ "task-run-dag-task": getTaskRunStatus("dag-task-1", corev1.ConditionFalse), "task-run-final-task": getTaskRunStatus("final-task-1", corev1.ConditionFalse), }, - expectedChildReferences: []v1beta1.ChildStatusReference{{ + expectedChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "task-run-dag-task", PipelineTaskName: "dag-task-1", }, { TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "task-run-final-task", PipelineTaskName: "final-task-1", @@ -5525,7 +5527,7 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { "pipeline-run-with-dag-running", "pipeline-with-dag-running", corev1.ConditionUnknown, - v1beta1.PipelineRunReasonRunning.String(), + v1.PipelineRunReasonRunning.String(), "Tasks Completed: 1 (Failed: 1, Cancelled 0), Incomplete: 2, Skipped: 0", map[string]string{ "dag-task-1": "task-run-dag-task-1", @@ -5535,26 +5537,26 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ps: getPipeline( "pipeline-with-dag-running", - v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{ + v1.PipelineSpec{ + Tasks: []v1.PipelineTask{ { Name: "dag-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }, { Name: "dag-task-2", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }, }, - Finally: []v1beta1.PipelineTask{{ + Finally: []v1.PipelineTask{{ Name: "final-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }}, }), - ts: []*v1beta1.Task{simpleHelloWorldTask}, + ts: []*v1.Task{simpleHelloWorldTask}, - trs: []*v1beta1.TaskRun{ + trs: []*v1.TaskRun{ getTaskRun( t, "task-run-dag-task-1", @@ -5573,23 +5575,23 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ), }, - expectedChildReferences: []v1beta1.ChildStatusReference{{ + expectedChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "task-run-dag-task-1", PipelineTaskName: "dag-task-1", }, { TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "task-run-dag-task-2", PipelineTaskName: "dag-task-2", }}, - expectedTaskRuns: map[string]*v1beta1.PipelineRunTaskRunStatus{ + expectedTaskRuns: map[string]*v1.PipelineRunTaskRunStatus{ "task-run-dag-task-1": getTaskRunStatus("dag-task-1", corev1.ConditionFalse), "task-run-dag-task-2": getTaskRunStatus("dag-task-2", corev1.ConditionUnknown), }, @@ -5614,7 +5616,7 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { "pipeline-run-dag-task-running", "pipeline-dag-task-running", corev1.ConditionUnknown, - v1beta1.PipelineRunReasonRunning.String(), + v1.PipelineRunReasonRunning.String(), "Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0", map[string]string{ "dag-task-1": "task-run-dag-task-1", @@ -5623,20 +5625,20 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ps: getPipeline( "pipeline-dag-task-running", - v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "dag-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }}, - Finally: []v1beta1.PipelineTask{{ + Finally: []v1.PipelineTask{{ Name: "final-task-1", - TaskRef: &v1beta1.TaskRef{Name: "hello-world"}, + TaskRef: &v1.TaskRef{Name: "hello-world"}, }}, }), - ts: []*v1beta1.Task{simpleHelloWorldTask}, + ts: []*v1.Task{simpleHelloWorldTask}, - trs: []*v1beta1.TaskRun{ + trs: []*v1.TaskRun{ getTaskRun( t, "task-run-dag-task-1", @@ -5647,16 +5649,16 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { ), }, - expectedChildReferences: []v1beta1.ChildStatusReference{{ + expectedChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: taskRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: "TaskRun", }, Name: "task-run-dag-task-1", PipelineTaskName: "dag-task-1", }}, - expectedTaskRuns: map[string]*v1beta1.PipelineRunTaskRunStatus{ + expectedTaskRuns: map[string]*v1.PipelineRunTaskRunStatus{ "task-run-dag-task-1": getTaskRunStatus("dag-task-1", corev1.ConditionUnknown), }, @@ -5685,10 +5687,10 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { } // The first update action should be updating the PipelineRun. - var actual *v1beta1.PipelineRun + var actual *v1.PipelineRun for _, action := range actions { if actualPrime, ok := action.(ktesting.UpdateAction); ok { - actual = actualPrime.GetObject().(*v1beta1.PipelineRun) + actual = actualPrime.GetObject().(*v1.PipelineRun) break } } @@ -5731,7 +5733,7 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { // checkTaskRunStatusFromChildRefs checks the status of taskruns from ChildReferences to be expected. func checkTaskRunStatusFromChildRefs(ctx context.Context, t *testing.T, namespace string, clients test.Clients, - childRefs []v1beta1.ChildStatusReference, expectedTaskRuns map[string]*v1beta1.PipelineRunTaskRunStatus) { + childRefs []v1.ChildStatusReference, expectedTaskRuns map[string]*v1.PipelineRunTaskRunStatus) { t.Helper() taskrunsToCheck := len(expectedTaskRuns) if taskrunsToCheck == 0 { @@ -5744,7 +5746,7 @@ func checkTaskRunStatusFromChildRefs(ctx context.Context, t *testing.T, namespac } trName := childRef.Name - trFromChildRef, err := clients.Pipeline.TektonV1beta1().TaskRuns(namespace).Get(ctx, trName, metav1.GetOptions{}) + trFromChildRef, err := clients.Pipeline.TektonV1().TaskRuns(namespace).Get(ctx, trName, metav1.GetOptions{}) if err != nil { t.Fatalf("Failure to get TaskRun from ChildReference %s: %s", childRef.Name, err) } @@ -5762,14 +5764,16 @@ func checkTaskRunStatusFromChildRefs(ctx context.Context, t *testing.T, namespac } } -func getPipelineRun(pr, p string, status corev1.ConditionStatus, reason string, m string, tr map[string]string) []*v1beta1.PipelineRun { - pRun := &v1beta1.PipelineRun{ +func getPipelineRun(pr, p string, status corev1.ConditionStatus, reason string, m string, tr map[string]string) []*v1.PipelineRun { + pRun := &v1.PipelineRun{ ObjectMeta: baseObjectMeta(pr, "foo"), - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{Name: p}, - ServiceAccountName: "test-sa", + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{Name: p}, + TaskRunTemplate: v1.PipelineTaskRunTemplate{ + ServiceAccountName: "test-sa", + }, }, - Status: v1beta1.PipelineRunStatus{ + Status: v1.PipelineRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{ apis.Condition{ @@ -5783,36 +5787,36 @@ func getPipelineRun(pr, p string, status corev1.ConditionStatus, reason string, }, } for k, v := range tr { - pRun.Status.ChildReferences = append(pRun.Status.ChildReferences, v1beta1.ChildStatusReference{ + pRun.Status.ChildReferences = append(pRun.Status.ChildReferences, v1.ChildStatusReference{ PipelineTaskName: k, Name: v, TypeMeta: runtime.TypeMeta{ - Kind: taskRun, - APIVersion: "tekton.dev/v1beta1", + Kind: "TaskRun", + APIVersion: "tekton.dev/v1", }, }) } - return []*v1beta1.PipelineRun{pRun} + return []*v1.PipelineRun{pRun} } // withOwnerReference adds the PipelineRun name to each TaskRun as their OwnerReference // TODO: This shall be removed along with the refactor of `getTaskRun` to populate matched // OwnerReference with the PipelineRun at https://github.com/tektoncd/pipeline/issues/6008 -func withOwnerReference(trs []*v1beta1.TaskRun, prName string) { +func withOwnerReference(trs []*v1.TaskRun, prName string) { for _, tr := range trs { tr.OwnerReferences = []metav1.OwnerReference{{Name: prName}} } } -func getPipeline(p string, spec v1beta1.PipelineSpec) []*v1beta1.Pipeline { - ps := []*v1beta1.Pipeline{{ +func getPipeline(p string, spec v1.PipelineSpec) []*v1.Pipeline { + ps := []*v1.Pipeline{{ ObjectMeta: baseObjectMeta(p, "foo"), Spec: spec, }} return ps } -func getTaskRun(t *testing.T, tr, pr, p, tl string, status corev1.ConditionStatus) *v1beta1.TaskRun { +func getTaskRun(t *testing.T, tr, pr, p, tl string, status corev1.ConditionStatus) *v1.TaskRun { t.Helper() return createHelloWorldTaskRunWithStatusTaskLabel(t, tr, "foo", pr, p, "", tl, apis.Condition{ @@ -5821,10 +5825,10 @@ func getTaskRun(t *testing.T, tr, pr, p, tl string, status corev1.ConditionStatu }) } -func getTaskRunStatus(t string, status corev1.ConditionStatus) *v1beta1.PipelineRunTaskRunStatus { - return &v1beta1.PipelineRunTaskRunStatus{ +func getTaskRunStatus(t string, status corev1.ConditionStatus) *v1.PipelineRunTaskRunStatus { + return &v1.PipelineRunTaskRunStatus{ PipelineTaskName: t, - Status: &v1beta1.TaskRunStatus{ + Status: &v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{ {Type: apis.ConditionSucceeded, Status: status}, @@ -5839,8 +5843,8 @@ func getTaskRunStatus(t string, status corev1.ConditionStatus) *v1beta1.Pipeline func TestReconcile_CloudEvents(t *testing.T) { names.TestingSeed() - prs := []*v1beta1.PipelineRun{ - parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{ + parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipelinerun namespace: foo @@ -5850,8 +5854,8 @@ spec: name: test-pipeline `), } - ps := []*v1beta1.Pipeline{ - parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{ + parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -5862,8 +5866,8 @@ spec: name: test-task `), } - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: test-task namespace: foo @@ -5905,7 +5909,7 @@ spec: reconciledRun, clients := prt.reconcileRun("foo", "test-pipelinerun", wantEvents, false) // This PipelineRun is in progress now and the status should reflect that - checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) verifyTaskRunStatusesCount(t, reconciledRun.Status, 1) @@ -5921,8 +5925,8 @@ spec: func TestReconcilePipeline_TaskSpecMetadata(t *testing.T) { names.TestingSeed() - prs := []*v1beta1.PipelineRun{ - parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{ + parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-success namespace: foo @@ -5932,8 +5936,8 @@ spec: `), } - ps := []*v1beta1.Pipeline{ - parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{ + parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -5974,10 +5978,10 @@ spec: t.Fatalf("Expected client to have been used to create a TaskRun but it wasn't") } - actualTaskRun := make(map[string]*v1beta1.TaskRun) + actualTaskRun := make(map[string]*v1.TaskRun) for _, a := range actions { if a.GetResource().Resource == "taskruns" { - t := a.(ktesting.CreateAction).GetObject().(*v1beta1.TaskRun) + t := a.(ktesting.CreateAction).GetObject().(*v1.TaskRun) actualTaskRun[t.Name] = t } } @@ -5987,7 +5991,7 @@ spec: t.Errorf("Expected two TaskRuns to be created, but found %d TaskRuns.", len(actualTaskRun)) } - expectedTaskRun := make(map[string]*v1beta1.TaskRun) + expectedTaskRun := make(map[string]*v1.TaskRun) expectedTaskRun["test-pipeline-run-success-task-with-metadata"] = getTaskRunWithTaskSpec( "test-pipeline-run-success-task-with-metadata", "test-pipeline-run-success", @@ -6019,7 +6023,7 @@ func TestReconciler_ReconcileKind_PipelineTaskContext(t *testing.T) { pipelineName := "p-pipelinetask-status" pipelineRunName := "pr-pipelinetask-status" - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: p-pipelinetask-status namespace: foo @@ -6037,7 +6041,7 @@ spec: name: mytask `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: pr-pipelinetask-status namespace: foo @@ -6047,9 +6051,9 @@ spec: serviceAccountName: test-sa `)} - ts := []*v1beta1.Task{ + ts := []*v1.Task{ {ObjectMeta: baseObjectMeta("mytask", "foo")}, - parse.MustParseV1beta1Task(t, ` + parse.MustParseV1Task(t, ` metadata: name: finaltask namespace: foo @@ -6059,7 +6063,7 @@ spec: type: string `)} - trs := []*v1beta1.TaskRun{mustParseTaskRunWithObjectMeta(t, + trs := []*v1.TaskRun{mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta(pipelineRunName+"-task1-xxyy", "foo", pipelineRunName, pipelineName, "task1", false), ` spec: @@ -6087,7 +6091,7 @@ status: expectedTaskRunName := pipelineRunName + "-finaltask" expectedTaskRunObjectMeta := taskRunObjectMeta(expectedTaskRunName, "foo", pipelineRunName, pipelineName, "finaltask", false) - expectedTaskRunObjectMeta.Labels[pipeline.MemberOfLabelKey] = v1beta1.PipelineFinallyTasks + expectedTaskRunObjectMeta.Labels[pipeline.MemberOfLabelKey] = v1.PipelineFinallyTasks expectedTaskRun := mustParseTaskRunWithObjectMeta(t, expectedTaskRunObjectMeta, ` spec: params: @@ -6099,7 +6103,7 @@ spec: kind: Task `) // Check that the expected TaskRun was created - actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + actual, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: "tekton.dev/pipelineTask=finaltask,tekton.dev/pipelineRun=" + pipelineRunName, Limit: 1, }) @@ -6119,7 +6123,7 @@ spec: func TestReconcileWithTaskResultsInFinalTasks(t *testing.T) { names.TestingSeed() - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -6190,7 +6194,7 @@ spec: name: dag-task `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-final-task-results namespace: foo @@ -6200,13 +6204,13 @@ spec: serviceAccountName: test-sa-0 `)} - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: dag-task namespace: foo `), - parse.MustParseV1beta1Task(t, ` + parse.MustParseV1Task(t, ` metadata: name: final-task namespace: foo @@ -6217,7 +6221,7 @@ spec: `), } - trs := []*v1beta1.TaskRun{ + trs := []*v1.TaskRun{ mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("test-pipeline-run-final-task-results-dag-task-1-xxyyy", "foo", "test-pipeline-run-final-task-results", "test-pipeline", "dag-task-1", false), @@ -6265,7 +6269,7 @@ status: expectedTaskRunName := "test-pipeline-run-final-task-results-final-task-1" expectedTaskRunObjectMeta := taskRunObjectMeta("test-pipeline-run-final-task-results-final-task-1", "foo", "test-pipeline-run-final-task-results", "test-pipeline", "final-task-1", true) - expectedTaskRunObjectMeta.Labels[pipeline.MemberOfLabelKey] = v1beta1.PipelineFinallyTasks + expectedTaskRunObjectMeta.Labels[pipeline.MemberOfLabelKey] = v1.PipelineFinallyTasks expectedTaskRun := mustParseTaskRunWithObjectMeta(t, expectedTaskRunObjectMeta, ` spec: params: @@ -6278,7 +6282,7 @@ spec: `) // Check that the expected TaskRun was created - actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + actual, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: "tekton.dev/pipelineTask=final-task-1,tekton.dev/pipelineRun=test-pipeline-run-final-task-results", Limit: 1, }) @@ -6293,23 +6297,23 @@ spec: if d := cmp.Diff(*expectedTaskRun, actualTaskRun, ignoreResourceVersion, ignoreTypeMeta); d != "" { t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRunName, diff.PrintWantGot(d)) } - expectedSkippedTasks := []v1beta1.SkippedTask{{ + expectedSkippedTasks := []v1.SkippedTask{{ Name: "final-task-2", - Reason: v1beta1.MissingResultsSkip, + Reason: v1.MissingResultsSkip, }, { Name: "final-task-3", - Reason: v1beta1.WhenExpressionsSkip, - WhenExpressions: v1beta1.WhenExpressions{{ + Reason: v1.WhenExpressionsSkip, + WhenExpressions: v1.WhenExpressions{{ Input: "aResultValue", Operator: "notin", Values: []string{"aResultValue"}, }}, }, { Name: "final-task-5", - Reason: v1beta1.MissingResultsSkip, + Reason: v1.MissingResultsSkip, }, { Name: "final-task-6", - Reason: v1beta1.MissingResultsSkip, + Reason: v1.MissingResultsSkip, }} if d := cmp.Diff(expectedSkippedTasks, reconciledRun.Status.SkippedTasks); d != "" { @@ -6330,7 +6334,7 @@ func newPipelineRunTest(t *testing.T, data test.Data) *PipelineRunTest { } } -func (prt PipelineRunTest) reconcileRun(namespace, pipelineRunName string, wantEvents []string, permanentError bool) (*v1beta1.PipelineRun, test.Clients) { +func (prt PipelineRunTest) reconcileRun(namespace, pipelineRunName string, wantEvents []string, permanentError bool) (*v1.PipelineRun, test.Clients) { prt.Test.Helper() c := prt.TestAssets.Controller clients := prt.TestAssets.Clients @@ -6350,7 +6354,7 @@ func (prt PipelineRunTest) reconcileRun(namespace, pipelineRunName string, wantE prt.Test.Fatalf("Error reconciling: %s", reconcileError) } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns(namespace).Get(prt.TestAssets.Ctx, pipelineRunName, metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1().PipelineRuns(namespace).Get(prt.TestAssets.Ctx, pipelineRunName, metav1.GetOptions{}) if err != nil { prt.Test.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } @@ -6383,7 +6387,7 @@ func TestReconcile_RemotePipelineRef(t *testing.T) { ref := u.Host + "/testreconcile_remotepipelineref" - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: test-pipeline-run-success namespace: foo @@ -6394,7 +6398,7 @@ spec: serviceAccountName: test-sa timeout: 1h0m0s `, ref))} - ps := parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` + ps := parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: test-pipeline namespace: foo @@ -6408,7 +6412,7 @@ spec: cms := []*corev1.ConfigMap{withOCIBundles(newFeatureFlagsConfigMap())} // This task will be uploaded along with the pipeline definition. - remoteTask := parse.MustParseV1beta1Task(t, ` + remoteTask := parse.MustParseV1Task(t, ` metadata: name: unit-test-task namespace: foo @@ -6423,7 +6427,7 @@ metadata: d := test.Data{ PipelineRuns: prs, ServiceAccounts: []*corev1.ServiceAccount{{ - ObjectMeta: metav1.ObjectMeta{Name: prs[0].Spec.ServiceAccountName, Namespace: "foo"}, + ObjectMeta: metav1.ObjectMeta{Name: prs[0].Spec.TaskRunTemplate.ServiceAccountName, Namespace: "foo"}, }}, ConfigMaps: cms, } @@ -6456,7 +6460,7 @@ spec: } // This PipelineRun is in progress now and the status should reflect that - checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) verifyTaskRunStatusesCount(t, reconciledRun.Status, 1) verifyTaskRunStatusesNames(t, reconciledRun.Status, "test-pipeline-run-success-unit-test-1") @@ -6472,7 +6476,7 @@ func TestReconcile_OptionalWorkspacesOmitted(t *testing.T) { cfg := config.NewStore(logtesting.TestLogger(t)) ctx = cfg.ToContext(ctx) - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-success namespace: foo @@ -6499,7 +6503,7 @@ spec: d := test.Data{ PipelineRuns: prs, ServiceAccounts: []*corev1.ServiceAccount{{ - ObjectMeta: metav1.ObjectMeta{Name: prs[0].Spec.ServiceAccountName, Namespace: "foo"}, + ObjectMeta: metav1.ObjectMeta{Name: prs[0].Spec.TaskRunTemplate.ServiceAccountName, Namespace: "foo"}, }}, ConfigMaps: []*corev1.ConfigMap{newFeatureFlagsConfigMap()}, } @@ -6530,7 +6534,7 @@ spec: } // This PipelineRun is in progress now and the status should reflect that - checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) verifyTaskRunStatusesCount(t, reconciledRun.Status, 1) verifyTaskRunStatusesNames(t, reconciledRun.Status, "test-pipeline-run-success-unit-test-1") @@ -6543,8 +6547,8 @@ func TestReconcile_DependencyValidationsImmediatelyFailPipelineRun(t *testing.T) cfg := config.NewStore(logtesting.TestLogger(t)) ctx = cfg.ToContext(ctx) - prs := []*v1beta1.PipelineRun{ - parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{ + parse.MustParseV1PipelineRun(t, ` metadata: name: pipelinerun-param-invalid-result-variable namespace: foo @@ -6566,7 +6570,7 @@ spec: - image: foo:latest serviceAccountName: test-sa `), - parse.MustParseV1beta1PipelineRun(t, ` + parse.MustParseV1PipelineRun(t, ` metadata: name: pipelinerun-pipeline-result-invalid-result-variable namespace: foo @@ -6586,7 +6590,7 @@ spec: - image: foo:latest serviceAccountName: test-sa `), - parse.MustParseV1beta1PipelineRun(t, ` + parse.MustParseV1PipelineRun(t, ` metadata: name: pipelinerun-with-optional-workspace-validation namespace: foo @@ -6612,7 +6616,7 @@ spec: d := test.Data{ PipelineRuns: prs, ServiceAccounts: []*corev1.ServiceAccount{{ - ObjectMeta: metav1.ObjectMeta{Name: prs[0].Spec.ServiceAccountName, Namespace: "foo"}, + ObjectMeta: metav1.ObjectMeta{Name: prs[0].Spec.TaskRunTemplate.ServiceAccountName, Namespace: "foo"}, }}, } @@ -6651,7 +6655,7 @@ spec: // that when the request is successfully resolved the PipelineRun begins running. func TestReconcileWithResolver(t *testing.T) { resolverName := "foobar" - pr := parse.MustParseV1beta1PipelineRun(t, ` + pr := parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: default @@ -6662,9 +6666,9 @@ spec: `) d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{pr}, + PipelineRuns: []*v1.PipelineRun{pr}, ServiceAccounts: []*corev1.ServiceAccount{{ - ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.ServiceAccountName, Namespace: "foo"}, + ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.TaskRunTemplate.ServiceAccountName, Namespace: "foo"}, }}, } @@ -6694,7 +6698,7 @@ spec: // Mock a successful resolution var pipelineBytes = []byte(` kind: Pipeline - apiVersion: tekton.dev/v1beta1 + apiVersion: tekton.dev/v1 metadata: name: foo spec: @@ -6718,7 +6722,7 @@ spec: // PipelineRun reconciler and that the PipelineRun has now // started executing. updatedPipelineRun, _ := prt.reconcileRun("default", "pr", nil, false) - checkPipelineRunConditionStatusAndReason(t, updatedPipelineRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, updatedPipelineRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) } // TestReconcileWithFailingResolver checks that a PipelineRun with a failing Resolver @@ -6726,7 +6730,7 @@ spec: // that when the request fails, the PipelineRun fails. func TestReconcileWithFailingResolver(t *testing.T) { resolverName := "does-not-exist" - pr := parse.MustParseV1beta1PipelineRun(t, ` + pr := parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: default @@ -6737,9 +6741,9 @@ spec: `) d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{pr}, + PipelineRuns: []*v1.PipelineRun{pr}, ServiceAccounts: []*corev1.ServiceAccount{{ - ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.ServiceAccountName, Namespace: "foo"}, + ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.TaskRunTemplate.ServiceAccountName, Namespace: "foo"}, }}, } @@ -6782,7 +6786,7 @@ spec: // that when the request fails, the PipelineRun fails. func TestReconcileWithFailingTaskResolver(t *testing.T) { resolverName := "foobar" - pr := parse.MustParseV1beta1PipelineRun(t, ` + pr := parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: default @@ -6796,9 +6800,9 @@ spec: `) d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{pr}, + PipelineRuns: []*v1.PipelineRun{pr}, ServiceAccounts: []*corev1.ServiceAccount{{ - ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.ServiceAccountName, Namespace: "foo"}, + ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.TaskRunTemplate.ServiceAccountName, Namespace: "foo"}, }}, } @@ -6807,7 +6811,7 @@ spec: wantEvents := []string(nil) pipelinerun, _ := prt.reconcileRun(pr.Namespace, pr.Name, wantEvents, false) - checkPipelineRunConditionStatusAndReason(t, pipelinerun, corev1.ConditionUnknown, v1beta1.TaskRunReasonResolvingTaskRef) + checkPipelineRunConditionStatusAndReason(t, pipelinerun, corev1.ConditionUnknown, v1.TaskRunReasonResolvingTaskRef) client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1beta1().ResolutionRequests("default") resolutionrequests, err := client.List(prt.TestAssets.Ctx, metav1.ListOptions{}) @@ -6841,7 +6845,7 @@ spec: // that when the request is successfully resolved the PipelineRun begins running. func TestReconcileWithTaskResolver(t *testing.T) { resolverName := "foobar" - pr := parse.MustParseV1beta1PipelineRun(t, ` + pr := parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: default @@ -6858,9 +6862,9 @@ spec: `) d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{pr}, + PipelineRuns: []*v1.PipelineRun{pr}, ServiceAccounts: []*corev1.ServiceAccount{{ - ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.ServiceAccountName, Namespace: "foo"}, + ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.TaskRunTemplate.ServiceAccountName, Namespace: "foo"}, }}, } @@ -6869,7 +6873,7 @@ spec: wantEvents := []string(nil) pipelinerun, _ := prt.reconcileRun(pr.Namespace, pr.Name, wantEvents, false) - checkPipelineRunConditionStatusAndReason(t, pipelinerun, corev1.ConditionUnknown, v1beta1.TaskRunReasonResolvingTaskRef) + checkPipelineRunConditionStatusAndReason(t, pipelinerun, corev1.ConditionUnknown, v1.TaskRunReasonResolvingTaskRef) client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1beta1().ResolutionRequests("default") resolutionrequests, err := client.List(prt.TestAssets.Ctx, metav1.ListOptions{}) @@ -6898,7 +6902,7 @@ spec: taskBytes := []byte(` kind: Task -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 metadata: name: foo spec: @@ -6920,21 +6924,21 @@ spec: // PipelineRun reconciler and that the PipelineRun has now // started executing. updatedPipelineRun, _ := prt.reconcileRun("default", "pr", nil, false) - checkPipelineRunConditionStatusAndReason(t, updatedPipelineRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, updatedPipelineRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) } -func getTaskRunWithTaskSpec(tr, pr, p, t string, labels, annotations map[string]string) *v1beta1.TaskRun { +func getTaskRunWithTaskSpec(tr, pr, p, t string, labels, annotations map[string]string) *v1.TaskRun { om := taskRunObjectMeta(tr, "foo", pr, p, t, false) for k, v := range labels { om.Labels[k] = v } om.Annotations = annotations - return &v1beta1.TaskRun{ + return &v1.TaskRun{ ObjectMeta: om, - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "mystep", Image: "myimage", }}, @@ -6960,7 +6964,7 @@ func taskRunObjectMeta(trName, ns, prName, pipelineName, pipelineTaskName string OwnerReferences: []metav1.OwnerReference{{ Kind: "PipelineRun", Name: prName, - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Controller: &trueb, BlockOwnerDeletion: &trueb, }}, @@ -6972,7 +6976,7 @@ func taskRunObjectMeta(trName, ns, prName, pipelineName, pipelineTaskName string Annotations: map[string]string{}, } if !skipMemberOfLabel { - om.Labels[pipeline.MemberOfLabelKey] = v1beta1.PipelineTasks + om.Labels[pipeline.MemberOfLabelKey] = v1.PipelineTasks } return om } @@ -6989,14 +6993,14 @@ func createHelloWorldTaskRunWithStatus( t *testing.T, trName, ns, prName, pName, podName string, condition apis.Condition, -) *v1beta1.TaskRun { +) *v1.TaskRun { t.Helper() p := createHelloWorldTaskRun(t, trName, ns, prName, pName) - p.Status = v1beta1.TaskRunStatus{ + p.Status = v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{condition}, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + TaskRunStatusFields: v1.TaskRunStatusFields{ PodName: podName, }, } @@ -7007,7 +7011,7 @@ func createHelloWorldTaskRunWithStatusTaskLabel( t *testing.T, trName, ns, prName, pName, podName, taskLabel string, condition apis.Condition, -) *v1beta1.TaskRun { +) *v1.TaskRun { t.Helper() p := createHelloWorldTaskRunWithStatus(t, trName, ns, prName, pName, podName, condition) p.Labels[pipeline.PipelineTaskLabelKey] = taskLabel @@ -7015,9 +7019,9 @@ func createHelloWorldTaskRunWithStatusTaskLabel( return p } -func createHelloWorldTaskRun(t *testing.T, trName, ns, prName, pName string) *v1beta1.TaskRun { +func createHelloWorldTaskRun(t *testing.T, trName, ns, prName, pName string) *v1.TaskRun { t.Helper() - return parse.MustParseV1beta1TaskRun(t, fmt.Sprintf(` + return parse.MustParseV1TaskRun(t, fmt.Sprintf(` metadata: name: %s namespace: %s @@ -7031,9 +7035,9 @@ spec: `, trName, ns, pipeline.PipelineLabelKey, pName, pipeline.PipelineRunLabelKey, prName)) } -func createCancelledPipelineRun(t *testing.T, prName string, specStatus v1beta1.PipelineRunSpecStatus) *v1beta1.PipelineRun { +func createCancelledPipelineRun(t *testing.T, prName string, specStatus v1.PipelineRunSpecStatus) *v1.PipelineRun { t.Helper() - return parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + return parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -7045,14 +7049,14 @@ spec: status: startTime: %s`, prName, specStatus, now.Format(time.RFC3339))) } -func verifyTaskRunStatusesCount(t *testing.T, prStatus v1beta1.PipelineRunStatus, taskCount int) { +func verifyTaskRunStatusesCount(t *testing.T, prStatus v1.PipelineRunStatus, taskCount int) { t.Helper() if len(filterChildRefsForKind(prStatus.ChildReferences, taskRun)) != taskCount { t.Errorf("Expected PipelineRun status ChildReferences to have %d tasks, but was %d", taskCount, len(filterChildRefsForKind(prStatus.ChildReferences, taskRun))) } } -func verifyTaskRunStatusesNames(t *testing.T, prStatus v1beta1.PipelineRunStatus, taskNames ...string) { +func verifyTaskRunStatusesNames(t *testing.T, prStatus v1.PipelineRunStatus, taskNames ...string) { t.Helper() tnMap := make(map[string]struct{}) @@ -7067,14 +7071,14 @@ func verifyTaskRunStatusesNames(t *testing.T, prStatus v1beta1.PipelineRunStatus } } -func verifyCustomRunOrRunStatusesCount(t *testing.T, kind string, prStatus v1beta1.PipelineRunStatus, runCount int) { +func verifyCustomRunOrRunStatusesCount(t *testing.T, kind string, prStatus v1.PipelineRunStatus, runCount int) { t.Helper() if len(filterChildRefsForKind(prStatus.ChildReferences, kind)) != runCount { t.Errorf("Expected PipelineRun status ChildReferences to have %d %ss, but was %d", runCount, kind, len(filterChildRefsForKind(prStatus.ChildReferences, kind))) } } -func verifyCustomRunOrRunStatusesNames(t *testing.T, kind string, prStatus v1beta1.PipelineRunStatus, runNames ...string) { +func verifyCustomRunOrRunStatusesNames(t *testing.T, kind string, prStatus v1.PipelineRunStatus, runNames ...string) { t.Helper() rnMap := make(map[string]struct{}) @@ -7089,9 +7093,9 @@ func verifyCustomRunOrRunStatusesNames(t *testing.T, kind string, prStatus v1bet } } -func verifyTaskRunStatusesWhenExpressions(t *testing.T, prStatus v1beta1.PipelineRunStatus, trName string, expectedWhen []v1beta1.WhenExpression) { +func verifyTaskRunStatusesWhenExpressions(t *testing.T, prStatus v1.PipelineRunStatus, trName string, expectedWhen []v1.WhenExpression) { t.Helper() - var actualWhenExpressionsInTaskRun []v1beta1.WhenExpression + var actualWhenExpressionsInTaskRun []v1.WhenExpression for _, cr := range prStatus.ChildReferences { if cr.Name == trName { actualWhenExpressionsInTaskRun = append(actualWhenExpressionsInTaskRun, cr.WhenExpressions...) @@ -7102,8 +7106,8 @@ func verifyTaskRunStatusesWhenExpressions(t *testing.T, prStatus v1beta1.Pipelin } } -func filterChildRefsForKind(childRefs []v1beta1.ChildStatusReference, kind string) []v1beta1.ChildStatusReference { - var filtered []v1beta1.ChildStatusReference +func filterChildRefsForKind(childRefs []v1.ChildStatusReference, kind string) []v1.ChildStatusReference { + var filtered []v1.ChildStatusReference for _, cr := range childRefs { if cr.Kind == kind { filtered = append(filtered, cr) @@ -7112,9 +7116,9 @@ func filterChildRefsForKind(childRefs []v1beta1.ChildStatusReference, kind strin return filtered } -func mustParseTaskRunWithObjectMeta(t *testing.T, objectMeta metav1.ObjectMeta, asYAML string) *v1beta1.TaskRun { +func mustParseTaskRunWithObjectMeta(t *testing.T, objectMeta metav1.ObjectMeta, asYAML string) *v1.TaskRun { t.Helper() - tr := parse.MustParseV1beta1TaskRun(t, asYAML) + tr := parse.MustParseV1TaskRun(t, asYAML) tr.ObjectMeta = objectMeta return tr } @@ -7133,9 +7137,9 @@ func mustParseRunWithObjectMeta(t *testing.T, objectMeta metav1.ObjectMeta, asYA return r } -func helloWorldPipelineWithRunAfter(t *testing.T) *v1beta1.Pipeline { +func helloWorldPipelineWithRunAfter(t *testing.T) *v1.Pipeline { t.Helper() - return parse.MustParseV1beta1Pipeline(t, ` + return parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -7152,7 +7156,7 @@ spec: `) } -func checkPipelineRunConditionStatusAndReason(t *testing.T, reconciledRun *v1beta1.PipelineRun, conditionStatus corev1.ConditionStatus, conditionReason string) { +func checkPipelineRunConditionStatusAndReason(t *testing.T, reconciledRun *v1.PipelineRun, conditionStatus corev1.ConditionStatus, conditionReason string) { t.Helper() condition := reconciledRun.Status.GetCondition(apis.ConditionSucceeded) @@ -7167,11 +7171,11 @@ func checkPipelineRunConditionStatusAndReason(t *testing.T, reconciledRun *v1bet func TestGetTaskrunWorkspaces_Failure(t *testing.T) { tests := []struct { name string - pr *v1beta1.PipelineRun + pr *v1.PipelineRun expectedError string }{{ name: "failure declaring workspace with different name", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline spec: @@ -7189,7 +7193,7 @@ spec: }, { name: "failure mapping workspace with different name", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline spec: @@ -7208,7 +7212,7 @@ spec: }, { name: "failure propagating workspaces using scripts", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline spec: @@ -7229,7 +7233,7 @@ spec: }, { name: "failure propagating workspaces using args", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline spec: @@ -7273,20 +7277,20 @@ spec: func TestGetTaskrunWorkspaces_Success(t *testing.T) { tests := []struct { name string - pr *v1beta1.PipelineRun + pr *v1.PipelineRun rprt *resources.ResolvedPipelineTask }{{ name: "valid declaration of workspace names", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline spec: workspaces: - name: source`), rprt: &resources.ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "resolved-pipelinetask", - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{{ + Workspaces: []v1.WorkspacePipelineTaskBinding{{ Name: "my-task-workspace", Workspace: "source", }}, @@ -7295,16 +7299,16 @@ spec: }, { name: "valid mapping with same workspace names", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline spec: workspaces: - name: source`), rprt: &resources.ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "resolved-pipelinetask", - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{{ + Workspaces: []v1.WorkspacePipelineTaskBinding{{ Name: "source", Workspace: "", }}, @@ -7313,18 +7317,18 @@ spec: }, { name: "propagating workspaces using scripts", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline spec: workspaces: - name: source`), rprt: &resources.ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "resolved-pipelinetask", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "mystep", Image: "myimage", Script: "echo $(workspaces.source.path)", @@ -7336,18 +7340,18 @@ spec: }, { name: "propagating workspaces using args", - pr: parse.MustParseV1beta1PipelineRun(t, ` + pr: parse.MustParseV1PipelineRun(t, ` metadata: name: pipeline spec: workspaces: - name: source`), rprt: &resources.ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "resolved-pipelinetask", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "mystep", Image: "myimage", Command: []string{"/mycmd"}, @@ -7355,7 +7359,7 @@ spec: }}, }, }, - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{{ + Workspaces: []v1.WorkspacePipelineTaskBinding{{ Name: "source", }}, }, @@ -7377,8 +7381,8 @@ spec: func TestReconcile_PropagatePipelineTaskRunSpecMetadata(t *testing.T) { names.TestingSeed() prName := "test-pipeline-run" - ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + ps := []*v1.Pipeline{simpleHelloWorldPipeline} + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run namespace: foo @@ -7394,7 +7398,7 @@ spec: PipelineTaskRunSpecAnnotation: PipelineTaskRunSpecValue taskServiceAccountName: custom-sa `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ PipelineRuns: prs, @@ -7426,7 +7430,7 @@ spec: func TestReconcile_AddMetadataByPrecedence(t *testing.T) { names.TestingSeed() prName := "test-pipeline-run" - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -7443,7 +7447,7 @@ spec: annotations: TestPrecedenceAnnotation: PipelineTaskSpecValue `)} - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run namespace: foo @@ -7464,7 +7468,7 @@ spec: TestPrecedenceAnnotation: PipelineTaskRunSpecValue taskServiceAccountName: custom-sa `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} d := test.Data{ PipelineRuns: prs, @@ -7497,7 +7501,7 @@ spec: func TestReconciler_PipelineTaskMatrix(t *testing.T) { names.TestingSeed() - task := parse.MustParseV1beta1Task(t, ` + task := parse.MustParseV1Task(t, ` metadata: name: mytask namespace: foo @@ -7513,7 +7517,7 @@ spec: echo "$(params.platform) and $(params.browser) and $(params.version)" `) - expectedTaskRuns := []*v1beta1.TaskRun{ + expectedTaskRuns := []*v1.TaskRun{ mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("pr-platforms-and-browsers-0", "foo", "pr", "p", "platforms-and-browsers", false), @@ -7674,13 +7678,13 @@ spec: tests := []struct { name string memberOf string - p *v1beta1.Pipeline - tr *v1beta1.TaskRun - expectedPipelineRun *v1beta1.PipelineRun + p *v1.Pipeline + tr *v1.TaskRun + expectedPipelineRun *v1.PipelineRun }{{ name: "p-dag", memberOf: "tasks", - p: parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` + p: parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -7705,7 +7709,7 @@ spec: - name: version value: v0.33.0 `, "p-dag")), - expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + expectedPipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -7744,39 +7748,39 @@ status: reason: "Running" message: "Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-2 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-3 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-4 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-5 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-6 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-7 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers @@ -7784,7 +7788,7 @@ status: }, { name: "p-finally", memberOf: "finally", - p: parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` + p: parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -7843,7 +7847,7 @@ status: reason: Succeeded message: All Tasks have completed executing `), - expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + expectedPipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -7894,43 +7898,43 @@ status: reason: "Running" message: "Tasks Completed: 1 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-unmatrixed-pt pipelineTaskName: unmatrixed-pt - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-2 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-3 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-4 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-5 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-6 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-7 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers @@ -7938,7 +7942,7 @@ status: }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - pr := parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + pr := parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: pr namespace: foo @@ -7948,19 +7952,19 @@ spec: name: %s `, tt.name)) d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{pr}, - Pipelines: []*v1beta1.Pipeline{tt.p}, - Tasks: []*v1beta1.Task{task}, + PipelineRuns: []*v1.PipelineRun{pr}, + Pipelines: []*v1.Pipeline{tt.p}, + Tasks: []*v1.Task{task}, ConfigMaps: cms, } if tt.tr != nil { - d.TaskRuns = []*v1beta1.TaskRun{tt.tr} + d.TaskRuns = []*v1.TaskRun{tt.tr} } prt := newPipelineRunTest(t, d) defer prt.Cancel() _, clients := prt.reconcileRun("foo", "pr", []string{}, false) - taskRuns, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + taskRuns, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: fmt.Sprintf("tekton.dev/pipelineRun=pr,tekton.dev/pipeline=%s,tekton.dev/pipelineTask=platforms-and-browsers", tt.name), Limit: 1, }) @@ -7981,7 +7985,7 @@ spec: } } - pipelineRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "pr", metav1.GetOptions{}) + pipelineRun, err := clients.Pipeline.TektonV1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "pr", metav1.GetOptions{}) if err != nil { t.Fatalf("Got an error getting reconciled run out of fake client: %s", err) } @@ -7995,7 +7999,7 @@ spec: func TestReconciler_PipelineTaskMatrixWithResults(t *testing.T) { names.TestingSeed() - task := parse.MustParseV1beta1Task(t, ` + task := parse.MustParseV1Task(t, ` metadata: name: mytask namespace: foo @@ -8011,7 +8015,7 @@ spec: echo "$(params.platform) and $(params.browser) and $(params.version)" `) - taskwithresults := parse.MustParseV1beta1Task(t, ` + taskwithresults := parse.MustParseV1Task(t, ` metadata: name: taskwithresults namespace: foo @@ -8037,7 +8041,7 @@ spec: printf v0.33.0 | tee /tekton/results/version `) - expectedTaskRuns := []*v1beta1.TaskRun{ + expectedTaskRuns := []*v1.TaskRun{ mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("pr-platforms-and-browsers-0", "foo", "pr", "p", "platforms-and-browsers", false), @@ -8198,13 +8202,13 @@ spec: tests := []struct { name string memberOf string - p *v1beta1.Pipeline - tr *v1beta1.TaskRun - expectedPipelineRun *v1beta1.PipelineRun + p *v1.Pipeline + tr *v1.TaskRun + expectedPipelineRun *v1.PipelineRun }{{ name: "p-dag", memberOf: "tasks", - p: parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` + p: parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -8272,7 +8276,7 @@ status: - name: version value: v0.33.0 `), - expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + expectedPipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -8322,43 +8326,43 @@ status: reason: "Running" message: "Tasks Completed: 1 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-pt-with-result pipelineTaskName: pt-with-result - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-2 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-3 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-4 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-5 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-6 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-7 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers @@ -8366,7 +8370,7 @@ status: }, { name: "p-finally", memberOf: "finally", - p: parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` + p: parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -8436,7 +8440,7 @@ status: - name: version value: v0.33.0 `), - expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + expectedPipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -8487,43 +8491,43 @@ status: reason: "Running" message: "Tasks Completed: 1 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-pt-with-result pipelineTaskName: pt-with-result - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-2 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-3 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-4 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-5 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-6 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-7 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers @@ -8531,7 +8535,7 @@ status: }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - pr := parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + pr := parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: pr namespace: foo @@ -8541,19 +8545,19 @@ spec: name: %s `, tt.name)) d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{pr}, - Pipelines: []*v1beta1.Pipeline{tt.p}, - Tasks: []*v1beta1.Task{task, taskwithresults}, + PipelineRuns: []*v1.PipelineRun{pr}, + Pipelines: []*v1.Pipeline{tt.p}, + Tasks: []*v1.Task{task, taskwithresults}, ConfigMaps: cms, } if tt.tr != nil { - d.TaskRuns = []*v1beta1.TaskRun{tt.tr} + d.TaskRuns = []*v1.TaskRun{tt.tr} } prt := newPipelineRunTest(t, d) defer prt.Cancel() _, clients := prt.reconcileRun("foo", "pr", []string{}, false) - taskRuns, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + taskRuns, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: fmt.Sprintf("tekton.dev/pipelineRun=pr,tekton.dev/pipeline=%s,tekton.dev/pipelineTask=platforms-and-browsers", tt.name), Limit: 1, }) @@ -8574,7 +8578,7 @@ spec: } } - pipelineRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "pr", metav1.GetOptions{}) + pipelineRun, err := clients.Pipeline.TektonV1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "pr", metav1.GetOptions{}) if err != nil { t.Fatalf("Got an error getting reconciled run out of fake client: %s", err) } @@ -8588,7 +8592,7 @@ spec: func TestReconciler_PipelineTaskMatrixWithRetries(t *testing.T) { names.TestingSeed() - task := parse.MustParseV1beta1Task(t, ` + task := parse.MustParseV1Task(t, ` metadata: name: mytask namespace: foo @@ -8609,13 +8613,13 @@ spec: tests := []struct { name string - trs []*v1beta1.TaskRun - prs []*v1beta1.PipelineRun - expectedPipelineRun *v1beta1.PipelineRun - expectedTaskRuns []*v1beta1.TaskRun + trs []*v1.TaskRun + prs []*v1.PipelineRun + expectedPipelineRun *v1.PipelineRun + expectedTaskRuns []*v1.TaskRun }{{ name: "matrixed pipelinetask with retries, where one taskrun has failed and another one is running", - trs: []*v1beta1.TaskRun{ + trs: []*v1.TaskRun{ mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("pr-platforms-and-browsers-0", "foo", "pr", "p", "platforms-and-browsers", false), @@ -8661,8 +8665,8 @@ status: status: "Unknown" `), }, - prs: []*v1beta1.PipelineRun{ - parse.MustParseV1beta1PipelineRun(t, ` + prs: []*v1.PipelineRun{ + parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -8696,17 +8700,17 @@ status: reason: "Running" message: "Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers `), }, - expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + expectedPipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -8740,16 +8744,16 @@ status: reason: "Running" message: "Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers `), - expectedTaskRuns: []*v1beta1.TaskRun{ + expectedTaskRuns: []*v1.TaskRun{ mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("pr-platforms-and-browsers-0", "foo", "pr", "p", "platforms-and-browsers", false), @@ -8797,7 +8801,7 @@ status: }, }, { name: "matrixed pipelinetask with retries, where both taskruns have failed", - trs: []*v1beta1.TaskRun{ + trs: []*v1.TaskRun{ mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("pr-platforms-and-browsers-0", "foo", "pr", "p", "platforms-and-browsers", false), @@ -8847,8 +8851,8 @@ status: type: Succeeded `), }, - prs: []*v1beta1.PipelineRun{ - parse.MustParseV1beta1PipelineRun(t, ` + prs: []*v1.PipelineRun{ + parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -8882,17 +8886,17 @@ status: reason: "Running" message: "Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers `), }, - expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + expectedPipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -8926,16 +8930,16 @@ status: reason: "Running" message: "Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers `), - expectedTaskRuns: []*v1beta1.TaskRun{ + expectedTaskRuns: []*v1.TaskRun{ mustParseTaskRunWithObjectMeta(t, taskRunObjectMeta("pr-platforms-and-browsers-0", "foo", "pr", "p", "platforms-and-browsers", false), @@ -8990,7 +8994,7 @@ status: for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { d := test.Data{ - Tasks: []*v1beta1.Task{task}, + Tasks: []*v1.Task{task}, TaskRuns: tt.trs, PipelineRuns: tt.prs, ConfigMaps: cms, @@ -8999,7 +9003,7 @@ status: defer prt.Cancel() _, clients := prt.reconcileRun("foo", "pr", []string{}, false) - taskRuns, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ + taskRuns, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{ LabelSelector: "tekton.dev/pipelineRun=pr,tekton.dev/pipelineTask=platforms-and-browsers", Limit: 1, }) @@ -9018,7 +9022,7 @@ status: } } - pipelineRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "pr", metav1.GetOptions{}) + pipelineRun, err := clients.Pipeline.TektonV1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "pr", metav1.GetOptions{}) if err != nil { t.Fatalf("Got an error getting reconciled run out of fake client: %s", err) } @@ -9032,7 +9036,7 @@ status: func TestReconciler_PipelineTaskMatrixWithCustomTask(t *testing.T) { names.TestingSeed() - task := parse.MustParseV1beta1Task(t, ` + task := parse.MustParseV1Task(t, ` metadata: name: mytask namespace: foo @@ -9229,13 +9233,13 @@ spec: tests := []struct { name string memberOf string - p *v1beta1.Pipeline - tr *v1beta1.TaskRun - expectedPipelineRun *v1beta1.PipelineRun + p *v1.Pipeline + tr *v1.TaskRun + expectedPipelineRun *v1.PipelineRun }{{ name: "p-dag", memberOf: "tasks", - p: parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` + p: parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -9261,7 +9265,7 @@ spec: - name: version value: v0.1 `, "p-dag")), - expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + expectedPipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -9300,39 +9304,39 @@ status: reason: "Running" message: "Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-2 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-3 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-4 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-5 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-6 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-7 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers @@ -9340,7 +9344,7 @@ status: }, { name: "p-finally", memberOf: "finally", - p: parse.MustParseV1beta1Pipeline(t, fmt.Sprintf(` + p: parse.MustParseV1Pipeline(t, fmt.Sprintf(` metadata: name: %s namespace: foo @@ -9400,7 +9404,7 @@ status: reason: Succeeded message: All Tasks have completed executing `), - expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + expectedPipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: pr namespace: foo @@ -9451,43 +9455,43 @@ status: reason: "Running" message: "Tasks Completed: 1 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0" childReferences: - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-unmatrixed-pt pipelineTaskName: unmatrixed-pt - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-0 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-2 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-3 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-4 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-5 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-6 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-7 pipelineTaskName: platforms-and-browsers - - apiVersion: tekton.dev/v1beta1 + - apiVersion: tekton.dev/v1 kind: CustomRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers @@ -9495,7 +9499,7 @@ status: }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - pr := parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` + pr := parse.MustParseV1PipelineRun(t, fmt.Sprintf(` metadata: name: pr namespace: foo @@ -9505,13 +9509,13 @@ spec: name: %s `, tt.name)) d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{pr}, - Pipelines: []*v1beta1.Pipeline{tt.p}, - Tasks: []*v1beta1.Task{task}, + PipelineRuns: []*v1.PipelineRun{pr}, + Pipelines: []*v1.Pipeline{tt.p}, + Tasks: []*v1.Task{task}, ConfigMaps: cms, } if tt.tr != nil { - d.TaskRuns = []*v1beta1.TaskRun{tt.tr} + d.TaskRuns = []*v1.TaskRun{tt.tr} } prt := newPipelineRunTest(t, d) defer prt.Cancel() @@ -9538,7 +9542,7 @@ spec: } } - pipelineRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "pr", metav1.GetOptions{}) + pipelineRun, err := clients.Pipeline.TektonV1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "pr", metav1.GetOptions{}) if err != nil { t.Fatalf("Got an error getting reconciled run out of fake client: %s", err) } @@ -9551,7 +9555,7 @@ spec: func TestReconcile_SetDefaults(t *testing.T) { names.TestingSeed() - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, ` + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipeline-run-success namespace: foo @@ -9563,7 +9567,7 @@ spec: name: test-pipeline serviceAccountName: test-sa `)} - ps := []*v1beta1.Pipeline{parse.MustParseV1beta1Pipeline(t, ` + ps := []*v1.Pipeline{parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -9593,8 +9597,8 @@ spec: kind: ClusterTask name: unit-test-cluster-task `)} - ts := []*v1beta1.Task{ - parse.MustParseV1beta1Task(t, ` + ts := []*v1.Task{ + parse.MustParseV1Task(t, ` metadata: name: unit-test-task namespace: foo @@ -9654,7 +9658,7 @@ spec: } // This PipelineRun is in progress now and the status should reflect that - checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) tr1Name := "test-pipeline-run-success-unit-test-1" tr2Name := "test-pipeline-run-success-unit-test-cluster-task" @@ -9664,7 +9668,7 @@ spec: } func TestReconcile_CreateTaskRunWithComputeResources(t *testing.T) { - simplePipeline := parse.MustParseV1beta1Pipeline(t, ` + simplePipeline := parse.MustParseV1Pipeline(t, ` metadata: name: foo-pipeline namespace: default @@ -9685,13 +9689,13 @@ spec: testCases := []struct { name string - pipeline *v1beta1.Pipeline - pipelineRun *v1beta1.PipelineRun + pipeline *v1.Pipeline + pipelineRun *v1.PipelineRun expectedComputeResources []corev1.ResourceRequirements }{{ name: "only with requests", pipeline: simplePipeline, - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: foo-pipeline-run namespace: default @@ -9710,7 +9714,7 @@ spec: }, { name: "only with limits", pipeline: simplePipeline, - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: foo-pipeline-run namespace: default @@ -9729,7 +9733,7 @@ spec: }, { name: "both with requests and limits", pipeline: simplePipeline, - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: foo-pipeline-run namespace: default @@ -9751,7 +9755,7 @@ spec: }, { name: "both with cpu and memory", pipeline: simplePipeline, - pipelineRun: parse.MustParseV1beta1PipelineRun(t, ` + pipelineRun: parse.MustParseV1PipelineRun(t, ` metadata: name: foo-pipeline-run namespace: default @@ -9776,7 +9780,7 @@ spec: }} // verifyTaskLevelComputeResources verifies that the created TaskRuns have the expected compute resources - verifyTaskLevelComputeResources := func(expectedComputeResources []corev1.ResourceRequirements, taskRuns []v1beta1.TaskRun) error { + verifyTaskLevelComputeResources := func(expectedComputeResources []corev1.ResourceRequirements, taskRuns []v1.TaskRun) error { if len(expectedComputeResources) != len(taskRuns) { return fmt.Errorf("expected %d compute resource requirements, got %d", len(expectedComputeResources), len(taskRuns)) } @@ -9791,8 +9795,8 @@ spec: for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{tc.pipelineRun}, - Pipelines: []*v1beta1.Pipeline{tc.pipeline}, + PipelineRuns: []*v1.PipelineRun{tc.pipelineRun}, + Pipelines: []*v1.Pipeline{tc.pipeline}, } prt := newPipelineRunTest(t, d) defer prt.Cancel() @@ -9803,7 +9807,7 @@ spec: t.Errorf("Expected a CompletionTime on valid PipelineRun, but got nil") } - TaskRunList, err := clients.Pipeline.TektonV1beta1().TaskRuns("default").List(prt.TestAssets.Ctx, metav1.ListOptions{}) + TaskRunList, err := clients.Pipeline.TektonV1().TaskRuns("default").List(prt.TestAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("Failure to list TaskRun's %s", err) } @@ -9817,7 +9821,7 @@ spec: func TestReconcile_CancelUnscheduled(t *testing.T) { pipelineRunName := "cancel-test-run" - prs := []*v1beta1.PipelineRun{parse.MustParseV1beta1PipelineRun(t, `metadata: + prs := []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, `metadata: name: cancel-test-run namespace: foo spec: @@ -9846,7 +9850,7 @@ spec: name: hello-world `)} - ts := []*v1beta1.Task{simpleHelloWorldTask} + ts := []*v1.Task{simpleHelloWorldTask} cms := []*corev1.ConfigMap{newFeatureFlagsConfigMap()} @@ -9893,7 +9897,7 @@ func TestReconcile_verifyResolvedPipeline_Success(t *testing.T) { ctx, cancel := context.WithCancel(ctx) defer cancel() - prs := parse.MustParseV1beta1PipelineRun(t, ` + prs := parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipelinerun namespace: foo @@ -9902,7 +9906,7 @@ spec: pipelineRef: name: test-pipeline `) - ps := parse.MustParseV1beta1Pipeline(t, ` + ps := parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -9912,7 +9916,7 @@ spec: taskRef: name: test-task `) - ts := parse.MustParseV1beta1Task(t, ` + ts := parse.MustParseV1Task(t, ` metadata: name: test-task namespace: foo @@ -9937,9 +9941,9 @@ spec: } d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{prs}, - Pipelines: []*v1beta1.Pipeline{signedPipeline}, - Tasks: []*v1beta1.Task{signedTask}, + PipelineRuns: []*v1.PipelineRun{prs}, + Pipelines: []*v1.Pipeline{signedPipeline}, + Tasks: []*v1.Task{signedTask}, VerificationPolicies: vps, } prt := newPipelineRunTest(t, d) @@ -9947,7 +9951,7 @@ spec: reconciledRun, _ := prt.reconcileRun("foo", "test-pipelinerun", []string{}, false) - checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1beta1.PipelineRunReasonRunning.String()) + checkPipelineRunConditionStatusAndReason(t, reconciledRun, corev1.ConditionUnknown, v1.PipelineRunReasonRunning.String()) } func TestReconcile_verifyResolvedPipeline_Error(t *testing.T) { @@ -9956,7 +9960,7 @@ func TestReconcile_verifyResolvedPipeline_Error(t *testing.T) { ctx, cancel := context.WithCancel(ctx) defer cancel() - prs := parse.MustParseV1beta1PipelineRun(t, ` + prs := parse.MustParseV1PipelineRun(t, ` metadata: name: test-pipelinerun namespace: foo @@ -9965,7 +9969,7 @@ spec: pipelineRef: name: test-pipeline `) - ps := parse.MustParseV1beta1Pipeline(t, ` + ps := parse.MustParseV1Pipeline(t, ` metadata: name: test-pipeline namespace: foo @@ -9975,7 +9979,7 @@ spec: taskRef: name: test-task `) - ts := parse.MustParseV1beta1Task(t, ` + ts := parse.MustParseV1Task(t, ` metadata: name: test-task namespace: foo @@ -10013,32 +10017,32 @@ spec: testCases := []struct { name string - pipelinerun []*v1beta1.PipelineRun - pipeline []*v1beta1.Pipeline - task []*v1beta1.Task + pipelinerun []*v1.PipelineRun + pipeline []*v1.Pipeline + task []*v1.Task }{ { name: "unsigned pipeline fails verification", - pipelinerun: []*v1beta1.PipelineRun{prs}, - pipeline: []*v1beta1.Pipeline{ps}, + pipelinerun: []*v1.PipelineRun{prs}, + pipeline: []*v1.Pipeline{ps}, }, { name: "signed pipeline with unsigned task fails verification", - pipelinerun: []*v1beta1.PipelineRun{prs}, - pipeline: []*v1beta1.Pipeline{signedPipeline}, - task: []*v1beta1.Task{ts}, + pipelinerun: []*v1.PipelineRun{prs}, + pipeline: []*v1.Pipeline{signedPipeline}, + task: []*v1.Task{ts}, }, { name: "signed pipeline with modified task fails verification", - pipelinerun: []*v1beta1.PipelineRun{prs}, - pipeline: []*v1beta1.Pipeline{signedPipeline}, - task: []*v1beta1.Task{tamperedTask}, + pipelinerun: []*v1.PipelineRun{prs}, + pipeline: []*v1.Pipeline{signedPipeline}, + task: []*v1.Task{tamperedTask}, }, { name: "modified pipeline with signed task fails verification", - pipelinerun: []*v1beta1.PipelineRun{prs}, - pipeline: []*v1beta1.Pipeline{tamperedPipeline}, - task: []*v1beta1.Task{signedTask}, + pipelinerun: []*v1.PipelineRun{prs}, + pipeline: []*v1.Pipeline{tamperedPipeline}, + task: []*v1.Task{signedTask}, }, } diff --git a/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go b/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go index 0bc023ad057..4ce8362ad51 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go @@ -27,6 +27,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/parse" @@ -41,11 +42,11 @@ import ( ) type updateStatusTaskRunsData struct { - noTaskRuns map[string]*v1beta1.PipelineRunTaskRunStatus - missingTaskRun map[string]*v1beta1.PipelineRunTaskRunStatus - foundTaskRun map[string]*v1beta1.PipelineRunTaskRunStatus - recovered map[string]*v1beta1.PipelineRunTaskRunStatus - simple map[string]*v1beta1.PipelineRunTaskRunStatus + noTaskRuns map[string]*v1.PipelineRunTaskRunStatus + missingTaskRun map[string]*v1.PipelineRunTaskRunStatus + foundTaskRun map[string]*v1.PipelineRunTaskRunStatus + recovered map[string]*v1.PipelineRunTaskRunStatus + simple map[string]*v1.PipelineRunTaskRunStatus } func getUpdateStatusTaskRunsData(t *testing.T) updateStatusTaskRunsData { @@ -66,32 +67,32 @@ status: {} pipelineTaskName: task-4 ` - noTaskRuns := map[string]*v1beta1.PipelineRunTaskRunStatus{ + noTaskRuns := map[string]*v1.PipelineRunTaskRunStatus{ "pr-task-1-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask1Yaml), "pr-task-2-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask2Yaml), "pr-task-3-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask3Yaml), "pr-task-4-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask4Yaml), } - missingTaskRuns := map[string]*v1beta1.PipelineRunTaskRunStatus{ + missingTaskRuns := map[string]*v1.PipelineRunTaskRunStatus{ "pr-task-1-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask1Yaml), "pr-task-2-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask2Yaml), "pr-task-4-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask4Yaml), } - foundTaskRun := map[string]*v1beta1.PipelineRunTaskRunStatus{ + foundTaskRun := map[string]*v1.PipelineRunTaskRunStatus{ "pr-task-1-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask1Yaml), "pr-task-2-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask2Yaml), "pr-task-3-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask3Yaml), "pr-task-4-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask4Yaml), } - recovered := map[string]*v1beta1.PipelineRunTaskRunStatus{ + recovered := map[string]*v1.PipelineRunTaskRunStatus{ "pr-task-1-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask1Yaml), "pr-task-3-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask3Yaml), } - simple := map[string]*v1beta1.PipelineRunTaskRunStatus{ + simple := map[string]*v1.PipelineRunTaskRunStatus{ "pr-task-1-xxyyy": mustParsePipelineRunTaskRunStatus(t, prTask1Yaml), } @@ -105,60 +106,60 @@ pipelineTaskName: task-4 } type updateStatusChildRefsData struct { - noTaskRuns []v1beta1.ChildStatusReference - missingTaskRun []v1beta1.ChildStatusReference - foundTaskRun []v1beta1.ChildStatusReference - missingRun []v1beta1.ChildStatusReference - recovered []v1beta1.ChildStatusReference - simple []v1beta1.ChildStatusReference - simpleRun []v1beta1.ChildStatusReference + noTaskRuns []v1.ChildStatusReference + missingTaskRun []v1.ChildStatusReference + foundTaskRun []v1.ChildStatusReference + missingRun []v1.ChildStatusReference + recovered []v1.ChildStatusReference + simple []v1.ChildStatusReference + simpleRun []v1.ChildStatusReference } func getUpdateStatusChildRefsData(t *testing.T) updateStatusChildRefsData { t.Helper() prTask1Yaml := ` -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: TaskRun name: pr-task-1-xxyyy pipelineTaskName: task-1 ` prTask2Yaml := ` -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: TaskRun name: pr-task-2-xxyyy pipelineTaskName: task-2 ` prTask3Yaml := ` -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: TaskRun name: pr-task-3-xxyyy pipelineTaskName: task-3 ` prTask4Yaml := ` -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: TaskRun name: pr-task-4-xxyyy pipelineTaskName: task-4 ` prTask6Yaml := ` -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: CustomRun name: pr-run-6-xxyyy pipelineTaskName: task-6 ` prTask3NoStatusYaml := ` -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: TaskRun name: pr-task-3-xxyyy pipelineTaskName: task-3 ` - noTaskRuns := []v1beta1.ChildStatusReference{ + noTaskRuns := []v1.ChildStatusReference{ mustParseChildStatusReference(t, prTask1Yaml), mustParseChildStatusReference(t, prTask2Yaml), mustParseChildStatusReference(t, prTask3Yaml), @@ -166,14 +167,14 @@ pipelineTaskName: task-3 mustParseChildStatusReference(t, prTask6Yaml), } - missingTaskRun := []v1beta1.ChildStatusReference{ + missingTaskRun := []v1.ChildStatusReference{ mustParseChildStatusReference(t, prTask1Yaml), mustParseChildStatusReference(t, prTask2Yaml), mustParseChildStatusReference(t, prTask4Yaml), mustParseChildStatusReference(t, prTask6Yaml), } - foundTaskRun := []v1beta1.ChildStatusReference{ + foundTaskRun := []v1.ChildStatusReference{ mustParseChildStatusReference(t, prTask1Yaml), mustParseChildStatusReference(t, prTask2Yaml), mustParseChildStatusReference(t, prTask3NoStatusYaml), @@ -181,22 +182,22 @@ pipelineTaskName: task-3 mustParseChildStatusReference(t, prTask6Yaml), } - missingRun := []v1beta1.ChildStatusReference{ + missingRun := []v1.ChildStatusReference{ mustParseChildStatusReference(t, prTask1Yaml), mustParseChildStatusReference(t, prTask2Yaml), mustParseChildStatusReference(t, prTask3Yaml), mustParseChildStatusReference(t, prTask4Yaml), } - recovered := []v1beta1.ChildStatusReference{ + recovered := []v1.ChildStatusReference{ mustParseChildStatusReference(t, prTask1Yaml), mustParseChildStatusReference(t, prTask3NoStatusYaml), mustParseChildStatusReference(t, prTask6Yaml), } - simple := []v1beta1.ChildStatusReference{mustParseChildStatusReference(t, prTask1Yaml)} + simple := []v1.ChildStatusReference{mustParseChildStatusReference(t, prTask1Yaml)} - simpleRun := []v1beta1.ChildStatusReference{mustParseChildStatusReference(t, prTask6Yaml)} + simpleRun := []v1.ChildStatusReference{mustParseChildStatusReference(t, prTask6Yaml)} return updateStatusChildRefsData{ noTaskRuns: noTaskRuns, @@ -225,40 +226,40 @@ func TestUpdatePipelineRunStatusFromChildRefs(t *testing.T) { }, } - prStatusWithNoTaskRuns := v1beta1.PipelineRunStatus{ + prStatusWithNoTaskRuns := v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ ChildReferences: childRefsPRStatusData.noTaskRuns, }, } - prStatusMissingTaskRun := v1beta1.PipelineRunStatus{ + prStatusMissingTaskRun := v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ ChildReferences: childRefsPRStatusData.missingTaskRun, }, } - prStatusFoundTaskRun := v1beta1.PipelineRunStatus{ + prStatusFoundTaskRun := v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ ChildReferences: childRefsPRStatusData.foundTaskRun, }, } - prStatusMissingRun := v1beta1.PipelineRunStatus{ + prStatusMissingRun := v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ ChildReferences: childRefsPRStatusData.missingRun, }, } - prStatusWithEmptyChildRefs := v1beta1.PipelineRunStatus{ + prStatusWithEmptyChildRefs := v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{}, + PipelineRunStatusFields: v1.PipelineRunStatusFields{}, } - prStatusWithOrphans := v1beta1.PipelineRunStatus{ + prStatusWithOrphans := v1.PipelineRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{ { @@ -269,30 +270,30 @@ func TestUpdatePipelineRunStatusFromChildRefs(t *testing.T) { }, }, }, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{}, + PipelineRunStatusFields: v1.PipelineRunStatusFields{}, } - prStatusRecovered := v1beta1.PipelineRunStatus{ + prStatusRecovered := v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ ChildReferences: childRefsPRStatusData.recovered, }, } - prStatusRecoveredSimple := v1beta1.PipelineRunStatus{ + prStatusRecoveredSimple := v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ ChildReferences: childRefsPRStatusData.simple, }, } - prStatusRecoveredSimpleWithRun := v1beta1.PipelineRunStatus{ + prStatusRecoveredSimpleWithRun := v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: customRun, + APIVersion: "tekton.dev/v1", + Kind: "CustomRun", }, Name: "pr-run-6-xxyyy", PipelineTaskName: "task-6", @@ -313,17 +314,17 @@ metadata: tcs := []struct { prName string - prStatus v1beta1.PipelineRunStatus - trs []*v1beta1.TaskRun + prStatus v1.PipelineRunStatus + trs []*v1.TaskRun runs []v1beta1.RunObject - expectedPrStatus v1beta1.PipelineRunStatus + expectedPrStatus v1.PipelineRunStatus }{ { prName: "no-status-no-taskruns-or-runs", - prStatus: v1beta1.PipelineRunStatus{}, + prStatus: v1.PipelineRunStatus{}, trs: nil, runs: nil, - expectedPrStatus: v1beta1.PipelineRunStatus{}, + expectedPrStatus: v1.PipelineRunStatus{}, }, { prName: "status-no-taskruns-or-runs", prStatus: prStatusWithNoTaskRuns, @@ -333,7 +334,7 @@ metadata: }, { prName: "status-nil-taskruns", prStatus: prStatusWithEmptyChildRefs, - trs: []*v1beta1.TaskRun{parse.MustParseV1beta1TaskRun(t, ` + trs: []*v1.TaskRun{parse.MustParseV1TaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-1 @@ -350,8 +351,8 @@ metadata: }, { prName: "status-missing-taskruns", prStatus: prStatusMissingTaskRun, - trs: []*v1beta1.TaskRun{ - parse.MustParseV1beta1TaskRun(t, ` + trs: []*v1.TaskRun{ + parse.MustParseV1TaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-3 @@ -392,8 +393,8 @@ metadata: }, { prName: "matrixed-taskruns-pr", prStatus: prStatusWithEmptyChildRefs, - trs: []*v1beta1.TaskRun{ - parse.MustParseV1beta1TaskRun(t, ` + trs: []*v1.TaskRun{ + parse.MustParseV1TaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task @@ -401,7 +402,7 @@ metadata: ownerReferences: - uid: 11111111-1111-1111-1111-111111111111 `), - parse.MustParseV1beta1TaskRun(t, ` + parse.MustParseV1TaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task @@ -411,18 +412,18 @@ metadata: `), }, runs: nil, - expectedPrStatus: v1beta1.PipelineRunStatus{ + expectedPrStatus: v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{ mustParseChildStatusReference(t, ` -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: TaskRun name: pr-task-0-xxyyy pipelineTaskName: task `), mustParseChildStatusReference(t, ` -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: TaskRun name: pr-task-1-xxyyy pipelineTaskName: task @@ -437,7 +438,7 @@ pipelineTaskName: task t.Run(tc.prName, func(t *testing.T) { logger := logtesting.TestLogger(t) - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: tc.prName, UID: prUID}, Status: tc.prStatus, } @@ -448,7 +449,7 @@ pipelineTaskName: task actualChildRefs := actualPrStatus.ChildReferences if len(actualChildRefs) != 0 { - var fixedChildRefs []v1beta1.ChildStatusReference + var fixedChildRefs []v1.ChildStatusReference re := regexp.MustCompile(`^[a-z\-]*?-(task|run)-[0-9]`) for _, cr := range actualChildRefs { cr.Name = fmt.Sprintf("%s-xxyyy", re.FindString(cr.Name)) @@ -481,7 +482,7 @@ func TestUpdatePipelineRunStatusFromChildObjects(t *testing.T) { }, } - prStatusWithOrphans := v1beta1.PipelineRunStatus{ + prStatusWithOrphans := v1.PipelineRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{ { @@ -492,13 +493,13 @@ func TestUpdatePipelineRunStatusFromChildObjects(t *testing.T) { }, }, }, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{}, + PipelineRunStatusFields: v1.PipelineRunStatusFields{}, } - prStatusWithEmptyEverything := func() v1beta1.PipelineRunStatus { - return v1beta1.PipelineRunStatus{ + prStatusWithEmptyEverything := func() v1.PipelineRunStatus { + return v1.PipelineRunStatus{ Status: prRunningStatus, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{}, + PipelineRunStatusFields: v1.PipelineRunStatusFields{}, } } @@ -529,17 +530,17 @@ status: tcs := []struct { prName string - prStatus func() v1beta1.PipelineRunStatus - trs []*v1beta1.TaskRun + prStatus func() v1.PipelineRunStatus + trs []*v1.TaskRun runs []v1beta1.RunObject - expectedStatusTRs map[string]*v1beta1.PipelineRunTaskRunStatus - expectedStatusRuns map[string]*v1beta1.PipelineRunRunStatus - expectedStatusCRs []v1beta1.ChildStatusReference + expectedStatusTRs map[string]*v1.PipelineRunTaskRunStatus + expectedStatusRuns map[string]*v1.PipelineRunRunStatus + expectedStatusCRs []v1.ChildStatusReference }{ { prName: "status-nil-taskruns", prStatus: prStatusWithEmptyEverything, - trs: []*v1beta1.TaskRun{parse.MustParseV1beta1TaskRun(t, ` + trs: []*v1.TaskRun{parse.MustParseV1TaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-1 @@ -554,7 +555,7 @@ metadata: prStatus: prStatusWithEmptyEverything, runs: singleCustomRun, expectedStatusCRs: childRefsPRStatusData.simpleRun, - expectedStatusRuns: map[string]*v1beta1.PipelineRunRunStatus{ + expectedStatusRuns: map[string]*v1.PipelineRunRunStatus{ "pr-run-6-xxyyy": { PipelineTaskName: "task-6", Status: &v1beta1.CustomRunStatus{}, @@ -564,13 +565,13 @@ metadata: prName: "status-nil-runs-with-alpha-run", prStatus: prStatusWithEmptyEverything, runs: singleRunWithStatus, - expectedStatusCRs: []v1beta1.ChildStatusReference{mustParseChildStatusReference(t, ` + expectedStatusCRs: []v1.ChildStatusReference{mustParseChildStatusReference(t, ` apiVersion: tekton.dev/v1alpha1 kind: Run name: pr-run-6-xxyyy pipelineTaskName: task-6 `)}, - expectedStatusRuns: map[string]*v1beta1.PipelineRunRunStatus{ + expectedStatusRuns: map[string]*v1.PipelineRunRunStatus{ "pr-run-6-xxyyy": { PipelineTaskName: "task-6", Status: &v1beta1.CustomRunStatus{ @@ -588,12 +589,12 @@ pipelineTaskName: task-6 }, }, { prName: "orphaned-taskruns-pr", - prStatus: func() v1beta1.PipelineRunStatus { return prStatusWithOrphans }, + prStatus: func() v1.PipelineRunStatus { return prStatusWithOrphans }, trs: allTaskRuns, runs: singleCustomRun, expectedStatusTRs: taskRunsPRStatusData.recovered, expectedStatusCRs: childRefsPRStatusData.recovered, - expectedStatusRuns: map[string]*v1beta1.PipelineRunRunStatus{ + expectedStatusRuns: map[string]*v1.PipelineRunRunStatus{ "pr-run-6-xxyyy": { PipelineTaskName: "task-6", Status: &v1beta1.CustomRunStatus{}, @@ -610,7 +611,7 @@ pipelineTaskName: task-6 ctx = cfg.ToContext(ctx) logger := logtesting.TestLogger(t) - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: tc.prName, UID: prUID}, Status: tc.prStatus(), } @@ -623,7 +624,7 @@ pipelineTaskName: task-6 actualChildRefs := actualPrStatus.ChildReferences if len(actualChildRefs) != 0 { - var fixedChildRefs []v1beta1.ChildStatusReference + var fixedChildRefs []v1.ChildStatusReference re := regexp.MustCompile(`^[a-z\-]*?-(task|run)-[0-9]`) for _, cr := range actualChildRefs { cr.Name = fmt.Sprintf("%s-xxyyy", re.FindString(cr.Name)) @@ -644,20 +645,20 @@ pipelineTaskName: task-6 func TestValidateChildObjectsInPipelineRunStatus(t *testing.T) { testCases := []struct { name string - prStatus v1beta1.PipelineRunStatus + prStatus v1.PipelineRunStatus expectedErrStrs []string }{ { name: "empty everything", - prStatus: v1beta1.PipelineRunStatus{ - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{}, + prStatus: v1.PipelineRunStatus{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{}, }, expectedErrStrs: nil, }, { name: "error ChildObjects", - prStatus: v1beta1.PipelineRunStatus{ - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{ + prStatus: v1.PipelineRunStatus{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{ { TypeMeta: runtime.TypeMeta{Kind: taskRun}, Name: "t1", @@ -679,9 +680,9 @@ func TestValidateChildObjectsInPipelineRunStatus(t *testing.T) { }, }, { name: "valid ChildObjects", - prStatus: v1beta1.PipelineRunStatus{ - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{ + prStatus: v1.PipelineRunStatus{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{ { TypeMeta: runtime.TypeMeta{Kind: taskRun}, Name: "t1", @@ -728,10 +729,10 @@ func TestValidateChildObjectsInPipelineRunStatus(t *testing.T) { } } -func prStatusFromInputs(status duckv1.Status, taskRuns map[string]*v1beta1.PipelineRunTaskRunStatus, runs map[string]*v1beta1.PipelineRunRunStatus, childRefs []v1beta1.ChildStatusReference) v1beta1.PipelineRunStatus { - prs := v1beta1.PipelineRunStatus{ +func prStatusFromInputs(status duckv1.Status, taskRuns map[string]*v1.PipelineRunTaskRunStatus, runs map[string]*v1.PipelineRunRunStatus, childRefs []v1.ChildStatusReference) v1.PipelineRunStatus { + prs := v1.PipelineRunStatus{ Status: status, - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{}, + PipelineRunStatusFields: v1.PipelineRunStatusFields{}, } prs.ChildReferences = append(prs.ChildReferences, childRefs...) @@ -739,10 +740,10 @@ func prStatusFromInputs(status duckv1.Status, taskRuns map[string]*v1beta1.Pipel return prs } -func getTestTaskRunsAndRuns(t *testing.T) ([]*v1beta1.TaskRun, []*v1beta1.TaskRun, []*v1beta1.TaskRun, []v1beta1.RunObject, []v1beta1.RunObject, []v1beta1.RunObject) { +func getTestTaskRunsAndRuns(t *testing.T) ([]*v1.TaskRun, []*v1.TaskRun, []*v1.TaskRun, []v1beta1.RunObject, []v1beta1.RunObject, []v1beta1.RunObject) { t.Helper() - allTaskRuns := []*v1beta1.TaskRun{ - parse.MustParseV1beta1TaskRun(t, ` + allTaskRuns := []*v1.TaskRun{ + parse.MustParseV1TaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-1 @@ -750,7 +751,7 @@ metadata: ownerReferences: - uid: 11111111-1111-1111-1111-111111111111 `), - parse.MustParseV1beta1TaskRun(t, ` + parse.MustParseV1TaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-3 @@ -760,7 +761,7 @@ metadata: `), } - taskRunsFromAnotherPR := []*v1beta1.TaskRun{parse.MustParseV1beta1TaskRun(t, ` + taskRunsFromAnotherPR := []*v1.TaskRun{parse.MustParseV1TaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-1 @@ -769,7 +770,7 @@ metadata: - uid: 22222222-2222-2222-2222-222222222222 `)} - taskRunsWithNoOwner := []*v1beta1.TaskRun{parse.MustParseV1beta1TaskRun(t, ` + taskRunsWithNoOwner := []*v1.TaskRun{parse.MustParseV1TaskRun(t, ` metadata: labels: tekton.dev/pipelineTask: task-1 @@ -822,24 +823,24 @@ metadata: return allTaskRuns, taskRunsFromAnotherPR, taskRunsWithNoOwner, allRuns, runsFromAnotherPR, runsWithNoOwner } -func mustParsePipelineRunTaskRunStatus(t *testing.T, yamlStr string) *v1beta1.PipelineRunTaskRunStatus { +func mustParsePipelineRunTaskRunStatus(t *testing.T, yamlStr string) *v1.PipelineRunTaskRunStatus { t.Helper() - var output v1beta1.PipelineRunTaskRunStatus + var output v1.PipelineRunTaskRunStatus if err := yaml.Unmarshal([]byte(yamlStr), &output); err != nil { t.Fatalf("parsing task run status %s: %v", yamlStr, err) } return &output } -func mustParseChildStatusReference(t *testing.T, yamlStr string) v1beta1.ChildStatusReference { +func mustParseChildStatusReference(t *testing.T, yamlStr string) v1.ChildStatusReference { t.Helper() - var output v1beta1.ChildStatusReference + var output v1.ChildStatusReference if err := yaml.Unmarshal([]byte(yamlStr), &output); err != nil { t.Fatalf("parsing task run status %s: %v", yamlStr, err) } return output } -func lessChildReferences(i, j v1beta1.ChildStatusReference) bool { +func lessChildReferences(i, j v1.ChildStatusReference) bool { return i.Name < j.Name } diff --git a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go index 98ea54d6355..460087a9908 100644 --- a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go +++ b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go @@ -21,21 +21,21 @@ import ( "errors" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" resolutionutil "github.com/tektoncd/pipeline/pkg/internal/resolution" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // GetPipeline is a function used to retrieve Pipelines. -type GetPipeline func(context.Context, string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) +type GetPipeline func(context.Context, string) (v1.PipelineObject, *v1.ConfigSource, error) // GetPipelineData will retrieve the Pipeline metadata and Spec associated with the // provided PipelineRun. This can come from a reference Pipeline or from the PipelineRun's // metadata and embedded PipelineSpec. -func GetPipelineData(ctx context.Context, pipelineRun *v1beta1.PipelineRun, getPipeline GetPipeline) (*resolutionutil.ResolvedObjectMeta, *v1beta1.PipelineSpec, error) { +func GetPipelineData(ctx context.Context, pipelineRun *v1.PipelineRun, getPipeline GetPipeline) (*resolutionutil.ResolvedObjectMeta, *v1.PipelineSpec, error) { pipelineMeta := metav1.ObjectMeta{} - var configSource *v1beta1.ConfigSource - pipelineSpec := v1beta1.PipelineSpec{} + var configSource *v1.ConfigSource + pipelineSpec := v1.PipelineSpec{} switch { case pipelineRun.Spec.PipelineRef != nil && pipelineRun.Spec.PipelineRef.Name != "": // Get related pipeline for pipelinerun diff --git a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go index f88073f8204..aa0e2b8b65d 100644 --- a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go +++ b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go @@ -22,37 +22,41 @@ import ( "testing" "github.com/google/go-cmp/cmp" +<<<<<<< Updated upstream cfgtesting "github.com/tektoncd/pipeline/pkg/apis/config/testing" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" +======= + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" +>>>>>>> Stashed changes "github.com/tektoncd/pipeline/test/diff" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestGetPipelineSpec_Ref(t *testing.T) { - pipeline := &v1beta1.Pipeline{ + pipeline := &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: "orchestrate", }, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "mytask", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "mytask", }, }}, }, } - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ Name: "orchestrate", }, }, } - gt := func(ctx context.Context, n string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { + gt := func(ctx context.Context, n string) (v1.PipelineObject, *v1.ConfigSource, error) { return pipeline, nil, nil } resolvedObjectMeta, pipelineSpec, err := GetPipelineData(context.Background(), pr, gt) @@ -75,22 +79,22 @@ func TestGetPipelineSpec_Ref(t *testing.T) { } func TestGetPipelineSpec_Embedded(t *testing.T) { - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ - PipelineSpec: &v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + Spec: v1.PipelineRunSpec{ + PipelineSpec: &v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "mytask", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "mytask", }, }}, }, }, } - gt := func(ctx context.Context, n string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { + gt := func(ctx context.Context, n string) (v1.PipelineObject, *v1.ConfigSource, error) { return nil, nil, errors.New("shouldn't be called") } resolvedObjectMeta, pipelineSpec, err := GetPipelineData(context.Background(), pr, gt) @@ -113,12 +117,12 @@ func TestGetPipelineSpec_Embedded(t *testing.T) { } func TestGetPipelineSpec_Invalid(t *testing.T) { - tr := &v1beta1.PipelineRun{ + tr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, } - gt := func(ctx context.Context, n string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { + gt := func(ctx context.Context, n string) (v1.PipelineObject, *v1.ConfigSource, error) { return nil, nil, errors.New("shouldn't be called") } _, _, err := GetPipelineData(context.Background(), tr, gt) @@ -128,6 +132,7 @@ func TestGetPipelineSpec_Invalid(t *testing.T) { } func TestGetPipelineData_ResolutionSuccess(t *testing.T) { +<<<<<<< Updated upstream sourceMeta := &metav1.ObjectMeta{ Name: "pipeline", } @@ -212,6 +217,63 @@ func TestGetPipelineData_ResolutionSuccess(t *testing.T) { "default-resolver-type": "foo", }, }, +======= + pr := &v1.PipelineRun{ + ObjectMeta: metav1.ObjectMeta{ + Name: "mypipelinerun", + }, + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ + ResolverRef: v1.ResolverRef{ + Resolver: "foo", + Params: []v1.Param{{ + Name: "bar", + Value: v1.ParamValue{ + Type: v1.ParamTypeString, + StringVal: "baz", + }, + }}, + }, + }, + }, + } + sourceMeta := metav1.ObjectMeta{ + Name: "pipeline", + } + sourceSpec := v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + Name: "pt1", + TaskRef: &v1.TaskRef{ + Kind: "Task", + Name: "tref", + }, + }}, + } + expectedConfigSource := &v1.ConfigSource{ + URI: "abc.com", + Digest: map[string]string{ + "sha1": "a123", + }, + EntryPoint: "foo/bar", + } + + getPipeline := func(ctx context.Context, n string) (v1.PipelineObject, *v1.ConfigSource, error) { + return &v1.Pipeline{ + ObjectMeta: *sourceMeta.DeepCopy(), + Spec: *sourceSpec.DeepCopy(), + }, expectedConfigSource.DeepCopy(), nil + } + ctx := context.Background() + resolvedMeta, resolvedSpec, err := GetPipelineData(ctx, pr, getPipeline) + if err != nil { + t.Fatalf("Unexpected error getting mocked data: %v", err) + } + if sourceMeta.Name != resolvedMeta.Name { + t.Errorf("Expected name %q but resolved to %q", sourceMeta.Name, resolvedMeta.Name) + } + if d := cmp.Diff(sourceSpec, *resolvedSpec); d != "" { + t.Errorf(diff.PrintWantGot(d)) +>>>>>>> Stashed changes } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { @@ -242,17 +304,17 @@ func TestGetPipelineData_ResolutionSuccess(t *testing.T) { } func TestGetPipelineSpec_Error(t *testing.T) { - tr := &v1beta1.PipelineRun{ + tr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ Name: "orchestrate", }, }, } - gt := func(ctx context.Context, n string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { + gt := func(ctx context.Context, n string) (v1.PipelineObject, *v1.ConfigSource, error) { return nil, nil, errors.New("something went wrong") } _, _, err := GetPipelineData(context.Background(), tr, gt) @@ -262,19 +324,19 @@ func TestGetPipelineSpec_Error(t *testing.T) { } func TestGetPipelineData_ResolutionError(t *testing.T) { - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ - ResolverRef: v1beta1.ResolverRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", }, }, }, } - getPipeline := func(ctx context.Context, n string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { + getPipeline := func(ctx context.Context, n string) (v1.PipelineObject, *v1.ConfigSource, error) { return nil, nil, errors.New("something went wrong") } ctx := context.Background() @@ -285,19 +347,19 @@ func TestGetPipelineData_ResolutionError(t *testing.T) { } func TestGetPipelineData_ResolvedNilPipeline(t *testing.T) { - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ - ResolverRef: v1beta1.ResolverRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", }, }, }, } - getPipeline := func(ctx context.Context, n string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { + getPipeline := func(ctx context.Context, n string) (v1.PipelineObject, *v1.ConfigSource, error) { return nil, nil, nil } ctx := context.Background() diff --git a/pkg/reconciler/pipelinerun/resources/apply.go b/pkg/reconciler/pipelinerun/resources/apply.go index 08e8ff8f097..6e955be5bd6 100644 --- a/pkg/reconciler/pipelinerun/resources/apply.go +++ b/pkg/reconciler/pipelinerun/resources/apply.go @@ -23,7 +23,7 @@ import ( "strings" "github.com/tektoncd/pipeline/pkg/apis/config" - + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "github.com/tektoncd/pipeline/pkg/substitution" @@ -48,7 +48,7 @@ var ( ) // ApplyParameters applies the params from a PipelineRun.Params to a PipelineSpec. -func ApplyParameters(ctx context.Context, p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) *v1beta1.PipelineSpec { +func ApplyParameters(ctx context.Context, p *v1.PipelineSpec, pr *v1.PipelineRun) *v1.PipelineSpec { // This assumes that the PipelineRun inputs have been validated against what the Pipeline requests. // stringReplacements is used for standard single-string stringReplacements, @@ -61,7 +61,7 @@ func ApplyParameters(ctx context.Context, p *v1beta1.PipelineSpec, pr *v1beta1.P for _, p := range p.Params { if p.Default != nil { switch p.Default.Type { - case v1beta1.ParamTypeArray: + case v1.ParamTypeArray: for _, pattern := range paramPatterns { // array indexing for param is beta feature - the feature flag can be either set to alpha or beta if config.CheckAlphaOrBetaAPIFields(ctx) { @@ -71,7 +71,7 @@ func ApplyParameters(ctx context.Context, p *v1beta1.PipelineSpec, pr *v1beta1.P } arrayReplacements[fmt.Sprintf(pattern, p.Name)] = p.Default.ArrayVal } - case v1beta1.ParamTypeObject: + case v1.ParamTypeObject: for _, pattern := range paramPatterns { objectReplacements[fmt.Sprintf(pattern, p.Name)] = p.Default.ObjectVal } @@ -101,7 +101,7 @@ func ApplyParameters(ctx context.Context, p *v1beta1.PipelineSpec, pr *v1beta1.P return ApplyReplacements(p, stringReplacements, arrayReplacements, objectReplacements) } -func paramsFromPipelineRun(ctx context.Context, pr *v1beta1.PipelineRun) (map[string]string, map[string][]string, map[string]map[string]string) { +func paramsFromPipelineRun(ctx context.Context, pr *v1.PipelineRun) (map[string]string, map[string][]string, map[string]map[string]string) { // stringReplacements is used for standard single-string stringReplacements, // while arrayReplacements/objectReplacements contains arrays/objects that need to be further processed. stringReplacements := map[string]string{} @@ -110,7 +110,7 @@ func paramsFromPipelineRun(ctx context.Context, pr *v1beta1.PipelineRun) (map[st for _, p := range pr.Spec.Params { switch p.Value.Type { - case v1beta1.ParamTypeArray: + case v1.ParamTypeArray: for _, pattern := range paramPatterns { // array indexing for param is beta feature - the feature flag can be either set to alpha ot beta if config.CheckAlphaOrBetaAPIFields(ctx) { @@ -120,7 +120,7 @@ func paramsFromPipelineRun(ctx context.Context, pr *v1beta1.PipelineRun) (map[st } arrayReplacements[fmt.Sprintf(pattern, p.Name)] = p.Value.ArrayVal } - case v1beta1.ParamTypeObject: + case v1.ParamTypeObject: for _, pattern := range paramPatterns { objectReplacements[fmt.Sprintf(pattern, p.Name)] = p.Value.ObjectVal } @@ -137,8 +137,7 @@ func paramsFromPipelineRun(ctx context.Context, pr *v1beta1.PipelineRun) (map[st return stringReplacements, arrayReplacements, objectReplacements } -// GetContextReplacements returns the pipelineRun context which can be used to replace context variables in the specifications -func GetContextReplacements(pipelineName string, pr *v1beta1.PipelineRun) map[string]string { +func GetContextReplacements(pipelineName string, pr *v1.PipelineRun) map[string]string { return map[string]string{ "context.pipelineRun.name": pr.Name, "context.pipeline.name": pipelineName, @@ -148,14 +147,14 @@ func GetContextReplacements(pipelineName string, pr *v1beta1.PipelineRun) map[st } // ApplyContexts applies the substitution from $(context.(pipelineRun|pipeline).*) with the specified values. -// Currently, supports only name substitution. Uses "" as a default if name is not specified. -func ApplyContexts(spec *v1beta1.PipelineSpec, pipelineName string, pr *v1beta1.PipelineRun) *v1beta1.PipelineSpec { +// Currently supports only name substitution. Uses "" as a default if name is not specified. +func ApplyContexts(spec *v1.PipelineSpec, pipelineName string, pr *v1.PipelineRun) *v1.PipelineSpec { return ApplyReplacements(spec, GetContextReplacements(pipelineName, pr), map[string][]string{}, map[string]map[string]string{}) } // ApplyPipelineTaskContexts applies the substitution from $(context.pipelineTask.*) with the specified values. // Uses "0" as a default if a value is not available. -func ApplyPipelineTaskContexts(pt *v1beta1.PipelineTask) *v1beta1.PipelineTask { +func ApplyPipelineTaskContexts(pt *v1.PipelineTask) *v1.PipelineTask { pt = pt.DeepCopy() replacements := map[string]string{ "context.pipelineTask.retries": strconv.Itoa(pt.Retries), @@ -170,7 +169,7 @@ func ApplyPipelineTaskContexts(pt *v1beta1.PipelineTask) *v1beta1.PipelineTask { return pt } -// ApplyTaskResults applies the ResolvedResultRef to each PipelineTask.Params and Pipeline.WhenExpressions in targets +// ApplyTaskResults applies the ResolvedResultRef to each PipelineTask.Params and Pipeline.When in targets func ApplyTaskResults(targets PipelineRunState, resolvedResultRefs ResolvedResultRefs) { stringReplacements := resolvedResultRefs.getStringReplacements() arrayReplacements := resolvedResultRefs.getArrayReplacements() @@ -188,7 +187,7 @@ func ApplyTaskResults(targets PipelineRunState, resolvedResultRefs ResolvedResul pipelineTask.Matrix.Include[i].Params = replaceParamValues(pipelineTask.Matrix.Include[i].Params, stringReplacements, nil, nil) } } - pipelineTask.WhenExpressions = pipelineTask.WhenExpressions.ReplaceWhenExpressionsVariables(stringReplacements, arrayReplacements) + pipelineTask.When = pipelineTask.When.ReplaceWhenExpressionsVariables(stringReplacements, arrayReplacements) if pipelineTask.TaskRef != nil && pipelineTask.TaskRef.Params != nil { pipelineTask.TaskRef.Params = replaceParamValues(pipelineTask.TaskRef.Params, stringReplacements, arrayReplacements, objectReplacements) } @@ -203,7 +202,7 @@ func ApplyPipelineTaskStateContext(state PipelineRunState, replacements map[stri if resolvedPipelineRunTask.PipelineTask != nil { pipelineTask := resolvedPipelineRunTask.PipelineTask.DeepCopy() pipelineTask.Params = replaceParamValues(pipelineTask.Params, replacements, nil, nil) - pipelineTask.WhenExpressions = pipelineTask.WhenExpressions.ReplaceWhenExpressionsVariables(replacements, nil) + pipelineTask.When = pipelineTask.When.ReplaceWhenExpressionsVariables(replacements, nil) if pipelineTask.TaskRef != nil && pipelineTask.TaskRef.Params != nil { pipelineTask.TaskRef.Params = replaceParamValues(pipelineTask.TaskRef.Params, replacements, nil, nil) } @@ -214,7 +213,7 @@ func ApplyPipelineTaskStateContext(state PipelineRunState, replacements map[stri // ApplyWorkspaces replaces workspace variables in the given pipeline spec with their // concrete values. -func ApplyWorkspaces(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) *v1beta1.PipelineSpec { +func ApplyWorkspaces(p *v1.PipelineSpec, pr *v1.PipelineRun) *v1.PipelineSpec { p = p.DeepCopy() replacements := map[string]string{} for _, declaredWorkspace := range p.Workspaces { @@ -229,7 +228,7 @@ func ApplyWorkspaces(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) *v1beta1. } // ApplyReplacements replaces placeholders for declared parameters with the specified replacements. -func ApplyReplacements(p *v1beta1.PipelineSpec, replacements map[string]string, arrayReplacements map[string][]string, objectReplacements map[string]map[string]string) *v1beta1.PipelineSpec { +func ApplyReplacements(p *v1.PipelineSpec, replacements map[string]string, arrayReplacements map[string][]string, objectReplacements map[string]map[string]string) *v1.PipelineSpec { p = p.DeepCopy() for i := range p.Tasks { @@ -243,7 +242,7 @@ func ApplyReplacements(p *v1beta1.PipelineSpec, replacements map[string]string, for j := range p.Tasks[i].Workspaces { p.Tasks[i].Workspaces[j].SubPath = substitution.ApplyReplacements(p.Tasks[i].Workspaces[j].SubPath, replacements) } - p.Tasks[i].WhenExpressions = p.Tasks[i].WhenExpressions.ReplaceWhenExpressionsVariables(replacements, arrayReplacements) + p.Tasks[i].When = p.Tasks[i].When.ReplaceWhenExpressionsVariables(replacements, arrayReplacements) if p.Tasks[i].TaskRef != nil && p.Tasks[i].TaskRef.Params != nil { p.Tasks[i].TaskRef.Params = replaceParamValues(p.Tasks[i].TaskRef.Params, replacements, arrayReplacements, objectReplacements) } @@ -261,7 +260,7 @@ func ApplyReplacements(p *v1beta1.PipelineSpec, replacements map[string]string, for j := range p.Finally[i].Workspaces { p.Finally[i].Workspaces[j].SubPath = substitution.ApplyReplacements(p.Finally[i].Workspaces[j].SubPath, replacements) } - p.Finally[i].WhenExpressions = p.Finally[i].WhenExpressions.ReplaceWhenExpressionsVariables(replacements, arrayReplacements) + p.Finally[i].When = p.Finally[i].When.ReplaceWhenExpressionsVariables(replacements, arrayReplacements) if p.Finally[i].TaskRef != nil && p.Finally[i].TaskRef.Params != nil { p.Finally[i].TaskRef.Params = replaceParamValues(p.Finally[i].TaskRef.Params, replacements, arrayReplacements, objectReplacements) } @@ -274,7 +273,7 @@ func ApplyReplacements(p *v1beta1.PipelineSpec, replacements map[string]string, // propagateParams returns a Pipeline Task spec that is the same as the input Pipeline Task spec, but with // all parameter replacements from `stringReplacements`, `arrayReplacements`, and `objectReplacements` substituted. // It does not modify `stringReplacements`, `arrayReplacements`, or `objectReplacements`. -func propagateParams(t v1beta1.PipelineTask, stringReplacements map[string]string, arrayReplacements map[string][]string, objectReplacements map[string]map[string]string) v1beta1.PipelineTask { +func propagateParams(t v1.PipelineTask, stringReplacements map[string]string, arrayReplacements map[string][]string, objectReplacements map[string]map[string]string) v1.PipelineTask { if t.TaskSpec == nil { return t } @@ -317,7 +316,7 @@ func propagateParams(t v1beta1.PipelineTask, stringReplacements map[string]strin return t } -func replaceParamValues(params []v1beta1.Param, stringReplacements map[string]string, arrayReplacements map[string][]string, objectReplacements map[string]map[string]string) []v1beta1.Param { +func replaceParamValues(params []v1.Param, stringReplacements map[string]string, arrayReplacements map[string][]string, objectReplacements map[string]map[string]string) []v1.Param { for i := range params { params[i].Value.ApplyReplacements(stringReplacements, arrayReplacements, objectReplacements) } @@ -331,11 +330,11 @@ func replaceParamValues(params []v1beta1.Param, stringReplacements map[string]st // results are invalid. func ApplyTaskResultsToPipelineResults( ctx context.Context, - results []v1beta1.PipelineResult, - taskRunResults map[string][]v1beta1.TaskRunResult, + results []v1.PipelineResult, + taskRunResults map[string][]v1.TaskRunResult, customTaskResults map[string][]v1beta1.CustomRunResult, - skippedTasks []v1beta1.SkippedTask) ([]v1beta1.PipelineRunResult, error) { - var runResults []v1beta1.PipelineRunResult + skippedTasks []v1.SkippedTask) ([]v1.PipelineRunResult, error) { + var runResults []v1.PipelineRunResult var invalidPipelineResults []string skippedTaskNames := map[string]bool{} for _, t := range skippedTasks { @@ -346,7 +345,7 @@ func ApplyTaskResultsToPipelineResults( arrayReplacements := map[string][]string{} objectReplacements := map[string]map[string]string{} for _, pipelineResult := range results { - variablesInPipelineResult, _ := v1beta1.GetVarSubstitutionExpressionsForPipelineResult(pipelineResult) + variablesInPipelineResult, _ := v1.GetVarSubstitutionExpressionsForPipelineResult(pipelineResult) if len(variablesInPipelineResult) == 0 { continue } @@ -367,7 +366,7 @@ func ApplyTaskResultsToPipelineResults( validPipelineResult = false continue } - if (variableParts[0] != v1beta1.ResultTaskPart && variableParts[0] != v1beta1.ResultFinallyPart) || variableParts[2] != v1beta1.ResultResultPart { + if (variableParts[0] != v1.ResultTaskPart && variableParts[0] != v1.ResultFinallyPart) || variableParts[2] != v1.ResultResultPart { validPipelineResult = false invalidPipelineResults = append(invalidPipelineResults, pipelineResult.Name) continue @@ -378,12 +377,12 @@ func ApplyTaskResultsToPipelineResults( // For object result: tasks..results.[*], case resultsParseNumber: taskName, resultName := variableParts[1], variableParts[3] - resultName, stringIdx := v1beta1.ParseResultName(resultName) + resultName, stringIdx := v1.ParseResultName(resultName) if resultValue := taskResultValue(taskName, resultName, taskRunResults); resultValue != nil { switch resultValue.Type { - case v1beta1.ParamTypeString: + case v1.ParamTypeString: stringReplacements[variable] = resultValue.StringVal - case v1beta1.ParamTypeArray: + case v1.ParamTypeArray: if stringIdx != "*" { intIdx, _ := strconv.Atoi(stringIdx) if intIdx < len(resultValue.ArrayVal) { @@ -396,7 +395,7 @@ func ApplyTaskResultsToPipelineResults( } else { arrayReplacements[substitution.StripStarVarSubExpression(variable)] = resultValue.ArrayVal } - case v1beta1.ParamTypeObject: + case v1.ParamTypeObject: objectReplacements[substitution.StripStarVarSubExpression(variable)] = resultValue.ObjectVal } } else if resultValue := runResultValue(taskName, resultName, customTaskResults); resultValue != nil { @@ -409,7 +408,7 @@ func ApplyTaskResultsToPipelineResults( // For object type result: tasks..results.. case objectElementResultsParseNumber: taskName, resultName, objectKey := variableParts[1], variableParts[3], variableParts[4] - resultName, _ = v1beta1.ParseResultName(resultName) + resultName, _ = v1.ParseResultName(resultName) if resultValue := taskResultValue(taskName, resultName, taskRunResults); resultValue != nil { if _, ok := resultValue.ObjectVal[objectKey]; ok { stringReplacements[variable] = resultValue.ObjectVal[objectKey] @@ -431,7 +430,7 @@ func ApplyTaskResultsToPipelineResults( if validPipelineResult { finalValue := pipelineResult.Value finalValue.ApplyReplacements(stringReplacements, arrayReplacements, objectReplacements) - runResults = append(runResults, v1beta1.PipelineRunResult{ + runResults = append(runResults, v1.PipelineRunResult{ Name: pipelineResult.Name, Value: finalValue, }) @@ -448,7 +447,7 @@ func ApplyTaskResultsToPipelineResults( // taskResultValue returns the result value for a given pipeline task name and result name in a map of TaskRunResults for // pipeline task names. It returns nil if either the pipeline task name isn't present in the map, or if there is no // result with the result name in the pipeline task name's slice of results. -func taskResultValue(taskName string, resultName string, taskResults map[string][]v1beta1.TaskRunResult) *v1beta1.ResultValue { +func taskResultValue(taskName string, resultName string, taskResults map[string][]v1.TaskRunResult) *v1.ResultValue { for _, trResult := range taskResults[taskName] { if trResult.Name == resultName { return &trResult.Value diff --git a/pkg/reconciler/pipelinerun/resources/apply_test.go b/pkg/reconciler/pipelinerun/resources/apply_test.go index 72ac05c1902..520ca51e44e 100644 --- a/pkg/reconciler/pipelinerun/resources/apply_test.go +++ b/pkg/reconciler/pipelinerun/resources/apply_test.go @@ -23,6 +23,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/test/diff" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -32,46 +33,46 @@ import ( func TestApplyParameters(t *testing.T) { for _, tt := range []struct { name string - original v1beta1.PipelineSpec - params []v1beta1.Param - expected v1beta1.PipelineSpec + original v1.PipelineSpec + params []v1.Param + expected v1.PipelineSpec wc func(context.Context) context.Context }{{ name: "single parameter", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param)")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.second-param)")}, - {Name: "first-task-third-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param)")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("$(params.second-param)")}, + {Name: "first-task-third-param", Value: *v1.NewStructuredValues("static value")}, }, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("second-value")}, - {Name: "first-task-third-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("second-value")}, + {Name: "first-task-third-param", Value: *v1.NewStructuredValues("static value")}, }, }}, }, }, { name: "parameter propagation string no task or task default winner pipeline", - original: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + original: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "$(params.HELLO)"`, @@ -80,12 +81,12 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("hello param!")}}, - expected: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("hello param!")}}, + expected: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "hello param!"`, @@ -96,11 +97,11 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation string into finally task", - original: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + original: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "$(params.HELLO)"`, @@ -109,12 +110,12 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("hello param!")}}, - expected: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("hello param!")}}, + expected: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "hello param!"`, @@ -125,11 +126,11 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation array no task or task default winner pipeline", - original: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + original: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.HELLO[*])"}, @@ -138,12 +139,12 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("hello", "param", "!!!")}}, - expected: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("hello", "param", "!!!")}}, + expected: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "hello", "param", "!!!"}, @@ -154,11 +155,11 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation array finally task", - original: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + original: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.HELLO[*])"}, @@ -167,12 +168,12 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("hello", "param", "!!!")}}, - expected: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("hello", "param", "!!!")}}, + expected: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "hello", "param", "!!!"}, @@ -183,11 +184,11 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation object no task or task default winner pipeline", - original: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + original: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.myObject.key1) $(params.myObject.key2)"}, @@ -196,12 +197,12 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "myObject", Value: *v1beta1.NewObject(map[string]string{"key1": "hello", "key2": "world!"})}}, - expected: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + params: []v1.Param{{Name: "myObject", Value: *v1.NewObject(map[string]string{"key1": "hello", "key2": "world!"})}}, + expected: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "hello world!"}, @@ -213,11 +214,11 @@ func TestApplyParameters(t *testing.T) { wc: config.EnableAlphaAPIFields, }, { name: "parameter propagation object finally task", - original: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + original: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.myObject.key1) $(params.myObject.key2)"}, @@ -226,12 +227,12 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "myObject", Value: *v1beta1.NewObject(map[string]string{"key1": "hello", "key2": "world!"})}}, - expected: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + params: []v1.Param{{Name: "myObject", Value: *v1.NewObject(map[string]string{"key1": "hello", "key2": "world!"})}}, + expected: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "hello world!"}, @@ -243,15 +244,15 @@ func TestApplyParameters(t *testing.T) { wc: config.EnableAlphaAPIFields, }, { name: "parameter propagation with task default but no task winner pipeline", - original: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default param!"), + Default: v1.NewStructuredValues("default param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "$(params.HELLO)"`, @@ -260,16 +261,16 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("pipeline param!")}}, - expected: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("pipeline param!")}}, + expected: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default param!"), + Default: v1.NewStructuredValues("default param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "pipeline param!"`, @@ -280,15 +281,15 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation with task scoping Finally task", - original: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default param!"), + Default: v1.NewStructuredValues("default param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "$(params.HELLO)"`, @@ -297,16 +298,16 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("pipeline param!")}}, - expected: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("pipeline param!")}}, + expected: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default param!"), + Default: v1.NewStructuredValues("default param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "pipeline param!"`, @@ -317,15 +318,15 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation array with task default but no task winner pipeline", - original: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default", "param!"), + Default: v1.NewStructuredValues("default", "param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.HELLO)"}, @@ -334,16 +335,16 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("pipeline", "param!")}}, - expected: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("pipeline", "param!")}}, + expected: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default", "param!"), + Default: v1.NewStructuredValues("default", "param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "pipeline", "param!"}, @@ -354,15 +355,15 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation array with task scoping Finally task", - original: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default", "param!"), + Default: v1.NewStructuredValues("default", "param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.HELLO)"}, @@ -371,16 +372,16 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("pipeline", "param!")}}, - expected: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("pipeline", "param!")}}, + expected: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default", "param!"), + Default: v1.NewStructuredValues("default", "param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "pipeline", "param!"}, @@ -391,18 +392,18 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation array with task default and task winner task", - original: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "HELLO", Value: *v1beta1.NewStructuredValues("task", "param!")}, - }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "HELLO", Value: *v1.NewStructuredValues("task", "param!")}, + }, + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default", "param!"), + Default: v1.NewStructuredValues("default", "param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.HELLO)"}, @@ -411,19 +412,19 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("pipeline", "param!")}}, - expected: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "HELLO", Value: *v1beta1.NewStructuredValues("task", "param!")}, + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("pipeline", "param!")}}, + expected: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "HELLO", Value: *v1.NewStructuredValues("task", "param!")}, }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default", "param!"), + Default: v1.NewStructuredValues("default", "param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "task", "param!"}, @@ -434,18 +435,18 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "Finally task parameter propagation array with task default and task winner task", - original: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "HELLO", Value: *v1beta1.NewStructuredValues("task", "param!")}, - }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "HELLO", Value: *v1.NewStructuredValues("task", "param!")}, + }, + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default", "param!"), + Default: v1.NewStructuredValues("default", "param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.HELLO)"}, @@ -454,19 +455,19 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("pipeline", "param!")}}, - expected: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "HELLO", Value: *v1beta1.NewStructuredValues("task", "param!")}, + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("pipeline", "param!")}}, + expected: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "HELLO", Value: *v1.NewStructuredValues("task", "param!")}, }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default", "param!"), + Default: v1.NewStructuredValues("default", "param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "task", "param!"}, @@ -477,18 +478,18 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation with task default and task winner task", - original: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "HELLO", Value: *v1beta1.NewStructuredValues("task param!")}, - }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "HELLO", Value: *v1.NewStructuredValues("task param!")}, + }, + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default param!"), + Default: v1.NewStructuredValues("default param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "$(params.HELLO)"`, @@ -497,19 +498,19 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("pipeline param!")}}, - expected: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "HELLO", Value: *v1beta1.NewStructuredValues("task param!")}, + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("pipeline param!")}}, + expected: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "HELLO", Value: *v1.NewStructuredValues("task param!")}, }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default param!"), + Default: v1.NewStructuredValues("default param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "task param!"`, @@ -520,18 +521,18 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "Finally task parameter propagation with task default and task winner task", - original: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "HELLO", Value: *v1beta1.NewStructuredValues("task param!")}, - }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "HELLO", Value: *v1.NewStructuredValues("task param!")}, + }, + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default param!"), + Default: v1.NewStructuredValues("default param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "$(params.HELLO)"`, @@ -540,19 +541,19 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "HELLO", Value: *v1beta1.NewStructuredValues("pipeline param!")}}, - expected: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "HELLO", Value: *v1beta1.NewStructuredValues("task param!")}, + params: []v1.Param{{Name: "HELLO", Value: *v1.NewStructuredValues("pipeline param!")}}, + expected: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "HELLO", Value: *v1.NewStructuredValues("task param!")}, }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "HELLO", - Default: v1beta1.NewStructuredValues("default param!"), + Default: v1.NewStructuredValues("default param!"), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `#!/usr/bin/env bash\necho "task param!"`, @@ -563,22 +564,22 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter propagation object with task default but no task winner pipeline", - original: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "myobject", - Properties: map[string]v1beta1.PropertySpec{ + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "default", "key2": "param!", }), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.myobject.key1) $(params.myobject.key2)"}, @@ -587,26 +588,26 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{{Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "pipeline", "key2": "param!!", })}}, - expected: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + expected: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "myobject", - Properties: map[string]v1beta1.PropertySpec{ + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "default", "key2": "param!", }), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "pipeline param!!"}, @@ -618,22 +619,22 @@ func TestApplyParameters(t *testing.T) { wc: config.EnableAlphaAPIFields, }, { name: "Finally task parameter propagation object with task default but no task winner pipeline", - original: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + original: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "myobject", - Properties: map[string]v1beta1.PropertySpec{ + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "default", "key2": "param!", }), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.myobject.key1) $(params.myobject.key2)"}, @@ -642,26 +643,26 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{{Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "pipeline", "key2": "param!!", })}}, - expected: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + expected: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "myobject", - Properties: map[string]v1beta1.PropertySpec{ + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "default", "key2": "param!", }), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "pipeline param!!"}, @@ -673,28 +674,28 @@ func TestApplyParameters(t *testing.T) { wc: config.EnableAlphaAPIFields, }, { name: "parameter propagation object with task default and task winner task", - original: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + original: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "task", "key2": "param!", })}, }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "myobject", - Properties: map[string]v1beta1.PropertySpec{ + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "default", "key2": "param!!", }), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.myobject.key1) $(params.myobject.key2)"}, @@ -703,29 +704,29 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "myobject", Value: *v1beta1.NewObject(map[string]string{"key1": "pipeline", "key2": "param!!!"})}}, - expected: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{{Name: "myobject", Value: *v1.NewObject(map[string]string{"key1": "pipeline", "key2": "param!!!"})}}, + expected: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "task", "key2": "param!", })}, }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "myobject", - Properties: map[string]v1beta1.PropertySpec{ + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "default", "key2": "param!!", }), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "task param!"}, @@ -737,28 +738,28 @@ func TestApplyParameters(t *testing.T) { wc: config.EnableAlphaAPIFields, }, { name: "Finally task parameter propagation object with task default and task winner task", - original: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + original: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "task", "key2": "param!", })}, }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "myobject", - Properties: map[string]v1beta1.PropertySpec{ + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "default", "key2": "param!!", }), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "$(params.myobject.key1) $(params.myobject.key2)"}, @@ -767,29 +768,29 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "myobject", Value: *v1beta1.NewObject(map[string]string{"key1": "pipeline", "key2": "param!!!"})}}, - expected: v1beta1.PipelineSpec{ - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{{Name: "myobject", Value: *v1.NewObject(map[string]string{"key1": "pipeline", "key2": "param!!!"})}}, + expected: v1.PipelineSpec{ + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "task", "key2": "param!", })}, }, - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "myobject", - Properties: map[string]v1beta1.PropertySpec{ + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "default", "key2": "param!!", }), }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Args: []string{"#!/usr/bin/env bash\n", "echo", "task param!"}, @@ -801,27 +802,27 @@ func TestApplyParameters(t *testing.T) { wc: config.EnableAlphaAPIFields, }, { name: "single parameter with when expression", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - WhenExpressions: []v1beta1.WhenExpression{{ + Tasks: []v1.PipelineTask{{ + When: []v1.WhenExpression{{ Input: "$(params.first-param)", Operator: selection.In, Values: []string{"$(params.second-param)"}, }}, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - WhenExpressions: []v1beta1.WhenExpression{{ + Tasks: []v1.PipelineTask{{ + When: []v1.WhenExpression{{ Input: "default-value", Operator: selection.In, Values: []string{"second-value"}, @@ -830,55 +831,55 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "object parameter with when expression", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, "key3": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", "key3": "val3", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - WhenExpressions: []v1beta1.WhenExpression{{ + Tasks: []v1.PipelineTask{{ + When: []v1.WhenExpression{{ Input: "$(params.myobject.key1)", Operator: selection.In, Values: []string{"$(params.myobject.key2)", "$(params.myobject.key3)"}, }}, }}, }, - params: []v1beta1.Param{{Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{{Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", "key3": "val1", })}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, "key3": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", "key3": "val3", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - WhenExpressions: []v1beta1.WhenExpression{{ + Tasks: []v1.PipelineTask{{ + When: []v1.WhenExpression{{ Input: "val1", Operator: selection.In, Values: []string{"val2", "val1"}, @@ -887,138 +888,138 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "string pipeline parameter nested inside task parameter", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.$(params.first-param))")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.$(params.second-param))")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(input.workspace.$(params.first-param))")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("$(input.workspace.$(params.second-param))")}, }, }}, }, params: nil, // no parameter values. - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.default-value)")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.default-value)")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(input.workspace.default-value)")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("$(input.workspace.default-value)")}, }, }}, }, }, { name: "array pipeline parameter nested inside task parameter", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default", "array", "value")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default", "array", "value")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("firstelement", "$(params.first-param)")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("firstelement", "$(params.second-param)")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("firstelement", "$(params.first-param)")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("firstelement", "$(params.second-param)")}, }, }}, }, - params: []v1beta1.Param{ - {Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "array")}, + params: []v1.Param{ + {Name: "second-param", Value: *v1.NewStructuredValues("second-value", "array")}, }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default", "array", "value")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default", "array", "value")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("firstelement", "default", "array", "value")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("firstelement", "second-value", "array")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("firstelement", "default", "array", "value")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("firstelement", "second-value", "array")}, }, }}, }, }, { name: "object pipeline parameter nested inside task parameter", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.$(params.myobject.key1))")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.$(params.myobject.key2))")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(input.workspace.$(params.myobject.key1))")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("$(input.workspace.$(params.myobject.key2))")}, }, }}, }, params: nil, // no parameter values. - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.val1)")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.val2)")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(input.workspace.val1)")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("$(input.workspace.val2)")}, }, }}, }, }, { name: "parameter evaluation with final tasks", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param)")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.second-param)")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param)")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("$(params.second-param)")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "$(params.first-param)", Operator: selection.In, Values: []string{"$(params.second-param)"}, }}, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("second-value")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("second-value")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "default-value", Operator: selection.In, Values: []string{"second-value"}, @@ -1027,47 +1028,47 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter evaluation with both tasks and final tasks", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param)")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.second-param)")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param)")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("$(params.second-param)")}, }, }}, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param)")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.second-param)")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param)")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("$(params.second-param)")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "$(params.first-param)", Operator: selection.In, Values: []string{"$(params.second-param)"}, }}, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("second-value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("second-value")}, }, }}, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("second-value")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("second-value")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "default-value", Operator: selection.In, Values: []string{"second-value"}, @@ -1076,70 +1077,70 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "object parameter evaluation with both tasks and final tasks", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.myobject.key1)")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.myobject.key2)")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("$(params.myobject.key1)")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("$(params.myobject.key2)")}, }, }}, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.myobject.key1)")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.myobject.key2)")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("$(params.myobject.key1)")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("$(params.myobject.key2)")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "$(params.myobject.key1)", Operator: selection.In, Values: []string{"$(params.myobject.key2)"}, }}, }}, }, - params: []v1beta1.Param{{Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{{Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "foo", "key2": "bar", })}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("foo")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("bar")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("foo")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("bar")}, }, }}, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("foo")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("bar")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("foo")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("bar")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "foo", Operator: selection.In, Values: []string{"bar"}, @@ -1148,57 +1149,57 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "parameter references with bracket notation and special characters", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first.param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second/param", Type: v1beta1.ParamTypeString}, - {Name: "third.param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "fourth/param", Type: v1beta1.ParamTypeString}, - }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues(`$(params["first.param"])`)}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues(`$(params["second/param"])`)}, - {Name: "first-task-third-param", Value: *v1beta1.NewStructuredValues(`$(params['third.param'])`)}, - {Name: "first-task-fourth-param", Value: *v1beta1.NewStructuredValues(`$(params['fourth/param'])`)}, - {Name: "first-task-fifth-param", Value: *v1beta1.NewStructuredValues("static value")}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first.param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second/param", Type: v1.ParamTypeString}, + {Name: "third.param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "fourth/param", Type: v1.ParamTypeString}, + }, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues(`$(params["first.param"])`)}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues(`$(params["second/param"])`)}, + {Name: "first-task-third-param", Value: *v1.NewStructuredValues(`$(params['third.param'])`)}, + {Name: "first-task-fourth-param", Value: *v1.NewStructuredValues(`$(params['fourth/param'])`)}, + {Name: "first-task-fifth-param", Value: *v1.NewStructuredValues("static value")}, }, }}, }, - params: []v1beta1.Param{ - {Name: "second/param", Value: *v1beta1.NewStructuredValues("second-value")}, - {Name: "fourth/param", Value: *v1beta1.NewStructuredValues("fourth-value")}, - }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first.param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second/param", Type: v1beta1.ParamTypeString}, - {Name: "third.param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "fourth/param", Type: v1beta1.ParamTypeString}, - }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("second-value")}, - {Name: "first-task-third-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "first-task-fourth-param", Value: *v1beta1.NewStructuredValues("fourth-value")}, - {Name: "first-task-fifth-param", Value: *v1beta1.NewStructuredValues("static value")}, + params: []v1.Param{ + {Name: "second/param", Value: *v1.NewStructuredValues("second-value")}, + {Name: "fourth/param", Value: *v1.NewStructuredValues("fourth-value")}, + }, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first.param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second/param", Type: v1.ParamTypeString}, + {Name: "third.param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "fourth/param", Type: v1.ParamTypeString}, + }, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("second-value")}, + {Name: "first-task-third-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "first-task-fourth-param", Value: *v1.NewStructuredValues("fourth-value")}, + {Name: "first-task-fifth-param", Value: *v1.NewStructuredValues("static value")}, }, }}, }, }, { name: "single parameter in workspace subpath", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param)")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param)")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("static value")}, }, - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{ + Workspaces: []v1.WorkspacePipelineTaskBinding{ { Name: "first-workspace", Workspace: "first-workspace", @@ -1207,18 +1208,18 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("static value")}, }, - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{ + Workspaces: []v1.WorkspacePipelineTaskBinding{ { Name: "first-workspace", Workspace: "first-workspace", @@ -1229,27 +1230,27 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "object parameter in workspace subpath", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.myobject.key1)")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(params.myobject.key1)")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("static value")}, }, - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{ + Workspaces: []v1.WorkspacePipelineTaskBinding{ { Name: "first-workspace", Workspace: "first-workspace", @@ -1258,31 +1259,31 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{{Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "foo", "key2": "bar", })}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("foo")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("foo")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("static value")}, }, - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{ + Workspaces: []v1.WorkspacePipelineTaskBinding{ { Name: "first-workspace", Workspace: "first-workspace", @@ -1293,40 +1294,40 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "single parameter with resolver", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewArrayOrString("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, - }, - Tasks: []v1beta1.PipelineTask{{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, + }, + Tasks: []v1.PipelineTask{{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "first-resolver-param", - Value: *v1beta1.NewArrayOrString("$(params.first-param)"), + Value: *v1.NewStructuredValues("$(params.first-param)"), }, { Name: "second-resolver-param", - Value: *v1beta1.NewArrayOrString("$(params.second-param)"), + Value: *v1.NewStructuredValues("$(params.second-param)"), }}, }, }, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewArrayOrString("second-value")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewArrayOrString("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + Tasks: []v1.PipelineTask{{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "first-resolver-param", - Value: *v1beta1.NewArrayOrString("default-value"), + Value: *v1.NewStructuredValues("default-value"), }, { Name: "second-resolver-param", - Value: *v1beta1.NewArrayOrString("second-value"), + Value: *v1.NewStructuredValues("second-value"), }}, }, }, @@ -1334,74 +1335,74 @@ func TestApplyParameters(t *testing.T) { }, }, { name: "object parameter with resolver", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, "key3": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", "key3": "val3", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + Tasks: []v1.PipelineTask{{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "first-resolver-param", - Value: *v1beta1.NewArrayOrString("$(params.myobject.key1)"), + Value: *v1.NewStructuredValues("$(params.myobject.key1)"), }, { Name: "second-resolver-param", - Value: *v1beta1.NewArrayOrString("$(params.myobject.key2)"), + Value: *v1.NewStructuredValues("$(params.myobject.key2)"), }, { Name: "third-resolver-param", - Value: *v1beta1.NewArrayOrString("$(params.myobject.key3)"), + Value: *v1.NewStructuredValues("$(params.myobject.key3)"), }}, }, }, }}, }, - params: []v1beta1.Param{{Name: "myobject", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{{Name: "myobject", Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", "key3": "val1", })}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "myobject", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, "key3": {Type: "string"}, }, - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", "key3": "val3", }), }, }, - Tasks: []v1beta1.PipelineTask{{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + Tasks: []v1.PipelineTask{{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "first-resolver-param", - Value: *v1beta1.NewArrayOrString("val1"), + Value: *v1.NewStructuredValues("val1"), }, { Name: "second-resolver-param", - Value: *v1beta1.NewArrayOrString("val2"), + Value: *v1.NewStructuredValues("val2"), }, { Name: "third-resolver-param", - Value: *v1beta1.NewArrayOrString("val1"), + Value: *v1.NewStructuredValues("val1"), }}, }, }, @@ -1410,17 +1411,17 @@ func TestApplyParameters(t *testing.T) { wc: config.EnableAlphaAPIFields, }, { name: "single parameter in finally workspace subpath", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param)")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("static value")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param)")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("static value")}, }, - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{ + Workspaces: []v1.WorkspacePipelineTaskBinding{ { Name: "first-workspace", Workspace: "first-workspace", @@ -1429,18 +1430,18 @@ func TestApplyParameters(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeString, Default: v1beta1.NewStructuredValues("default-value")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeString, Default: v1.NewStructuredValues("default-value")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("static value")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("static value")}, }, - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{ + Workspaces: []v1.WorkspacePipelineTaskBinding{ { Name: "first-workspace", Workspace: "first-workspace", @@ -1452,38 +1453,38 @@ func TestApplyParameters(t *testing.T) { }, { name: "tasks with the same parameter name but referencing different values", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Default: &v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Default: &v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "a", }, - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, - Tasks: []v1beta1.PipelineTask{ + Tasks: []v1.PipelineTask{ { Name: "previous-task-with-result", }, { Name: "print-msg", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, }, }, - Params: []v1beta1.Param{ + Params: []v1.Param{ { Name: "param1", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "$(tasks.previous-task-with-result.results.Output)", }, }, @@ -1491,21 +1492,21 @@ func TestApplyParameters(t *testing.T) { }, { Name: "print-msg-2", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, }, }, - Params: []v1beta1.Param{ + Params: []v1.Param{ { Name: "param1", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "$(params.param1)", }, }, @@ -1513,38 +1514,38 @@ func TestApplyParameters(t *testing.T) { }, }, }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Default: &v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Default: &v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "a", }, - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, - Tasks: []v1beta1.PipelineTask{ + Tasks: []v1.PipelineTask{ { Name: "previous-task-with-result", }, { Name: "print-msg", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, }, }, - Params: []v1beta1.Param{ + Params: []v1.Param{ { Name: "param1", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "$(tasks.previous-task-with-result.results.Output)", }, }, @@ -1552,21 +1553,21 @@ func TestApplyParameters(t *testing.T) { }, { Name: "print-msg-2", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, }, }, - Params: []v1beta1.Param{ + Params: []v1.Param{ { Name: "param1", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "a", }, }, @@ -1577,40 +1578,40 @@ func TestApplyParameters(t *testing.T) { }, { name: "finally tasks with the same parameter name but referencing different values", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Default: &v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Default: &v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "a", }, - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, - Tasks: []v1beta1.PipelineTask{ + Tasks: []v1.PipelineTask{ { Name: "previous-task-with-result", }, }, - Finally: []v1beta1.PipelineTask{ + Finally: []v1.PipelineTask{ { Name: "print-msg", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, }, }, - Params: []v1beta1.Param{ + Params: []v1.Param{ { Name: "param1", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "$(tasks.previous-task-with-result.results.Output)", }, }, @@ -1618,21 +1619,21 @@ func TestApplyParameters(t *testing.T) { }, { Name: "print-msg-2", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, }, }, - Params: []v1beta1.Param{ + Params: []v1.Param{ { Name: "param1", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "$(params.param1)", }, }, @@ -1640,40 +1641,40 @@ func TestApplyParameters(t *testing.T) { }, }, }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Default: &v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Default: &v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "a", }, - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, - Tasks: []v1beta1.PipelineTask{ + Tasks: []v1.PipelineTask{ { Name: "previous-task-with-result", }, }, - Finally: []v1beta1.PipelineTask{ + Finally: []v1.PipelineTask{ { Name: "print-msg", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, }, }, - Params: []v1beta1.Param{ + Params: []v1.Param{ { Name: "param1", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "$(tasks.previous-task-with-result.results.Output)", }, }, @@ -1681,21 +1682,21 @@ func TestApplyParameters(t *testing.T) { }, { Name: "print-msg-2", - TaskSpec: &v1beta1.EmbeddedTask{ - TaskSpec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{ + TaskSpec: &v1.EmbeddedTask{ + TaskSpec: v1.TaskSpec{ + Params: []v1.ParamSpec{ { Name: "param1", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, }, }, - Params: []v1beta1.Param{ + Params: []v1.Param{ { Name: "param1", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "a", }, }, @@ -1712,8 +1713,8 @@ func TestApplyParameters(t *testing.T) { } t.Run(tt.name, func(t *testing.T) { t.Parallel() - run := &v1beta1.PipelineRun{ - Spec: v1beta1.PipelineRunSpec{ + run := &v1.PipelineRun{ + Spec: v1.PipelineRunSpec{ Params: tt.params, }, } @@ -1732,61 +1733,61 @@ func TestApplyParameters_ArrayIndexing(t *testing.T) { ctx = config.ToContext(ctx, cfg) for _, tt := range []struct { name string - original v1beta1.PipelineSpec - params []v1beta1.Param - expected v1beta1.PipelineSpec + original v1.PipelineSpec + params []v1.Param + expected v1.PipelineSpec }{{ name: "single parameter", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param[1])")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.second-param[0])")}, - {Name: "first-task-third-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param[1])")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("$(params.second-param[0])")}, + {Name: "first-task-third-param", Value: *v1.NewStructuredValues("static value")}, }, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "second-value-again")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value", "second-value-again")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("default-value-again")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("second-value")}, - {Name: "first-task-third-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("default-value-again")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("second-value")}, + {Name: "first-task-third-param", Value: *v1.NewStructuredValues("static value")}, }, }}, }, }, { name: "single parameter with when expression", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - WhenExpressions: []v1beta1.WhenExpression{{ + Tasks: []v1.PipelineTask{{ + When: []v1.WhenExpression{{ Input: "$(params.first-param[1])", Operator: selection.In, Values: []string{"$(params.second-param[0])"}, }}, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "second-value-again")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeString}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value", "second-value-again")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeString}, }, - Tasks: []v1beta1.PipelineTask{{ - WhenExpressions: []v1beta1.WhenExpression{{ + Tasks: []v1.PipelineTask{{ + When: []v1.WhenExpression{{ Input: "default-value-again", Operator: selection.In, Values: []string{"second-value"}, @@ -1795,91 +1796,91 @@ func TestApplyParameters_ArrayIndexing(t *testing.T) { }, }, { name: "pipeline parameter nested inside task parameter", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.$(params.first-param[0]))")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.$(params.second-param[1]))")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(input.workspace.$(params.first-param[0]))")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("$(input.workspace.$(params.second-param[1]))")}, }, }}, }, params: nil, // no parameter values. - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.default-value)")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("$(input.workspace.default-value-again)")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(input.workspace.default-value)")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("$(input.workspace.default-value-again)")}, }, }}, }, }, { name: "array parameter", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default", "array", "value")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default", "array", "value")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("firstelement", "$(params.first-param)")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("firstelement", "$(params.second-param[0])")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("firstelement", "$(params.first-param)")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("firstelement", "$(params.second-param[0])")}, }, }}, }, - params: []v1beta1.Param{ - {Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "array")}, + params: []v1.Param{ + {Name: "second-param", Value: *v1.NewStructuredValues("second-value", "array")}, }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default", "array", "value")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default", "array", "value")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("firstelement", "default", "array", "value")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("firstelement", "second-value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("firstelement", "default", "array", "value")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("firstelement", "second-value")}, }, }}, }, }, { name: "parameter evaluation with final tasks", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param[0])")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.second-param[1])")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param[0])")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("$(params.second-param[1])")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "$(params.first-param[0])", Operator: selection.In, Values: []string{"$(params.second-param[1])"}, }}, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "second-value-again")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value", "second-value-again")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("second-value-again")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("second-value-again")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "default-value", Operator: selection.In, Values: []string{"second-value-again"}, @@ -1888,47 +1889,47 @@ func TestApplyParameters_ArrayIndexing(t *testing.T) { }, }, { name: "parameter evaluation with both tasks and final tasks", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param[0])")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.second-param[1])")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param[0])")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("$(params.second-param[1])")}, }, }}, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param[0])")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.second-param[1])")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param[0])")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("$(params.second-param[1])")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "$(params.first-param[0])", Operator: selection.In, Values: []string{"$(params.second-param[1])"}, }}, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "second-value-again")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value", "second-value-again")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("second-value-again")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("second-value-again")}, }, }}, - Finally: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("second-value-again")}, + Finally: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "final-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "final-task-second-param", Value: *v1.NewStructuredValues("second-value-again")}, }, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "default-value", Operator: selection.In, Values: []string{"second-value-again"}, @@ -1937,57 +1938,57 @@ func TestApplyParameters_ArrayIndexing(t *testing.T) { }, }, { name: "parameter references with bracket notation and special characters", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first.param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second/param", Type: v1beta1.ParamTypeArray}, - {Name: "third.param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "fourth/param", Type: v1beta1.ParamTypeArray}, - }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues(`$(params["first.param"][0])`)}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues(`$(params["second/param"][0])`)}, - {Name: "first-task-third-param", Value: *v1beta1.NewStructuredValues(`$(params['third.param'][1])`)}, - {Name: "first-task-fourth-param", Value: *v1beta1.NewStructuredValues(`$(params['fourth/param'][1])`)}, - {Name: "first-task-fifth-param", Value: *v1beta1.NewStructuredValues("static value")}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first.param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second/param", Type: v1.ParamTypeArray}, + {Name: "third.param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "fourth/param", Type: v1.ParamTypeArray}, + }, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues(`$(params["first.param"][0])`)}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues(`$(params["second/param"][0])`)}, + {Name: "first-task-third-param", Value: *v1.NewStructuredValues(`$(params['third.param'][1])`)}, + {Name: "first-task-fourth-param", Value: *v1.NewStructuredValues(`$(params['fourth/param'][1])`)}, + {Name: "first-task-fifth-param", Value: *v1.NewStructuredValues("static value")}, }, }}, }, - params: []v1beta1.Param{ - {Name: "second/param", Value: *v1beta1.NewStructuredValues("second-value", "second-value-again")}, - {Name: "fourth/param", Value: *v1beta1.NewStructuredValues("fourth-value", "fourth-value-again")}, - }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first.param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second/param", Type: v1beta1.ParamTypeArray}, - {Name: "third.param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "fourth/param", Type: v1beta1.ParamTypeArray}, - }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("second-value")}, - {Name: "first-task-third-param", Value: *v1beta1.NewStructuredValues("default-value-again")}, - {Name: "first-task-fourth-param", Value: *v1beta1.NewStructuredValues("fourth-value-again")}, - {Name: "first-task-fifth-param", Value: *v1beta1.NewStructuredValues("static value")}, + params: []v1.Param{ + {Name: "second/param", Value: *v1.NewStructuredValues("second-value", "second-value-again")}, + {Name: "fourth/param", Value: *v1.NewStructuredValues("fourth-value", "fourth-value-again")}, + }, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first.param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second/param", Type: v1.ParamTypeArray}, + {Name: "third.param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "fourth/param", Type: v1.ParamTypeArray}, + }, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("second-value")}, + {Name: "first-task-third-param", Value: *v1.NewStructuredValues("default-value-again")}, + {Name: "first-task-fourth-param", Value: *v1.NewStructuredValues("fourth-value-again")}, + {Name: "first-task-fifth-param", Value: *v1.NewStructuredValues("static value")}, }, }}, }, }, { name: "single parameter in workspace subpath", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param[0])")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param[0])")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("static value")}, }, - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{ + Workspaces: []v1.WorkspacePipelineTaskBinding{ { Name: "first-workspace", Workspace: "first-workspace", @@ -1996,18 +1997,18 @@ func TestApplyParameters_ArrayIndexing(t *testing.T) { }, }}, }, - params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "second-value-again")}}, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, - {Name: "second-param", Type: v1beta1.ParamTypeArray}, + params: []v1.Param{{Name: "second-param", Value: *v1.NewStructuredValues("second-value", "second-value-again")}}, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{ + {Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1.ParamTypeArray}, }, - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{ - {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("default-value")}, - {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("static value")}, + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{ + {Name: "first-task-first-param", Value: *v1.NewStructuredValues("default-value")}, + {Name: "first-task-second-param", Value: *v1.NewStructuredValues("static value")}, }, - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{ + Workspaces: []v1.WorkspacePipelineTaskBinding{ { Name: "first-workspace", Workspace: "first-workspace", @@ -2021,8 +2022,8 @@ func TestApplyParameters_ArrayIndexing(t *testing.T) { tt := tt // capture range variable t.Run(tt.name, func(t *testing.T) { t.Parallel() - run := &v1beta1.PipelineRun{ - Spec: v1beta1.PipelineRunSpec{ + run := &v1.PipelineRun{ + Spec: v1.PipelineRunSpec{ Params: tt.params, }, } @@ -2041,118 +2042,118 @@ func TestApplyReplacementsMatrix(t *testing.T) { ctx = config.ToContext(ctx, cfg) for _, tt := range []struct { name string - original v1beta1.PipelineSpec - params []v1beta1.Param - expected v1beta1.PipelineSpec + original v1.PipelineSpec + params []v1.Param + expected v1.PipelineSpec }{{ name: "matrix params replacements", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{{ - Name: "foo", Type: v1beta1.ParamTypeString, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{{ + Name: "foo", Type: v1.ParamTypeString, }, { - Name: "bar", Type: v1beta1.ParamTypeArray, + Name: "bar", Type: v1.ParamTypeArray, }, { - Name: "rad", Type: v1beta1.ParamTypeObject, + Name: "rad", Type: v1.ParamTypeObject, }}, - Tasks: []v1beta1.PipelineTask{{ - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Tasks: []v1.PipelineTask{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ // string replacements from string param, array param and object param - Name: "first-param", Value: *v1beta1.NewStructuredValues("$(params.foo)", "$(params.bar[0])", "$(params.rad.key1)"), + Name: "first-param", Value: *v1.NewStructuredValues("$(params.foo)", "$(params.bar[0])", "$(params.rad.key1)"), }, { // array replacement from array param - Name: "second-param", Value: *v1beta1.NewStructuredValues("$(params.bar)"), + Name: "second-param", Value: *v1.NewStructuredValues("$(params.bar)"), }}, }, }}, }, - params: []v1beta1.Param{ - {Name: "foo", Value: *v1beta1.NewStructuredValues("foo")}, - {Name: "bar", Value: *v1beta1.NewStructuredValues("b", "a", "r")}, - {Name: "rad", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{ + {Name: "foo", Value: *v1.NewStructuredValues("foo")}, + {Name: "bar", Value: *v1.NewStructuredValues("b", "a", "r")}, + {Name: "rad", Value: *v1.NewObject(map[string]string{ "key1": "r", "key2": "a", "key3": "d", })}, }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{{ - Name: "foo", Type: v1beta1.ParamTypeString, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{{ + Name: "foo", Type: v1.ParamTypeString, }, { - Name: "bar", Type: v1beta1.ParamTypeArray, + Name: "bar", Type: v1.ParamTypeArray, }, { - Name: "rad", Type: v1beta1.ParamTypeObject, + Name: "rad", Type: v1.ParamTypeObject, }}, - Tasks: []v1beta1.PipelineTask{{ - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Tasks: []v1.PipelineTask{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ // string replacements from string param, array param and object param - Name: "first-param", Value: *v1beta1.NewStructuredValues("foo", "b", "r"), + Name: "first-param", Value: *v1.NewStructuredValues("foo", "b", "r"), }, { // array replacement from array param - Name: "second-param", Value: *v1beta1.NewStructuredValues("b", "a", "r"), + Name: "second-param", Value: *v1.NewStructuredValues("b", "a", "r"), }}, }, }}, }, }, { name: "matrix include params replacement", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{{ - Name: "foo", Type: v1beta1.ParamTypeString, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{{ + Name: "foo", Type: v1.ParamTypeString, }, { - Name: "bar", Type: v1beta1.ParamTypeArray, + Name: "bar", Type: v1.ParamTypeArray, }, { - Name: "rad", Type: v1beta1.ParamTypeObject, + Name: "rad", Type: v1.ParamTypeObject, }}, - Tasks: []v1beta1.PipelineTask{{ - Matrix: &v1beta1.Matrix{ - Include: []v1beta1.IncludeParams{{ + Tasks: []v1.PipelineTask{{ + Matrix: &v1.Matrix{ + Include: []v1.MatrixInclude{{ Name: "build-1", - Params: v1beta1.Params{{ + Params: v1.Params{{ // string replacements from string param - Name: "first-param", Value: *v1beta1.NewStructuredValues("$(params.foo)"), + Name: "first-param", Value: *v1.NewStructuredValues("$(params.foo)"), }, { // string replacements from array param - Name: "second-param", Value: *v1beta1.NewStructuredValues("$(params.bar[0])"), + Name: "second-param", Value: *v1.NewStructuredValues("$(params.bar[0])"), }, { // string replacements from object param - Name: "third-param", Value: *v1beta1.NewStructuredValues("$(params.rad.key1)"), + Name: "third-param", Value: *v1.NewStructuredValues("$(params.rad.key1)"), }}, }}, }, }}, }, - params: []v1beta1.Param{ - {Name: "foo", Value: *v1beta1.NewStructuredValues("foo")}, - {Name: "bar", Value: *v1beta1.NewStructuredValues("b", "a", "r")}, - {Name: "rad", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{ + {Name: "foo", Value: *v1.NewStructuredValues("foo")}, + {Name: "bar", Value: *v1.NewStructuredValues("b", "a", "r")}, + {Name: "rad", Value: *v1.NewObject(map[string]string{ "key1": "r", "key2": "a", "key3": "d", })}, }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{{ - Name: "foo", Type: v1beta1.ParamTypeString, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{{ + Name: "foo", Type: v1.ParamTypeString, }, { - Name: "bar", Type: v1beta1.ParamTypeArray, + Name: "bar", Type: v1.ParamTypeArray, }, { - Name: "rad", Type: v1beta1.ParamTypeObject, + Name: "rad", Type: v1.ParamTypeObject, }}, - Tasks: []v1beta1.PipelineTask{{ - Matrix: &v1beta1.Matrix{ - Include: []v1beta1.IncludeParams{{ + Tasks: []v1.PipelineTask{{ + Matrix: &v1.Matrix{ + Include: []v1.MatrixInclude{{ Name: "build-1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ // string replacements from string param - Name: "first-param", Value: *v1beta1.NewStructuredValues("foo"), + Name: "first-param", Value: *v1.NewStructuredValues("foo"), }, { // string replacements from array param - Name: "second-param", Value: *v1beta1.NewStructuredValues("b"), + Name: "second-param", Value: *v1.NewStructuredValues("b"), }, { // string replacements from object param - Name: "third-param", Value: *v1beta1.NewStructuredValues("r"), + Name: "third-param", Value: *v1.NewStructuredValues("r"), }}, }}, }, @@ -2160,113 +2161,113 @@ func TestApplyReplacementsMatrix(t *testing.T) { }, }, { name: "matrix params with final tasks", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{{ - Name: "foo", Type: v1beta1.ParamTypeString, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{{ + Name: "foo", Type: v1.ParamTypeString, }, { - Name: "bar", Type: v1beta1.ParamTypeArray, + Name: "bar", Type: v1.ParamTypeArray, }, { - Name: "rad", Type: v1beta1.ParamTypeObject, + Name: "rad", Type: v1.ParamTypeObject, }}, - Finally: []v1beta1.PipelineTask{{ - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Finally: []v1.PipelineTask{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ // string replacements from string param, array param and object param - Name: "first-param", Value: *v1beta1.NewStructuredValues("$(params.foo)", "$(params.bar[0])", "$(params.rad.key1)"), + Name: "first-param", Value: *v1.NewStructuredValues("$(params.foo)", "$(params.bar[0])", "$(params.rad.key1)"), }, { // array replacement from array param - Name: "second-param", Value: *v1beta1.NewStructuredValues("$(params.bar)"), + Name: "second-param", Value: *v1.NewStructuredValues("$(params.bar)"), }}, }, }}, }, - params: []v1beta1.Param{ - {Name: "foo", Value: *v1beta1.NewStructuredValues("foo")}, - {Name: "bar", Value: *v1beta1.NewStructuredValues("b", "a", "r")}, - {Name: "rad", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{ + {Name: "foo", Value: *v1.NewStructuredValues("foo")}, + {Name: "bar", Value: *v1.NewStructuredValues("b", "a", "r")}, + {Name: "rad", Value: *v1.NewObject(map[string]string{ "key1": "r", "key2": "a", "key3": "d", })}, }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{{ - Name: "foo", Type: v1beta1.ParamTypeString, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{{ + Name: "foo", Type: v1.ParamTypeString, }, { - Name: "bar", Type: v1beta1.ParamTypeArray, + Name: "bar", Type: v1.ParamTypeArray, }, { - Name: "rad", Type: v1beta1.ParamTypeObject, + Name: "rad", Type: v1.ParamTypeObject, }}, - Finally: []v1beta1.PipelineTask{{ - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Finally: []v1.PipelineTask{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ // string replacements from string param, array param and object param - Name: "first-param", Value: *v1beta1.NewStructuredValues("foo", "b", "r"), + Name: "first-param", Value: *v1.NewStructuredValues("foo", "b", "r"), }, { // array replacement from array param - Name: "second-param", Value: *v1beta1.NewStructuredValues("b", "a", "r"), + Name: "second-param", Value: *v1.NewStructuredValues("b", "a", "r"), }}, }, }}, }, }, { name: "matrix include params with final tasks", - original: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{{ - Name: "foo", Type: v1beta1.ParamTypeString, + original: v1.PipelineSpec{ + Params: []v1.ParamSpec{{ + Name: "foo", Type: v1.ParamTypeString, }, { - Name: "bar", Type: v1beta1.ParamTypeArray, + Name: "bar", Type: v1.ParamTypeArray, }, { - Name: "rad", Type: v1beta1.ParamTypeObject, + Name: "rad", Type: v1.ParamTypeObject, }}, - Finally: []v1beta1.PipelineTask{{ - Matrix: &v1beta1.Matrix{ - Include: []v1beta1.IncludeParams{{ + Finally: []v1.PipelineTask{{ + Matrix: &v1.Matrix{ + Include: []v1.MatrixInclude{{ Name: "build-1", - Params: v1beta1.Params{{ + Params: v1.Params{{ // string replacements from string param - Name: "first-param", Value: *v1beta1.NewStructuredValues("$(params.foo)"), + Name: "first-param", Value: *v1.NewStructuredValues("$(params.foo)"), }, { // string replacements from array param - Name: "second-param", Value: *v1beta1.NewStructuredValues("$(params.bar[0])"), + Name: "second-param", Value: *v1.NewStructuredValues("$(params.bar[0])"), }, { // string replacements from object param - Name: "third-param", Value: *v1beta1.NewStructuredValues("$(params.rad.key1)"), + Name: "third-param", Value: *v1.NewStructuredValues("$(params.rad.key1)"), }}, }}, }, }}, }, - params: []v1beta1.Param{ - {Name: "foo", Value: *v1beta1.NewStructuredValues("foo")}, - {Name: "bar", Value: *v1beta1.NewStructuredValues("b", "a", "r")}, - {Name: "rad", Value: *v1beta1.NewObject(map[string]string{ + params: []v1.Param{ + {Name: "foo", Value: *v1.NewStructuredValues("foo")}, + {Name: "bar", Value: *v1.NewStructuredValues("b", "a", "r")}, + {Name: "rad", Value: *v1.NewObject(map[string]string{ "key1": "r", "key2": "a", "key3": "d", })}, }, - expected: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{{ - Name: "foo", Type: v1beta1.ParamTypeString, + expected: v1.PipelineSpec{ + Params: []v1.ParamSpec{{ + Name: "foo", Type: v1.ParamTypeString, }, { - Name: "bar", Type: v1beta1.ParamTypeArray, + Name: "bar", Type: v1.ParamTypeArray, }, { - Name: "rad", Type: v1beta1.ParamTypeObject, + Name: "rad", Type: v1.ParamTypeObject, }}, - Finally: []v1beta1.PipelineTask{{ - Matrix: &v1beta1.Matrix{ - Include: []v1beta1.IncludeParams{{ + Finally: []v1.PipelineTask{{ + Matrix: &v1.Matrix{ + Include: []v1.MatrixInclude{{ Name: "build-1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ // string replacements from string param - Name: "first-param", Value: *v1beta1.NewStructuredValues("foo"), + Name: "first-param", Value: *v1.NewStructuredValues("foo"), }, { // string replacements from array param - Name: "second-param", Value: *v1beta1.NewStructuredValues("b"), + Name: "second-param", Value: *v1.NewStructuredValues("b"), }, { // string replacements from object param - Name: "third-param", Value: *v1beta1.NewStructuredValues("r"), + Name: "third-param", Value: *v1.NewStructuredValues("r"), }}, }}, }, @@ -2277,8 +2278,8 @@ func TestApplyReplacementsMatrix(t *testing.T) { tt := tt // capture range variable t.Run(tt.name, func(t *testing.T) { t.Parallel() - run := &v1beta1.PipelineRun{ - Spec: v1beta1.PipelineRunSpec{ + run := &v1.PipelineRun{ + Spec: v1.PipelineRunSpec{ Params: tt.params, }, } @@ -2299,157 +2300,157 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }{{ name: "Test result substitution on minimal variable substitution expression - params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "a.Result", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results["a.Result"])`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results["a.Result"])`), }}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("aResultValue"), + Value: *v1.NewStructuredValues("aResultValue"), }}, }, }}, }, { name: "Test array indexing result substitution on minimal variable substitution expression - params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "a.Result", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][1])`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][1])`), }}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("arrayResultValueTwo"), + Value: *v1.NewStructuredValues("arrayResultValueTwo"), }}, }, }}, }, { name: "Test array indexing result substitution out of bound - params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "a.Result", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][3])`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][3])`), }}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", // index validation is done in ResolveResultRefs() before ApplyTaskResults() - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][3])`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][3])`), }}, }, }}, }, { name: "Test array result substitution on minimal variable substitution expression - params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "a.Result", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{`$(tasks.aTask.results["a.Result"][*])`}, }, }}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), }}, }, }}, }, { name: "Test object result as a whole substitution - params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), - ResultReference: v1beta1.ResultRef{ + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "resultName", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results.resultName[*])`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results.resultName[*])`), }}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", // index validation is done in ResolveResultRefs() before ApplyTaskResults() - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), @@ -2459,148 +2460,148 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, { name: "Test object result element substitution - params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), - ResultReference: v1beta1.ResultRef{ + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "resultName", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results.resultName.key1)`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results.resultName.key1)`), }}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", // index validation is done in ResolveResultRefs() before ApplyTaskResults() - Value: *v1beta1.NewStructuredValues("val1"), + Value: *v1.NewStructuredValues("val1"), }}, }, }}, }, { name: "Test result substitution on minimal variable substitution expression - matrix", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "a.Result", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results["a.Result"])`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results["a.Result"])`), }}}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("aResultValue"), + Value: *v1.NewStructuredValues("aResultValue"), }}}, }, }}, }, { name: "Test array indexing result substitution on minimal variable substitution expression - matrix", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "a.Result", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][1])`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][1])`), }}}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("arrayResultValueTwo"), + Value: *v1.NewStructuredValues("arrayResultValueTwo"), }}}, }, }}, }, { name: "Test array indexing result substitution out of bound - matrix", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "a.Result", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][3])`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][3])`), }}}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][3])`), + Value: *v1.NewStructuredValues(`$(tasks.aTask.results["a.Result"][3])`), }}}, }, }}, }, { name: "Test array result substitution on minimal variable substitution expression - when expressions", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ // Note that Input doesn't support array replacement. Input: "anInput", Operator: selection.In, @@ -2609,10 +2610,10 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ Input: "anInput", Operator: selection.In, Values: []string{"arrayResultValueOne", "arrayResultValueTwo"}, @@ -2622,18 +2623,18 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, { name: "Test result substitution on minimal variable substitution expression - when expressions", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ Input: "$(tasks.aTask.results.aResult)", Operator: selection.In, Values: []string{"$(tasks.aTask.results.aResult)"}, @@ -2641,10 +2642,10 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ Input: "aResultValue", Operator: selection.In, Values: []string{"aResultValue"}, @@ -2654,18 +2655,18 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, { name: "Test array indexing result substitution on minimal variable substitution expression - when expressions", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ Input: "$(tasks.aTask.results.aResult[1])", Operator: selection.In, Values: []string{"$(tasks.aTask.results.aResult[0])"}, @@ -2673,10 +2674,10 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ Input: "arrayResultValueTwo", Operator: selection.In, Values: []string{"arrayResultValueOne"}, @@ -2686,20 +2687,20 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, { name: "Test array result substitution on minimal variable substitution expression - resolver params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewArrayOrString("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: v1beta1.ArrayOrString{Type: v1beta1.ParamTypeArray, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{`$(tasks.aTask.results["aResult"][*])`}, }, }}, @@ -2708,12 +2709,12 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: v1beta1.ArrayOrString{Type: v1beta1.ParamTypeArray, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"arrayResultValueOne", "arrayResultValueTwo"}, }, }}, @@ -2724,32 +2725,32 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, { name: "Test result substitution on minimal variable substitution expression - resolver params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewArrayOrString("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewArrayOrString("$(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult)"), }}, }, }, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewArrayOrString("aResultValue"), + Value: *v1.NewStructuredValues("aResultValue"), }}, }, }, @@ -2758,38 +2759,38 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, { name: "Test array indexing result substitution on minimal variable substitution expression - resolver params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewArrayOrString("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewArrayOrString("$(tasks.aTask.results.aResult[0])"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult[0])"), }, { Name: "cParam", - Value: *v1beta1.NewArrayOrString("$(tasks.aTask.results.aResult[1])"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult[1])"), }}, }, }, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewArrayOrString("arrayResultValueOne"), + Value: *v1.NewStructuredValues("arrayResultValueOne"), }, { Name: "cParam", - Value: *v1beta1.NewArrayOrString("arrayResultValueTwo"), + Value: *v1.NewStructuredValues("arrayResultValueTwo"), }}, }, }, @@ -2814,143 +2815,143 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }{{ name: "Test result substitution on embedded variable substitution expression - params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("Result value --> $(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("Result value --> $(tasks.aTask.results.aResult)"), }}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("Result value --> aResultValue"), + Value: *v1.NewStructuredValues("Result value --> aResultValue"), }}, }, }}, }, { name: "Test array indexing result substitution on embedded variable substitution expression - params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("Result value --> $(tasks.aTask.results.aResult[0])"), + Value: *v1.NewStructuredValues("Result value --> $(tasks.aTask.results.aResult[0])"), }}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("Result value --> arrayResultValueOne"), + Value: *v1.NewStructuredValues("Result value --> arrayResultValueOne"), }}, }, }}, }, { name: "Test result substitution on embedded variable substitution expression - matrix", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("Result value --> $(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("Result value --> $(tasks.aTask.results.aResult)"), }}}, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("Result value --> aResultValue"), + Value: *v1.NewStructuredValues("Result value --> aResultValue"), }}}, }, }}, }, { name: "test result substitution for strings and arrays in matrix params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("foo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("foo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "foo", }, FromTaskRun: "aTaskRun", }, { - Value: *v1beta1.NewStructuredValues("b", "a", "r"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("b", "a", "r"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "bar", }, FromTaskRun: "aTaskRun", }, { - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "r", "key2": "a", "key3": "d", }), - ResultReference: v1beta1.ResultRef{ + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "rad", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ // string replacements from string param, array param and object results - Name: "first-param", Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.foo)", "$(tasks.aTask.results.bar[0])", "$(tasks.aTask.results.rad.key1)"), + Name: "first-param", Value: *v1.NewStructuredValues("$(tasks.aTask.results.foo)", "$(tasks.aTask.results.bar[0])", "$(tasks.aTask.results.rad.key1)"), }}, }, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Params: v1beta1.Params{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Params: v1.Params{{ // string replacements from string param, array param and object results - Name: "first-param", Value: *v1beta1.NewStructuredValues("foo", "b", "r"), + Name: "first-param", Value: *v1.NewStructuredValues("foo", "b", "r"), }}, }, }, @@ -2958,56 +2959,56 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }, { name: "test result substitution for strings from string, arr, obj results in matrix include params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("foo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("foo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "foo", }, FromTaskRun: "aTaskRun", }, { - Value: *v1beta1.NewStructuredValues("b", "a", "r"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("b", "a", "r"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "bar", }, FromTaskRun: "aTaskRun", }, { - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "r", "key2": "a", "key3": "d", }), - ResultReference: v1beta1.ResultRef{ + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "rad", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Include: []v1beta1.IncludeParams{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Include: []v1.IncludeParams{{ Name: "build-1", - Params: v1beta1.Params{{ + Params: v1.Params{{ // string replacements from string results, array results and object results - Name: "first-param", Value: *v1beta1.NewStructuredValues("foo", "b", "r"), + Name: "first-param", Value: *v1.NewStructuredValues("foo", "b", "r"), }}, }}, }, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Matrix: &v1beta1.Matrix{ - Include: []v1beta1.IncludeParams{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Matrix: &v1.Matrix{ + Include: []v1.MatrixInclude{{ Name: "build-1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ // string replacements from string results, array results and object results - Name: "first-param", Value: *v1beta1.NewStructuredValues("foo", "b", "r"), + Name: "first-param", Value: *v1.NewStructuredValues("foo", "b", "r"), }}, }}, }, @@ -3016,18 +3017,18 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }, { name: "Test result substitution on embedded variable substitution expression - when expressions", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{ { Input: "Result value --> $(tasks.aTask.results.aResult)", Operator: selection.In, @@ -3037,10 +3038,10 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ Input: "Result value --> aResultValue", Operator: selection.In, Values: []string{"Result value --> aResultValue"}, @@ -3050,18 +3051,18 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }, { name: "Test array indexing result substitution on embedded variable substitution expression - when expressions", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{ { Input: "Result value --> $(tasks.aTask.results.aResult[1])", Operator: selection.In, @@ -3071,10 +3072,10 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ Input: "Result value --> arrayResultValueTwo", Operator: selection.In, Values: []string{"Result value --> arrayResultValueOne"}, @@ -3084,32 +3085,32 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }, { name: "Test result substitution on embedded variable substitution expression - resolver params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewArrayOrString("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewArrayOrString("Result value --> $(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("Result value --> $(tasks.aTask.results.aResult)"), }}, }, }, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewArrayOrString("Result value --> aResultValue"), + Value: *v1.NewStructuredValues("Result value --> aResultValue"), }}, }, }, @@ -3118,38 +3119,38 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }, { name: "Test array indexing result substitution on embedded variable substitution expression - resolver params", resolvedResultRefs: ResolvedResultRefs{{ - Value: *v1beta1.NewArrayOrString("arrayResultValueOne", "arrayResultValueTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultValueOne", "arrayResultValueTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }}, targets: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewArrayOrString("Result value --> $(tasks.aTask.results.aResult[0])"), + Value: *v1.NewStructuredValues("Result value --> $(tasks.aTask.results.aResult[0])"), }, { Name: "cParam", - Value: *v1beta1.NewArrayOrString("Result value --> $(tasks.aTask.results.aResult[1])"), + Value: *v1.NewStructuredValues("Result value --> $(tasks.aTask.results.aResult[1])"), }}, }, }, }, }}, want: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{{ + PipelineTask: &v1.PipelineTask{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewArrayOrString("Result value --> arrayResultValueOne"), + Value: *v1.NewStructuredValues("Result value --> arrayResultValueOne"), }, { Name: "cParam", - Value: *v1beta1.NewArrayOrString("Result value --> arrayResultValueTwo"), + Value: *v1.NewStructuredValues("Result value --> arrayResultValueTwo"), }}, }, }, @@ -3168,67 +3169,67 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { func TestContext(t *testing.T) { for _, tc := range []struct { description string - pr *v1beta1.PipelineRun - original v1beta1.Param - expected v1beta1.Param + pr *v1.PipelineRun + original v1.Param + expected v1.Param }{{ description: "context.pipeline.name defined", - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "name"}, }, - original: v1beta1.Param{Value: *v1beta1.NewStructuredValues("$(context.pipeline.name)-1")}, - expected: v1beta1.Param{Value: *v1beta1.NewStructuredValues("test-pipeline-1")}, + original: v1.Param{Value: *v1.NewStructuredValues("$(context.pipeline.name)-1")}, + expected: v1.Param{Value: *v1.NewStructuredValues("test-pipeline-1")}, }, { description: "context.pipelineRun.name defined", - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "name"}, }, - original: v1beta1.Param{Value: *v1beta1.NewStructuredValues("$(context.pipelineRun.name)-1")}, - expected: v1beta1.Param{Value: *v1beta1.NewStructuredValues("name-1")}, + original: v1.Param{Value: *v1.NewStructuredValues("$(context.pipelineRun.name)-1")}, + expected: v1.Param{Value: *v1.NewStructuredValues("name-1")}, }, { description: "context.pipelineRun.name undefined", - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: ""}, }, - original: v1beta1.Param{Value: *v1beta1.NewStructuredValues("$(context.pipelineRun.name)-1")}, - expected: v1beta1.Param{Value: *v1beta1.NewStructuredValues("-1")}, + original: v1.Param{Value: *v1.NewStructuredValues("$(context.pipelineRun.name)-1")}, + expected: v1.Param{Value: *v1.NewStructuredValues("-1")}, }, { description: "context.pipelineRun.namespace defined", - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "namespace"}, }, - original: v1beta1.Param{Value: *v1beta1.NewStructuredValues("$(context.pipelineRun.namespace)-1")}, - expected: v1beta1.Param{Value: *v1beta1.NewStructuredValues("namespace-1")}, + original: v1.Param{Value: *v1.NewStructuredValues("$(context.pipelineRun.namespace)-1")}, + expected: v1.Param{Value: *v1.NewStructuredValues("namespace-1")}, }, { description: "context.pipelineRun.namespace undefined", - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: ""}, }, - original: v1beta1.Param{Value: *v1beta1.NewStructuredValues("$(context.pipelineRun.namespace)-1")}, - expected: v1beta1.Param{Value: *v1beta1.NewStructuredValues("-1")}, + original: v1.Param{Value: *v1.NewStructuredValues("$(context.pipelineRun.namespace)-1")}, + expected: v1.Param{Value: *v1.NewStructuredValues("-1")}, }, { description: "context.pipelineRun.uid defined", - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{UID: "UID"}, }, - original: v1beta1.Param{Value: *v1beta1.NewStructuredValues("$(context.pipelineRun.uid)-1")}, - expected: v1beta1.Param{Value: *v1beta1.NewStructuredValues("UID-1")}, + original: v1.Param{Value: *v1.NewStructuredValues("$(context.pipelineRun.uid)-1")}, + expected: v1.Param{Value: *v1.NewStructuredValues("UID-1")}, }, { description: "context.pipelineRun.uid undefined", - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{UID: ""}, }, - original: v1beta1.Param{Value: *v1beta1.NewStructuredValues("$(context.pipelineRun.uid)-1")}, - expected: v1beta1.Param{Value: *v1beta1.NewStructuredValues("-1")}, + original: v1.Param{Value: *v1.NewStructuredValues("$(context.pipelineRun.uid)-1")}, + expected: v1.Param{Value: *v1.NewStructuredValues("-1")}, }} { t.Run(tc.description, func(t *testing.T) { - orig := &v1beta1.Pipeline{ + orig := &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline"}, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{tc.original}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{tc.original}, + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{tc.original}, + Matrix: &v1.Matrix{ + Params: []v1.Param{tc.original}, }}}, }, } @@ -3246,86 +3247,86 @@ func TestContext(t *testing.T) { func TestApplyPipelineTaskContexts(t *testing.T) { for _, tc := range []struct { description string - pt v1beta1.PipelineTask - want v1beta1.PipelineTask + pt v1.PipelineTask + want v1.PipelineTask }{{ description: "context retries replacement", - pt: v1beta1.PipelineTask{ + pt: v1.PipelineTask{ Retries: 5, - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"), + Value: *v1.NewStructuredValues("$(context.pipelineTask.retries)"), }}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"), + Value: *v1.NewStructuredValues("$(context.pipelineTask.retries)"), }}, - Include: []v1beta1.IncludeParams{{ + Include: []v1.IncludeParams{{ Name: "build-1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"), + Value: *v1.NewStructuredValues("$(context.pipelineTask.retries)"), }}, }}, }, }, - want: v1beta1.PipelineTask{ + want: v1.PipelineTask{ Retries: 5, - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("5"), + Value: *v1.NewStructuredValues("5"), }}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("5"), + Value: *v1.NewStructuredValues("5"), }}, - Include: []v1beta1.IncludeParams{{ + Include: []v1.IncludeParams{{ Name: "build-1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("5"), + Value: *v1.NewStructuredValues("5"), }}, }}, }, }, }, { description: "context retries replacement with no defined retries", - pt: v1beta1.PipelineTask{ - Params: []v1beta1.Param{{ + pt: v1.PipelineTask{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"), + Value: *v1.NewStructuredValues("$(context.pipelineTask.retries)"), }}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"), + Value: *v1.NewStructuredValues("$(context.pipelineTask.retries)"), }}, - Include: []v1beta1.IncludeParams{{ + Include: []v1.IncludeParams{{ Name: "build-1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"), + Value: *v1.NewStructuredValues("$(context.pipelineTask.retries)"), }}, }}, }, }, - want: v1beta1.PipelineTask{ - Params: []v1beta1.Param{{ + want: v1.PipelineTask{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("0"), + Value: *v1.NewStructuredValues("0"), }}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("0"), + Value: *v1.NewStructuredValues("0"), }}, - Include: []v1beta1.IncludeParams{{ + Include: []v1.IncludeParams{{ Name: "build-1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "retries", - Value: *v1beta1.NewStructuredValues("0"), + Value: *v1.NewStructuredValues("0"), }}, }}, }, @@ -3343,40 +3344,40 @@ func TestApplyPipelineTaskContexts(t *testing.T) { func TestApplyWorkspaces(t *testing.T) { for _, tc := range []struct { description string - declarations []v1beta1.PipelineWorkspaceDeclaration - bindings []v1beta1.WorkspaceBinding + declarations []v1.PipelineWorkspaceDeclaration + bindings []v1.WorkspaceBinding variableUsage string expectedReplacement string }{{ description: "workspace declared and bound", - declarations: []v1beta1.PipelineWorkspaceDeclaration{{ + declarations: []v1.PipelineWorkspaceDeclaration{{ Name: "foo", }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "foo", }}, variableUsage: "$(workspaces.foo.bound)", expectedReplacement: "true", }, { description: "workspace declared not bound", - declarations: []v1beta1.PipelineWorkspaceDeclaration{{ + declarations: []v1.PipelineWorkspaceDeclaration{{ Name: "foo", Optional: true, }}, - bindings: []v1beta1.WorkspaceBinding{}, + bindings: []v1.WorkspaceBinding{}, variableUsage: "$(workspaces.foo.bound)", expectedReplacement: "false", }} { t.Run(tc.description, func(t *testing.T) { - p1 := v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Params: []v1beta1.Param{{Value: *v1beta1.NewStructuredValues(tc.variableUsage)}}, + p1 := v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ + Params: []v1.Param{{Value: *v1.NewStructuredValues(tc.variableUsage)}}, }}, Workspaces: tc.declarations, } - pr := &v1beta1.PipelineRun{ - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ + pr := &v1.PipelineRun{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ Name: "test-pipeline", }, Workspaces: tc.bindings, @@ -3394,52 +3395,53 @@ func TestApplyWorkspaces(t *testing.T) { func TestApplyFinallyResultsToPipelineResults(t *testing.T) { for _, tc := range []struct { description string - results []v1beta1.PipelineResult - taskResults map[string][]v1beta1.TaskRunResult + results []v1.PipelineResult + taskResults map[string][]v1.TaskRunResult runResults map[string][]v1beta1.CustomRunResult - expected []v1beta1.PipelineRunResult + skippedTasks []v1.SkippedTask + expected []v1.PipelineRunResult expectedError error }{{ description: "single-string-result-single-successful-task", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(finally.pt1.results.foo)"), + Value: *v1.NewStructuredValues("$(finally.pt1.results.foo)"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewStructuredValues("do"), + Value: *v1.NewStructuredValues("do"), }, }, }, - expected: []v1beta1.PipelineRunResult{{ + expected: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("do"), + Value: *v1.NewStructuredValues("do"), }}, }, { description: "single-array-result-single-successful-task", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(finally.pt1.results.foo[*])"), + Value: *v1.NewStructuredValues("$(finally.pt1.results.foo[*])"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewStructuredValues("do", "rae"), + Value: *v1.NewStructuredValues("do", "rae"), }, }, }, - expected: []v1beta1.PipelineRunResult{{ + expected: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("do", "rae"), + Value: *v1.NewStructuredValues("do", "rae"), }}, }, { description: "multiple-results-custom-and-normal-tasks", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(finally.customtask.results.foo)"), + Value: *v1.NewStructuredValues("$(finally.customtask.results.foo)"), }}, runResults: map[string][]v1beta1.CustomRunResult{ "customtask": { @@ -3449,30 +3451,30 @@ func TestApplyFinallyResultsToPipelineResults(t *testing.T) { }, }, }, - expected: []v1beta1.PipelineRunResult{{ + expected: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("do"), + Value: *v1.NewStructuredValues("do"), }}, }, { description: "apply-object-results", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(finally.pt1.results.foo[*])"), + Value: *v1.NewStructuredValues("$(finally.pt1.results.foo[*])"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }, }, }, - expected: []v1beta1.PipelineRunResult{{ + expected: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), @@ -3480,15 +3482,15 @@ func TestApplyFinallyResultsToPipelineResults(t *testing.T) { }, { description: "referencing-invalid-finally-task", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(finally.pt2.results.foo)"), + Value: *v1.NewStructuredValues("$(finally.pt2.results.foo)"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewStructuredValues("do"), + Value: *v1.NewStructuredValues("do"), }, }, }, @@ -3508,100 +3510,100 @@ func TestApplyFinallyResultsToPipelineResults(t *testing.T) { func TestApplyTaskResultsToPipelineResults_Success(t *testing.T) { for _, tc := range []struct { description string - results []v1beta1.PipelineResult - taskResults map[string][]v1beta1.TaskRunResult + results []v1.PipelineResult + taskResults map[string][]v1.TaskRunResult runResults map[string][]v1beta1.CustomRunResult - skippedTasks []v1beta1.SkippedTask - expectedResults []v1beta1.PipelineRunResult + skippedTasks []v1.SkippedTask + expectedResults []v1.PipelineRunResult }{{ description: "non-reference-results", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("resultName"), + Value: *v1.NewStructuredValues("resultName"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewStructuredValues("do", "rae", "mi"), + Value: *v1.NewStructuredValues("do", "rae", "mi"), }, }, }, expectedResults: nil, }, { description: "apply-array-results", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.foo[*])"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo[*])"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewStructuredValues("do", "rae", "mi"), + Value: *v1.NewStructuredValues("do", "rae", "mi"), }, }, }, - expectedResults: []v1beta1.PipelineRunResult{{ + expectedResults: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("do", "rae", "mi"), + Value: *v1.NewStructuredValues("do", "rae", "mi"), }}, }, { description: "apply-array-indexing-results", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.foo[1])"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo[1])"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewStructuredValues("do", "rae", "mi"), + Value: *v1.NewStructuredValues("do", "rae", "mi"), }, }, }, - expectedResults: []v1beta1.PipelineRunResult{{ + expectedResults: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("rae"), + Value: *v1.NewStructuredValues("rae"), }}, }, { description: "apply-object-results", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.foo[*])"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo[*])"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }, }, }, - expectedResults: []v1beta1.PipelineRunResult{{ + expectedResults: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }}, }, { description: "object-results-from-array-indexing-and-object-element", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "pkey1": "$(tasks.pt1.results.foo.key1)", "pkey2": "$(tasks.pt2.results.bar[1])", }), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), @@ -3610,28 +3612,28 @@ func TestApplyTaskResultsToPipelineResults_Success(t *testing.T) { "pt2": { { Name: "bar", - Value: *v1beta1.NewStructuredValues("do", "rae", "mi"), + Value: *v1.NewStructuredValues("do", "rae", "mi"), }, }, }, - expectedResults: []v1beta1.PipelineRunResult{{ + expectedResults: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "pkey1": "val1", "pkey2": "rae", }), }}, }, { description: "array-results-from-array-indexing-and-object-element", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.foo.key1)", "$(tasks.pt2.results.bar[1])"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo.key1)", "$(tasks.pt2.results.bar[1])"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), @@ -3640,114 +3642,194 @@ func TestApplyTaskResultsToPipelineResults_Success(t *testing.T) { "pt2": { { Name: "bar", - Value: *v1beta1.NewStructuredValues("do", "rae", "mi"), + Value: *v1.NewStructuredValues("do", "rae", "mi"), }, }, }, - expectedResults: []v1beta1.PipelineRunResult{{ + expectedResults: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("val1", "rae"), + Value: *v1.NewStructuredValues("val1", "rae"), }}, }, { description: "apply-object-element", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.foo.key1)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo.key1)"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", }), }, }, }, - expectedResults: []v1beta1.PipelineRunResult{{ + expectedResults: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("val1"), + Value: *v1.NewStructuredValues("val1"), }}, }, { description: "multiple-array-results-multiple-successful-tasks ", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.foo[*])"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo[*])"), }, { Name: "pipeline-result-2", - Value: *v1beta1.NewStructuredValues("$(tasks.pt2.results.bar[*])"), + Value: *v1.NewStructuredValues("$(tasks.pt2.results.bar[*])"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewStructuredValues("do", "rae"), + Value: *v1.NewStructuredValues("do", "rae"), }, }, "pt2": { { Name: "bar", - Value: *v1beta1.NewStructuredValues("do", "rae", "mi"), + Value: *v1.NewStructuredValues("do", "rae", "mi"), }, }, }, - expectedResults: []v1beta1.PipelineRunResult{{ + expectedResults: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("do", "rae"), + Value: *v1.NewStructuredValues("do", "rae"), }, { Name: "pipeline-result-2", - Value: *v1beta1.NewStructuredValues("do", "rae", "mi"), + Value: *v1.NewStructuredValues("do", "rae", "mi"), }}, }, { description: "no-pipeline-results-no-returned-results", - results: []v1beta1.PipelineResult{}, - taskResults: map[string][]v1beta1.TaskRunResult{ + results: []v1.PipelineResult{}, + taskResults: map[string][]v1.TaskRunResult{ "pt1": {{ Name: "foo", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), + }}, + }, + expectedResults: nil, + }, { + description: "invalid-result-variable-no-returned-result", + results: []v1.PipelineResult{{ + Name: "foo", + Value: *v1.NewStructuredValues("$(tasks.pt1_results.foo)"), + }}, + taskResults: map[string][]v1.TaskRunResult{ + "pt1": {{ + Name: "foo", + Value: *v1.NewStructuredValues("bar"), }}, }, expectedResults: nil, + expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"), + }, { + description: "no-taskrun-results-no-returned-results", + results: []v1.PipelineResult{{ + Name: "foo", + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo)"), + }}, + taskResults: map[string][]v1.TaskRunResult{ + "pt1": {}, + }, + expectedResults: nil, + expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"), + }, { + description: "invalid-taskrun-name-no-returned-result", + results: []v1.PipelineResult{{ + Name: "foo", + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo)"), + }}, + taskResults: map[string][]v1.TaskRunResult{ + "definitely-not-pt1": {{ + Name: "foo", + Value: *v1.NewStructuredValues("bar"), + }}, + }, + expectedResults: nil, + }, { + description: "invalid-result-name-no-returned-result", + results: []v1.PipelineResult{{ + Name: "foo", + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo)"), + }}, + taskResults: map[string][]v1.TaskRunResult{ + "pt1": {{ + Name: "definitely-not-foo", + Value: *v1.NewStructuredValues("bar"), + }}, + }, + expectedResults: nil, + expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"), + }, { + description: "unsuccessful-taskrun-no-returned-result", + results: []v1.PipelineResult{{ + Name: "foo", + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo)"), + }}, + taskResults: map[string][]v1.TaskRunResult{}, + expectedResults: nil, + }, { + description: "mixed-success-tasks-some-returned-results", + results: []v1.PipelineResult{{ + Name: "foo", + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo)"), + }, { + Name: "bar", + Value: *v1.NewStructuredValues("$(tasks.pt2.results.bar)"), + }}, + taskResults: map[string][]v1.TaskRunResult{ + "pt2": {{ + Name: "bar", + Value: *v1.NewStructuredValues("rae"), + }}, + }, + expectedResults: []v1.PipelineRunResult{{ + Name: "bar", + Value: *v1.NewStructuredValues("rae"), + }}, + expectedError: fmt.Errorf("invalid pipelineresults [foo], the referred results don't exist"), }, { description: "multiple-results-multiple-successful-tasks ", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.foo)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo)"), }, { Name: "pipeline-result-2", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.foo), $(tasks.pt2.results.baz), $(tasks.pt1.results.bar), $(tasks.pt2.results.baz), $(tasks.pt1.results.foo)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.foo), $(tasks.pt2.results.baz), $(tasks.pt1.results.bar), $(tasks.pt2.results.baz), $(tasks.pt1.results.foo)"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "pt1": { { Name: "foo", - Value: *v1beta1.NewStructuredValues("do"), + Value: *v1.NewStructuredValues("do"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("mi"), + Value: *v1.NewStructuredValues("mi"), }, }, "pt2": {{ Name: "baz", - Value: *v1beta1.NewStructuredValues("rae"), + Value: *v1.NewStructuredValues("rae"), }}, }, - expectedResults: []v1beta1.PipelineRunResult{{ + expectedResults: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("do"), + Value: *v1.NewStructuredValues("do"), }, { Name: "pipeline-result-2", - Value: *v1beta1.NewStructuredValues("do, rae, mi, rae, do"), + Value: *v1.NewStructuredValues("do, rae, mi, rae, do"), }}, }, { description: "multiple-results-custom-and-normal-tasks", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(tasks.customtask.results.foo)"), + Value: *v1.NewStructuredValues("$(tasks.customtask.results.foo)"), }, { Name: "pipeline-result-2", - Value: *v1beta1.NewStructuredValues("$(tasks.customtask.results.foo), $(tasks.normaltask.results.baz), $(tasks.customtask.results.bar), $(tasks.normaltask.results.baz), $(tasks.customtask.results.foo)"), + Value: *v1.NewStructuredValues("$(tasks.customtask.results.foo), $(tasks.normaltask.results.baz), $(tasks.customtask.results.bar), $(tasks.normaltask.results.baz), $(tasks.customtask.results.foo)"), }}, runResults: map[string][]v1beta1.CustomRunResult{ "customtask": { @@ -3760,35 +3842,35 @@ func TestApplyTaskResultsToPipelineResults_Success(t *testing.T) { }, }, }, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "normaltask": {{ Name: "baz", - Value: *v1beta1.NewStructuredValues("rae"), + Value: *v1.NewStructuredValues("rae"), }}, }, - expectedResults: []v1beta1.PipelineRunResult{{ + expectedResults: []v1.PipelineRunResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("do"), + Value: *v1.NewStructuredValues("do"), }, { Name: "pipeline-result-2", - Value: *v1beta1.NewStructuredValues("do, rae, mi, rae, do"), + Value: *v1.NewStructuredValues("do, rae, mi, rae, do"), }}, }, { description: "multiple-results-skipped-and-normal-tasks", - results: []v1beta1.PipelineResult{{ + results: []v1.PipelineResult{{ Name: "pipeline-result-1", - Value: *v1beta1.NewStructuredValues("$(tasks.skippedTask.results.foo)"), + Value: *v1.NewStructuredValues("$(tasks.skippedTask.results.foo)"), }, { Name: "pipeline-result-2", - Value: *v1beta1.NewStructuredValues("$(tasks.skippedTask.results.foo), $(tasks.normaltask.results.baz)"), + Value: *v1.NewStructuredValues("$(tasks.skippedTask.results.foo), $(tasks.normaltask.results.baz)"), }}, - taskResults: map[string][]v1beta1.TaskRunResult{ + taskResults: map[string][]v1.TaskRunResult{ "normaltask": {{ Name: "baz", - Value: *v1beta1.NewStructuredValues("rae"), + Value: *v1.NewStructuredValues("rae"), }}, }, - skippedTasks: []v1beta1.SkippedTask{{ + skippedTasks: []v1.SkippedTask{{ Name: "skippedTask", }}, expectedResults: nil, @@ -4032,17 +4114,17 @@ func TestApplyTaskRunContext(t *testing.T) { "tasks.task3.status": "none", } state := PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "task4", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "task"}, + Params: []v1.Param{{ Name: "task1", - Value: *v1beta1.NewStructuredValues("$(tasks.task1.status)"), + Value: *v1.NewStructuredValues("$(tasks.task1.status)"), }, { Name: "task3", - Value: *v1beta1.NewStructuredValues("$(tasks.task3.status)"), + Value: *v1.NewStructuredValues("$(tasks.task3.status)"), }}, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "$(tasks.task1.status)", Operator: selection.In, Values: []string{"$(tasks.task3.status)"}, @@ -4050,17 +4132,17 @@ func TestApplyTaskRunContext(t *testing.T) { }, }} expectedState := PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "task4", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "task"}, + Params: []v1.Param{{ Name: "task1", - Value: *v1beta1.NewStructuredValues("succeeded"), + Value: *v1.NewStructuredValues("succeeded"), }, { Name: "task3", - Value: *v1beta1.NewStructuredValues("none"), + Value: *v1.NewStructuredValues("none"), }}, - WhenExpressions: v1beta1.WhenExpressions{{ + When: v1.WhenExpressions{{ Input: "succeeded", Operator: selection.In, Values: []string{"none"}, diff --git a/pkg/reconciler/pipelinerun/resources/pipelineref.go b/pkg/reconciler/pipelinerun/resources/pipelineref.go index a571f43a70a..bd927a0bf32 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelineref.go +++ b/pkg/reconciler/pipelinerun/resources/pipelineref.go @@ -41,19 +41,19 @@ import ( // GetPipelineFunc is a factory function that will use the given PipelineRef to return a valid GetPipeline function that // looks up the pipeline. It uses as context a k8s client, tekton client, namespace, and service account name to return // the pipeline. It knows whether it needs to look in the cluster or in a remote location to fetch the reference. -func GetPipelineFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, requester remoteresource.Requester, pipelineRun *v1beta1.PipelineRun) rprp.GetPipeline { +func GetPipelineFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, requester remoteresource.Requester, pipelineRun *v1.PipelineRun) rprp.GetPipeline { cfg := config.FromContextOrDefaults(ctx) pr := pipelineRun.Spec.PipelineRef namespace := pipelineRun.Namespace // if the spec is already in the status, do not try to fetch it again, just use it as source of truth. // Same for the Source field in the Status.Provenance. if pipelineRun.Status.PipelineSpec != nil { - return func(_ context.Context, name string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { - var configSource *v1beta1.ConfigSource + return func(_ context.Context, name string) (v1.PipelineObject, *v1.ConfigSource, error) { + var configSource *v1.ConfigSource if pipelineRun.Status.Provenance != nil { configSource = pipelineRun.Status.Provenance.ConfigSource } - return &v1beta1.Pipeline{ + return &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -67,11 +67,11 @@ func GetPipelineFunc(ctx context.Context, k8s kubernetes.Interface, tekton clien case cfg.FeatureFlags.EnableTektonOCIBundles && pr != nil && pr.Bundle != "": // Return an inline function that implements GetTask by calling Resolver.Get with the specified task type and // casting it to a PipelineObject. - return func(ctx context.Context, name string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { + return func(ctx context.Context, name string) (v1.PipelineObject, *v1.ConfigSource, error) { // If there is a bundle url at all, construct an OCI resolver to fetch the pipeline. kc, err := k8schain.New(ctx, k8s, k8schain.Options{ Namespace: namespace, - ServiceAccountName: pipelineRun.Spec.ServiceAccountName, + ServiceAccountName: pipelineRun.Spec.TaskRunTemplate.ServiceAccountName, }) if err != nil { return nil, nil, fmt.Errorf("failed to get keychain: %w", err) @@ -80,7 +80,7 @@ func GetPipelineFunc(ctx context.Context, k8s kubernetes.Interface, tekton clien return resolvePipeline(ctx, resolver, name) } case pr != nil && pr.Resolver != "" && requester != nil: - return func(ctx context.Context, name string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { + return func(ctx context.Context, name string) (v1.PipelineObject, *v1.ConfigSource, error) { stringReplacements, arrayReplacements, objectReplacements := paramsFromPipelineRun(ctx, pipelineRun) for k, v := range GetContextReplacements("", pipelineRun) { stringReplacements[k] = v @@ -101,9 +101,9 @@ func GetPipelineFunc(ctx context.Context, k8s kubernetes.Interface, tekton clien // GetVerifiedPipelineFunc is a wrapper of GetPipelineFunc and return the function to // verify the pipeline if there are matching verification policies -func GetVerifiedPipelineFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, requester remoteresource.Requester, pipelineRun *v1beta1.PipelineRun, verificationpolicies []*v1alpha1.VerificationPolicy) rprp.GetPipeline { +func GetVerifiedPipelineFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, requester remoteresource.Requester, pipelineRun *v1.PipelineRun, verificationpolicies []*v1alpha1.VerificationPolicy) rprp.GetPipeline { get := GetPipelineFunc(ctx, k8s, tekton, requester, pipelineRun) - return func(context.Context, string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { + return func(context.Context, string) (v1.PipelineObject, *v1.ConfigSource, error) { p, s, err := get(ctx, pipelineRun.Spec.PipelineRef.Name) if err != nil { return nil, nil, fmt.Errorf("failed to get pipeline: %w", err) @@ -133,13 +133,13 @@ type LocalPipelineRefResolver struct { // return an error if it can't find an appropriate Pipeline for any reason. // TODO: if we want to set source for in-cluster pipeline, set it here. // https://github.com/tektoncd/pipeline/issues/5522 -func (l *LocalPipelineRefResolver) GetPipeline(ctx context.Context, name string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { +func (l *LocalPipelineRefResolver) GetPipeline(ctx context.Context, name string) (v1.PipelineObject, *v1.ConfigSource, error) { // If we are going to resolve this reference locally, we need a namespace scope. if l.Namespace == "" { return nil, nil, fmt.Errorf("Must specify namespace to resolve reference to pipeline %s", name) } - pipeline, err := l.Tektonclient.TektonV1beta1().Pipelines(l.Namespace).Get(ctx, name, metav1.GetOptions{}) + pipeline, err := l.Tektonclient.TektonV1().Pipelines(l.Namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { return nil, nil, err } @@ -149,8 +149,8 @@ func (l *LocalPipelineRefResolver) GetPipeline(ctx context.Context, name string) // resolvePipeline accepts an impl of remote.Resolver and attempts to // fetch a pipeline with given name. An error is returned if the // resolution doesn't work or the returned data isn't a valid -// v1beta1.PipelineObject. -func resolvePipeline(ctx context.Context, resolver remote.Resolver, name string) (v1beta1.PipelineObject, *v1beta1.ConfigSource, error) { +// v1.PipelineObject. +func resolvePipeline(ctx context.Context, resolver remote.Resolver, name string) (v1.PipelineObject, *v1.ConfigSource, error) { obj, configSource, err := resolver.Get(ctx, "pipeline", name) if err != nil { return nil, nil, err diff --git a/pkg/reconciler/pipelinerun/resources/pipelineref_test.go b/pkg/reconciler/pipelinerun/resources/pipelineref_test.go index ea7a66ef7f5..81affd010f7 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelineref_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelineref_test.go @@ -29,6 +29,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-containerregistry/pkg/registry" "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/fake" @@ -38,7 +39,6 @@ import ( "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/parse" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" fakek8s "k8s.io/client-go/kubernetes/fake" @@ -47,18 +47,18 @@ import ( ) var ( - dummyPipeline = &v1beta1.Pipeline{ + dummyPipeline = &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: "dummy", Namespace: "default", }, TypeMeta: metav1.TypeMeta{ Kind: "Pipeline", - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", }, } - sampleConfigSource = &v1beta1.ConfigSource{ + sampleConfigSource = &v1.ConfigSource{ URI: "abc.com", Digest: map[string]string{ "sha1": "a123", @@ -71,14 +71,14 @@ func TestLocalPipelineRef(t *testing.T) { testcases := []struct { name string pipelines []runtime.Object - ref *v1beta1.PipelineRef + ref *v1.PipelineRef expected runtime.Object wantErr bool }{ { name: "local-pipeline", pipelines: []runtime.Object{simplePipeline(), dummyPipeline}, - ref: &v1beta1.PipelineRef{ + ref: &v1.PipelineRef{ Name: "simple", }, expected: simplePipeline(), @@ -87,7 +87,7 @@ func TestLocalPipelineRef(t *testing.T) { { name: "pipeline-not-found", pipelines: []runtime.Object{}, - ref: &v1beta1.PipelineRef{ + ref: &v1.PipelineRef{ Name: "simple", }, expected: nil, @@ -148,7 +148,7 @@ func TestGetPipelineFunc(t *testing.T) { name string localPipelines []runtime.Object remotePipelines []runtime.Object - ref *v1beta1.PipelineRef + ref *v1.PipelineRef expected runtime.Object }{{ name: "remote-pipeline", @@ -157,7 +157,7 @@ func TestGetPipelineFunc(t *testing.T) { dummyPipeline, }, remotePipelines: []runtime.Object{simplePipeline(), dummyPipeline}, - ref: &v1beta1.PipelineRef{ + ref: &v1.PipelineRef{ Name: "simple", Bundle: u.Host + "/remote-pipeline", }, @@ -169,7 +169,7 @@ func TestGetPipelineFunc(t *testing.T) { dummyPipeline, }, remotePipelines: []runtime.Object{simplePipeline(), dummyPipeline}, - ref: &v1beta1.PipelineRef{ + ref: &v1.PipelineRef{ Name: "simple", }, expected: simplePipelineWithBaseSpec(), @@ -179,17 +179,17 @@ func TestGetPipelineFunc(t *testing.T) { remotePipelines: []runtime.Object{ simplePipelineWithSpecAndParam(""), dummyPipeline}, - ref: &v1beta1.PipelineRef{ + ref: &v1.PipelineRef{ Name: "simple", Bundle: u.Host + "/remote-pipeline-without-defaults", }, - expected: simplePipelineWithSpecParamAndKind(v1beta1.ParamTypeString, v1beta1.NamespacedTaskKind), + expected: simplePipelineWithSpecParamAndKind(v1.ParamTypeString, v1.NamespacedTaskKind), }} for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { tektonclient := fake.NewSimpleClientset(tc.localPipelines...) - kubeclient := fakek8s.NewSimpleClientset(&v1.ServiceAccount{ + kubeclient := fakek8s.NewSimpleClientset(&corev1.ServiceAccount{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "default", @@ -201,9 +201,9 @@ func TestGetPipelineFunc(t *testing.T) { t.Fatalf("failed to upload test image: %s", err.Error()) } - fn := resources.GetPipelineFunc(ctx, kubeclient, tektonclient, nil, &v1beta1.PipelineRun{ + fn := resources.GetPipelineFunc(ctx, kubeclient, tektonclient, nil, &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "default"}, - Spec: v1beta1.PipelineRunSpec{ + Spec: v1.PipelineRunSpec{ PipelineRef: tc.ref, ServiceAccountName: "default", }, @@ -233,7 +233,7 @@ func TestGetPipelineFuncSpecAlreadyFetched(t *testing.T) { ctx, cancel := context.WithCancel(ctx) defer cancel() tektonclient := fake.NewSimpleClientset(simplePipeline(), dummyPipeline) - kubeclient := fakek8s.NewSimpleClientset(&v1.ServiceAccount{ + kubeclient := fakek8s.NewSimpleClientset(&corev1.ServiceAccount{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "default", @@ -241,30 +241,30 @@ func TestGetPipelineFuncSpecAlreadyFetched(t *testing.T) { }) name := "anyname-really" - pipelineSpec := v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + pipelineSpec := v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "task1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }}, } - pipelineRun := &v1beta1.PipelineRun{ + pipelineRun := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "default"}, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ // Using simple here to show that, it won't fetch the simple pipelinespec, // which is different from the pipelineSpec above Name: "simple", }, ServiceAccountName: "default", }, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ PipelineSpec: &pipelineSpec, - Provenance: &v1beta1.Provenance{ + Provenance: &v1.Provenance{ ConfigSource: sampleConfigSource.DeepCopy(), }, }}, } - expectedPipeline := &v1beta1.Pipeline{ + expectedPipeline := &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: "default", @@ -344,47 +344,47 @@ func TestGetPipelineFunc_RemoteResolution_ReplacedParams(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) ctx = config.ToContext(ctx, cfg) - pipeline := parse.MustParseV1beta1Pipeline(t, pipelineYAMLString) - pipelineRef := &v1beta1.PipelineRef{ - ResolverRef: v1beta1.ResolverRef{ + pipeline := parse.MustParseV1Pipeline(t, pipelineYAMLString) + pipelineRef := &v1.PipelineRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("$(params.resolver-param)"), + Value: *v1.NewStructuredValues("$(params.resolver-param)"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("$(context.pipelineRun.name)"), + Value: *v1.NewStructuredValues("$(context.pipelineRun.name)"), }}, }, } pipelineYAML := strings.Join([]string{ "kind: Pipeline", - "apiVersion: tekton.dev/v1beta1", + "apiVersion: tekton.dev/v1", pipelineYAMLString, }, "\n") resolved := test.NewResolvedResource([]byte(pipelineYAML), nil, sampleConfigSource.DeepCopy(), nil) requester := &test.Requester{ ResolvedResource: resolved, - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("test-pipeline"), + Value: *v1.NewStructuredValues("test-pipeline"), }}, } - fn := resources.GetPipelineFunc(ctx, nil, nil, requester, &v1beta1.PipelineRun{ + fn := resources.GetPipelineFunc(ctx, nil, nil, requester, &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-pipeline", Namespace: "default", }, - Spec: v1beta1.PipelineRunSpec{ + Spec: v1.PipelineRunSpec{ PipelineRef: pipelineRef, ServiceAccountName: "default", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "resolver-param", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }}, }, }) @@ -402,30 +402,30 @@ func TestGetPipelineFunc_RemoteResolution_ReplacedParams(t *testing.T) { t.Errorf("configsource did not match: %s", diff.PrintWantGot(d)) } - pipelineRefNotMatching := &v1beta1.PipelineRef{ - ResolverRef: v1beta1.ResolverRef{ + pipelineRefNotMatching := &v1.PipelineRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("$(params.resolver-param)"), + Value: *v1.NewStructuredValues("$(params.resolver-param)"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("$(context.pipelineRun.name)"), + Value: *v1.NewStructuredValues("$(context.pipelineRun.name)"), }}, }, } - fnNotMatching := resources.GetPipelineFunc(ctx, nil, nil, requester, &v1beta1.PipelineRun{ + fnNotMatching := resources.GetPipelineFunc(ctx, nil, nil, requester, &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "other-pipeline", Namespace: "default", }, - Spec: v1beta1.PipelineRunSpec{ + Spec: v1.PipelineRunSpec{ PipelineRef: pipelineRefNotMatching, ServiceAccountName: "default", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "resolver-param", - Value: *v1beta1.NewStructuredValues("banana"), + Value: *v1.NewStructuredValues("banana"), }}, }, }) @@ -443,13 +443,13 @@ func TestGetPipelineFunc_RemoteResolutionInvalidData(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) ctx = config.ToContext(ctx, cfg) - pipelineRef := &v1beta1.PipelineRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} + pipelineRef := &v1.PipelineRef{ResolverRef: v1.ResolverRef{Resolver: "git"}} resolvesTo := []byte("INVALID YAML") resource := test.NewResolvedResource(resolvesTo, nil, nil, nil) requester := test.NewRequester(resource, nil) - fn := resources.GetPipelineFunc(ctx, nil, nil, requester, &v1beta1.PipelineRun{ + fn := resources.GetPipelineFunc(ctx, nil, nil, requester, &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "default"}, - Spec: v1beta1.PipelineRunSpec{ + Spec: v1.PipelineRunSpec{ PipelineRef: pipelineRef, ServiceAccountName: "default", }, @@ -500,32 +500,32 @@ func TestGetVerifiedPipelineFunc_Success(t *testing.T) { resolvedMatched := test.NewResolvedResource(signedPipelineBytes, nil, matchPolicySource, nil) requesterMatched := test.NewRequester(resolvedMatched, nil) - pipelineRef := &v1beta1.PipelineRef{ + pipelineRef := &v1.PipelineRef{ Name: signedPipeline.Name, - ResolverRef: v1beta1.ResolverRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", }, } - pr := v1beta1.PipelineRun{ + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"}, - Spec: v1beta1.PipelineRunSpec{ + Spec: v1.PipelineRunSpec{ PipelineRef: pipelineRef, ServiceAccountName: "default", }, } - prWithStatus := v1beta1.PipelineRun{ + prWithStatus := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"}, - Spec: v1beta1.PipelineRunSpec{ + Spec: v1.PipelineRunSpec{ PipelineRef: pipelineRef, ServiceAccountName: "default", }, - Status: v1beta1.PipelineRunStatus{ - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + Status: v1.PipelineRunStatus{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ PipelineSpec: &signedPipeline.Spec, - Provenance: &v1beta1.Provenance{ - ConfigSource: &v1beta1.ConfigSource{ + Provenance: &v1.Provenance{ + ConfigSource: &v1.ConfigSource{ URI: "abc.com", Digest: map[string]string{"sha1": "a123"}, EntryPoint: "foo/bar", @@ -539,10 +539,10 @@ func TestGetVerifiedPipelineFunc_Success(t *testing.T) { name string requester *test.Requester verificationNoMatchPolicy string - pipelinerun v1beta1.PipelineRun + pipelinerun v1.PipelineRun policies []*v1alpha1.VerificationPolicy expected runtime.Object - expectedSource *v1beta1.ConfigSource + expectedSource *v1.ConfigSource }{{ name: "signed pipeline with matching policy pass verification with enforce no match policy", requester: requesterMatched, @@ -683,7 +683,7 @@ func TestGetVerifiedPipelineFunc_VerifyError(t *testing.T) { resolvedModified := test.NewResolvedResource(modifiedPipelineBytes, nil, matchPolicySource, nil) requesterModified := test.NewRequester(resolvedModified, nil) - pipelineRef := &v1beta1.PipelineRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} + pipelineRef := &v1.PipelineRef{ResolverRef: v1.ResolverRef{Resolver: "git"}} testcases := []struct { name string @@ -739,9 +739,9 @@ func TestGetVerifiedPipelineFunc_VerifyError(t *testing.T) { for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy) - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"}, - Spec: v1beta1.PipelineRunSpec{ + Spec: v1.PipelineRunSpec{ PipelineRef: pipelineRef, ServiceAccountName: "default", }, @@ -777,10 +777,10 @@ func TestGetVerifiedPipelineFunc_GetFuncError(t *testing.T) { requesterUnsigned := test.NewRequester(resolvedUnsigned, nil) resolvedUnsigned.DataErr = fmt.Errorf("resolution error") - prBundleError := &v1beta1.PipelineRun{ + prBundleError := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"}, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ Name: "pipelineName", Bundle: "bundle", }, @@ -788,12 +788,12 @@ func TestGetVerifiedPipelineFunc_GetFuncError(t *testing.T) { }, } - prResolutionError := &v1beta1.PipelineRun{ + prResolutionError := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"}, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ Name: "pipelineName", - ResolverRef: v1beta1.ResolverRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", }, }, @@ -804,7 +804,7 @@ func TestGetVerifiedPipelineFunc_GetFuncError(t *testing.T) { testcases := []struct { name string requester *test.Requester - pipelinerun v1beta1.PipelineRun + pipelinerun v1.PipelineRun expectedErr error }{ { @@ -845,29 +845,29 @@ func TestGetVerifiedPipelineFunc_GetFuncError(t *testing.T) { } } -func basePipeline(name string) *v1beta1.Pipeline { - return &v1beta1.Pipeline{ +func basePipeline(name string) *v1.Pipeline { + return &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: "default", }, TypeMeta: metav1.TypeMeta{ Kind: "Pipeline", - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", }, } } -func simplePipeline() *v1beta1.Pipeline { +func simplePipeline() *v1.Pipeline { return basePipeline("simple") } -func simplePipelineWithBaseSpec() *v1beta1.Pipeline { +func simplePipelineWithBaseSpec() *v1.Pipeline { p := simplePipeline() - p.Spec = v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + p.Spec = v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "something", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "something", }, }}, @@ -876,9 +876,9 @@ func simplePipelineWithBaseSpec() *v1beta1.Pipeline { return p } -func simplePipelineWithSpecAndParam(pt v1beta1.ParamType) *v1beta1.Pipeline { +func simplePipelineWithSpecAndParam(pt v1.ParamType) *v1.Pipeline { p := simplePipelineWithBaseSpec() - p.Spec.Params = []v1beta1.ParamSpec{{ + p.Spec.Params = []v1.ParamSpec{{ Name: "foo", Type: pt, }} @@ -886,9 +886,9 @@ func simplePipelineWithSpecAndParam(pt v1beta1.ParamType) *v1beta1.Pipeline { return p } -func simplePipelineWithSpecParamAndKind(pt v1beta1.ParamType, tk v1beta1.TaskKind) *v1beta1.Pipeline { +func simplePipelineWithSpecParamAndKind(pt v1.ParamType, tk v1.TaskKind) *v1.Pipeline { p := simplePipelineWithBaseSpec() - p.Spec.Params = []v1beta1.ParamSpec{{ + p.Spec.Params = []v1.ParamSpec{{ Name: "foo", }} diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go index 7524c980600..f323caf4d95 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go @@ -23,6 +23,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" @@ -42,7 +43,7 @@ const ( // TaskSkipStatus stores whether a task was skipped and why type TaskSkipStatus struct { IsSkipped bool - SkippingReason v1beta1.SkippingReason + SkippingReason v1.SkippingReason } // TaskNotFoundError indicates that the resolution failed because a referenced Task couldn't be retrieved @@ -58,16 +59,16 @@ func (e *TaskNotFoundError) Error() string { // ResolvedPipelineTask contains a PipelineTask and its associated TaskRun(s) or RunObjects, if they exist. type ResolvedPipelineTask struct { TaskRunName string - TaskRun *v1beta1.TaskRun + TaskRun *v1.TaskRun TaskRunNames []string - TaskRuns []*v1beta1.TaskRun + TaskRuns []*v1.TaskRun // If the PipelineTask is a Custom Task, RunObjectName and RunObject will be set. CustomTask bool RunObjectName string RunObject v1beta1.RunObject RunObjectNames []string RunObjects []v1beta1.RunObject - PipelineTask *v1beta1.PipelineTask + PipelineTask *v1.PipelineTask ResolvedTask *resources.ResolvedTask } @@ -256,8 +257,8 @@ func (t ResolvedPipelineTask) isCancelledForTimeOut() bool { isDone = isDone && taskRun.IsDone() c := taskRun.Status.GetCondition(apis.ConditionSucceeded) taskRunCancelled := c.IsFalse() && - c.Reason == v1beta1.TaskRunReasonCancelled.String() && - taskRun.Spec.StatusMessage == v1beta1.TaskRunCancelledByPipelineTimeoutMsg + c.Reason == v1.TaskRunReasonCancelled.String() && + taskRun.Spec.StatusMessage == v1.TaskRunCancelledByPipelineTimeoutMsg atLeastOneCancelled = atLeastOneCancelled || taskRunCancelled } return atLeastOneCancelled && isDone @@ -267,8 +268,8 @@ func (t ResolvedPipelineTask) isCancelledForTimeOut() bool { } c := t.TaskRun.Status.GetCondition(apis.ConditionSucceeded) return c != nil && c.IsFalse() && - c.Reason == v1beta1.TaskRunReasonCancelled.String() && - t.TaskRun.Spec.StatusMessage == v1beta1.TaskRunCancelledByPipelineTimeoutMsg + c.Reason == v1.TaskRunReasonCancelled.String() && + t.TaskRun.Spec.StatusMessage == v1.TaskRunCancelledByPipelineTimeoutMsg } } @@ -304,7 +305,7 @@ func (t ResolvedPipelineTask) isCancelled() bool { for _, taskRun := range t.TaskRuns { isDone = isDone && taskRun.IsDone() c := taskRun.Status.GetCondition(apis.ConditionSucceeded) - taskRunCancelled := c.IsFalse() && c.Reason == v1beta1.TaskRunReasonCancelled.String() + taskRunCancelled := c.IsFalse() && c.Reason == v1.TaskRunReasonCancelled.String() atLeastOneCancelled = atLeastOneCancelled || taskRunCancelled } return atLeastOneCancelled && isDone @@ -313,7 +314,7 @@ func (t ResolvedPipelineTask) isCancelled() bool { return false } c := t.TaskRun.Status.GetCondition(apis.ConditionSucceeded) - return c != nil && c.IsFalse() && c.Reason == v1beta1.TaskRunReasonCancelled.String() + return c != nil && c.IsFalse() && c.Reason == v1.TaskRunReasonCancelled.String() } } @@ -362,33 +363,33 @@ func (t *ResolvedPipelineTask) checkParentsDone(facts *PipelineRunFacts) bool { } func (t *ResolvedPipelineTask) skip(facts *PipelineRunFacts) TaskSkipStatus { - var skippingReason v1beta1.SkippingReason + var skippingReason v1.SkippingReason switch { case facts.isFinalTask(t.PipelineTask.Name) || t.isScheduled(): - skippingReason = v1beta1.None + skippingReason = v1.None case facts.IsStopping(): - skippingReason = v1beta1.StoppingSkip + skippingReason = v1.StoppingSkip case facts.IsGracefullyCancelled(): - skippingReason = v1beta1.GracefullyCancelledSkip + skippingReason = v1.GracefullyCancelledSkip case facts.IsGracefullyStopped(): - skippingReason = v1beta1.GracefullyStoppedSkip + skippingReason = v1.GracefullyStoppedSkip case t.skipBecauseParentTaskWasSkipped(facts): - skippingReason = v1beta1.ParentTasksSkip + skippingReason = v1.ParentTasksSkip case t.skipBecauseResultReferencesAreMissing(facts): - skippingReason = v1beta1.MissingResultsSkip + skippingReason = v1.MissingResultsSkip case t.skipBecauseWhenExpressionsEvaluatedToFalse(facts): - skippingReason = v1beta1.WhenExpressionsSkip + skippingReason = v1.WhenExpressionsSkip case t.skipBecausePipelineRunPipelineTimeoutReached(facts): - skippingReason = v1beta1.PipelineTimedOutSkip + skippingReason = v1.PipelineTimedOutSkip case t.skipBecausePipelineRunTasksTimeoutReached(facts): - skippingReason = v1beta1.TasksTimedOutSkip + skippingReason = v1.TasksTimedOutSkip default: - skippingReason = v1beta1.None + skippingReason = v1.None } return TaskSkipStatus{ - IsSkipped: skippingReason != v1beta1.None, + IsSkipped: skippingReason != v1.None, SkippingReason: skippingReason, } } @@ -413,7 +414,7 @@ func (t *ResolvedPipelineTask) Skip(facts *PipelineRunFacts) TaskSkipStatus { // it returns true if any of the when expressions evaluate to false func (t *ResolvedPipelineTask) skipBecauseWhenExpressionsEvaluatedToFalse(facts *PipelineRunFacts) bool { if t.checkParentsDone(facts) { - if !t.PipelineTask.WhenExpressions.AllowsExecution() { + if !t.PipelineTask.When.AllowsExecution() { return true } } @@ -434,7 +435,7 @@ func (t *ResolvedPipelineTask) skipBecauseParentTaskWasSkipped(facts *PipelineRu if parentSkipStatus := parentTask.Skip(facts); parentSkipStatus.IsSkipped { // if the parent task was skipped due to its `when` expressions, // then we should ignore that and continue evaluating if we should skip because of other parent tasks - if parentSkipStatus.SkippingReason == v1beta1.WhenExpressionsSkip { + if parentSkipStatus.SkippingReason == v1.WhenExpressionsSkip { continue } return true @@ -450,7 +451,7 @@ func (t *ResolvedPipelineTask) skipBecauseResultReferencesAreMissing(facts *Pipe resolvedResultRefs, pt, err := ResolveResultRefs(facts.State, PipelineRunState{t}) rpt := facts.State.ToMap()[pt] if rpt != nil { - if err != nil && (t.IsFinalTask(facts) || rpt.Skip(facts).SkippingReason == v1beta1.WhenExpressionsSkip) { + if err != nil && (t.IsFinalTask(facts) || rpt.Skip(facts).SkippingReason == v1.WhenExpressionsSkip) { return true } } @@ -506,30 +507,30 @@ func (t *ResolvedPipelineTask) IsFinalTask(facts *PipelineRunFacts) bool { // IsFinallySkipped returns true if a finally task is not executed and skipped due to task result validation failure func (t *ResolvedPipelineTask) IsFinallySkipped(facts *PipelineRunFacts) TaskSkipStatus { - var skippingReason v1beta1.SkippingReason + var skippingReason v1.SkippingReason switch { case t.isScheduled(): - skippingReason = v1beta1.None + skippingReason = v1.None case facts.checkDAGTasksDone() && facts.isFinalTask(t.PipelineTask.Name): switch { case t.skipBecauseResultReferencesAreMissing(facts): - skippingReason = v1beta1.MissingResultsSkip + skippingReason = v1.MissingResultsSkip case t.skipBecauseWhenExpressionsEvaluatedToFalse(facts): - skippingReason = v1beta1.WhenExpressionsSkip + skippingReason = v1.WhenExpressionsSkip case t.skipBecausePipelineRunPipelineTimeoutReached(facts): - skippingReason = v1beta1.PipelineTimedOutSkip + skippingReason = v1.PipelineTimedOutSkip case t.skipBecausePipelineRunFinallyTimeoutReached(facts): - skippingReason = v1beta1.FinallyTimedOutSkip + skippingReason = v1.FinallyTimedOutSkip default: - skippingReason = v1beta1.None + skippingReason = v1.None } default: - skippingReason = v1beta1.None + skippingReason = v1.None } return TaskSkipStatus{ - IsSkipped: skippingReason != v1beta1.None, + IsSkipped: skippingReason != v1.None, SkippingReason: skippingReason, } } @@ -538,8 +539,8 @@ func (t *ResolvedPipelineTask) IsFinallySkipped(facts *PipelineRunFacts) TaskSki type GetRun func(name string) (v1beta1.RunObject, error) // ValidateWorkspaceBindings validates that the Workspaces expected by a Pipeline are provided by a PipelineRun. -func ValidateWorkspaceBindings(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) error { - pipelineRunWorkspaces := make(map[string]v1beta1.WorkspaceBinding) +func ValidateWorkspaceBindings(p *v1.PipelineSpec, pr *v1.PipelineRun) error { + pipelineRunWorkspaces := make(map[string]v1.WorkspaceBinding) for _, binding := range pr.Spec.Workspaces { pipelineRunWorkspaces[binding.Name] = binding } @@ -556,7 +557,7 @@ func ValidateWorkspaceBindings(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) } // ValidateTaskRunSpecs that the TaskRunSpecs defined by a PipelineRun are correct. -func ValidateTaskRunSpecs(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) error { +func ValidateTaskRunSpecs(p *v1.PipelineSpec, pr *v1.PipelineRun) error { pipelineTasks := make(map[string]string) for _, task := range p.Tasks { pipelineTasks[task.Name] = task.Name @@ -589,11 +590,11 @@ func isCustomTask(ctx context.Context, rpt ResolvedPipelineTask) bool { // the Resources needed for the TaskRuns or RunObjects using the mapping of providedResources. func ResolvePipelineTask( ctx context.Context, - pipelineRun v1beta1.PipelineRun, + pipelineRun v1.PipelineRun, getTask resources.GetTask, getTaskRun resources.GetTaskRun, getRun GetRun, - pipelineTask v1beta1.PipelineTask, + pipelineTask v1.PipelineTask, ) (*ResolvedPipelineTask, error) { rpt := ResolvedPipelineTask{ PipelineTask: &pipelineTask, @@ -641,7 +642,7 @@ func (t *ResolvedPipelineTask) resolvePipelineRunTaskWithTaskRun( taskRunName string, getTask resources.GetTask, getTaskRun resources.GetTaskRun, - pipelineTask v1beta1.PipelineTask, + pipelineTask v1.PipelineTask, ) error { taskRun, err := getTaskRun(taskRunName) if err != nil { @@ -667,8 +668,8 @@ func (t *ResolvedPipelineTask) resolvePipelineRunTaskWithTaskRun( func (t *ResolvedPipelineTask) resolveTaskResources( ctx context.Context, getTask resources.GetTask, - pipelineTask v1beta1.PipelineTask, - taskRun *v1beta1.TaskRun, + pipelineTask v1.PipelineTask, + taskRun *v1.TaskRun, ) error { spec, taskName, kind, err := resolveTask(ctx, taskRun, getTask, pipelineTask) if err != nil { @@ -687,16 +688,16 @@ func (t *ResolvedPipelineTask) resolveTaskResources( func resolveTask( ctx context.Context, - taskRun *v1beta1.TaskRun, + taskRun *v1.TaskRun, getTask resources.GetTask, - pipelineTask v1beta1.PipelineTask, -) (v1beta1.TaskSpec, string, v1beta1.TaskKind, error) { + pipelineTask v1.PipelineTask, +) (v1.TaskSpec, string, v1.TaskKind, error) { var ( - t v1beta1.TaskObject + t *v1.Task err error - spec v1beta1.TaskSpec + spec v1.TaskSpec taskName string - kind v1beta1.TaskKind + kind v1.TaskKind ) if pipelineTask.TaskRef != nil { @@ -709,18 +710,18 @@ func resolveTask( // Instead, the child TaskRun's status will be the place recording the source of individual task. t, _, err = getTask(ctx, pipelineTask.TaskRef.Name) switch { - case errors.Is(err, remote.ErrRequestInProgress): - return v1beta1.TaskSpec{}, "", "", err + case errors.Is(err, remote.ErrorRequestInProgress): + return v1.TaskSpec{}, "", "", err case errors.Is(err, trustedresources.ErrResourceVerificationFailed): - return v1beta1.TaskSpec{}, "", "", err + return v1.TaskSpec{}, "", "", err case err != nil: - return v1beta1.TaskSpec{}, "", "", &TaskNotFoundError{ + return v1.TaskSpec{}, "", "", &TaskNotFoundError{ Name: pipelineTask.TaskRef.Name, Msg: err.Error(), } default: - spec = t.TaskSpec() - taskName = t.TaskMetadata().Name + spec = t.Spec + taskName = t.ObjectMeta.Name } } kind = pipelineTask.TaskRef.Kind @@ -731,7 +732,7 @@ func resolveTask( } // GetTaskRunName should return a unique name for a `TaskRun` if one has not already been defined, and the existing one otherwise. -func GetTaskRunName(childRefs []v1beta1.ChildStatusReference, ptName, prName string) string { +func GetTaskRunName(childRefs []v1.ChildStatusReference, ptName, prName string) string { for _, cr := range childRefs { if cr.Kind == pipeline.TaskRunControllerName && cr.PipelineTaskName == ptName { return cr.Name @@ -741,14 +742,14 @@ func GetTaskRunName(childRefs []v1beta1.ChildStatusReference, ptName, prName str } // GetNamesOfTaskRuns should return unique names for `TaskRuns` if one has not already been defined, and the existing one otherwise. -func GetNamesOfTaskRuns(childRefs []v1beta1.ChildStatusReference, ptName, prName string, combinationCount int) []string { +func GetNamesOfTaskRuns(childRefs []v1.ChildStatusReference, ptName, prName string, combinationCount int) []string { if taskRunNames := getTaskRunNamesFromChildRefs(childRefs, ptName); taskRunNames != nil { return taskRunNames } return getNewTaskRunNames(ptName, prName, combinationCount) } -func getTaskRunNamesFromChildRefs(childRefs []v1beta1.ChildStatusReference, ptName string) []string { +func getTaskRunNamesFromChildRefs(childRefs []v1.ChildStatusReference, ptName string) []string { var taskRunNames []string for _, cr := range childRefs { if cr.Kind == pipeline.TaskRunControllerName && cr.PipelineTaskName == ptName { @@ -769,7 +770,7 @@ func getNewTaskRunNames(ptName, prName string, combinationCount int) []string { // getRunName should return a unique name for a `Run` if one has not already // been defined, and the existing one otherwise. -func getRunName(childRefs []v1beta1.ChildStatusReference, ptName, prName string) string { +func getRunName(childRefs []v1.ChildStatusReference, ptName, prName string) string { for _, cr := range childRefs { if cr.PipelineTaskName == ptName { if cr.Kind == pipeline.CustomRunControllerName || cr.Kind == pipeline.RunControllerName { @@ -783,14 +784,14 @@ func getRunName(childRefs []v1beta1.ChildStatusReference, ptName, prName string) // getNamesOfRuns should return a unique names for `RunObjects` if they have not already been defined, // and the existing ones otherwise. -func getNamesOfRuns(childRefs []v1beta1.ChildStatusReference, ptName, prName string, combinationCount int) []string { +func getNamesOfRuns(childRefs []v1.ChildStatusReference, ptName, prName string, combinationCount int) []string { if runNames := getRunNamesFromChildRefs(childRefs, ptName); runNames != nil { return runNames } return getNewTaskRunNames(ptName, prName, combinationCount) } -func getRunNamesFromChildRefs(childRefs []v1beta1.ChildStatusReference, ptName string) []string { +func getRunNamesFromChildRefs(childRefs []v1.ChildStatusReference, ptName string) []string { var runNames []string for _, cr := range childRefs { if cr.PipelineTaskName == ptName { @@ -804,7 +805,7 @@ func getRunNamesFromChildRefs(childRefs []v1beta1.ChildStatusReference, ptName s // resolvePipelineTaskResources matches PipelineResources referenced by pt inputs and outputs with the // providedResources and returns an instance of ResolvedTask. -func resolvePipelineTaskResources(pt v1beta1.PipelineTask, ts *v1beta1.TaskSpec, taskName string, kind v1beta1.TaskKind) (*resources.ResolvedTask, error) { +func resolvePipelineTaskResources(pt v1.PipelineTask, ts *v1.TaskSpec, taskName string, kind v1.TaskKind) (*resources.ResolvedTask, error) { rtr := resources.ResolvedTask{ TaskName: taskName, TaskSpec: ts, @@ -814,20 +815,20 @@ func resolvePipelineTaskResources(pt v1beta1.PipelineTask, ts *v1beta1.TaskSpec, } func (t *ResolvedPipelineTask) hasResultReferences() bool { - var matrixParams []v1beta1.Param + var matrixParams []v1.Param if t.PipelineTask.IsMatrixed() { matrixParams = t.PipelineTask.Params } for _, param := range append(t.PipelineTask.Params, matrixParams...) { - if ps, ok := v1beta1.GetVarSubstitutionExpressionsForParam(param); ok { - if v1beta1.LooksLikeContainsResultRefs(ps) { + if ps, ok := v1.GetVarSubstitutionExpressionsForParam(param); ok { + if v1.LooksLikeContainsResultRefs(ps) { return true } } } - for _, we := range t.PipelineTask.WhenExpressions { + for _, we := range t.PipelineTask.When { if ps, ok := we.GetVarSubstitutionExpressions(); ok { - if v1beta1.LooksLikeContainsResultRefs(ps) { + if v1.LooksLikeContainsResultRefs(ps) { return true } } diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go index e69a9e5d44d..915b08e1179 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go @@ -27,6 +27,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" @@ -47,65 +48,65 @@ import ( func nopGetRun(string) (v1beta1.RunObject, error) { return nil, errors.New("GetRun should not be called") } -func nopGetTask(context.Context, string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { +func nopGetTask(context.Context, string) (*v1.Task, *v1.ConfigSource, error) { return nil, nil, errors.New("GetTask should not be called") } -func nopGetTaskRun(string) (*v1beta1.TaskRun, error) { +func nopGetTaskRun(string) (*v1.TaskRun, error) { return nil, errors.New("GetTaskRun should not be called") } -var pts = []v1beta1.PipelineTask{{ +var pts = []v1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, { Name: "mytask2", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, { Name: "mytask3", - TaskRef: &v1beta1.TaskRef{Name: "clustertask"}, + TaskRef: &v1.TaskRef{Name: "clustertask"}, }, { Name: "mytask4", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, Retries: 1, }, { Name: "mytask5", - TaskRef: &v1beta1.TaskRef{Name: "cancelledTask"}, + TaskRef: &v1.TaskRef{Name: "cancelledTask"}, Retries: 2, }, { Name: "mytask6", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, { Name: "mytask7", - TaskRef: &v1beta1.TaskRef{Name: "taskWithOneParent"}, + TaskRef: &v1.TaskRef{Name: "taskWithOneParent"}, RunAfter: []string{"mytask6"}, }, { Name: "mytask8", - TaskRef: &v1beta1.TaskRef{Name: "taskWithTwoParents"}, + TaskRef: &v1.TaskRef{Name: "taskWithTwoParents"}, RunAfter: []string{"mytask1", "mytask6"}, }, { Name: "mytask9", - TaskRef: &v1beta1.TaskRef{Name: "taskHasParentWithRunAfter"}, + TaskRef: &v1.TaskRef{Name: "taskHasParentWithRunAfter"}, RunAfter: []string{"mytask8"}, }, { Name: "mytask10", - TaskRef: &v1beta1.TaskRef{Name: "taskWithWhenExpressions"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "taskWithWhenExpressions"}, + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, }, { Name: "mytask11", - TaskRef: &v1beta1.TaskRef{Name: "taskWithWhenExpressions"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "taskWithWhenExpressions"}, + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.NotIn, Values: []string{"foo", "bar"}, }}, }, { Name: "mytask12", - TaskRef: &v1beta1.TaskRef{Name: "taskWithWhenExpressions"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "taskWithWhenExpressions"}, + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, @@ -113,103 +114,103 @@ var pts = []v1beta1.PipelineTask{{ RunAfter: []string{"mytask1"}, }, { Name: "mytask13", - TaskRef: &v1beta1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "customtask"}, + TaskRef: &v1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "customtask"}, }, { Name: "mytask14", - TaskRef: &v1beta1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "customtask"}, + TaskRef: &v1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "customtask"}, }, { Name: "mytask15", - TaskRef: &v1beta1.TaskRef{Name: "taskWithReferenceToTaskResult"}, - Params: []v1beta1.Param{{Name: "param1", Value: *v1beta1.NewStructuredValues("$(tasks.mytask1.results.result1)")}}, + TaskRef: &v1.TaskRef{Name: "taskWithReferenceToTaskResult"}, + Params: []v1.Param{{Name: "param1", Value: *v1.NewStructuredValues("$(tasks.mytask1.results.result1)")}}, }, { Name: "mytask16", - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "browser", - Value: v1beta1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, + Value: v1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, }}}, }, { Name: "mytask17", - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "browser", - Value: v1beta1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, + Value: v1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, }}}, }, { Name: "mytask18", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, Retries: 1, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "browser", - Value: v1beta1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, + Value: v1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, }}}, }, { Name: "mytask19", - TaskRef: &v1beta1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "customtask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "customtask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "browser", - Value: v1beta1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, + Value: v1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, }}}, }, { Name: "mytask20", - TaskRef: &v1beta1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "customtask"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "customtask"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "browser", - Value: v1beta1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, + Value: v1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, }}}, }, { Name: "mytask21", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, Retries: 2, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "browser", - Value: v1beta1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, + Value: v1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, }}}, }} -var p = &v1beta1.Pipeline{ +var p = &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "pipeline", }, - Spec: v1beta1.PipelineSpec{ + Spec: v1.PipelineSpec{ Tasks: pts, }, } -var task = &v1beta1.Task{ +var task = &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task", }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", }}, }, } -var trs = []v1beta1.TaskRun{{ +var trs = []v1.TaskRun{{ ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "pipelinerun-mytask1", }, - Spec: v1beta1.TaskRunSpec{}, + Spec: v1.TaskRunSpec{}, }, { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "pipelinerun-mytask2", }, - Spec: v1beta1.TaskRunSpec{}, + Spec: v1.TaskRunSpec{}, }, { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "pipelinerun-mytask4", }, - Spec: v1beta1.TaskRunSpec{}, + Spec: v1.TaskRunSpec{}, }} var runs = []v1beta1.CustomRun{{ @@ -240,22 +241,22 @@ var v1alpha1Runs = []v1alpha1.Run{{ Spec: v1alpha1.RunSpec{}, }} -var matrixedPipelineTask = &v1beta1.PipelineTask{ +var matrixedPipelineTask = &v1.PipelineTask{ Name: "task", - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "browser", - Value: v1beta1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, + Value: v1.ParamValue{ArrayVal: []string{"safari", "chrome"}}, }}}, } -func makeScheduled(tr v1beta1.TaskRun) *v1beta1.TaskRun { +func makeScheduled(tr v1.TaskRun) *v1.TaskRun { newTr := newTaskRun(tr) - newTr.Status = v1beta1.TaskRunStatus{ /* explicitly empty */ } + newTr.Status = v1.TaskRunStatus{ /* explicitly empty */ } return newTr } -func makeStarted(tr v1beta1.TaskRun) *v1beta1.TaskRun { +func makeStarted(tr v1.TaskRun) *v1.TaskRun { newTr := newTaskRun(tr) newTr.Status.Conditions[0].Status = corev1.ConditionUnknown return newTr @@ -267,7 +268,7 @@ func makeRunStarted(run v1beta1.CustomRun) *v1beta1.CustomRun { return newRun } -func makeSucceeded(tr v1beta1.TaskRun) *v1beta1.TaskRun { +func makeSucceeded(tr v1.TaskRun) *v1.TaskRun { newTr := newTaskRun(tr) newTr.Status.Conditions[0].Status = corev1.ConditionTrue return newTr @@ -279,16 +280,16 @@ func makeRunSucceeded(run v1beta1.CustomRun) *v1beta1.CustomRun { return newRun } -func makeFailed(tr v1beta1.TaskRun) *v1beta1.TaskRun { +func makeFailed(tr v1.TaskRun) *v1.TaskRun { newTr := newTaskRun(tr) newTr.Status.Conditions[0].Status = corev1.ConditionFalse return newTr } -func makeToBeRetried(tr v1beta1.TaskRun) *v1beta1.TaskRun { +func makeToBeRetried(tr v1.TaskRun) *v1.TaskRun { newTr := newTaskRun(tr) newTr.Status.Conditions[0].Status = corev1.ConditionUnknown - newTr.Status.Conditions[0].Reason = v1beta1.TaskRunReasonToBeRetried.String() + newTr.Status.Conditions[0].Reason = v1.TaskRunReasonToBeRetried.String() return newTr } @@ -304,14 +305,14 @@ func makeRunFailed(run v1beta1.CustomRun) *v1beta1.CustomRun { return newRun } -func withCancelled(tr *v1beta1.TaskRun) *v1beta1.TaskRun { - tr.Status.Conditions[0].Reason = v1beta1.TaskRunSpecStatusCancelled +func withCancelled(tr *v1.TaskRun) *v1.TaskRun { + tr.Status.Conditions[0].Reason = v1.TaskRunSpecStatusCancelled return tr } -func withCancelledForTimeout(tr *v1beta1.TaskRun) *v1beta1.TaskRun { - tr.Spec.StatusMessage = v1beta1.TaskRunCancelledByPipelineTimeoutMsg - tr.Status.Conditions[0].Reason = v1beta1.TaskRunSpecStatusCancelled +func withCancelledForTimeout(tr *v1.TaskRun) *v1.TaskRun { + tr.Spec.StatusMessage = v1.TaskRunCancelledByPipelineTimeoutMsg + tr.Status.Conditions[0].Reason = v1.TaskRunSpecStatusCancelled return tr } @@ -331,8 +332,8 @@ func withRunCancelledForTimeout(run *v1beta1.CustomRun) *v1beta1.CustomRun { return run } -func withCancelledBySpec(tr *v1beta1.TaskRun) *v1beta1.TaskRun { - tr.Spec.Status = v1beta1.TaskRunSpecStatusCancelled +func withCancelledBySpec(tr *v1.TaskRun) *v1.TaskRun { + tr.Spec.Status = v1.TaskRunSpecStatusCancelled return tr } @@ -341,14 +342,14 @@ func withRunCancelledBySpec(run *v1beta1.CustomRun) *v1beta1.CustomRun { return run } -func makeRetried(tr v1beta1.TaskRun) (newTr *v1beta1.TaskRun) { +func makeRetried(tr v1.TaskRun) (newTr *v1.TaskRun) { newTr = newTaskRun(tr) newTr = withRetries(newTr) return } -func withRetries(tr *v1beta1.TaskRun) *v1beta1.TaskRun { - tr.Status.RetriesStatus = []v1beta1.TaskRunStatus{{ +func withRetries(tr *v1.TaskRun) *v1.TaskRun { + tr.Status.RetriesStatus = []v1.TaskRunStatus{{ Status: duckv1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -383,14 +384,14 @@ func withV1alpha1RunRetries(r *v1alpha1.Run) *v1alpha1.Run { return r } -func newTaskRun(tr v1beta1.TaskRun) *v1beta1.TaskRun { - return &v1beta1.TaskRun{ +func newTaskRun(tr v1.TaskRun) *v1.TaskRun { + return &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Namespace: tr.Namespace, Name: tr.Name, }, Spec: tr.Spec, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded}}, }, @@ -398,7 +399,7 @@ func newTaskRun(tr v1beta1.TaskRun) *v1beta1.TaskRun { } } -func withPipelineTaskRetries(pt v1beta1.PipelineTask, retries int) *v1beta1.PipelineTask { +func withPipelineTaskRetries(pt v1.PipelineTask, retries int) *v1.PipelineTask { pt.Retries = retries return &pt } @@ -611,7 +612,7 @@ var noneStartedStateMatrix = PipelineRunState{{ var oneStartedStateMatrix = PipelineRunState{{ PipelineTask: &pts[15], TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0])}, + TaskRuns: []*v1.TaskRun{makeStarted(trs[0])}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -627,7 +628,7 @@ var oneStartedStateMatrix = PipelineRunState{{ var oneFinishedStateMatrix = PipelineRunState{{ PipelineTask: &pts[15], TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0])}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -643,7 +644,7 @@ var oneFinishedStateMatrix = PipelineRunState{{ var oneFailedStateMatrix = PipelineRunState{{ PipelineTask: &pts[15], TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0])}, + TaskRuns: []*v1.TaskRun{makeFailed(trs[0])}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -659,14 +660,14 @@ var oneFailedStateMatrix = PipelineRunState{{ var finalScheduledStateMatrix = PipelineRunState{{ PipelineTask: &pts[15], TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0])}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, }, { PipelineTask: &pts[16], TaskRunNames: []string{"pipelinerun-mytask2"}, - TaskRuns: []*v1beta1.TaskRun{makeScheduled(trs[1])}, + TaskRuns: []*v1.TaskRun{makeScheduled(trs[1])}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -675,14 +676,14 @@ var finalScheduledStateMatrix = PipelineRunState{{ var allFinishedStateMatrix = PipelineRunState{{ PipelineTask: &pts[15], TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0])}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, }, { PipelineTask: &pts[16], TaskRunNames: []string{"pipelinerun-mytask2"}, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0])}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -727,18 +728,18 @@ var oneRunFailedStateMatrix = PipelineRunState{{ var taskCancelledMatrix = PipelineRunState{{ PipelineTask: &pts[20], TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeRetried(trs[0]))}, + TaskRuns: []*v1.TaskRun{withCancelled(makeRetried(trs[0]))}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, }} func dagFromState(state PipelineRunState) (*dag.Graph, error) { - pts := []v1beta1.PipelineTask{} + pts := []v1.PipelineTask{} for _, rpt := range state { pts = append(pts, *rpt.PipelineTask) } - return dag.Build(v1beta1.PipelineTaskList(pts), v1beta1.PipelineTaskList(pts).Deps()) + return dag.Build(v1.PipelineTaskList(pts), v1.PipelineTaskList(pts).Deps()) } func TestIsSkipped(t *testing.T) { @@ -831,9 +832,9 @@ func TestIsSkipped(t *testing.T) { TaskSpec: &task.Spec, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask10", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask7"}, }, // mytask10 runAfter mytask7 runAfter mytask6 TaskRunName: "pipelinerun-mytask3", @@ -967,9 +968,9 @@ func TestIsSkipped(t *testing.T) { }, }, { // not skipped regardless of its parent task being skipped because when expressions are scoped to task - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask18", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask11"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-1", @@ -994,9 +995,9 @@ func TestIsSkipped(t *testing.T) { }, }, { // not skipped regardless of its parent task being skipped because when expressions are scoped to task - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask18", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask11"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-1", @@ -1006,9 +1007,9 @@ func TestIsSkipped(t *testing.T) { }, }, { // not skipped regardless of its grandparent task being skipped because when expressions are scoped to task - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask19", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask18"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-2", @@ -1034,9 +1035,9 @@ func TestIsSkipped(t *testing.T) { }, }, { // not skipped regardless of its parent task mytask11 being skipped because when expressions are scoped to task - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask18", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask11"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-1", @@ -1046,9 +1047,9 @@ func TestIsSkipped(t *testing.T) { }, }, { // not skipped regardless of its grandparent task mytask11 being skipped because when expressions are scoped to task - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask19", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask18"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-2", @@ -1058,12 +1059,12 @@ func TestIsSkipped(t *testing.T) { }, }, { // attempted but skipped because of missing result in params from parent task mytask11 which was skipped - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask20", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "task"}, + Params: []v1.Param{{ Name: "commit", - Value: *v1beta1.NewStructuredValues("$(tasks.mytask11.results.missingResult)"), + Value: *v1.NewStructuredValues("$(tasks.mytask11.results.missingResult)"), }}, }, TaskRunName: "pipelinerun-resource-dependent-task-1", @@ -1074,9 +1075,9 @@ func TestIsSkipped(t *testing.T) { }, { // skipped because of parent task mytask20 was skipped because of missing result from grandparent task // mytask11 which was skipped - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask21", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask20"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-3", @@ -1086,10 +1087,10 @@ func TestIsSkipped(t *testing.T) { }, }, { // attempted but skipped because of missing result from parent task mytask11 which was skipped in when expressions - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask22", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - WhenExpressions: v1beta1.WhenExpressions{{ + TaskRef: &v1.TaskRef{Name: "task"}, + When: v1.WhenExpressions{{ Input: "$(tasks.mytask11.results.missingResult)", Operator: selection.In, Values: []string{"expectedResult"}, @@ -1103,9 +1104,9 @@ func TestIsSkipped(t *testing.T) { }, { // skipped because of parent task mytask22 was skipping because of missing result from grandparent task // mytask11 which was skipped - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask23", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask22"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-4", @@ -1206,27 +1207,27 @@ func TestIsFailure(t *testing.T) { }{{ name: "taskrun not started", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, }, want: false, }, { name: "run not started", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, }, want: false, }, { name: "taskrun running", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: makeStarted(trs[0]), }, want: false, }, { name: "run running", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, RunObject: makeRunStarted(runs[0]), }, @@ -1234,14 +1235,14 @@ func TestIsFailure(t *testing.T) { }, { name: "taskrun succeeded", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: makeSucceeded(trs[0]), }, want: false, }, { name: "run succeeded", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, RunObject: makeRunSucceeded(runs[0]), }, @@ -1249,14 +1250,14 @@ func TestIsFailure(t *testing.T) { }, { name: "taskrun failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: makeFailed(trs[0]), }, want: true, }, { name: "run failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, RunObject: makeRunFailed(runs[0]), }, @@ -1264,7 +1265,7 @@ func TestIsFailure(t *testing.T) { }, { name: "run failed: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, RunObject: makeRunFailed(runs[0]), }, @@ -1272,7 +1273,7 @@ func TestIsFailure(t *testing.T) { }, { name: "v1alpha1 run failed: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, RunObject: makeV1alpha1RunFailed(v1alpha1Runs[0]), }, @@ -1280,14 +1281,14 @@ func TestIsFailure(t *testing.T) { }, { name: "taskrun failed - Retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, TaskRun: withRetries(makeFailed(trs[0])), }, want: true, }, { name: "v1alpha1 run failed - Retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, RunObject: withV1alpha1RunRetries(makeV1alpha1RunFailed(v1alpha1Runs[0])), }, @@ -1295,7 +1296,7 @@ func TestIsFailure(t *testing.T) { }, { name: "run failed - Retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, RunObject: withRunRetries(makeRunFailed(runs[0])), }, @@ -1303,28 +1304,28 @@ func TestIsFailure(t *testing.T) { }, { name: "taskrun cancelled", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: withCancelled(makeFailed(trs[0])), }, want: true, }, { name: "taskrun cancelled but not failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: withCancelled(newTaskRun(trs[0])), }, want: false, }, { name: "taskrun cancelled for timeout", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: withCancelledForTimeout(makeFailed(trs[0])), }, want: true, }, { name: "run cancelled", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, RunObject: withRunCancelled(makeRunFailed(runs[0])), CustomTask: true, }, @@ -1332,7 +1333,7 @@ func TestIsFailure(t *testing.T) { }, { name: "run cancelled for timeout", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, RunObject: withRunCancelledForTimeout(makeRunFailed(runs[0])), CustomTask: true, }, @@ -1340,7 +1341,7 @@ func TestIsFailure(t *testing.T) { }, { name: "run cancelled but not failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, RunObject: withRunCancelled(newRun(runs[0])), CustomTask: true, }, @@ -1348,14 +1349,14 @@ func TestIsFailure(t *testing.T) { }, { name: "taskrun cancelled: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, TaskRun: withCancelled(makeFailed(trs[0])), }, want: true, }, { name: "v1alpha1 run cancelled: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, RunObject: withV1alpha1RunCancelled(makeV1alpha1RunFailed(v1alpha1Runs[0])), CustomTask: true, }, @@ -1363,7 +1364,7 @@ func TestIsFailure(t *testing.T) { }, { name: "run cancelled: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, RunObject: withRunCancelled(makeRunFailed(runs[0])), CustomTask: true, }, @@ -1371,14 +1372,14 @@ func TestIsFailure(t *testing.T) { }, { name: "taskrun cancelled: retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, TaskRun: withCancelled(withRetries(makeFailed(trs[0]))), }, want: true, }, { name: "run cancelled: retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, RunObject: withRunCancelled(withRunRetries(makeRunFailed(runs[0]))), CustomTask: true, }, @@ -1400,7 +1401,7 @@ func TestIsFailure(t *testing.T) { name: "matrixed taskruns running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{makeStarted(trs[0]), makeStarted(trs[1])}, }, want: false, }, { @@ -1415,7 +1416,7 @@ func TestIsFailure(t *testing.T) { name: "one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeSucceeded(trs[1])}, + TaskRuns: []*v1.TaskRun{makeStarted(trs[0]), makeSucceeded(trs[1])}, }, want: false, }, { @@ -1430,14 +1431,14 @@ func TestIsFailure(t *testing.T) { name: "matrixed taskruns succeeded", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0]), makeSucceeded(trs[1])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0]), makeSucceeded(trs[1])}, }, want: false, }, { name: "one matrixed taskrun succeeded", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0]), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0]), makeStarted(trs[1])}, }, want: false, }, { @@ -1452,7 +1453,7 @@ func TestIsFailure(t *testing.T) { name: "matrixed taskruns failed", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])}, + TaskRuns: []*v1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])}, }, want: true, }, { @@ -1467,7 +1468,7 @@ func TestIsFailure(t *testing.T) { name: "one matrixed taskrun failed, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{makeFailed(trs[0]), makeStarted(trs[1])}, }, want: false, }, { @@ -1482,7 +1483,7 @@ func TestIsFailure(t *testing.T) { name: "matrixed taskruns failed: retried", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withRetries(makeFailed(trs[0])), withRetries(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withRetries(makeFailed(trs[0])), withRetries(makeFailed(trs[1]))}, }, want: true, }, { @@ -1505,7 +1506,7 @@ func TestIsFailure(t *testing.T) { name: "matrixed taskruns failed: one taskrun with retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeFailed(trs[1]))}, }, want: false, }, { @@ -1528,7 +1529,7 @@ func TestIsFailure(t *testing.T) { name: "matrixed taskruns cancelled", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, }, want: true, }, { @@ -1543,7 +1544,7 @@ func TestIsFailure(t *testing.T) { name: "one matrixed taskrun cancelled, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, }, want: false, }, { @@ -1558,7 +1559,7 @@ func TestIsFailure(t *testing.T) { name: "matrixed taskruns cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), withCancelled(newTaskRun(trs[1]))}, + TaskRuns: []*v1.TaskRun{withCancelled(newTaskRun(trs[0])), withCancelled(newTaskRun(trs[1]))}, }, want: false, }, { @@ -1573,7 +1574,7 @@ func TestIsFailure(t *testing.T) { name: "one matrixed taskrun cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(newTaskRun(trs[0])), makeStarted(trs[1])}, }, want: false, }, { @@ -1588,7 +1589,7 @@ func TestIsFailure(t *testing.T) { name: "matrixed taskruns cancelled: retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, }, want: true, }, { @@ -1611,7 +1612,7 @@ func TestIsFailure(t *testing.T) { name: "one matrixed taskrun cancelled: retries remaining, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, }, want: false, }, { @@ -1626,7 +1627,7 @@ func TestIsFailure(t *testing.T) { name: "matrixed taskruns cancelled: retried", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), withCancelled(withRetries(makeFailed(trs[1])))}, + TaskRuns: []*v1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), withCancelled(withRetries(makeFailed(trs[1])))}, }, want: true, }, { @@ -1641,7 +1642,7 @@ func TestIsFailure(t *testing.T) { name: "one matrixed taskrun cancelled: retried, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), makeStarted(trs[1])}, }, want: false, }, { @@ -1699,9 +1700,9 @@ func TestSkipBecauseParentTaskWasSkipped(t *testing.T) { }, { // child task is not skipped regardless of its parent task being skipped due to when expressions evaluating // to false, because when expressions are scoped to task only - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask18", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask11"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-1", @@ -1727,9 +1728,9 @@ func TestSkipBecauseParentTaskWasSkipped(t *testing.T) { }, { // child task is not skipped regardless of its parent task being skipped due to when expressions evaluating // to false, because when expressions are scoped to task only - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask18", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask11"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-1", @@ -1740,9 +1741,9 @@ func TestSkipBecauseParentTaskWasSkipped(t *testing.T) { }, { // child task is not skipped regardless of its parent task being skipped due to when expressions evaluating // to false, because when expressions are scoped to task only - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "mytask19", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"mytask18"}, }, TaskRunName: "pipelinerun-ordering-dependent-task-2", @@ -1784,11 +1785,11 @@ func TestSkipBecauseParentTaskWasSkipped(t *testing.T) { } } -func getExpectedMessage(runName string, specStatus v1beta1.PipelineRunSpecStatus, status corev1.ConditionStatus, +func getExpectedMessage(runName string, specStatus v1.PipelineRunSpecStatus, status corev1.ConditionStatus, successful, incomplete, skipped, failed, cancelled int) string { if status == corev1.ConditionFalse && - (specStatus == v1beta1.PipelineRunSpecStatusCancelledRunFinally || - specStatus == v1beta1.PipelineRunSpecStatusStoppedRunFinally) { + (specStatus == v1.PipelineRunSpecStatusCancelledRunFinally || + specStatus == v1.PipelineRunSpecStatusStoppedRunFinally) { return fmt.Sprintf("PipelineRun %q was cancelled", runName) } if status == corev1.ConditionFalse || status == corev1.ConditionTrue { @@ -1801,12 +1802,12 @@ func getExpectedMessage(runName string, specStatus v1beta1.PipelineRunSpecStatus func TestResolvePipelineRun_CustomTask(t *testing.T) { names.TestingSeed() - pts := []v1beta1.PipelineTask{{ + pts := []v1.PipelineTask{{ Name: "customtask", - TaskRef: &v1beta1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example"}, + TaskRef: &v1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example"}, }, { Name: "customtask-spec", - TaskSpec: &v1beta1.EmbeddedTask{ + TaskSpec: &v1.EmbeddedTask{ TypeMeta: runtime.TypeMeta{ APIVersion: "example.dev/v0", Kind: "Example", @@ -1814,9 +1815,9 @@ func TestResolvePipelineRun_CustomTask(t *testing.T) { }, }, { Name: "run-exists", - TaskRef: &v1beta1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example"}, + TaskRef: &v1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example"}, }} - pr := v1beta1.PipelineRun{ + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "pipelinerun"}, } run := &v1beta1.CustomRun{ObjectMeta: metav1.ObjectMeta{Name: "run-exists-abcde"}} @@ -1824,7 +1825,7 @@ func TestResolvePipelineRun_CustomTask(t *testing.T) { if name == "pipelinerun-run-exists" { return run, nil } - return nil, kerrors.NewNotFound(v1beta1.Resource("run"), name) + return nil, kerrors.NewNotFound(v1.Resource("run"), name) } pipelineState := PipelineRunState{} ctx := context.Background() @@ -1860,22 +1861,22 @@ func TestResolvePipelineRun_CustomTask(t *testing.T) { } func TestResolvePipelineRun_PipelineTaskHasNoResources(t *testing.T) { - pts := []v1beta1.PipelineTask{{ + pts := []v1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, { Name: "mytask2", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, { Name: "mytask3", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }} - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + getTask := func(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { return task, nil, nil } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return &trs[0], nil } - pr := v1beta1.PipelineRun{ + getTaskRun := func(name string) (*v1.TaskRun, error) { return &trs[0], nil } + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1895,39 +1896,39 @@ func TestResolvePipelineRun_PipelineTaskHasNoResources(t *testing.T) { TaskName: task.Name, TaskSpec: &task.Spec, } - if d := cmp.Diff(pipelineState[0].ResolvedTask, expectedTask, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{})); d != "" { + if d := cmp.Diff(pipelineState[0].ResolvedTask, expectedTask, cmpopts.IgnoreUnexported(v1.TaskRunSpec{})); d != "" { t.Fatalf("Expected resources where only Tasks were resolved but actual differed %s", diff.PrintWantGot(d)) } - if d := cmp.Diff(pipelineState[1].ResolvedTask, expectedTask, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{})); d != "" { + if d := cmp.Diff(pipelineState[1].ResolvedTask, expectedTask, cmpopts.IgnoreUnexported(v1.TaskRunSpec{})); d != "" { t.Fatalf("Expected resources where only Tasks were resolved but actual differed %s", diff.PrintWantGot(d)) } } func TestResolvePipelineRun_TaskDoesntExist(t *testing.T) { - pts := []v1beta1.PipelineTask{{ + pts := []v1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, { Name: "mytask2", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "task"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("f", "o", "o"), + Value: *v1.NewStructuredValues("f", "o", "o"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("b", "a", "r"), + Value: *v1.NewStructuredValues("b", "a", "r"), }}, }}} // Return an error when the Task is retrieved, as if it didn't exist - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { - return nil, nil, kerrors.NewNotFound(v1beta1.Resource("task"), name) + getTask := func(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { + return nil, nil, kerrors.NewNotFound(v1.Resource("task"), name) } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { - return nil, kerrors.NewNotFound(v1beta1.Resource("taskrun"), name) + getTaskRun := func(name string) (*v1.TaskRun, error) { + return nil, kerrors.NewNotFound(v1.Resource("taskrun"), name) } - pr := v1beta1.PipelineRun{ + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1946,27 +1947,27 @@ func TestResolvePipelineRun_TaskDoesntExist(t *testing.T) { } func TestResolvePipelineRun_VerificationFailed(t *testing.T) { - pts := []v1beta1.PipelineTask{{ + pts := []v1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, { Name: "mytask2", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "task"}, + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("f", "o", "o"), + Value: *v1.NewStructuredValues("f", "o", "o"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("b", "a", "r"), + Value: *v1.NewStructuredValues("b", "a", "r"), }}, }}} - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + getTask := func(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { return nil, nil, trustedresources.ErrResourceVerificationFailed } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } - pr := v1beta1.PipelineRun{ + getTaskRun := func(name string) (*v1.TaskRun, error) { return nil, nil } + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1985,19 +1986,19 @@ func TestResolvePipelineRun_VerificationFailed(t *testing.T) { func TestValidateWorkspaceBindingsWithValidWorkspaces(t *testing.T) { for _, tc := range []struct { name string - spec *v1beta1.PipelineSpec - pr *v1beta1.PipelineRun + spec *v1.PipelineSpec + pr *v1.PipelineRun err string }{{ name: "include required workspace", - spec: &v1beta1.PipelineSpec{ - Workspaces: []v1beta1.PipelineWorkspaceDeclaration{{ + spec: &v1.PipelineSpec{ + Workspaces: []v1.PipelineWorkspaceDeclaration{{ Name: "foo", }}, }, - pr: &v1beta1.PipelineRun{ - Spec: v1beta1.PipelineRunSpec{ - Workspaces: []v1beta1.WorkspaceBinding{{ + pr: &v1.PipelineRun{ + Spec: v1.PipelineRunSpec{ + Workspaces: []v1.WorkspaceBinding{{ Name: "foo", EmptyDir: &corev1.EmptyDirVolumeSource{}, }}, @@ -2005,15 +2006,15 @@ func TestValidateWorkspaceBindingsWithValidWorkspaces(t *testing.T) { }, }, { name: "omit optional workspace", - spec: &v1beta1.PipelineSpec{ - Workspaces: []v1beta1.PipelineWorkspaceDeclaration{{ + spec: &v1.PipelineSpec{ + Workspaces: []v1.PipelineWorkspaceDeclaration{{ Name: "foo", Optional: true, }}, }, - pr: &v1beta1.PipelineRun{ - Spec: v1beta1.PipelineRunSpec{ - Workspaces: []v1beta1.WorkspaceBinding{}, + pr: &v1.PipelineRun{ + Spec: v1.PipelineRunSpec{ + Workspaces: []v1.WorkspaceBinding{}, }, }, }} { @@ -2028,19 +2029,19 @@ func TestValidateWorkspaceBindingsWithValidWorkspaces(t *testing.T) { func TestValidateWorkspaceBindingsWithInvalidWorkspaces(t *testing.T) { for _, tc := range []struct { name string - spec *v1beta1.PipelineSpec - pr *v1beta1.PipelineRun + spec *v1.PipelineSpec + pr *v1.PipelineRun err string }{{ name: "missing required workspace", - spec: &v1beta1.PipelineSpec{ - Workspaces: []v1beta1.PipelineWorkspaceDeclaration{{ + spec: &v1.PipelineSpec{ + Workspaces: []v1.PipelineWorkspaceDeclaration{{ Name: "foo", }}, }, - pr: &v1beta1.PipelineRun{ - Spec: v1beta1.PipelineRunSpec{ - Workspaces: []v1beta1.WorkspaceBinding{}, + pr: &v1.PipelineRun{ + Spec: v1.PipelineRunSpec{ + Workspaces: []v1.WorkspaceBinding{}, }, }, }} { @@ -2055,107 +2056,107 @@ func TestValidateWorkspaceBindingsWithInvalidWorkspaces(t *testing.T) { func TestValidateTaskRunSpecs(t *testing.T) { for _, tc := range []struct { name string - p *v1beta1.Pipeline - pr *v1beta1.PipelineRun + p *v1.Pipeline + pr *v1.PipelineRun wantErr bool }{{ name: "valid task mapping", - p: &v1beta1.Pipeline{ + p: &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelines", }, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "task", }, }}, }, }, - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ Name: "pipeline", }, - TaskRunSpecs: []v1beta1.PipelineTaskRunSpec{{ - PipelineTaskName: "mytask1", - TaskServiceAccountName: "default", + TaskRunSpecs: []v1.PipelineTaskRunSpec{{ + PipelineTaskName: "mytask1", + ServiceAccountName: "default", }}, }, }, wantErr: false, }, { name: "valid finally task mapping", - p: &v1beta1.Pipeline{ + p: &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelines", }, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "task", }, }}, - Finally: []v1beta1.PipelineTask{{ + Finally: []v1.PipelineTask{{ Name: "myfinaltask1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "finaltask", }, }}, }, }, - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ Name: "pipeline", }, - TaskRunSpecs: []v1beta1.PipelineTaskRunSpec{{ - PipelineTaskName: "myfinaltask1", - TaskServiceAccountName: "default", + TaskRunSpecs: []v1.PipelineTaskRunSpec{{ + PipelineTaskName: "myfinaltask1", + ServiceAccountName: "default", }}, }, }, wantErr: false, }, { name: "invalid task mapping", - p: &v1beta1.Pipeline{ + p: &v1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelines", }, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "task", }, }}, - Finally: []v1beta1.PipelineTask{{ + Finally: []v1.PipelineTask{{ Name: "myfinaltask1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "finaltask", }, }}, }, }, - pr: &v1beta1.PipelineRun{ + pr: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ - PipelineRef: &v1beta1.PipelineRef{ + Spec: v1.PipelineRunSpec{ + PipelineRef: &v1.PipelineRef{ Name: "pipeline", }, - TaskRunSpecs: []v1beta1.PipelineTaskRunSpec{{ - PipelineTaskName: "wrongtask", - TaskServiceAccountName: "default", + TaskRunSpecs: []v1.PipelineTaskRunSpec{{ + PipelineTaskName: "wrongtask", + ServiceAccountName: "default", }}, }, }, @@ -2181,34 +2182,34 @@ func TestResolvePipeline_WhenExpressions(t *testing.T) { names.TestingSeed() tName1 := "pipelinerun-mytask1-always-true" - t1 := &v1beta1.TaskRun{ + t1 := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: tName1, }, } - ptwe1 := v1beta1.WhenExpression{ + ptwe1 := v1.WhenExpression{ Input: "foo", Operator: selection.In, Values: []string{"foo"}, } - pt := v1beta1.PipelineTask{ - Name: "mytask1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - WhenExpressions: []v1beta1.WhenExpression{ptwe1}, + pt := v1.PipelineTask{ + Name: "mytask1", + TaskRef: &v1.TaskRef{Name: "task"}, + When: []v1.WhenExpression{ptwe1}, } - getTask := func(_ context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + getTask := func(_ context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { return task, nil, nil } - pr := v1beta1.PipelineRun{ + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { + getTaskRun := func(name string) (*v1.TaskRun, error) { switch name { case "pipelinerun-mytask1-always-true-0": return t1, nil @@ -2227,25 +2228,25 @@ func TestResolvePipeline_WhenExpressions(t *testing.T) { } func TestIsCustomTask(t *testing.T) { - pr := v1beta1.PipelineRun{ + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, } - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + getTask := func(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { return task, nil, nil } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } + getTaskRun := func(name string) (*v1.TaskRun, error) { return nil, nil } getRun := func(name string) (v1beta1.RunObject, error) { return nil, nil } for _, tc := range []struct { name string - pt v1beta1.PipelineTask + pt v1.PipelineTask want bool }{{ name: "custom taskSpec", - pt: v1beta1.PipelineTask{ - TaskSpec: &v1beta1.EmbeddedTask{ + pt: v1.PipelineTask{ + TaskSpec: &v1.EmbeddedTask{ TypeMeta: runtime.TypeMeta{ APIVersion: "example.dev/v0", Kind: "Sample", @@ -2255,8 +2256,8 @@ func TestIsCustomTask(t *testing.T) { want: true, }, { name: "custom taskSpec missing kind", - pt: v1beta1.PipelineTask{ - TaskSpec: &v1beta1.EmbeddedTask{ + pt: v1.PipelineTask{ + TaskSpec: &v1.EmbeddedTask{ TypeMeta: runtime.TypeMeta{ APIVersion: "example.dev/v0", Kind: "", @@ -2266,8 +2267,8 @@ func TestIsCustomTask(t *testing.T) { want: false, }, { name: "custom taskSpec missing apiVersion", - pt: v1beta1.PipelineTask{ - TaskSpec: &v1beta1.EmbeddedTask{ + pt: v1.PipelineTask{ + TaskSpec: &v1.EmbeddedTask{ TypeMeta: runtime.TypeMeta{ APIVersion: "", Kind: "Sample", @@ -2277,8 +2278,8 @@ func TestIsCustomTask(t *testing.T) { want: false, }, { name: "custom taskRef", - pt: v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ + pt: v1.PipelineTask{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Sample", }, @@ -2286,12 +2287,12 @@ func TestIsCustomTask(t *testing.T) { want: true, }, { name: "custom both taskRef and taskSpec", - pt: v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ + pt: v1.PipelineTask{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Sample", }, - TaskSpec: &v1beta1.EmbeddedTask{ + TaskSpec: &v1.EmbeddedTask{ TypeMeta: runtime.TypeMeta{ APIVersion: "example.dev/v0", Kind: "Sample", @@ -2301,8 +2302,8 @@ func TestIsCustomTask(t *testing.T) { want: false, }, { name: "custom taskRef missing kind", - pt: v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ + pt: v1.PipelineTask{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "", }, @@ -2310,8 +2311,8 @@ func TestIsCustomTask(t *testing.T) { want: false, }, { name: "custom taskRef missing apiVersion", - pt: v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ + pt: v1.PipelineTask{ + TaskRef: &v1.TaskRef{ APIVersion: "", Kind: "Sample", }, @@ -2319,16 +2320,16 @@ func TestIsCustomTask(t *testing.T) { want: false, }, { name: "non-custom taskref", - pt: v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ + pt: v1.PipelineTask{ + TaskRef: &v1.TaskRef{ Name: "task", }, }, want: false, }, { name: "non-custom taskspec", - pt: v1beta1.PipelineTask{ - TaskSpec: &v1beta1.EmbeddedTask{}, + pt: v1.PipelineTask{ + TaskSpec: &v1.EmbeddedTask{}, }, want: false, }} { @@ -2349,11 +2350,11 @@ func TestIsCustomTask(t *testing.T) { } func TestResolvedPipelineRunTask_IsFinallySkipped(t *testing.T) { - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "dag-task", }, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{ apis.Condition{ @@ -2362,10 +2363,10 @@ func TestResolvedPipelineRunTask_IsFinallySkipped(t *testing.T) { }, }, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "commit", - Value: *v1beta1.NewStructuredValues("SHA2"), + Value: *v1.NewStructuredValues("SHA2"), }}, }, }, @@ -2374,63 +2375,63 @@ func TestResolvedPipelineRunTask_IsFinallySkipped(t *testing.T) { state := PipelineRunState{{ TaskRunName: "dag-task", TaskRun: tr, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "dag-task", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "final-task-1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "task"}, + Params: []v1.Param{{ Name: "commit", - Value: *v1beta1.NewStructuredValues("$(tasks.dag-task.results.commit)"), + Value: *v1.NewStructuredValues("$(tasks.dag-task.results.commit)"), }}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "final-task-2", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "task"}, + Params: []v1.Param{{ Name: "commit", - Value: *v1beta1.NewStructuredValues("$(tasks.dag-task.results.missingResult)"), + Value: *v1.NewStructuredValues("$(tasks.dag-task.results.missingResult)"), }}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "final-task-3", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - WhenExpressions: v1beta1.WhenExpressions{{ + TaskRef: &v1.TaskRef{Name: "task"}, + When: v1.WhenExpressions{{ Input: "foo", Operator: selection.NotIn, Values: []string{"bar"}, }}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "final-task-4", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - WhenExpressions: v1beta1.WhenExpressions{{ + TaskRef: &v1.TaskRef{Name: "task"}, + When: v1.WhenExpressions{{ Input: "foo", Operator: selection.In, Values: []string{"bar"}, }}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "final-task-5", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - WhenExpressions: v1beta1.WhenExpressions{{ + TaskRef: &v1.TaskRef{Name: "task"}, + When: v1.WhenExpressions{{ Input: "$(tasks.dag-task.results.commit)", Operator: selection.In, Values: []string{"SHA2"}, }}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "final-task-6", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - WhenExpressions: v1beta1.WhenExpressions{{ + TaskRef: &v1.TaskRef{Name: "task"}, + When: v1.WhenExpressions{{ Input: "$(tasks.dag-task.results.missing)", Operator: selection.In, Values: []string{"none"}, @@ -2509,20 +2510,20 @@ func TestResolvedPipelineRunTask_IsFinallySkipped(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - tasks := v1beta1.PipelineTaskList([]v1beta1.PipelineTask{*state[0].PipelineTask}) + tasks := v1.PipelineTaskList([]v1.PipelineTask{*state[0].PipelineTask}) d, err := dag.Build(tasks, tasks.Deps()) if err != nil { t.Fatalf("Could not get a dag from the dag tasks %#v: %v", state[0], err) } // build graph with finally tasks - var pts []v1beta1.PipelineTask + var pts []v1.PipelineTask for i := range state { if i > 0 { // first one is a dag task that produces a result pts = append(pts, *state[i].PipelineTask) } } - dfinally, err := dag.Build(v1beta1.PipelineTaskList(pts), map[string][]string{}) + dfinally, err := dag.Build(v1.PipelineTaskList(pts), map[string][]string{}) if err != nil { t.Fatalf("Could not get a dag from the finally tasks %#v: %v", pts, err) } @@ -2567,11 +2568,11 @@ func TestResolvedPipelineRunTask_IsFinallySkipped(t *testing.T) { func TestResolvedPipelineRunTask_IsFinallySkippedByCondition(t *testing.T) { task := &ResolvedPipelineTask{ TaskRunName: "dag-task", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "dag-task", }, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -2580,9 +2581,9 @@ func TestResolvedPipelineRunTask_IsFinallySkippedByCondition(t *testing.T) { }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "dag-task", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, } for _, tc := range []struct { @@ -2594,11 +2595,11 @@ func TestResolvedPipelineRunTask_IsFinallySkippedByCondition(t *testing.T) { state: PipelineRunState{ task, { - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "final-task", }, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -2607,10 +2608,10 @@ func TestResolvedPipelineRunTask_IsFinallySkippedByCondition(t *testing.T) { }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "final-task", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - WhenExpressions: []v1beta1.WhenExpression{ + TaskRef: &v1.TaskRef{Name: "task"}, + When: []v1.WhenExpression{ { Input: "$(tasks.dag-task.status)", Operator: selection.In, @@ -2622,7 +2623,7 @@ func TestResolvedPipelineRunTask_IsFinallySkippedByCondition(t *testing.T) { }, want: TaskSkipStatus{ IsSkipped: false, - SkippingReason: v1beta1.None, + SkippingReason: v1.None, }, }, { name: "task scheduled", @@ -2630,20 +2631,20 @@ func TestResolvedPipelineRunTask_IsFinallySkippedByCondition(t *testing.T) { task, { TaskRunName: "final-task", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "final-task", }, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: []apis.Condition{ /* explicitly empty */ }, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "final-task", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - WhenExpressions: []v1beta1.WhenExpression{ + TaskRef: &v1.TaskRef{Name: "task"}, + When: []v1.WhenExpression{ { Input: "$(tasks.dag-task.status)", Operator: selection.In, @@ -2654,18 +2655,18 @@ func TestResolvedPipelineRunTask_IsFinallySkippedByCondition(t *testing.T) { }}, want: TaskSkipStatus{ IsSkipped: false, - SkippingReason: v1beta1.None, + SkippingReason: v1.None, }, }} { t.Run(tc.name, func(t *testing.T) { - tasks := v1beta1.PipelineTaskList([]v1beta1.PipelineTask{*tc.state[0].PipelineTask}) + tasks := v1.PipelineTaskList([]v1.PipelineTask{*tc.state[0].PipelineTask}) d, err := dag.Build(tasks, tasks.Deps()) if err != nil { t.Fatalf("Could not get a dag from the dag tasks %#v: %v", tc.state[0], err) } // build graph with finally tasks - var pts v1beta1.PipelineTaskList + var pts v1.PipelineTaskList for _, state := range tc.state[1:] { pts = append(pts, *state.PipelineTask) } @@ -2694,11 +2695,11 @@ func TestResolvedPipelineRunTask_IsFinallySkippedByCondition(t *testing.T) { } func TestResolvedPipelineRunTask_IsFinalTask(t *testing.T) { - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "dag-task", }, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{ apis.Condition{ @@ -2707,10 +2708,10 @@ func TestResolvedPipelineRunTask_IsFinalTask(t *testing.T) { }, }, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "commit", - Value: *v1beta1.NewStructuredValues("SHA2"), + Value: *v1.NewStructuredValues("SHA2"), }}, }, }, @@ -2719,32 +2720,32 @@ func TestResolvedPipelineRunTask_IsFinalTask(t *testing.T) { state := PipelineRunState{{ TaskRunName: "dag-task", TaskRun: tr, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "dag-task", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "final-task", - TaskRef: &v1beta1.TaskRef{Name: "task"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "task"}, + Params: []v1.Param{{ Name: "commit", - Value: *v1beta1.NewStructuredValues("$(tasks.dag-task.results.commit)"), + Value: *v1.NewStructuredValues("$(tasks.dag-task.results.commit)"), }}, }, }, } - tasks := v1beta1.PipelineTaskList([]v1beta1.PipelineTask{*state[0].PipelineTask}) + tasks := v1.PipelineTaskList([]v1.PipelineTask{*state[0].PipelineTask}) d, err := dag.Build(tasks, tasks.Deps()) if err != nil { t.Fatalf("Could not get a dag from the dag tasks %#v: %v", state[0], err) } // build graph with finally tasks - pts := []v1beta1.PipelineTask{*state[1].PipelineTask} + pts := []v1.PipelineTask{*state[1].PipelineTask} - dfinally, err := dag.Build(v1beta1.PipelineTaskList(pts), map[string][]string{}) + dfinally, err := dag.Build(v1.PipelineTaskList(pts), map[string][]string{}) if err != nil { t.Fatalf("Could not get a dag from the finally tasks %#v: %v", pts, err) } @@ -2767,7 +2768,7 @@ func TestResolvedPipelineRunTask_IsFinalTask(t *testing.T) { func TestGetTaskRunName(t *testing.T) { prName := "pipeline-run" - childRefs := []v1beta1.ChildStatusReference{{ + childRefs := []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{Kind: "TaskRun"}, Name: "taskrun-for-task1", PipelineTaskName: "task1", @@ -2816,7 +2817,7 @@ func TestGetTaskRunName(t *testing.T) { func TestGetNamesOfTaskRuns(t *testing.T) { prName := "mypipelinerun" - childRefs := []v1beta1.ChildStatusReference{{ + childRefs := []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{Kind: "TaskRun"}, Name: "mypipelinerun-mytask-0", PipelineTaskName: "mytask", @@ -2879,7 +2880,7 @@ func TestGetNamesOfTaskRuns(t *testing.T) { func TestGetNamesOfRuns(t *testing.T) { prName := "mypipelinerun" - childRefs := []v1beta1.ChildStatusReference{{ + childRefs := []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{Kind: "Run"}, Name: "mypipelinerun-mytask-0", PipelineTaskName: "mytask", @@ -2942,7 +2943,7 @@ func TestGetNamesOfRuns(t *testing.T) { func TestGetRunName(t *testing.T) { prName := "pipeline-run" - childRefs := []v1beta1.ChildStatusReference{{ + childRefs := []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{Kind: "CustomRun"}, Name: "run-for-task1", PipelineTaskName: "task1", @@ -2994,39 +2995,39 @@ func TestGetRunName(t *testing.T) { } func TestIsMatrixed(t *testing.T) { - pr := v1beta1.PipelineRun{ + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, } - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + getTask := func(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { return task, nil, nil } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return &trs[0], nil } + getTaskRun := func(name string) (*v1.TaskRun, error) { return &trs[0], nil } getRun := func(name string) (v1beta1.RunObject, error) { return &runs[0], nil } for _, tc := range []struct { name string - pt v1beta1.PipelineTask + pt v1.PipelineTask want bool }{{ name: "custom task with matrix", - pt: v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ + pt: v1.PipelineTask{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Sample", }, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "platform", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, }}}, }, want: true, }, { name: "custom task without matrix", - pt: v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ + pt: v1.PipelineTask{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Sample", }, @@ -3034,21 +3035,21 @@ func TestIsMatrixed(t *testing.T) { want: false, }, { name: "task with matrix", - pt: v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ + pt: v1.PipelineTask{ + TaskRef: &v1.TaskRef{ Name: "my-task", }, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "platform", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, }}}, }, want: true, }, { name: "task without matrix", - pt: v1beta1.PipelineTask{ - TaskRef: &v1beta1.TaskRef{ + pt: v1.PipelineTask{ + TaskRef: &v1.TaskRef{ Name: "my-task", }, }, @@ -3080,18 +3081,18 @@ func TestResolvePipelineRunTask_WithMatrix(t *testing.T) { pipelineRunName := "pipelinerun" pipelineTaskName := "pipelinetask" - pr := v1beta1.PipelineRun{ + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: pipelineRunName, }, } - var taskRuns []*v1beta1.TaskRun + var taskRuns []*v1.TaskRun var taskRunsNames []string - taskRunsMap := map[string]*v1beta1.TaskRun{} + taskRunsMap := map[string]*v1.TaskRun{} for i := 0; i < 9; i++ { trName := fmt.Sprintf("%s-%s-%d", pipelineRunName, pipelineTaskName, i) - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: trName, }, @@ -3101,47 +3102,47 @@ func TestResolvePipelineRunTask_WithMatrix(t *testing.T) { taskRunsMap[trName] = tr } - pts := []v1beta1.PipelineTask{{ + pts := []v1.PipelineTask{{ Name: "pipelinetask", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "my-task", }, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "platform", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, }}}, }, { Name: "pipelinetask", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "my-task", }, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "platform", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, }, { Name: "browsers", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"chrome", "safari", "firefox"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"chrome", "safari", "firefox"}}, }}, }}} rtr := &resources.ResolvedTask{ TaskName: "task", - TaskSpec: &v1beta1.TaskSpec{Steps: []v1beta1.Step{{ + TaskSpec: &v1.TaskSpec{Steps: []v1.Step{{ Name: "step1", }}}, } - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + getTask := func(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { return task, nil, nil } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return taskRunsMap[name], nil } + getTaskRun := func(name string) (*v1.TaskRun, error) { return taskRunsMap[name], nil } getRun := func(name string) (v1beta1.RunObject, error) { return &runs[0], nil } for _, tc := range []struct { name string - pt v1beta1.PipelineTask + pt v1.PipelineTask want *ResolvedPipelineTask }{{ name: "task with matrix - single parameter", @@ -3187,7 +3188,7 @@ func TestResolvePipelineRunTask_WithMatrixedCustomTask(t *testing.T) { pipelineRunName := "pipelinerun" pipelineTaskName := "pipelinetask" - pr := v1beta1.PipelineRun{ + pr := v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: pipelineRunName, }, @@ -3208,44 +3209,44 @@ func TestResolvePipelineRunTask_WithMatrixedCustomTask(t *testing.T) { runsMap[runName] = run } - pts := []v1beta1.PipelineTask{{ + pts := []v1.PipelineTask{{ Name: "pipelinetask", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", Name: "my-task", }, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "platform", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, }}}, }, { Name: "pipelinetask", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", Name: "my-task", }, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "platform", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"linux", "mac", "windows"}}, }, { Name: "browsers", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"chrome", "safari", "firefox"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"chrome", "safari", "firefox"}}, }}}, }} - getTask := func(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + getTask := func(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { return task, nil, nil } - getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return &trs[0], nil } + getTaskRun := func(name string) (*v1.TaskRun, error) { return &trs[0], nil } getRun := func(name string) (v1beta1.RunObject, error) { return runsMap[name], nil } for _, tc := range []struct { name string - pt v1beta1.PipelineTask + pt v1.PipelineTask getRun GetRun want *ResolvedPipelineTask }{{ @@ -3270,7 +3271,7 @@ func TestResolvePipelineRunTask_WithMatrixedCustomTask(t *testing.T) { name: "custom task with matrix - nil run", pt: pts[1], getRun: func(name string) (v1beta1.RunObject, error) { - return nil, kerrors.NewNotFound(v1beta1.Resource("run"), name) + return nil, kerrors.NewNotFound(v1.Resource("run"), name) }, want: &ResolvedPipelineTask{ CustomTask: true, @@ -3311,27 +3312,27 @@ func TestIsSuccessful(t *testing.T) { }{{ name: "taskrun not started", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, }, want: false, }, { name: "run not started", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, }, want: false, }, { name: "taskrun running", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: makeStarted(trs[0]), }, want: false, }, { name: "run running", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, RunObject: makeRunStarted(runs[0]), }, @@ -3339,14 +3340,14 @@ func TestIsSuccessful(t *testing.T) { }, { name: "taskrun succeeded", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: makeSucceeded(trs[0]), }, want: true, }, { name: "run succeeded", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, RunObject: makeRunSucceeded(runs[0]), }, @@ -3354,14 +3355,14 @@ func TestIsSuccessful(t *testing.T) { }, { name: "taskrun failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: makeFailed(trs[0]), }, want: false, }, { name: "run failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, RunObject: makeRunFailed(runs[0]), }, @@ -3369,14 +3370,14 @@ func TestIsSuccessful(t *testing.T) { }, { name: "taskrun failed: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, TaskRun: withRetries(makeToBeRetried(trs[0])), }, want: false, }, { name: "run failed: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, RunObject: makeRunFailed(runs[0]), }, @@ -3384,7 +3385,7 @@ func TestIsSuccessful(t *testing.T) { }, { name: "run failed: retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, RunObject: withRunRetries(makeRunFailed(runs[0])), }, @@ -3392,21 +3393,21 @@ func TestIsSuccessful(t *testing.T) { }, { name: "taskrun cancelled", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: withCancelled(makeFailed(trs[0])), }, want: false, }, { name: "taskrun cancelled but not failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: withCancelled(newTaskRun(trs[0])), }, want: false, }, { name: "run cancelled", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, RunObject: withRunCancelled(makeRunFailed(runs[0])), CustomTask: true, }, @@ -3414,7 +3415,7 @@ func TestIsSuccessful(t *testing.T) { }, { name: "run cancelled but not failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, RunObject: withRunCancelled(newRun(runs[0])), CustomTask: true, }, @@ -3422,14 +3423,14 @@ func TestIsSuccessful(t *testing.T) { }, { name: "taskrun cancelled: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, TaskRun: withCancelled(makeFailed(trs[0])), }, want: false, }, { name: "run cancelled: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, RunObject: withRunCancelled(makeRunFailed(runs[0])), CustomTask: true, }, @@ -3437,14 +3438,14 @@ func TestIsSuccessful(t *testing.T) { }, { name: "taskrun cancelled: retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, TaskRun: withCancelled(withRetries(makeFailed(trs[0]))), }, want: false, }, { name: "run cancelled: retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, RunObject: withRunCancelled(withRunRetries(makeRunFailed(runs[0]))), CustomTask: true, }, @@ -3466,7 +3467,7 @@ func TestIsSuccessful(t *testing.T) { name: "matrixed taskruns running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{makeStarted(trs[0]), makeStarted(trs[1])}, }, want: false, }, { @@ -3481,7 +3482,7 @@ func TestIsSuccessful(t *testing.T) { name: "one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeSucceeded(trs[1])}, + TaskRuns: []*v1.TaskRun{makeStarted(trs[0]), makeSucceeded(trs[1])}, }, want: false, }, { @@ -3496,7 +3497,7 @@ func TestIsSuccessful(t *testing.T) { name: "matrixed taskruns succeeded", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0]), makeSucceeded(trs[1])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0]), makeSucceeded(trs[1])}, }, want: true, }, { @@ -3511,7 +3512,7 @@ func TestIsSuccessful(t *testing.T) { name: "one matrixed taskrun succeeded", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0]), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0]), makeStarted(trs[1])}, }, want: false, }, { @@ -3526,7 +3527,7 @@ func TestIsSuccessful(t *testing.T) { name: "matrixed taskruns failed", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])}, + TaskRuns: []*v1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])}, }, want: false, }, { @@ -3541,7 +3542,7 @@ func TestIsSuccessful(t *testing.T) { name: "one matrixed taskrun failed, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{makeFailed(trs[0]), makeStarted(trs[1])}, }, want: false, }, { @@ -3556,7 +3557,7 @@ func TestIsSuccessful(t *testing.T) { name: "matrixed taskruns failed: retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeToBeRetried(trs[1]))}, + TaskRuns: []*v1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeToBeRetried(trs[1]))}, }, want: false, }, { @@ -3571,7 +3572,7 @@ func TestIsSuccessful(t *testing.T) { name: "matrixed taskruns failed: one taskrun with retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeFailed(trs[1]))}, }, want: false, }, { @@ -3594,7 +3595,7 @@ func TestIsSuccessful(t *testing.T) { name: "matrixed taskruns cancelled", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, }, want: false, }, { @@ -3609,7 +3610,7 @@ func TestIsSuccessful(t *testing.T) { name: "one matrixed taskrun cancelled, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, }, want: false, }, { @@ -3624,7 +3625,7 @@ func TestIsSuccessful(t *testing.T) { name: "matrixed taskruns cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), withCancelled(newTaskRun(trs[1]))}, + TaskRuns: []*v1.TaskRun{withCancelled(newTaskRun(trs[0])), withCancelled(newTaskRun(trs[1]))}, }, want: false, }, { @@ -3639,7 +3640,7 @@ func TestIsSuccessful(t *testing.T) { name: "one matrixed taskrun cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(newTaskRun(trs[0])), makeStarted(trs[1])}, }, want: false, }, { @@ -3654,7 +3655,7 @@ func TestIsSuccessful(t *testing.T) { name: "matrixed taskruns cancelled: retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, }, want: false, }, { @@ -3669,7 +3670,7 @@ func TestIsSuccessful(t *testing.T) { name: "one matrixed taskrun cancelled: retries remaining, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, }, want: false, }, { @@ -3684,7 +3685,7 @@ func TestIsSuccessful(t *testing.T) { name: "matrixed taskruns cancelled: retried", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), withCancelled(withRetries(makeFailed(trs[1])))}, + TaskRuns: []*v1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), withCancelled(withRetries(makeFailed(trs[1])))}, }, want: false, }, { @@ -3699,7 +3700,7 @@ func TestIsSuccessful(t *testing.T) { name: "one matrixed taskrun cancelled: retried, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), makeStarted(trs[1])}, }, want: false, }, { @@ -3727,27 +3728,27 @@ func TestIsRunning(t *testing.T) { }{{ name: "taskrun not started", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, }, want: false, }, { name: "run not started", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, }, want: false, }, { name: "taskrun running", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: makeStarted(trs[0]), }, want: true, }, { name: "run running", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, RunObject: makeRunStarted(runs[0]), }, @@ -3755,14 +3756,14 @@ func TestIsRunning(t *testing.T) { }, { name: "taskrun succeeded", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: makeSucceeded(trs[0]), }, want: false, }, { name: "run succeeded", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, RunObject: makeRunSucceeded(runs[0]), }, @@ -3770,14 +3771,14 @@ func TestIsRunning(t *testing.T) { }, { name: "taskrun failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: makeFailed(trs[0]), }, want: false, }, { name: "run failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, CustomTask: true, RunObject: makeRunFailed(runs[0]), }, @@ -3785,14 +3786,14 @@ func TestIsRunning(t *testing.T) { }, { name: "taskrun failed: retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, TaskRun: withRetries(makeFailed(trs[0])), }, want: false, }, { name: "run failed: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, RunObject: makeRunFailed(runs[0]), }, @@ -3800,7 +3801,7 @@ func TestIsRunning(t *testing.T) { }, { name: "run failed: retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, CustomTask: true, RunObject: withRunRetries(makeRunFailed(runs[0])), }, @@ -3808,21 +3809,21 @@ func TestIsRunning(t *testing.T) { }, { name: "taskrun cancelled", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: withCancelled(makeFailed(trs[0])), }, want: false, }, { name: "taskrun cancelled but not failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, TaskRun: withCancelled(newTaskRun(trs[0])), }, want: true, }, { name: "run cancelled", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, RunObject: withRunCancelled(makeRunFailed(runs[0])), CustomTask: true, }, @@ -3830,7 +3831,7 @@ func TestIsRunning(t *testing.T) { }, { name: "run cancelled but not failed", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task"}, + PipelineTask: &v1.PipelineTask{Name: "task"}, RunObject: withRunCancelled(newRun(runs[0])), CustomTask: true, }, @@ -3838,14 +3839,14 @@ func TestIsRunning(t *testing.T) { }, { name: "taskrun cancelled: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, TaskRun: withCancelled(makeFailed(trs[0])), }, want: false, }, { name: "run cancelled: retries remaining", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, RunObject: withRunCancelled(makeRunFailed(runs[0])), CustomTask: true, }, @@ -3853,14 +3854,14 @@ func TestIsRunning(t *testing.T) { }, { name: "taskrun cancelled: retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, TaskRun: withCancelled(withRetries(makeFailed(trs[0]))), }, want: false, }, { name: "run cancelled: retried", rpt: ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{Name: "task", Retries: 1}, + PipelineTask: &v1.PipelineTask{Name: "task", Retries: 1}, RunObject: withRunCancelled(withRunRetries(makeRunFailed(runs[0]))), CustomTask: true, }, @@ -3882,7 +3883,7 @@ func TestIsRunning(t *testing.T) { name: "matrixed taskruns running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{makeStarted(trs[0]), makeStarted(trs[1])}, }, want: true, }, { @@ -3897,7 +3898,7 @@ func TestIsRunning(t *testing.T) { name: "one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeSucceeded(trs[1])}, + TaskRuns: []*v1.TaskRun{makeStarted(trs[0]), makeSucceeded(trs[1])}, }, want: true, }, { @@ -3912,7 +3913,7 @@ func TestIsRunning(t *testing.T) { name: "matrixed taskruns succeeded", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0]), makeSucceeded(trs[1])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0]), makeSucceeded(trs[1])}, }, want: false, }, { @@ -3927,7 +3928,7 @@ func TestIsRunning(t *testing.T) { name: "matrixed taskruns failed", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])}, + TaskRuns: []*v1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])}, }, want: false, }, { @@ -3942,7 +3943,7 @@ func TestIsRunning(t *testing.T) { name: "one matrixed taskrun failed, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{makeFailed(trs[0]), makeStarted(trs[1])}, }, want: true, }, { @@ -3957,7 +3958,7 @@ func TestIsRunning(t *testing.T) { name: "matrixed taskruns failed: retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeToBeRetried(trs[1]))}, + TaskRuns: []*v1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeToBeRetried(trs[1]))}, }, want: true, }, { @@ -3972,7 +3973,7 @@ func TestIsRunning(t *testing.T) { name: "matrixed taskruns failed: one taskrun with retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withRetries(makeToBeRetried(trs[0])), withRetries(makeFailed(trs[1]))}, }, want: true, }, { @@ -3995,7 +3996,7 @@ func TestIsRunning(t *testing.T) { name: "matrixed taskruns cancelled", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, }, want: false, }, { @@ -4010,7 +4011,7 @@ func TestIsRunning(t *testing.T) { name: "one matrixed taskrun cancelled, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, }, want: true, }, { @@ -4025,7 +4026,7 @@ func TestIsRunning(t *testing.T) { name: "matrixed taskruns cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), withCancelled(newTaskRun(trs[1]))}, + TaskRuns: []*v1.TaskRun{withCancelled(newTaskRun(trs[0])), withCancelled(newTaskRun(trs[1]))}, }, want: true, }, { @@ -4040,7 +4041,7 @@ func TestIsRunning(t *testing.T) { name: "one matrixed taskrun cancelled but not failed", rpt: ResolvedPipelineTask{ PipelineTask: matrixedPipelineTask, - TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(newTaskRun(trs[0])), makeStarted(trs[1])}, }, want: true, }, { @@ -4055,7 +4056,7 @@ func TestIsRunning(t *testing.T) { name: "matrixed taskruns cancelled: retries remaining", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, }, want: false, }, { @@ -4070,7 +4071,7 @@ func TestIsRunning(t *testing.T) { name: "one matrixed taskrun cancelled: retries remaining, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, }, want: true, }, { @@ -4085,7 +4086,7 @@ func TestIsRunning(t *testing.T) { name: "matrixed taskruns cancelled: retried", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), withCancelled(withRetries(makeFailed(trs[1])))}, + TaskRuns: []*v1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), withCancelled(withRetries(makeFailed(trs[1])))}, }, want: false, }, { @@ -4100,7 +4101,7 @@ func TestIsRunning(t *testing.T) { name: "one matrixed taskrun cancelled: retried, one matrixed taskrun running", rpt: ResolvedPipelineTask{ PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), - TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), makeStarted(trs[1])}, + TaskRuns: []*v1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), makeStarted(trs[1])}, }, want: true, }, { diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go index 10a2d6cfbd2..3af5b40855b 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go @@ -22,6 +22,7 @@ import ( "time" "github.com/tektoncd/pipeline/pkg/apis/pipeline" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" @@ -53,7 +54,7 @@ type PipelineRunState []*ResolvedPipelineTask // finally tasks, cache of skipped tasks. type PipelineRunFacts struct { State PipelineRunState - SpecStatus v1beta1.PipelineRunSpecStatus + SpecStatus v1.PipelineRunSpecStatus TasksGraph *dag.Graph FinalTasksGraph *dag.Graph TimeoutsState PipelineRunTimeoutsState @@ -151,8 +152,8 @@ func (state PipelineRunState) AdjustStartTime(unadjustedStartTime *metav1.Time) // GetTaskRunsResults returns a map of all successfully completed TaskRuns in the state, with the pipeline task name as // the key and the results from the corresponding TaskRun as the value. It only includes tasks which have completed successfully. -func (state PipelineRunState) GetTaskRunsResults() map[string][]v1beta1.TaskRunResult { - results := make(map[string][]v1beta1.TaskRunResult) +func (state PipelineRunState) GetTaskRunsResults() map[string][]v1.TaskRunResult { + results := make(map[string][]v1.TaskRunResult) for _, rpt := range state { if rpt.IsCustomTask() { continue @@ -161,7 +162,7 @@ func (state PipelineRunState) GetTaskRunsResults() map[string][]v1beta1.TaskRunR continue } if rpt.TaskRun != nil { - results[rpt.PipelineTask.Name] = rpt.TaskRun.Status.TaskRunResults + results[rpt.PipelineTask.Name] = rpt.TaskRun.Status.Results } } return results @@ -198,8 +199,8 @@ func (state PipelineRunState) GetRunsResults() map[string][]v1beta1.CustomRunRes // GetChildReferences returns a slice of references, including version, kind, name, and pipeline task name, for all // TaskRuns and Runs in the state. -func (state PipelineRunState) GetChildReferences() []v1beta1.ChildStatusReference { - var childRefs []v1beta1.ChildStatusReference +func (state PipelineRunState) GetChildReferences() []v1.ChildStatusReference { + var childRefs []v1.ChildStatusReference for _, rpt := range state { switch { @@ -224,38 +225,38 @@ func (state PipelineRunState) GetChildReferences() []v1beta1.ChildStatusReferenc return childRefs } -func (t *ResolvedPipelineTask) getChildRefForRun(runObj v1beta1.RunObject) v1beta1.ChildStatusReference { +func (t *ResolvedPipelineTask) getChildRefForRun(runObj v1beta1.RunObject) v1.ChildStatusReference { apiVersion := "" kind := "" switch runObj.(type) { case *v1beta1.CustomRun: - apiVersion = v1beta1.SchemeGroupVersion.String() + apiVersion = v1.SchemeGroupVersion.String() kind = pipeline.CustomRunControllerName case *v1alpha1.Run: apiVersion = v1alpha1.SchemeGroupVersion.String() kind = pipeline.RunControllerName } - return v1beta1.ChildStatusReference{ + return v1.ChildStatusReference{ TypeMeta: runtime.TypeMeta{ APIVersion: apiVersion, Kind: kind, }, Name: runObj.GetObjectMeta().GetName(), PipelineTaskName: t.PipelineTask.Name, - WhenExpressions: t.PipelineTask.WhenExpressions, + WhenExpressions: t.PipelineTask.When, } } -func (t *ResolvedPipelineTask) getChildRefForTaskRun(taskRun *v1beta1.TaskRun) v1beta1.ChildStatusReference { - return v1beta1.ChildStatusReference{ +func (t *ResolvedPipelineTask) getChildRefForTaskRun(taskRun *v1.TaskRun) v1.ChildStatusReference { + return v1.ChildStatusReference{ TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), + APIVersion: v1.SchemeGroupVersion.String(), Kind: pipeline.TaskRunControllerName, }, Name: taskRun.Name, PipelineTaskName: t.PipelineTask.Name, - WhenExpressions: t.PipelineTask.WhenExpressions, + WhenExpressions: t.PipelineTask.When, } } @@ -335,17 +336,17 @@ func (facts *PipelineRunFacts) IsRunning() bool { // IsCancelled returns true if the PipelineRun was cancelled func (facts *PipelineRunFacts) IsCancelled() bool { - return facts.SpecStatus == v1beta1.PipelineRunSpecStatusCancelled + return facts.SpecStatus == v1.PipelineRunSpecStatusCancelled } // IsGracefullyCancelled returns true if the PipelineRun was gracefully cancelled func (facts *PipelineRunFacts) IsGracefullyCancelled() bool { - return facts.SpecStatus == v1beta1.PipelineRunSpecStatusCancelledRunFinally + return facts.SpecStatus == v1.PipelineRunSpecStatusCancelledRunFinally } // IsGracefullyStopped returns true if the PipelineRun was gracefully stopped func (facts *PipelineRunFacts) IsGracefullyStopped() bool { - return facts.SpecStatus == v1beta1.PipelineRunSpecStatusStoppedRunFinally + return facts.SpecStatus == v1.PipelineRunSpecStatusStoppedRunFinally } // DAGExecutionQueue returns a list of DAG tasks which needs to be scheduled next @@ -417,7 +418,7 @@ func (facts *PipelineRunFacts) GetFinalTasks() PipelineRunState { // GetPipelineConditionStatus will return the Condition that the PipelineRun prName should be // updated with, based on the status of the TaskRuns in state. -func (facts *PipelineRunFacts) GetPipelineConditionStatus(ctx context.Context, pr *v1beta1.PipelineRun, logger *zap.SugaredLogger, c clock.PassiveClock) *apis.Condition { +func (facts *PipelineRunFacts) GetPipelineConditionStatus(ctx context.Context, pr *v1.PipelineRun, logger *zap.SugaredLogger, c clock.PassiveClock) *apis.Condition { // We have 4 different states here: // 1. Timed out -> Failed // 2. All tasks are done and at least one has failed or has been cancelled -> Failed @@ -427,7 +428,7 @@ func (facts *PipelineRunFacts) GetPipelineConditionStatus(ctx context.Context, p return &apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.PipelineRunReasonTimedOut.String(), + Reason: v1.PipelineRunReasonTimedOut.String(), Message: fmt.Sprintf("PipelineRun %q failed to finish within %q", pr.Name, pr.PipelineTimeout(ctx).String()), } } @@ -440,32 +441,32 @@ func (facts *PipelineRunFacts) GetPipelineConditionStatus(ctx context.Context, p // The completion reason is set from the TaskRun completion reason // by default, set it to ReasonRunning - reason := v1beta1.PipelineRunReasonRunning.String() + reason := v1.PipelineRunReasonRunning.String() // check if the pipeline is finished executing all tasks i.e. no incomplete tasks if s.Incomplete == 0 { status := corev1.ConditionTrue - reason := v1beta1.PipelineRunReasonSuccessful.String() + reason := v1.PipelineRunReasonSuccessful.String() message := fmt.Sprintf("Tasks Completed: %d (Failed: %d, Cancelled %d), Skipped: %d", cmTasks, s.Failed, s.Cancelled, s.Skipped) // Set reason to ReasonCompleted - At least one is skipped if s.Skipped > 0 { - reason = v1beta1.PipelineRunReasonCompleted.String() + reason = v1.PipelineRunReasonCompleted.String() } switch { case s.Failed > 0 || s.SkippedDueToTimeout > 0: // Set reason to ReasonFailed - At least one failed - reason = v1beta1.PipelineRunReasonFailed.String() + reason = v1.PipelineRunReasonFailed.String() status = corev1.ConditionFalse case pr.IsGracefullyCancelled() || pr.IsGracefullyStopped(): // Set reason to ReasonCancelled - Cancellation requested - reason = v1beta1.PipelineRunReasonCancelled.String() + reason = v1.PipelineRunReasonCancelled.String() status = corev1.ConditionFalse message = fmt.Sprintf("PipelineRun %q was cancelled", pr.Name) case s.Cancelled > 0: // Set reason to ReasonCancelled - At least one is cancelled and no failure yet - reason = v1beta1.PipelineRunReasonCancelled.String() + reason = v1.PipelineRunReasonCancelled.String() status = corev1.ConditionFalse } logger.Infof("All TaskRuns have finished for PipelineRun %s so it has finished", pr.Name) @@ -481,15 +482,15 @@ func (facts *PipelineRunFacts) GetPipelineConditionStatus(ctx context.Context, p switch { case pr.IsGracefullyCancelled(): // Transition pipeline into running finally state, when graceful cancel is in progress - reason = v1beta1.PipelineRunReasonCancelledRunningFinally.String() + reason = v1.PipelineRunReasonCancelledRunningFinally.String() case pr.IsGracefullyStopped(): // Transition pipeline into running finally state, when graceful stop is in progress - reason = v1beta1.PipelineRunReasonStoppedRunningFinally.String() + reason = v1.PipelineRunReasonStoppedRunningFinally.String() case s.Cancelled > 0 || (s.Failed > 0 && facts.checkFinalTasksDone()): // Transition pipeline into stopping state when one of the tasks(dag/final) cancelled or one of the dag tasks failed // for a pipeline with final tasks, single dag task failure does not transition to interim stopping state // pipeline stays in running state until all final tasks are done before transitioning to failed state - reason = v1beta1.PipelineRunReasonStopping.String() + reason = v1.PipelineRunReasonStopping.String() } // return the status @@ -503,26 +504,26 @@ func (facts *PipelineRunFacts) GetPipelineConditionStatus(ctx context.Context, p } // GetSkippedTasks constructs a list of SkippedTask struct to be included in the PipelineRun Status -func (facts *PipelineRunFacts) GetSkippedTasks() []v1beta1.SkippedTask { - var skipped []v1beta1.SkippedTask +func (facts *PipelineRunFacts) GetSkippedTasks() []v1.SkippedTask { + var skipped []v1.SkippedTask for _, rpt := range facts.State { if rpt.Skip(facts).IsSkipped { - skippedTask := v1beta1.SkippedTask{ + skippedTask := v1.SkippedTask{ Name: rpt.PipelineTask.Name, Reason: rpt.Skip(facts).SkippingReason, - WhenExpressions: rpt.PipelineTask.WhenExpressions, + WhenExpressions: rpt.PipelineTask.When, } skipped = append(skipped, skippedTask) } if rpt.IsFinallySkipped(facts).IsSkipped { - skippedTask := v1beta1.SkippedTask{ + skippedTask := v1.SkippedTask{ Name: rpt.PipelineTask.Name, Reason: rpt.IsFinallySkipped(facts).SkippingReason, } // include the when expressions only when the finally task was skipped because // its when expressions evaluated to false (not because results variables were missing) - if rpt.IsFinallySkipped(facts).SkippingReason == v1beta1.WhenExpressionsSkip { - skippedTask.WhenExpressions = rpt.PipelineTask.WhenExpressions + if rpt.IsFinallySkipped(facts).SkippingReason == v1.WhenExpressionsSkip { + skippedTask.WhenExpressions = rpt.PipelineTask.When } skipped = append(skipped, skippedTask) } @@ -541,10 +542,10 @@ func (facts *PipelineRunFacts) GetPipelineTaskStatus() map[string]string { switch { // execution status is Succeeded when a task has succeeded condition with status set to true case t.isSuccessful(): - s = v1beta1.TaskRunReasonSuccessful.String() + s = v1.TaskRunReasonSuccessful.String() // execution status is Failed when a task has succeeded condition with status set to false case t.isConditionStatusFalse(): - s = v1beta1.TaskRunReasonFailed.String() + s = v1.TaskRunReasonFailed.String() default: // None includes skipped as well s = PipelineTaskStateNone @@ -557,23 +558,23 @@ func (facts *PipelineRunFacts) GetPipelineTaskStatus() map[string]string { if facts.checkDAGTasksDone() { // all dag tasks are done, change the aggregate status to succeeded // will reset it to failed/skipped if needed - aggregateStatus = v1beta1.PipelineRunReasonSuccessful.String() + aggregateStatus = v1.PipelineRunReasonSuccessful.String() for _, t := range facts.State { if facts.isDAGTask(t.PipelineTask.Name) { // if any of the dag task failed, change the aggregate status to failed and return if t.isConditionStatusFalse() { - aggregateStatus = v1beta1.PipelineRunReasonFailed.String() + aggregateStatus = v1.PipelineRunReasonFailed.String() break } // if any of the dag task skipped, change the aggregate status to completed // but continue checking for any other failure if t.Skip(facts).IsSkipped { - aggregateStatus = v1beta1.PipelineRunReasonCompleted.String() + aggregateStatus = v1.PipelineRunReasonCompleted.String() } } } } - tStatus[v1beta1.PipelineTasksAggregateStatus] = aggregateStatus + tStatus[v1.PipelineTasksAggregateStatus] = aggregateStatus return tStatus } @@ -639,9 +640,9 @@ func (facts *PipelineRunFacts) getPipelineTasksCount() pipelineRunStatusCount { case t.isFailure(): s.Failed++ // increment skipped and skipped due to timeout counters since the task was skipped due to the pipeline, tasks, or finally timeout being reached before the task was launched - case t.Skip(facts).SkippingReason == v1beta1.PipelineTimedOutSkip || - t.Skip(facts).SkippingReason == v1beta1.TasksTimedOutSkip || - t.IsFinallySkipped(facts).SkippingReason == v1beta1.FinallyTimedOutSkip: + case t.Skip(facts).SkippingReason == v1.PipelineTimedOutSkip || + t.Skip(facts).SkippingReason == v1.TasksTimedOutSkip || + t.IsFinallySkipped(facts).SkippingReason == v1.FinallyTimedOutSkip: s.Skipped++ s.SkippedDueToTimeout++ // increment skip counter since the task is skipped diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go index b887ac46dce..6d980435140 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go @@ -24,6 +24,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" @@ -682,7 +683,7 @@ status: var taskCancelledByStatusStateMatrix = PipelineRunState{{ PipelineTask: &pts[20], // 2 retries needed TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeRetried(trs[0]))}, + TaskRuns: []*v1.TaskRun{withCancelled(makeRetried(trs[0]))}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -691,7 +692,7 @@ status: var taskCancelledBySpecStateMatrix = PipelineRunState{{ PipelineTask: &pts[20], // 2 retries needed TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{withCancelledBySpec(makeRetried(trs[0]))}, + TaskRuns: []*v1.TaskRun{withCancelledBySpec(makeRetried(trs[0]))}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -700,7 +701,7 @@ status: var taskRunningStateMatrix = PipelineRunState{{ PipelineTask: &pts[20], // 2 retries needed TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0])}, + TaskRuns: []*v1.TaskRun{makeStarted(trs[0])}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -709,7 +710,7 @@ status: var taskSucceededStateMatrix = PipelineRunState{{ PipelineTask: &pts[20], // 2 retries needed TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0])}, + TaskRuns: []*v1.TaskRun{makeSucceeded(trs[0])}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -718,7 +719,7 @@ status: var taskRetriedStateMatrix = PipelineRunState{{ PipelineTask: &pts[17], // 1 retry needed TaskRunNames: []string{"pipelinerun-mytask1"}, - TaskRuns: []*v1beta1.TaskRun{withCancelled(makeRetried(trs[0]))}, + TaskRuns: []*v1.TaskRun{withCancelled(makeRetried(trs[0]))}, ResolvedTask: &resources.ResolvedTask{ TaskSpec: &task.Spec, }, @@ -918,9 +919,9 @@ status: // in different states (without dependencies on each other) and the PipelineRun in different states. func TestDAGExecutionQueue(t *testing.T) { createdTask := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "createdtask", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, TaskRunName: "createdtask", ResolvedTask: &resources.ResolvedTask{ @@ -928,17 +929,17 @@ func TestDAGExecutionQueue(t *testing.T) { }, } createdRun := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "createdrun", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, RunObjectName: "createdrun", CustomTask: true, } runningTask := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "runningtask", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, TaskRunName: "runningtask", TaskRun: newTaskRun(trs[0]), @@ -947,18 +948,18 @@ func TestDAGExecutionQueue(t *testing.T) { }, } runningRun := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "runningrun", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, RunObjectName: "runningrun", RunObject: newRun(runs[0]), CustomTask: true, } successfulTask := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "successfultask", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, TaskRunName: "successfultask", TaskRun: makeSucceeded(trs[0]), @@ -967,18 +968,18 @@ func TestDAGExecutionQueue(t *testing.T) { }, } successfulRun := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "successfulrun", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, RunObjectName: "successfulrun", RunObject: makeRunSucceeded(runs[0]), CustomTask: true, } failedTask := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "failedtask", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, TaskRunName: "failedtask", TaskRun: makeFailed(trs[0]), @@ -1005,18 +1006,18 @@ status: reason: Timedout `) failedCustomRun := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "failedrun", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, RunObjectName: "failedrun", RunObject: makeRunFailed(runs[0]), CustomTask: true, } failedRunWithRetries := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "failedrunwithretries", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, Retries: 1, }, RunObjectName: "failedrunwithretries", @@ -1026,11 +1027,11 @@ status: tcs := []struct { name string state PipelineRunState - specStatus v1beta1.PipelineRunSpecStatus + specStatus v1.PipelineRunSpecStatus want PipelineRunState }{{ name: "cancelled", - specStatus: v1beta1.PipelineRunSpecStatusCancelled, + specStatus: v1.PipelineRunSpecStatusCancelled, state: PipelineRunState{ &createdTask, &createdRun, &runningTask, &runningRun, &successfulTask, &successfulRun, @@ -1038,7 +1039,7 @@ status: }, }, { name: "gracefully cancelled", - specStatus: v1beta1.PipelineRunSpecStatusCancelledRunFinally, + specStatus: v1.PipelineRunSpecStatusCancelledRunFinally, state: PipelineRunState{ &createdTask, &createdRun, &runningTask, &runningRun, &successfulTask, &successfulRun, @@ -1046,13 +1047,13 @@ status: }, }, { name: "gracefully stopped", - specStatus: v1beta1.PipelineRunSpecStatusStoppedRunFinally, + specStatus: v1.PipelineRunSpecStatusStoppedRunFinally, state: PipelineRunState{ &createdTask, &createdRun, &runningTask, &runningRun, &successfulTask, &successfulRun, }, }, { name: "gracefully stopped with retryable tasks", - specStatus: v1beta1.PipelineRunSpecStatusStoppedRunFinally, + specStatus: v1.PipelineRunSpecStatusStoppedRunFinally, state: PipelineRunState{ &createdTask, &createdRun, &runningTask, &runningRun, &successfulTask, &successfulRun, &failedTask, &failedCustomRun, &failedRunWithRetries, @@ -1113,9 +1114,9 @@ status: // in different states for a running or stopping PipelineRun. func TestDAGExecutionQueueSequentialTasks(t *testing.T) { firstTask := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "task-1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, TaskRunName: "task-1", ResolvedTask: &resources.ResolvedTask{ @@ -1123,9 +1124,9 @@ func TestDAGExecutionQueueSequentialTasks(t *testing.T) { }, } secondTask := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "task-2", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"task-1"}, }, TaskRunName: "task-2", @@ -1136,9 +1137,9 @@ func TestDAGExecutionQueueSequentialTasks(t *testing.T) { tcs := []struct { name string - firstTaskRun *v1beta1.TaskRun - secondTaskRun *v1beta1.TaskRun - specStatus v1beta1.PipelineRunSpecStatus + firstTaskRun *v1.TaskRun + secondTaskRun *v1.TaskRun + specStatus v1.PipelineRunSpecStatus wantFirst bool wantSecond bool }{{ @@ -1209,17 +1210,17 @@ func TestDAGExecutionQueueSequentialTasks(t *testing.T) { // in different states for a running or stopping PipelineRun. func TestDAGExecutionQueueSequentialRuns(t *testing.T) { firstRun := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "task-1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, RunObjectName: "task-1", CustomTask: true, } secondRun := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "task-2", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, RunAfter: []string{"task-1"}, }, RunObjectName: "task-2", @@ -1230,7 +1231,7 @@ func TestDAGExecutionQueueSequentialRuns(t *testing.T) { name string firstRun *v1beta1.CustomRun secondRun *v1beta1.CustomRun - specStatus v1beta1.PipelineRunSpecStatus + specStatus v1.PipelineRunSpecStatus wantFirst bool wantSecond bool }{{ @@ -1306,7 +1307,7 @@ func TestPipelineRunState_CompletedOrSkippedDAGTasks(t *testing.T) { tcs := []struct { name string state PipelineRunState - specStatus v1beta1.PipelineRunSpecStatus + specStatus v1.PipelineRunSpecStatus expectedNames []string }{{ name: "no-tasks-started", @@ -1315,7 +1316,7 @@ func TestPipelineRunState_CompletedOrSkippedDAGTasks(t *testing.T) { }, { name: "no-tasks-started-run-cancelled-gracefully", state: noneStartedState, - specStatus: v1beta1.PipelineRunSpecStatusCancelledRunFinally, + specStatus: v1.PipelineRunSpecStatusCancelledRunFinally, expectedNames: []string{pts[0].Name, pts[1].Name}, }, { name: "one-task-started", @@ -1324,7 +1325,7 @@ func TestPipelineRunState_CompletedOrSkippedDAGTasks(t *testing.T) { }, { name: "one-task-started-run-stopped-gracefully", state: oneStartedState, - specStatus: v1beta1.PipelineRunSpecStatusStoppedRunFinally, + specStatus: v1.PipelineRunSpecStatusStoppedRunFinally, expectedNames: []string{pts[1].Name}, }, { name: "one-task-finished", @@ -1333,7 +1334,7 @@ func TestPipelineRunState_CompletedOrSkippedDAGTasks(t *testing.T) { }, { name: "one-task-finished-run-cancelled-forcefully", state: oneFinishedState, - specStatus: v1beta1.PipelineRunSpecStatusCancelled, + specStatus: v1.PipelineRunSpecStatusCancelled, expectedNames: []string{pts[0].Name}, }, { name: "one-task-failed", @@ -1393,21 +1394,21 @@ func TestPipelineRunState_CompletedOrSkippedDAGTasks(t *testing.T) { func buildPipelineStateWithLargeDependencyGraph(t *testing.T) PipelineRunState { t.Helper() - var task = &v1beta1.Task{ + var task = &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task", }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", }}, }, } var pipelineRunState PipelineRunState pipelineRunState = []*ResolvedPipelineTask{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "t1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, TaskRun: nil, ResolvedTask: &resources.ResolvedTask{ @@ -1423,22 +1424,22 @@ func buildPipelineStateWithLargeDependencyGraph(t *testing.T) PipelineRunState { dependFrom = i - (i % 10) } } - params := []v1beta1.Param{} + params := []v1.Param{} var alpha byte for alpha = 'a'; alpha <= 'j'; alpha++ { - params = append(params, v1beta1.Param{ + params = append(params, v1.Param{ Name: fmt.Sprintf("%c", alpha), - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: fmt.Sprintf("$(tasks.t%d.results.%c)", dependFrom, alpha), }, }) } pipelineRunState = append(pipelineRunState, &ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: fmt.Sprintf("t%d", i), Params: params, - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, TaskRun: nil, ResolvedTask: &resources.ResolvedTask{ @@ -1452,21 +1453,21 @@ func buildPipelineStateWithLargeDependencyGraph(t *testing.T) PipelineRunState { func buildPipelineStateWithMultipleTaskResults(t *testing.T, includeWhen bool) PipelineRunState { t.Helper() - var task = &v1beta1.Task{ + var task = &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task", }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", }}, }, } var pipelineRunState PipelineRunState pipelineRunState = []*ResolvedPipelineTask{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "t1", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, TaskRun: nil, ResolvedTask: &resources.ResolvedTask{ @@ -1474,18 +1475,18 @@ func buildPipelineStateWithMultipleTaskResults(t *testing.T, includeWhen bool) P }, }} for i := 2; i < 400; i++ { - var params []v1beta1.Param - whenExpressions := v1beta1.WhenExpressions{} + var params []v1.Param + whenExpressions := v1.WhenExpressions{} var alpha byte // the task has a reference to multiple task results (a through j) from each parent task - causing a redundant references // the task dependents on all predecessors in a graph through params and/or whenExpressions for j := 1; j < i; j++ { for alpha = 'a'; alpha <= 'j'; alpha++ { // include param with task results - params = append(params, v1beta1.Param{ + params = append(params, v1.Param{ Name: fmt.Sprintf("%c", alpha), - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: fmt.Sprintf("$(tasks.t%d.results.%c)", j, alpha), }, }) @@ -1493,7 +1494,7 @@ func buildPipelineStateWithMultipleTaskResults(t *testing.T, includeWhen bool) P if includeWhen { for alpha = 'a'; alpha <= 'j'; alpha++ { // include when expressions with task results - whenExpressions = append(whenExpressions, v1beta1.WhenExpression{ + whenExpressions = append(whenExpressions, v1.WhenExpression{ Input: fmt.Sprintf("$(tasks.t%d.results.%c)", j, alpha), Operator: selection.In, Values: []string{"true"}, @@ -1502,11 +1503,11 @@ func buildPipelineStateWithMultipleTaskResults(t *testing.T, includeWhen bool) P } } pipelineRunState = append(pipelineRunState, &ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ - Name: fmt.Sprintf("t%d", i), - Params: params, - TaskRef: &v1beta1.TaskRef{Name: "task"}, - WhenExpressions: whenExpressions, + PipelineTask: &v1.PipelineTask{ + Name: fmt.Sprintf("t%d", i), + Params: params, + TaskRef: &v1.TaskRef{Name: "task"}, + When: whenExpressions, }, TaskRun: nil, ResolvedTask: &resources.ResolvedTask{ @@ -1523,8 +1524,8 @@ func TestPipelineRunState_GetFinalTasksAndNames(t *testing.T) { name string desc string state PipelineRunState - DAGTasks []v1beta1.PipelineTask - finalTasks []v1beta1.PipelineTask + DAGTasks []v1.PipelineTask + finalTasks []v1.PipelineTask expectedFinalTasks PipelineRunState expectedFinalNames sets.String expectedTaskNames sets.String @@ -1535,8 +1536,8 @@ func TestPipelineRunState_GetFinalTasksAndNames(t *testing.T) { desc: "DAG tasks (mytask1 and mytask2) finished successfully -" + " do not schedule final tasks since pipeline didnt have any", state: oneStartedState, - DAGTasks: []v1beta1.PipelineTask{pts[0], pts[1]}, - finalTasks: []v1beta1.PipelineTask{}, + DAGTasks: []v1.PipelineTask{pts[0], pts[1]}, + finalTasks: []v1.PipelineTask{}, expectedFinalTasks: PipelineRunState{}, expectedFinalNames: nil, expectedTaskNames: sets.NewString(pts[0].Name, pts[1].Name), @@ -1546,8 +1547,8 @@ func TestPipelineRunState_GetFinalTasksAndNames(t *testing.T) { name: "02 - DAG task not started, no final tasks", desc: "DAG tasks (mytask1) not started yet - do not schedule final tasks (mytask2)", state: noneStartedState, - DAGTasks: []v1beta1.PipelineTask{pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, + DAGTasks: []v1.PipelineTask{pts[0]}, + finalTasks: []v1.PipelineTask{pts[1]}, expectedFinalTasks: PipelineRunState{}, expectedFinalNames: sets.NewString(pts[1].Name), expectedTaskNames: sets.NewString(pts[0].Name), @@ -1557,8 +1558,8 @@ func TestPipelineRunState_GetFinalTasksAndNames(t *testing.T) { name: "03 - DAG task not finished, no final tasks", desc: "DAG tasks (mytask1) started but not finished - do not schedule final tasks (mytask2)", state: oneStartedState, - DAGTasks: []v1beta1.PipelineTask{pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, + DAGTasks: []v1.PipelineTask{pts[0]}, + finalTasks: []v1.PipelineTask{pts[1]}, expectedFinalTasks: PipelineRunState{}, expectedFinalNames: sets.NewString(pts[1].Name), expectedTaskNames: sets.NewString(pts[0].Name), @@ -1568,8 +1569,8 @@ func TestPipelineRunState_GetFinalTasksAndNames(t *testing.T) { name: "04 - DAG task done, return final tasks", desc: "DAG tasks (mytask1) done - schedule final tasks (mytask2)", state: oneFinishedState, - DAGTasks: []v1beta1.PipelineTask{pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, + DAGTasks: []v1.PipelineTask{pts[0]}, + finalTasks: []v1.PipelineTask{pts[1]}, expectedFinalTasks: PipelineRunState{oneFinishedState[1]}, expectedFinalNames: sets.NewString(pts[1].Name), expectedTaskNames: sets.NewString(pts[0].Name), @@ -1579,8 +1580,8 @@ func TestPipelineRunState_GetFinalTasksAndNames(t *testing.T) { name: "05 - DAG task failed, return final tasks", desc: "DAG task (mytask1) failed - schedule final tasks (mytask2)", state: oneFailedState, - DAGTasks: []v1beta1.PipelineTask{pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, + DAGTasks: []v1.PipelineTask{pts[0]}, + finalTasks: []v1.PipelineTask{pts[1]}, expectedFinalTasks: PipelineRunState{oneFinishedState[1]}, expectedFinalNames: sets.NewString(pts[1].Name), expectedTaskNames: sets.NewString(pts[0].Name), @@ -1590,18 +1591,18 @@ func TestPipelineRunState_GetFinalTasksAndNames(t *testing.T) { name: "06 - DAG tasks succeeded, final tasks scheduled - no final tasks", desc: "DAG task (mytask1) finished successfully - final task (mytask2) scheduled - no final tasks", state: finalScheduledState, - DAGTasks: []v1beta1.PipelineTask{pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, + DAGTasks: []v1.PipelineTask{pts[0]}, + finalTasks: []v1.PipelineTask{pts[1]}, expectedFinalTasks: PipelineRunState{}, expectedFinalNames: sets.NewString(pts[1].Name), expectedTaskNames: sets.NewString(pts[0].Name), }} for _, tc := range tcs { - dagGraph, err := dag.Build(v1beta1.PipelineTaskList(tc.DAGTasks), v1beta1.PipelineTaskList(tc.DAGTasks).Deps()) + dagGraph, err := dag.Build(v1.PipelineTaskList(tc.DAGTasks), v1.PipelineTaskList(tc.DAGTasks).Deps()) if err != nil { t.Fatalf("Unexpected error while building DAG for pipelineTasks %v: %v", tc.DAGTasks, err) } - finalGraph, err := dag.Build(v1beta1.PipelineTaskList(tc.finalTasks), map[string][]string{}) + finalGraph, err := dag.Build(v1.PipelineTaskList(tc.finalTasks), map[string][]string{}) if err != nil { t.Fatalf("Unexpected error while building DAG for final pipelineTasks %v: %v", tc.finalTasks, err) } @@ -1657,12 +1658,12 @@ func TestGetPipelineConditionStatus(t *testing.T) { var cancelledTask = PipelineRunState{{ PipelineTask: &pts[3], // 1 retry needed TaskRunName: "pipelinerun-mytask1", - TaskRun: &v1beta1.TaskRun{ - Status: v1beta1.TaskRunStatus{ + TaskRun: &v1.TaskRun{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.TaskRunSpecStatusCancelled, + Reason: v1.TaskRunSpecStatusCancelled, }}}, }, }, @@ -1752,7 +1753,7 @@ func TestGetPipelineConditionStatus(t *testing.T) { name string state PipelineRunState finallyState PipelineRunState - specStatus v1beta1.PipelineRunSpecStatus + specStatus v1.PipelineRunSpecStatus timeoutsState PipelineRunTimeoutsState expectedStatus corev1.ConditionStatus expectedReason string @@ -1765,87 +1766,87 @@ func TestGetPipelineConditionStatus(t *testing.T) { name: "no-tasks-started", state: noneStartedState, expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonRunning.String(), + expectedReason: v1.PipelineRunReasonRunning.String(), expectedIncomplete: 2, }, { name: "no-tasks-started-pipeline-run-gracefully-cancelled", state: noneStartedState, - specStatus: v1beta1.PipelineRunSpecStatusCancelledRunFinally, + specStatus: v1.PipelineRunSpecStatusCancelledRunFinally, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonCancelled.String(), + expectedReason: v1.PipelineRunReasonCancelled.String(), expectedSkipped: 2, }, { name: "no-tasks-started-pipeline-run-with-finally-gracefully-cancelled", state: noneStartedState, finallyState: noneStartedState, - specStatus: v1beta1.PipelineRunSpecStatusCancelledRunFinally, + specStatus: v1.PipelineRunSpecStatusCancelledRunFinally, expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonCancelledRunningFinally.String(), + expectedReason: v1.PipelineRunReasonCancelledRunningFinally.String(), expectedIncomplete: 2, }, { name: "no-tasks-started-pipeline-run-with-finally-gracefully-stopped", state: noneStartedState, finallyState: noneStartedState, - specStatus: v1beta1.PipelineRunSpecStatusStoppedRunFinally, + specStatus: v1.PipelineRunSpecStatusStoppedRunFinally, expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonStoppedRunningFinally.String(), + expectedReason: v1.PipelineRunReasonStoppedRunningFinally.String(), expectedIncomplete: 2, }, { name: "one-task-started", state: oneStartedState, expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonRunning.String(), + expectedReason: v1.PipelineRunReasonRunning.String(), expectedIncomplete: 2, }, { name: "one-task-finished", state: oneFinishedState, expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonRunning.String(), + expectedReason: v1.PipelineRunReasonRunning.String(), expectedSucceeded: 1, expectedIncomplete: 1, }, { name: "one-task-finished-pipeline-run-gracefully-stopped", state: oneFinishedState, - specStatus: v1beta1.PipelineRunSpecStatusStoppedRunFinally, + specStatus: v1.PipelineRunSpecStatusStoppedRunFinally, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonCancelled.String(), + expectedReason: v1.PipelineRunReasonCancelled.String(), expectedSucceeded: 1, expectedSkipped: 1, }, { name: "one-task-failed", state: oneFailedState, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), + expectedReason: v1.PipelineRunReasonFailed.String(), expectedFailed: 1, expectedSkipped: 1, }, { name: "all-finished", state: allFinishedState, expectedStatus: corev1.ConditionTrue, - expectedReason: v1beta1.PipelineRunReasonSuccessful.String(), + expectedReason: v1.PipelineRunReasonSuccessful.String(), expectedSucceeded: 2, }, { name: "one-retry-needed", state: taskRetriedState, expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonRunning.String(), + expectedReason: v1.PipelineRunReasonRunning.String(), expectedIncomplete: 1, }, { name: "task that was cancelled", state: taskCancelledFailed, - expectedReason: v1beta1.PipelineRunReasonCancelled.String(), + expectedReason: v1.PipelineRunReasonCancelled.String(), expectedStatus: corev1.ConditionFalse, expectedCancelled: 1, }, { name: "task that was cancelled for timeout", state: taskCancelledFailedTimedOut, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), + expectedReason: v1.PipelineRunReasonFailed.String(), expectedStatus: corev1.ConditionFalse, expectedFailed: 1, }, { name: "task with multiple failures", state: taskMultipleFailuresSkipRunning, - expectedReason: v1beta1.PipelineRunReasonStopping.String(), + expectedReason: v1.PipelineRunReasonStopping.String(), expectedStatus: corev1.ConditionUnknown, expectedSucceeded: 1, expectedFailed: 1, @@ -1855,7 +1856,7 @@ func TestGetPipelineConditionStatus(t *testing.T) { }, { name: "task with multiple failures; one cancelled", state: taskMultipleFailuresOneCancel, - expectedReason: v1beta1.PipelineRunReasonStopping.String(), + expectedReason: v1.PipelineRunReasonStopping.String(), expectedStatus: corev1.ConditionUnknown, expectedSucceeded: 1, expectedFailed: 1, @@ -1865,7 +1866,7 @@ func TestGetPipelineConditionStatus(t *testing.T) { }, { name: "task not started with passed parent; one failed", state: taskNotRunningWithSuccesfulParentsOneFailed, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), + expectedReason: v1.PipelineRunReasonFailed.String(), expectedStatus: corev1.ConditionFalse, expectedSucceeded: 1, expectedFailed: 1, @@ -1874,19 +1875,19 @@ func TestGetPipelineConditionStatus(t *testing.T) { name: "cancelled task should result in cancelled pipeline", state: cancelledTask, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonCancelled.String(), + expectedReason: v1.PipelineRunReasonCancelled.String(), expectedCancelled: 1, }, { name: "cancelled run should result in cancelled pipeline", state: cancelledRun, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonCancelled.String(), + expectedReason: v1.PipelineRunReasonCancelled.String(), expectedCancelled: 1, }, { name: "cancelled for timeout run should result in failed pipeline", state: timedOutRun, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), + expectedReason: v1.PipelineRunReasonFailed.String(), expectedFailed: 1, }, { name: "skipped for timeout run should result in failed pipeline", @@ -1896,16 +1897,16 @@ func TestGetPipelineConditionStatus(t *testing.T) { TasksTimeout: &fiveMinuteDuration, }, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), + expectedReason: v1.PipelineRunReasonFailed.String(), expectedSkipped: 1, }} for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "somepipelinerun", }, - Spec: v1beta1.PipelineRunSpec{ + Spec: v1.PipelineRunSpec{ Status: tc.specStatus, }, } @@ -1991,8 +1992,8 @@ func TestGetPipelineConditionStatus_WithFinalTasks(t *testing.T) { tcs := []struct { name string state PipelineRunState - dagTasks []v1beta1.PipelineTask - finalTasks []v1beta1.PipelineTask + dagTasks []v1.PipelineTask + finalTasks []v1.PipelineTask expectedStatus corev1.ConditionStatus expectedReason string expectedSucceeded int @@ -2003,10 +2004,10 @@ func TestGetPipelineConditionStatus_WithFinalTasks(t *testing.T) { }{{ name: "pipeline with one successful DAG task and failed final task", state: dagSucceededFinalFailed, - dagTasks: []v1beta1.PipelineTask{pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, + dagTasks: []v1.PipelineTask{pts[0]}, + finalTasks: []v1.PipelineTask{pts[1]}, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), + expectedReason: v1.PipelineRunReasonFailed.String(), expectedSucceeded: 1, expectedIncomplete: 0, expectedSkipped: 0, @@ -2015,10 +2016,10 @@ func TestGetPipelineConditionStatus_WithFinalTasks(t *testing.T) { }, { name: "pipeline with one failed DAG task and not started final task", state: dagFailedFinalNotStarted, - dagTasks: []v1beta1.PipelineTask{pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, + dagTasks: []v1.PipelineTask{pts[0]}, + finalTasks: []v1.PipelineTask{pts[1]}, expectedStatus: corev1.ConditionUnknown, - expectedReason: v1beta1.PipelineRunReasonRunning.String(), + expectedReason: v1.PipelineRunReasonRunning.String(), expectedSucceeded: 0, expectedIncomplete: 1, expectedSkipped: 0, @@ -2027,10 +2028,10 @@ func TestGetPipelineConditionStatus_WithFinalTasks(t *testing.T) { }, { name: "pipeline with one failed DAG task and failed final task", state: dagFailedFinalFailed, - dagTasks: []v1beta1.PipelineTask{pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[1]}, + dagTasks: []v1.PipelineTask{pts[0]}, + finalTasks: []v1.PipelineTask{pts[1]}, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), + expectedReason: v1.PipelineRunReasonFailed.String(), expectedSucceeded: 0, expectedIncomplete: 0, expectedSkipped: 0, @@ -2039,10 +2040,10 @@ func TestGetPipelineConditionStatus_WithFinalTasks(t *testing.T) { }, { name: "pipeline with one failed DAG task and skipped final task", state: dagFailedFinalSkipped, - dagTasks: []v1beta1.PipelineTask{pts[0]}, - finalTasks: []v1beta1.PipelineTask{pts[14]}, + dagTasks: []v1.PipelineTask{pts[0]}, + finalTasks: []v1.PipelineTask{pts[14]}, expectedStatus: corev1.ConditionFalse, - expectedReason: v1beta1.PipelineRunReasonFailed.String(), + expectedReason: v1.PipelineRunReasonFailed.String(), expectedSucceeded: 0, expectedIncomplete: 0, expectedSkipped: 1, @@ -2052,17 +2053,17 @@ func TestGetPipelineConditionStatus_WithFinalTasks(t *testing.T) { for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun-final-tasks", }, - Spec: v1beta1.PipelineRunSpec{}, + Spec: v1.PipelineRunSpec{}, } - d, err := dag.Build(v1beta1.PipelineTaskList(tc.dagTasks), v1beta1.PipelineTaskList(tc.dagTasks).Deps()) + d, err := dag.Build(v1.PipelineTaskList(tc.dagTasks), v1.PipelineTaskList(tc.dagTasks).Deps()) if err != nil { t.Fatalf("Unexpected error while building graph for DAG tasks %v: %v", tc.dagTasks, err) } - df, err := dag.Build(v1beta1.PipelineTaskList(tc.finalTasks), map[string][]string{}) + df, err := dag.Build(v1.PipelineTaskList(tc.finalTasks), map[string][]string{}) if err != nil { t.Fatalf("Unexpected error while building graph for final tasks %v: %v", tc.finalTasks, err) } @@ -2095,13 +2096,15 @@ func TestGetPipelineConditionStatus_PipelineTimeoutDeprecated(t *testing.T) { if err != nil { t.Fatalf("Unexpected error while building DAG for state %v: %v", oneFinishedState, err) } - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "pipelinerun-no-tasks-started"}, - Spec: v1beta1.PipelineRunSpec{ - Timeout: &metav1.Duration{Duration: 1 * time.Minute}, + Spec: v1.PipelineRunSpec{ + Timeouts: &v1.TimeoutFields{ + Pipeline: &metav1.Duration{Duration: 1 * time.Minute}, + }, }, - Status: v1beta1.PipelineRunStatus{ - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + Status: v1.PipelineRunStatus{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ StartTime: &metav1.Time{Time: now.Add(-2 * time.Minute)}, }, }, @@ -2115,7 +2118,7 @@ func TestGetPipelineConditionStatus_PipelineTimeoutDeprecated(t *testing.T) { }, } c := facts.GetPipelineConditionStatus(context.Background(), pr, zap.NewNop().Sugar(), testClock) - if c.Status != corev1.ConditionFalse && c.Reason != v1beta1.PipelineRunReasonTimedOut.String() { + if c.Status != corev1.ConditionFalse && c.Reason != v1.PipelineRunReasonTimedOut.String() { t.Fatalf("Expected to get status %s but got %s for state %v", corev1.ConditionFalse, c.Status, oneFinishedState) } } @@ -2126,15 +2129,15 @@ func TestGetPipelineConditionStatus_PipelineTimeouts(t *testing.T) { if err != nil { t.Fatalf("Unexpected error while building DAG for state %v: %v", oneFinishedState, err) } - pr := &v1beta1.PipelineRun{ + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "pipelinerun-no-tasks-started"}, - Spec: v1beta1.PipelineRunSpec{ - Timeouts: &v1beta1.TimeoutFields{ + Spec: v1.PipelineRunSpec{ + Timeouts: &v1.TimeoutFields{ Pipeline: &metav1.Duration{Duration: 1 * time.Minute}, }, }, - Status: v1beta1.PipelineRunStatus{ - PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + Status: v1.PipelineRunStatus{ + PipelineRunStatusFields: v1.PipelineRunStatusFields{ StartTime: &metav1.Time{Time: now.Add(-2 * time.Minute)}, }, }, @@ -2148,7 +2151,7 @@ func TestGetPipelineConditionStatus_PipelineTimeouts(t *testing.T) { }, } c := facts.GetPipelineConditionStatus(context.Background(), pr, zap.NewNop().Sugar(), testClock) - if c.Status != corev1.ConditionFalse && c.Reason != v1beta1.PipelineRunReasonTimedOut.String() { + if c.Status != corev1.ConditionFalse && c.Reason != v1.PipelineRunReasonTimedOut.String() { t.Fatalf("Expected to get status %s but got %s for state %v", corev1.ConditionFalse, c.Status, oneFinishedState) } } @@ -2163,7 +2166,7 @@ func TestAdjustStartTime(t *testing.T) { }{{ name: "same times", prs: PipelineRunState{{ - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "blah", CreationTimestamp: baseline, @@ -2174,7 +2177,7 @@ func TestAdjustStartTime(t *testing.T) { }, { name: "taskrun starts later", prs: PipelineRunState{{ - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "blah", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(1 * time.Second)}, @@ -2186,7 +2189,7 @@ func TestAdjustStartTime(t *testing.T) { }, { name: "taskrun starts earlier", prs: PipelineRunState{{ - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "blah", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(-1 * time.Second)}, @@ -2198,14 +2201,14 @@ func TestAdjustStartTime(t *testing.T) { }, { name: "multiple taskruns, some earlier", prs: PipelineRunState{{ - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "blah1", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(-1 * time.Second)}, }, }, }, { - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "blah2", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(-2 * time.Second)}, @@ -2214,7 +2217,7 @@ func TestAdjustStartTime(t *testing.T) { }, { TaskRun: nil, }, { - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "blah3", CreationTimestamp: metav1.Time{Time: baseline.Time.Add(2 * time.Second)}, @@ -2263,52 +2266,52 @@ func TestPipelineRunFacts_GetPipelineTaskStatus(t *testing.T) { tcs := []struct { name string state PipelineRunState - dagTasks []v1beta1.PipelineTask + dagTasks []v1.PipelineTask expectedStatus map[string]string }{{ name: "no-tasks-started", state: noneStartedState, - dagTasks: []v1beta1.PipelineTask{pts[0], pts[1]}, + dagTasks: []v1.PipelineTask{pts[0], pts[1]}, expectedStatus: map[string]string{ PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, PipelineTaskStatusPrefix + pts[1].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, - v1beta1.PipelineTasksAggregateStatus: PipelineTaskStateNone, + v1.PipelineTasksAggregateStatus: PipelineTaskStateNone, }, }, { name: "one-task-started", state: oneStartedState, - dagTasks: []v1beta1.PipelineTask{pts[0], pts[1]}, + dagTasks: []v1.PipelineTask{pts[0], pts[1]}, expectedStatus: map[string]string{ PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, PipelineTaskStatusPrefix + pts[1].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, - v1beta1.PipelineTasksAggregateStatus: PipelineTaskStateNone, + v1.PipelineTasksAggregateStatus: PipelineTaskStateNone, }, }, { name: "one-task-finished", state: oneFinishedState, - dagTasks: []v1beta1.PipelineTask{pts[0], pts[1]}, + dagTasks: []v1.PipelineTask{pts[0], pts[1]}, expectedStatus: map[string]string{ - PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: v1beta1.TaskRunReasonSuccessful.String(), + PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: v1.TaskRunReasonSuccessful.String(), PipelineTaskStatusPrefix + pts[1].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, - v1beta1.PipelineTasksAggregateStatus: PipelineTaskStateNone, + v1.PipelineTasksAggregateStatus: PipelineTaskStateNone, }, }, { name: "one-task-failed", state: oneFailedState, - dagTasks: []v1beta1.PipelineTask{pts[0], pts[1]}, + dagTasks: []v1.PipelineTask{pts[0], pts[1]}, expectedStatus: map[string]string{ - PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: v1beta1.TaskRunReasonFailed.String(), + PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: v1.TaskRunReasonFailed.String(), PipelineTaskStatusPrefix + pts[1].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, - v1beta1.PipelineTasksAggregateStatus: v1beta1.PipelineRunReasonFailed.String(), + v1.PipelineTasksAggregateStatus: v1.PipelineRunReasonFailed.String(), }, }, { name: "all-finished", state: allFinishedState, - dagTasks: []v1beta1.PipelineTask{pts[0], pts[1]}, + dagTasks: []v1.PipelineTask{pts[0], pts[1]}, expectedStatus: map[string]string{ - PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: v1beta1.TaskRunReasonSuccessful.String(), - PipelineTaskStatusPrefix + pts[1].Name + PipelineTaskStatusSuffix: v1beta1.TaskRunReasonSuccessful.String(), - v1beta1.PipelineTasksAggregateStatus: v1beta1.PipelineRunReasonSuccessful.String(), + PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: v1.TaskRunReasonSuccessful.String(), + PipelineTaskStatusPrefix + pts[1].Name + PipelineTaskStatusSuffix: v1.TaskRunReasonSuccessful.String(), + v1.PipelineTasksAggregateStatus: v1.PipelineRunReasonSuccessful.String(), }, }, { name: "task-with-when-expressions-passed", @@ -2320,10 +2323,10 @@ func TestPipelineRunFacts_GetPipelineTaskStatus(t *testing.T) { TaskSpec: &task.Spec, }, }}, - dagTasks: []v1beta1.PipelineTask{pts[9]}, + dagTasks: []v1.PipelineTask{pts[9]}, expectedStatus: map[string]string{ PipelineTaskStatusPrefix + pts[9].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, - v1beta1.PipelineTasksAggregateStatus: PipelineTaskStateNone, + v1.PipelineTasksAggregateStatus: PipelineTaskStateNone, }, }, { name: "tasks-when-expression-failed-and-task-skipped", @@ -2334,10 +2337,10 @@ func TestPipelineRunFacts_GetPipelineTaskStatus(t *testing.T) { TaskSpec: &task.Spec, }, }}, - dagTasks: []v1beta1.PipelineTask{pts[10]}, + dagTasks: []v1.PipelineTask{pts[10]}, expectedStatus: map[string]string{ PipelineTaskStatusPrefix + pts[10].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, - v1beta1.PipelineTasksAggregateStatus: v1beta1.PipelineRunReasonCompleted.String(), + v1.PipelineTasksAggregateStatus: v1.PipelineRunReasonCompleted.String(), }, }, { name: "when-expression-task-with-parent-started", @@ -2354,19 +2357,19 @@ func TestPipelineRunFacts_GetPipelineTaskStatus(t *testing.T) { TaskSpec: &task.Spec, }, }}, - dagTasks: []v1beta1.PipelineTask{pts[0], pts[11]}, + dagTasks: []v1.PipelineTask{pts[0], pts[11]}, expectedStatus: map[string]string{ PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, PipelineTaskStatusPrefix + pts[11].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, - v1beta1.PipelineTasksAggregateStatus: PipelineTaskStateNone, + v1.PipelineTasksAggregateStatus: PipelineTaskStateNone, }, }, { name: "task-cancelled", state: taskCancelled, - dagTasks: []v1beta1.PipelineTask{pts[4]}, + dagTasks: []v1.PipelineTask{pts[4]}, expectedStatus: map[string]string{ PipelineTaskStatusPrefix + pts[4].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, - v1beta1.PipelineTasksAggregateStatus: PipelineTaskStateNone, + v1.PipelineTasksAggregateStatus: PipelineTaskStateNone, }, }, { name: "one-skipped-one-failed-aggregate-status-must-be-failed", @@ -2384,16 +2387,16 @@ func TestPipelineRunFacts_GetPipelineTaskStatus(t *testing.T) { TaskSpec: &task.Spec, }, }}, - dagTasks: []v1beta1.PipelineTask{pts[0], pts[10]}, + dagTasks: []v1.PipelineTask{pts[0], pts[10]}, expectedStatus: map[string]string{ - PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: v1beta1.PipelineRunReasonFailed.String(), + PipelineTaskStatusPrefix + pts[0].Name + PipelineTaskStatusSuffix: v1.PipelineRunReasonFailed.String(), PipelineTaskStatusPrefix + pts[10].Name + PipelineTaskStatusSuffix: PipelineTaskStateNone, - v1beta1.PipelineTasksAggregateStatus: v1beta1.PipelineRunReasonFailed.String(), + v1.PipelineTasksAggregateStatus: v1.PipelineRunReasonFailed.String(), }, }} for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { - d, err := dag.Build(v1beta1.PipelineTaskList(tc.dagTasks), v1beta1.PipelineTaskList(tc.dagTasks).Deps()) + d, err := dag.Build(v1.PipelineTaskList(tc.dagTasks), v1.PipelineTaskList(tc.dagTasks).Deps()) if err != nil { t.Fatalf("Unexpected error while building graph for DAG tasks %v: %v", tc.dagTasks, err) } @@ -2417,9 +2420,9 @@ func TestPipelineRunFacts_GetSkippedTasks(t *testing.T) { for _, tc := range []struct { name string state PipelineRunState - dagTasks []v1beta1.PipelineTask - finallyTasks []v1beta1.PipelineTask - expectedSkippedTasks []v1beta1.SkippedTask + dagTasks []v1.PipelineTask + finallyTasks []v1.PipelineTask + expectedSkippedTasks []v1.SkippedTask }{{ name: "stopping-skip-taskruns", state: PipelineRunState{{ @@ -2428,10 +2431,10 @@ func TestPipelineRunFacts_GetSkippedTasks(t *testing.T) { }, { PipelineTask: &pts[14], }}, - dagTasks: []v1beta1.PipelineTask{pts[0], pts[14]}, - expectedSkippedTasks: []v1beta1.SkippedTask{{ + dagTasks: []v1.PipelineTask{pts[0], pts[14]}, + expectedSkippedTasks: []v1.SkippedTask{{ Name: pts[14].Name, - Reason: v1beta1.StoppingSkip, + Reason: v1.StoppingSkip, }}, }, { name: "missing-results-skip-finally", @@ -2442,22 +2445,22 @@ func TestPipelineRunFacts_GetSkippedTasks(t *testing.T) { }, { PipelineTask: &pts[14], }}, - dagTasks: []v1beta1.PipelineTask{pts[0]}, - finallyTasks: []v1beta1.PipelineTask{pts[14]}, - expectedSkippedTasks: []v1beta1.SkippedTask{{ + dagTasks: []v1.PipelineTask{pts[0]}, + finallyTasks: []v1.PipelineTask{pts[14]}, + expectedSkippedTasks: []v1.SkippedTask{{ Name: pts[14].Name, - Reason: v1beta1.MissingResultsSkip, + Reason: v1.MissingResultsSkip, }}, }, { name: "when-expressions-skip-finally", state: PipelineRunState{{ PipelineTask: &pts[10], }}, - finallyTasks: []v1beta1.PipelineTask{pts[10]}, - expectedSkippedTasks: []v1beta1.SkippedTask{{ + finallyTasks: []v1.PipelineTask{pts[10]}, + expectedSkippedTasks: []v1.SkippedTask{{ Name: pts[10].Name, - Reason: v1beta1.WhenExpressionsSkip, - WhenExpressions: []v1beta1.WhenExpression{{ + Reason: v1.WhenExpressionsSkip, + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: "notin", Values: []string{"foo", "bar"}, @@ -2465,13 +2468,13 @@ func TestPipelineRunFacts_GetSkippedTasks(t *testing.T) { }}, }} { t.Run(tc.name, func(t *testing.T) { - d, err := dag.Build(v1beta1.PipelineTaskList(tc.dagTasks), v1beta1.PipelineTaskList(tc.dagTasks).Deps()) + d, err := dag.Build(v1.PipelineTaskList(tc.dagTasks), v1.PipelineTaskList(tc.dagTasks).Deps()) if err != nil { - t.Fatalf("Unexpected error while building graph for DAG tasks %v: %v", v1beta1.PipelineTaskList{pts[0]}, err) + t.Fatalf("Unexpected error while building graph for DAG tasks %v: %v", v1.PipelineTaskList{pts[0]}, err) } - df, err := dag.Build(v1beta1.PipelineTaskList(tc.finallyTasks), map[string][]string{}) + df, err := dag.Build(v1.PipelineTaskList(tc.finallyTasks), map[string][]string{}) if err != nil { - t.Fatalf("Unexpected error while building graph for final tasks %v: %v", v1beta1.PipelineTaskList{pts[14]}, err) + t.Fatalf("Unexpected error while building graph for final tasks %v: %v", v1.PipelineTaskList{pts[14]}, err) } facts := PipelineRunFacts{ State: tc.state, @@ -2546,87 +2549,87 @@ func TestPipelineRunFacts_IsRunning(t *testing.T) { func TestPipelineRunState_GetResultsFuncs(t *testing.T) { state := PipelineRunState{{ TaskRunName: "successful-task-with-results", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "successful-task-with-results-1", }, - TaskRun: &v1beta1.TaskRun{ - Status: v1beta1.TaskRunStatus{ + TaskRun: &v1.TaskRun{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, }}}, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("oof"), + Value: *v1.NewStructuredValues("oof"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("rab"), + Value: *v1.NewStructuredValues("rab"), }}, }, }, }, }, { TaskRunName: "successful-task-without-results", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "successful-task-without-results-1", }, - TaskRun: &v1beta1.TaskRun{ - Status: v1beta1.TaskRunStatus{ + TaskRun: &v1.TaskRun{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, }}}, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{}, + TaskRunStatusFields: v1.TaskRunStatusFields{}, }, }, }, { TaskRunName: "failed-task", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "failed-task-1", }, - TaskRun: &v1beta1.TaskRun{ - Status: v1beta1.TaskRunStatus{ + TaskRun: &v1.TaskRun{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, }}}, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "fail-foo", - Value: *v1beta1.NewStructuredValues("fail-oof"), + Value: *v1.NewStructuredValues("fail-oof"), }}, }, }, }, }, { TaskRunName: "incomplete-task", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "incomplete-task-1", }, - TaskRun: &v1beta1.TaskRun{ - Status: v1beta1.TaskRunStatus{ + TaskRun: &v1.TaskRun{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionUnknown, }}}, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "unknown-foo", - Value: *v1beta1.NewStructuredValues("unknown-oof"), + Value: *v1.NewStructuredValues("unknown-oof"), }}, }, }, }, }, { TaskRunName: "nil-taskrun", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "nil-taskrun-1", }, }, { RunObjectName: "successful-run-with-results", CustomTask: true, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "successful-run-with-results-1", }, RunObject: &v1beta1.CustomRun{ @@ -2649,7 +2652,7 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }, { RunObjectName: "successful-run-without-results", CustomTask: true, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "successful-run-without-results-1", }, RunObject: &v1beta1.CustomRun{ @@ -2663,7 +2666,7 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }, }, { RunObjectName: "failed-run", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "failed-run-1", }, RunObject: &v1beta1.CustomRun{ @@ -2682,7 +2685,7 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }, }, { RunObjectName: "incomplete-run", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "incomplete-run-1", }, RunObject: &v1beta1.CustomRun{ @@ -2702,7 +2705,7 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }, { RunObjectName: "nil-run", CustomTask: true, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "nil-run-1", }, }, { @@ -2712,60 +2715,60 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { "matrixed-task-run-2", "matrixed-task-run-3", }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "matrixed-task", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "task", Kind: "Task", - APIVersion: "v1beta1", + APIVersion: "v1", }, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "foobar", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, }, { Name: "quxbaz", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, }}}, }, - TaskRuns: []*v1beta1.TaskRun{{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TaskRuns: []*v1.TaskRun{{ + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-0"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, - Reason: v1beta1.TaskRunReasonSuccessful.String(), + Reason: v1.TaskRunReasonSuccessful.String(), }}}, }, }, { - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-1"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, - Reason: v1beta1.TaskRunReasonSuccessful.String(), + Reason: v1.TaskRunReasonSuccessful.String(), }}}, }, }, { - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-2"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, - Reason: v1beta1.TaskRunReasonSuccessful.String(), + Reason: v1.TaskRunReasonSuccessful.String(), }}}, }, }, { - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-3"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, - Reason: v1beta1.TaskRunReasonSuccessful.String(), + Reason: v1.TaskRunReasonSuccessful.String(), }}}, }, }}, @@ -2776,19 +2779,19 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { "matrixed-run-2", "matrixed-run-3", }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "matrixed-task", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Kind: "Example", APIVersion: "example.dev/v0", }, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "foobar", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, }, { Name: "quxbaz", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, }}}, }, RunObjects: []v1beta1.RunObject{ @@ -2868,13 +2871,13 @@ func TestPipelineRunState_GetResultsFuncs(t *testing.T) { }, }} - expectedTaskResults := map[string][]v1beta1.TaskRunResult{ + expectedTaskResults := map[string][]v1.TaskRunResult{ "successful-task-with-results-1": {{ Name: "foo", - Value: *v1beta1.NewStructuredValues("oof"), + Value: *v1.NewStructuredValues("oof"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("rab"), + Value: *v1.NewStructuredValues("rab"), }}, "successful-task-without-results-1": nil, } @@ -2904,7 +2907,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { testCases := []struct { name string state PipelineRunState - childRefs []v1beta1.ChildStatusReference + childRefs []v1.ChildStatusReference }{ { name: "no-tasks", @@ -2915,12 +2918,12 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { name: "unresolved-task", state: PipelineRunState{{ TaskRunName: "unresolved-task-run", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "unresolved-task-1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "unresolved-task", Kind: "Task", - APIVersion: "v1beta1", + APIVersion: "v1", }, }, }}, @@ -2931,9 +2934,9 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { state: PipelineRunState{{ RunObjectName: "unresolved-custom-task-run", CustomTask: true, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "unresolved-custom-task-1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", Name: "unresolved-custom-task", @@ -2946,32 +2949,32 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { name: "single-task", state: PipelineRunState{{ TaskRunName: "single-task-run", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "single-task-1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "single-task", Kind: "Task", - APIVersion: "v1beta1", + APIVersion: "v1", }, - WhenExpressions: []v1beta1.WhenExpression{{ + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, }, - TaskRun: &v1beta1.TaskRun{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TaskRun: &v1.TaskRun{ + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "single-task-run"}, }, }}, - childRefs: []v1beta1.ChildStatusReference{{ + childRefs: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "TaskRun", }, Name: "single-task-run", PipelineTaskName: "single-task-1", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, @@ -2983,32 +2986,32 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { state: PipelineRunState{{ RunObjectName: "single-custom-task-run", CustomTask: true, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "single-custom-task-1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", Name: "single-custom-task", }, - WhenExpressions: []v1beta1.WhenExpression{{ + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, }, RunObject: &v1beta1.CustomRun{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "single-custom-task-run"}, }, }}, - childRefs: []v1beta1.ChildStatusReference{{ + childRefs: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "CustomRun", }, Name: "single-custom-task-run", PipelineTaskName: "single-custom-task-1", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, @@ -3019,44 +3022,44 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { name: "task-and-custom-task", state: PipelineRunState{{ TaskRunName: "single-task-run", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "single-task-1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "single-task", Kind: "Task", - APIVersion: "v1beta1", + APIVersion: "v1", }, }, - TaskRun: &v1beta1.TaskRun{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TaskRun: &v1.TaskRun{ + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "single-task-run"}, }, }, { RunObjectName: "single-custom-task-run", CustomTask: true, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "single-custom-task-1", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", Name: "single-custom-task", }, }, RunObject: &v1beta1.CustomRun{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "single-custom-task-run"}, }, }}, - childRefs: []v1beta1.ChildStatusReference{{ + childRefs: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "TaskRun", }, Name: "single-task-run", PipelineTaskName: "single-task-1", }, { TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "CustomRun", }, Name: "single-custom-task-run", @@ -3067,28 +3070,28 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { name: "unresolved-matrixed-task", state: PipelineRunState{{ TaskRunNames: []string{"task-run-0", "task-run-1", "task-run-2", "task-run-3"}, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "matrixed-task", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "task", Kind: "Task", - APIVersion: "v1beta1", + APIVersion: "v1", }, - WhenExpressions: []v1beta1.WhenExpression{{ + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "foobar", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, }, { Name: "quxbaz", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, }}}, }, - TaskRuns: []*v1beta1.TaskRun{nil, nil, nil, nil}, + TaskRuns: []*v1.TaskRun{nil, nil, nil, nil}, }}, childRefs: nil, }, @@ -3096,85 +3099,85 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { name: "matrixed-task", state: PipelineRunState{{ TaskRunName: "matrixed-task-run-0", - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "matrixed-task", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Name: "task", Kind: "Task", - APIVersion: "v1beta1", + APIVersion: "v1", }, - WhenExpressions: []v1beta1.WhenExpression{{ + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "foobar", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, }, { Name: "quxbaz", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, }}}, }, - TaskRuns: []*v1beta1.TaskRun{{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TaskRuns: []*v1.TaskRun{{ + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-0"}, }, { - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-1"}, }, { - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-2"}, }, { - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-3"}, }}, }}, - childRefs: []v1beta1.ChildStatusReference{{ + childRefs: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "TaskRun", }, Name: "matrixed-task-run-0", PipelineTaskName: "matrixed-task", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, }, { TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "TaskRun", }, Name: "matrixed-task-run-1", PipelineTaskName: "matrixed-task", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, }, { TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "TaskRun", }, Name: "matrixed-task-run-2", PipelineTaskName: "matrixed-task", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, }, { TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "TaskRun", }, Name: "matrixed-task-run-3", PipelineTaskName: "matrixed-task", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, @@ -3184,24 +3187,24 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { { name: "unresolved-matrixed-custom-task", state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "matrixed-task", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ Kind: "Example", APIVersion: "example.dev/v0", }, - WhenExpressions: []v1beta1.WhenExpression{{ + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "foobar", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, }, { Name: "quxbaz", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, }}}, }, CustomTask: true, @@ -3211,24 +3214,24 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { { name: "matrixed-custom-task", state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "matrixed-task", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", }, - WhenExpressions: []v1beta1.WhenExpression{{ + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "foobar", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, }, { Name: "quxbaz", - Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, }}}, }, CustomTask: true, @@ -3239,50 +3242,50 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { customRunWithName("matrixed-run-3"), }, }}, - childRefs: []v1beta1.ChildStatusReference{{ + childRefs: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "CustomRun", }, Name: "matrixed-run-0", PipelineTaskName: "matrixed-task", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, }, { TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "CustomRun", }, Name: "matrixed-run-1", PipelineTaskName: "matrixed-task", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, }, { TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "CustomRun", }, Name: "matrixed-run-2", PipelineTaskName: "matrixed-task", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, }}, }, { TypeMeta: runtime.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "CustomRun", }, Name: "matrixed-run-3", PipelineTaskName: "matrixed-task", - WhenExpressions: []v1beta1.WhenExpression{{ + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{"foo", "bar"}, @@ -3328,18 +3331,18 @@ status: reason: Timedout `) failedCustomRunPT := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "failedrun", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, }, RunObjectName: "failedrun", RunObject: makeRunFailed(runs[0]), CustomTask: true, } failedTaskRunPTWithRetries := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "failedtask", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, Retries: 1, }, TaskRunName: "failedtask", @@ -3349,9 +3352,9 @@ status: }, } failedRunPTWithRetries := ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "failedrunwithretries", - TaskRef: &v1beta1.TaskRef{Name: "task"}, + TaskRef: &v1.TaskRef{Name: "task"}, Retries: 1, }, RunObjectName: "failedrunwithretries", diff --git a/pkg/reconciler/pipelinerun/resources/resultrefresolution.go b/pkg/reconciler/pipelinerun/resources/resultrefresolution.go index 094d628b622..2572b73766b 100644 --- a/pkg/reconciler/pipelinerun/resources/resultrefresolution.go +++ b/pkg/reconciler/pipelinerun/resources/resultrefresolution.go @@ -20,6 +20,7 @@ import ( "fmt" "sort" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) @@ -31,8 +32,8 @@ type ResolvedResultRefs []*ResolvedResultRef // If the value is from a Result, then the ResultReference will be populated to point to the ResultReference // which resulted in the value type ResolvedResultRef struct { - Value v1beta1.ResultValue - ResultReference v1beta1.ResultRef + Value v1.ResultValue + ResultReference v1.ResultRef FromTaskRun string FromRun string } @@ -62,7 +63,7 @@ func ResolveResultRefs(pipelineRunState PipelineRunState, targets PipelineRunSta // validateArrayResultsIndex checks if the result array indexing reference is out of bound of the array size func validateArrayResultsIndex(allResolvedResultRefs ResolvedResultRefs) (ResolvedResultRefs, string, error) { for _, r := range allResolvedResultRefs { - if r.Value.Type == v1beta1.ParamTypeArray { + if r.Value.Type == v1.ParamTypeArray { if r.ResultReference.ResultsIndex >= len(r.Value.ArrayVal) { return nil, "", fmt.Errorf("Array Result Index %d for Task %s Result %s is out of bound of size %d", r.ResultReference.ResultsIndex, r.ResultReference.PipelineTask, r.ResultReference.Result, len(r.Value.ArrayVal)) } @@ -73,8 +74,8 @@ func validateArrayResultsIndex(allResolvedResultRefs ResolvedResultRefs) (Resolv // extractResultRefs resolves any ResultReference that are found in param or pipeline result // Returns nil if none are found -func extractResultRefsForParam(pipelineRunState PipelineRunState, param v1beta1.Param) (ResolvedResultRefs, error) { - expressions, ok := v1beta1.GetVarSubstitutionExpressionsForParam(param) +func extractResultRefsForParam(pipelineRunState PipelineRunState, param v1.Param) (ResolvedResultRefs, error) { + expressions, ok := v1.GetVarSubstitutionExpressionsForParam(param) if ok { return extractResultRefs(expressions, pipelineRunState) } @@ -82,7 +83,7 @@ func extractResultRefsForParam(pipelineRunState PipelineRunState, param v1beta1. } func extractResultRefs(expressions []string, pipelineRunState PipelineRunState) (ResolvedResultRefs, error) { - resultRefs := v1beta1.NewResultRefs(expressions) + resultRefs := v1.NewResultRefs(expressions) var resolvedResultRefs ResolvedResultRefs for _, resultRef := range resultRefs { resolvedResultRef, _, err := resolveResultRef(pipelineRunState, resultRef) @@ -98,14 +99,14 @@ func removeDup(refs ResolvedResultRefs) ResolvedResultRefs { if refs == nil { return nil } - resolvedResultRefByRef := make(map[v1beta1.ResultRef]*ResolvedResultRef, len(refs)) + resolvedResultRefByRef := make(map[v1.ResultRef]*ResolvedResultRef, len(refs)) for _, resolvedResultRef := range refs { resolvedResultRefByRef[resolvedResultRef.ResultReference] = resolvedResultRef } deduped := make([]*ResolvedResultRef, 0, len(resolvedResultRefByRef)) // Sort the resulting keys to produce a deterministic ordering. - order := make([]v1beta1.ResultRef, 0, len(refs)) + order := make([]v1.ResultRef, 0, len(refs)) for key := range resolvedResultRefByRef { order = append(order, key) } @@ -131,7 +132,7 @@ func removeDup(refs ResolvedResultRefs) ResolvedResultRefs { // then a nil list and error is returned instead. func convertToResultRefs(pipelineRunState PipelineRunState, target *ResolvedPipelineTask) (ResolvedResultRefs, string, error) { var resolvedResultRefs ResolvedResultRefs - for _, ref := range v1beta1.PipelineTaskResultRefs(target.PipelineTask) { + for _, ref := range v1.PipelineTaskResultRefs(target.PipelineTask) { resolved, pt, err := resolveResultRef(pipelineRunState, ref) if err != nil { return nil, pt, err @@ -141,7 +142,7 @@ func convertToResultRefs(pipelineRunState PipelineRunState, target *ResolvedPipe return resolvedResultRefs, "", nil } -func resolveResultRef(pipelineState PipelineRunState, resultRef *v1beta1.ResultRef) (*ResolvedResultRef, string, error) { +func resolveResultRef(pipelineState PipelineRunState, resultRef *v1.ResultRef) (*ResolvedResultRef, string, error) { referencedPipelineTask := pipelineState.ToMap()[resultRef.PipelineTask] if referencedPipelineTask == nil { return nil, resultRef.PipelineTask, fmt.Errorf("could not find task %q referenced by result", resultRef.PipelineTask) @@ -151,12 +152,12 @@ func resolveResultRef(pipelineState PipelineRunState, resultRef *v1beta1.ResultR } var runName, runValue, taskRunName string - var resultValue v1beta1.ResultValue + var resultValue v1.ResultValue var err error if referencedPipelineTask.IsCustomTask() { runName = referencedPipelineTask.RunObject.GetObjectMeta().GetName() runValue, err = findRunResultForParam(referencedPipelineTask.RunObject, resultRef) - resultValue = *v1beta1.NewStructuredValues(runValue) + resultValue = *v1.NewStructuredValues(runValue) if err != nil { return nil, resultRef.PipelineTask, err } @@ -176,7 +177,7 @@ func resolveResultRef(pipelineState PipelineRunState, resultRef *v1beta1.ResultR }, "", nil } -func findRunResultForParam(runObj v1beta1.RunObject, reference *v1beta1.ResultRef) (string, error) { +func findRunResultForParam(runObj v1beta1.RunObject, reference *v1.ResultRef) (string, error) { switch run := runObj.(type) { case *v1beta1.CustomRun: for _, result := range run.Status.Results { @@ -194,27 +195,27 @@ func findRunResultForParam(runObj v1beta1.RunObject, reference *v1beta1.ResultRe return "", fmt.Errorf("Could not find result with name %s for task %s", reference.Result, reference.PipelineTask) } -func findTaskResultForParam(taskRun *v1beta1.TaskRun, reference *v1beta1.ResultRef) (v1beta1.ResultValue, error) { - results := taskRun.Status.TaskRunStatusFields.TaskRunResults +func findTaskResultForParam(taskRun *v1.TaskRun, reference *v1.ResultRef) (v1.ResultValue, error) { + results := taskRun.Status.TaskRunStatusFields.Results for _, result := range results { if result.Name == reference.Result { return result.Value, nil } } - return v1beta1.ResultValue{}, fmt.Errorf("Could not find result with name %s for task %s", reference.Result, reference.PipelineTask) + return v1.ResultValue{}, fmt.Errorf("Could not find result with name %s for task %s", reference.Result, reference.PipelineTask) } func (rs ResolvedResultRefs) getStringReplacements() map[string]string { replacements := map[string]string{} for _, r := range rs { switch r.Value.Type { - case v1beta1.ParamTypeArray: + case v1.ParamTypeArray: for i := 0; i < len(r.Value.ArrayVal); i++ { for _, target := range r.getReplaceTargetfromArrayIndex(i) { replacements[target] = r.Value.ArrayVal[i] } } - case v1beta1.ParamTypeObject: + case v1.ParamTypeObject: for key, element := range r.Value.ObjectVal { for _, target := range r.getReplaceTargetfromObjectKey(key) { replacements[target] = element @@ -233,7 +234,7 @@ func (rs ResolvedResultRefs) getStringReplacements() map[string]string { func (rs ResolvedResultRefs) getArrayReplacements() map[string][]string { replacements := map[string][]string{} for _, r := range rs { - if r.Value.Type == v1beta1.ParamType(v1beta1.ResultsTypeArray) { + if r.Value.Type == v1.ParamType(v1.ResultsTypeArray) { for _, target := range r.getReplaceTarget() { replacements[target] = r.Value.ArrayVal } @@ -245,7 +246,7 @@ func (rs ResolvedResultRefs) getArrayReplacements() map[string][]string { func (rs ResolvedResultRefs) getObjectReplacements() map[string]map[string]string { replacements := map[string]map[string]string{} for _, r := range rs { - if r.Value.Type == v1beta1.ParamType(v1beta1.ResultsTypeObject) { + if r.Value.Type == v1.ParamType(v1.ResultsTypeObject) { for _, target := range r.getReplaceTarget() { replacements[target] = r.Value.ObjectVal } @@ -256,24 +257,24 @@ func (rs ResolvedResultRefs) getObjectReplacements() map[string]map[string]strin func (r *ResolvedResultRef) getReplaceTarget() []string { return []string{ - fmt.Sprintf("%s.%s.%s.%s", v1beta1.ResultTaskPart, r.ResultReference.PipelineTask, v1beta1.ResultResultPart, r.ResultReference.Result), - fmt.Sprintf("%s.%s.%s[%q]", v1beta1.ResultTaskPart, r.ResultReference.PipelineTask, v1beta1.ResultResultPart, r.ResultReference.Result), - fmt.Sprintf("%s.%s.%s['%s']", v1beta1.ResultTaskPart, r.ResultReference.PipelineTask, v1beta1.ResultResultPart, r.ResultReference.Result), + fmt.Sprintf("%s.%s.%s.%s", v1.ResultTaskPart, r.ResultReference.PipelineTask, v1.ResultResultPart, r.ResultReference.Result), + fmt.Sprintf("%s.%s.%s[%q]", v1.ResultTaskPart, r.ResultReference.PipelineTask, v1.ResultResultPart, r.ResultReference.Result), + fmt.Sprintf("%s.%s.%s['%s']", v1.ResultTaskPart, r.ResultReference.PipelineTask, v1.ResultResultPart, r.ResultReference.Result), } } func (r *ResolvedResultRef) getReplaceTargetfromArrayIndex(idx int) []string { return []string{ - fmt.Sprintf("%s.%s.%s.%s[%d]", v1beta1.ResultTaskPart, r.ResultReference.PipelineTask, v1beta1.ResultResultPart, r.ResultReference.Result, idx), - fmt.Sprintf("%s.%s.%s[%q][%d]", v1beta1.ResultTaskPart, r.ResultReference.PipelineTask, v1beta1.ResultResultPart, r.ResultReference.Result, idx), - fmt.Sprintf("%s.%s.%s['%s'][%d]", v1beta1.ResultTaskPart, r.ResultReference.PipelineTask, v1beta1.ResultResultPart, r.ResultReference.Result, idx), + fmt.Sprintf("%s.%s.%s.%s[%d]", v1.ResultTaskPart, r.ResultReference.PipelineTask, v1.ResultResultPart, r.ResultReference.Result, idx), + fmt.Sprintf("%s.%s.%s[%q][%d]", v1.ResultTaskPart, r.ResultReference.PipelineTask, v1.ResultResultPart, r.ResultReference.Result, idx), + fmt.Sprintf("%s.%s.%s['%s'][%d]", v1.ResultTaskPart, r.ResultReference.PipelineTask, v1.ResultResultPart, r.ResultReference.Result, idx), } } func (r *ResolvedResultRef) getReplaceTargetfromObjectKey(key string) []string { return []string{ - fmt.Sprintf("%s.%s.%s.%s.%s", v1beta1.ResultTaskPart, r.ResultReference.PipelineTask, v1beta1.ResultResultPart, r.ResultReference.Result, key), - fmt.Sprintf("%s.%s.%s[%q][%s]", v1beta1.ResultTaskPart, r.ResultReference.PipelineTask, v1beta1.ResultResultPart, r.ResultReference.Result, key), - fmt.Sprintf("%s.%s.%s['%s'][%s]", v1beta1.ResultTaskPart, r.ResultReference.PipelineTask, v1beta1.ResultResultPart, r.ResultReference.Result, key), + fmt.Sprintf("%s.%s.%s.%s.%s", v1.ResultTaskPart, r.ResultReference.PipelineTask, v1.ResultResultPart, r.ResultReference.Result, key), + fmt.Sprintf("%s.%s.%s[%q][%s]", v1.ResultTaskPart, r.ResultReference.PipelineTask, v1.ResultResultPart, r.ResultReference.Result, key), + fmt.Sprintf("%s.%s.%s['%s'][%s]", v1.ResultTaskPart, r.ResultReference.PipelineTask, v1.ResultResultPart, r.ResultReference.Result, key), } } diff --git a/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go b/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go index 3013d7de740..5174883cec9 100644 --- a/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go @@ -8,6 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/test/diff" corev1 "k8s.io/api/core/v1" @@ -30,62 +31,62 @@ var ( var pipelineRunState = PipelineRunState{{ TaskRunName: "aTaskRun", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "aTaskRun", }, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{successCondition}, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "aResult", - Value: *v1beta1.NewStructuredValues("aResultValue"), + Value: *v1.NewStructuredValues("aResultValue"), }}, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aTask", - TaskRef: &v1beta1.TaskRef{Name: "aTask"}, + TaskRef: &v1.TaskRef{Name: "aTask"}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult)"), }}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ Input: "$(tasks.aTask.results.aResult)", Operator: selection.In, Values: []string{"$(tasks.aTask.results.aResult)"}, }}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - WhenExpressions: []v1beta1.WhenExpression{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + When: []v1.WhenExpression{{ Input: "$(tasks.aTask.results.missingResult)", Operator: selection.In, Values: []string{"$(tasks.aTask.results.missingResult)"}, }}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.missingResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.missingResult)"), }}, }, }, { @@ -105,69 +106,69 @@ var pipelineRunState = PipelineRunState{{ }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aCustomPipelineTask", - TaskRef: &v1beta1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "aTask"}, + TaskRef: &v1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "aTask"}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "bTask"}, + Params: []v1.Param{{ Name: "bParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aCustomPipelineTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aCustomPipelineTask.results.aResult)"), }}, }, }, { TaskRunName: "cTaskRun", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "cTaskRun", }, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{successCondition}, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "cResult", - Value: *v1beta1.NewStructuredValues("arrayResultOne", "arrayResultTwo"), + Value: *v1.NewStructuredValues("arrayResultOne", "arrayResultTwo"), }}, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "cTask", - TaskRef: &v1beta1.TaskRef{Name: "cTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "cTask"}, + Params: []v1.Param{{ Name: "cParam", - Value: *v1beta1.NewStructuredValues("$(tasks.cTask.results.cResult[1])"), + Value: *v1.NewStructuredValues("$(tasks.cTask.results.cResult[1])"), }}, }, }, { TaskRunName: "dTaskRun", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "dTaskRun", }, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{successCondition}, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "dResult", - Value: *v1beta1.NewStructuredValues("arrayResultOne", "arrayResultTwo"), + Value: *v1.NewStructuredValues("arrayResultOne", "arrayResultTwo"), }}, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "dTask", - TaskRef: &v1beta1.TaskRef{Name: "dTask"}, - Params: []v1beta1.Param{{ + TaskRef: &v1.TaskRef{Name: "dTask"}, + Params: []v1.Param{{ Name: "dParam", - Value: *v1beta1.NewStructuredValues("$(tasks.dTask.results.dResult[3])"), + Value: *v1.NewStructuredValues("$(tasks.dTask.results.dResult[3])"), }}, }, }} @@ -176,22 +177,22 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { for _, tt := range []struct { name string pipelineRunState PipelineRunState - param v1beta1.Param + param v1.Param want ResolvedResultRefs wantErr bool }{{ name: "successful resolution: param not using result reference", pipelineRunState: PipelineRunState{{ TaskRunName: "aTaskRun", - TaskRun: &v1beta1.TaskRun{ObjectMeta: metav1.ObjectMeta{Name: "aTaskRun"}}, - PipelineTask: &v1beta1.PipelineTask{ + TaskRun: &v1.TaskRun{ObjectMeta: metav1.ObjectMeta{Name: "aTaskRun"}}, + PipelineTask: &v1.PipelineTask{ Name: "aTask", - TaskRef: &v1beta1.TaskRef{Name: "aTask"}, + TaskRef: &v1.TaskRef{Name: "aTask"}, }, }}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("explicitValueNoResultReference"), + Value: *v1.NewStructuredValues("explicitValueNoResultReference"), }, want: nil, wantErr: false, @@ -199,32 +200,32 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { name: "successful resolution: using result reference", pipelineRunState: PipelineRunState{{ TaskRunName: "aTaskRun", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Name: "aTaskRun"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{successCondition}, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "aResult", - Value: *v1beta1.NewStructuredValues("aResultValue"), + Value: *v1.NewStructuredValues("aResultValue"), }}, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aTask", - TaskRef: &v1beta1.TaskRef{Name: "aTask"}, + TaskRef: &v1.TaskRef{Name: "aTask"}, }, }}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult)"), }, want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, @@ -235,59 +236,59 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { name: "successful resolution: using multiple result reference", pipelineRunState: PipelineRunState{{ TaskRunName: "aTaskRun", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Name: "aTaskRun"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{successCondition}, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "aResult", - Value: *v1beta1.NewStructuredValues("aResultValue"), + Value: *v1.NewStructuredValues("aResultValue"), }}, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aTask", - TaskRef: &v1beta1.TaskRef{Name: "aTask"}, + TaskRef: &v1.TaskRef{Name: "aTask"}, }, }, { TaskRunName: "bTaskRun", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Name: "bTaskRun"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{successCondition}, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "bResult", - Value: *v1beta1.NewStructuredValues("bResultValue"), + Value: *v1.NewStructuredValues("bResultValue"), }}, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "bTask", - TaskRef: &v1beta1.TaskRef{Name: "bTask"}, + TaskRef: &v1.TaskRef{Name: "bTask"}, }, }}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.aResult) $(tasks.bTask.results.bResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult) $(tasks.bTask.results.bResult)"), }, want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, FromTaskRun: "aTaskRun", }, { - Value: *v1beta1.NewStructuredValues("bResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("bResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "bTask", Result: "bResult", }, @@ -298,32 +299,32 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { name: "successful resolution: duplicate result references", pipelineRunState: PipelineRunState{{ TaskRunName: "aTaskRun", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Name: "aTaskRun"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{successCondition}, }, - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{{ Name: "aResult", - Value: *v1beta1.NewStructuredValues("aResultValue"), + Value: *v1.NewStructuredValues("aResultValue"), }}, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aTask", - TaskRef: &v1beta1.TaskRef{Name: "aTask"}, + TaskRef: &v1.TaskRef{Name: "aTask"}, }, }}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.aResult) $(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult) $(tasks.aTask.results.aResult)"), }, want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, @@ -334,45 +335,45 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { name: "unsuccessful resolution: referenced result doesn't exist in referenced task", pipelineRunState: PipelineRunState{{ TaskRunName: "aTaskRun", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Name: "aTaskRun"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{successCondition}, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aTask", - TaskRef: &v1beta1.TaskRef{Name: "aTask"}, + TaskRef: &v1.TaskRef{Name: "aTask"}, }, }}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult)"), }, want: nil, wantErr: true, }, { name: "unsuccessful resolution: pipeline task missing", pipelineRunState: PipelineRunState{}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult)"), }, want: nil, wantErr: true, }, { name: "unsuccessful resolution: task run missing", pipelineRunState: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aTask", - TaskRef: &v1beta1.TaskRef{Name: "aTask"}, + TaskRef: &v1.TaskRef{Name: "aTask"}, }, }}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult)"), }, want: nil, wantErr: true, @@ -380,22 +381,22 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { name: "failed resolution: using result reference to a failed task", pipelineRunState: PipelineRunState{{ TaskRunName: "aTaskRun", - TaskRun: &v1beta1.TaskRun{ + TaskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Name: "aTaskRun"}, - Status: v1beta1.TaskRunStatus{ + Status: v1.TaskRunStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{failedCondition}, }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aTask", - TaskRef: &v1beta1.TaskRef{Name: "aTask"}, + TaskRef: &v1.TaskRef{Name: "aTask"}, }, }}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aTask.results.aResult)"), }, want: nil, wantErr: true, @@ -418,18 +419,18 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aCustomPipelineTask", - TaskRef: &v1beta1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "aTask"}, + TaskRef: &v1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "aTask"}, }, }}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aCustomPipelineTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aCustomPipelineTask.results.aResult)"), }, want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aCustomPipelineTask", Result: "aResult", }, @@ -449,14 +450,14 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { }, }, }, - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "aCustomPipelineTask", - TaskRef: &v1beta1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "aTask"}, + TaskRef: &v1.TaskRef{APIVersion: "example.dev/v0", Kind: "Example", Name: "aTask"}, }, }}, - param: v1beta1.Param{ + param: v1.Param{ Name: "targetParam", - Value: *v1beta1.NewStructuredValues("$(tasks.aCustomPipelineTask.results.aResult)"), + Value: *v1.NewStructuredValues("$(tasks.aCustomPipelineTask.results.aResult)"), }, want: nil, wantErr: true, @@ -520,8 +521,8 @@ func TestResolveResultRefs(t *testing.T) { pipelineRunState[1], }, want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, @@ -535,8 +536,8 @@ func TestResolveResultRefs(t *testing.T) { pipelineRunState[7], }, want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("arrayResultOne", "arrayResultTwo"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("arrayResultOne", "arrayResultTwo"), + ResultReference: v1.ResultRef{ PipelineTask: "cTask", Result: "cResult", ResultsIndex: 1, @@ -559,8 +560,8 @@ func TestResolveResultRefs(t *testing.T) { pipelineRunState[2], }, want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, @@ -600,8 +601,8 @@ func TestResolveResultRefs(t *testing.T) { pipelineRunState[6], }, want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aCustomPipelineTask", Result: "aResult", }, @@ -638,8 +639,8 @@ func TestResolveResultRef(t *testing.T) { pipelineRunState: pipelineRunState, target: pipelineRunState[1], want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, @@ -651,8 +652,8 @@ func TestResolveResultRef(t *testing.T) { pipelineRunState: pipelineRunState, target: pipelineRunState[2], want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aTask", Result: "aResult", }, @@ -684,8 +685,8 @@ func TestResolveResultRef(t *testing.T) { pipelineRunState: pipelineRunState, target: pipelineRunState[6], want: ResolvedResultRefs{{ - Value: *v1beta1.NewStructuredValues("aResultValue"), - ResultReference: v1beta1.ResultRef{ + Value: *v1.NewStructuredValues("aResultValue"), + ResultReference: v1.ResultRef{ PipelineTask: "aCustomPipelineTask", Result: "aResult", }, diff --git a/pkg/reconciler/pipelinerun/resources/validate_dependencies.go b/pkg/reconciler/pipelinerun/resources/validate_dependencies.go index 689199476aa..353ba7a941a 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_dependencies.go +++ b/pkg/reconciler/pipelinerun/resources/validate_dependencies.go @@ -19,7 +19,7 @@ package resources import ( "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "k8s.io/apimachinery/pkg/util/sets" ) @@ -30,7 +30,7 @@ import ( func ValidatePipelineTaskResults(state PipelineRunState) error { ptMap := state.ToMap() for _, rpt := range state { - for _, ref := range v1beta1.PipelineTaskResultRefs(rpt.PipelineTask) { + for _, ref := range v1.PipelineTaskResultRefs(rpt.PipelineTask) { if err := validateResultRef(ref, ptMap); err != nil { return fmt.Errorf("invalid result reference in pipeline task %q: %s", rpt.PipelineTask.Name, err) } @@ -43,11 +43,11 @@ func ValidatePipelineTaskResults(state PipelineRunState) error { // resolve to valid results. This prevents a situation where a PipelineResult references // a result in a PipelineTask that doesn't exist or where the user has either misspelled // a result name or the referenced task just doesn't return a result with that name. -func ValidatePipelineResults(ps *v1beta1.PipelineSpec, state PipelineRunState) error { +func ValidatePipelineResults(ps *v1.PipelineSpec, state PipelineRunState) error { ptMap := state.ToMap() for _, result := range ps.Results { - expressions, _ := v1beta1.GetVarSubstitutionExpressionsForPipelineResult(result) - refs := v1beta1.NewResultRefs(expressions) + expressions, _ := v1.GetVarSubstitutionExpressionsForPipelineResult(result) + refs := v1.NewResultRefs(expressions) for _, ref := range refs { if err := validateResultRef(ref, ptMap); err != nil { return fmt.Errorf("invalid pipeline result %q: %s", result.Name, err) @@ -60,7 +60,7 @@ func ValidatePipelineResults(ps *v1beta1.PipelineSpec, state PipelineRunState) e // validateResultRef takes a ResultRef and searches for the result using the given // map of PipelineTask name to ResolvedPipelineTask. If the ResultRef does not point // to a pipeline task or named result then an error is returned. -func validateResultRef(ref *v1beta1.ResultRef, ptMap map[string]*ResolvedPipelineTask) error { +func validateResultRef(ref *v1.ResultRef, ptMap map[string]*ResolvedPipelineTask) error { if _, ok := ptMap[ref.PipelineTask]; !ok { return fmt.Errorf("referenced pipeline task %q does not exist", ref.PipelineTask) } @@ -90,7 +90,7 @@ func validateResultRef(ref *v1beta1.ResultRef, ptMap map[string]*ResolvedPipelin // marked as optional are also marked optional in the Tasks that receive them. This // prevents a situation where a Task requires a workspace but a Pipeline does not offer // the same guarantee the workspace will be provided at runtime. -func ValidateOptionalWorkspaces(pipelineWorkspaces []v1beta1.PipelineWorkspaceDeclaration, state PipelineRunState) error { +func ValidateOptionalWorkspaces(pipelineWorkspaces []v1.PipelineWorkspaceDeclaration, state PipelineRunState) error { optionalWorkspaces := sets.NewString() for _, ws := range pipelineWorkspaces { if ws.Optional { diff --git a/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go b/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go index ffea110aefb..66a702adcad 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go +++ b/pkg/reconciler/pipelinerun/resources/validate_dependencies_test.go @@ -20,7 +20,7 @@ import ( "strings" "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "k8s.io/apimachinery/pkg/selection" ) @@ -34,75 +34,75 @@ func TestValidatePipelineTaskResults_ValidStates(t *testing.T) { }{{ desc: "no variables used", state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "p1", - Value: *v1beta1.NewStructuredValues("foo"), + Value: *v1.NewStructuredValues("foo"), }}, }, }}, }, { desc: "correct use of task and result names", state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", }, ResolvedTask: &resources.ResolvedTask{ TaskName: "t", - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result", }}, }, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt2", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "p", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.result)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.result)"), }}, }, }}, }, { desc: "correct use of task and result names in matrix", state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", }, ResolvedTask: &resources.ResolvedTask{ TaskName: "t", - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result", }}, }, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt2", - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "p", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.result)", "foo"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.result)", "foo"), }}}, }, }}, }, { desc: "custom task results are not validated", state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", }, CustomTask: true, RunObjectName: "foo-run", }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt2", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "p", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.a-dynamic-custom-task-result)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.a-dynamic-custom-task-result)"), }}, }, }}, @@ -125,31 +125,31 @@ func TestValidatePipelineTaskResults_IncorrectTaskName(t *testing.T) { }{{ desc: "invalid result reference in param", state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "p1", - Value: *v1beta1.NewStructuredValues(missingPipelineTaskVariable), + Value: *v1.NewStructuredValues(missingPipelineTaskVariable), }}, }, }}, }, { desc: "invalid result reference in matrix", state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "p1", - Value: *v1beta1.NewStructuredValues(missingPipelineTaskVariable, "foo"), + Value: *v1.NewStructuredValues(missingPipelineTaskVariable, "foo"), }}, }, }}, }, { desc: "invalid result reference in when expression", state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", - WhenExpressions: []v1beta1.WhenExpression{{ + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{ @@ -172,13 +172,13 @@ func TestValidatePipelineTaskResults_IncorrectTaskName(t *testing.T) { // a misnamed Result is correctly caught by the validatePipelineTaskResults func. func TestValidatePipelineTaskResults_IncorrectResultName(t *testing.T) { pt1 := &ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", }, ResolvedTask: &resources.ResolvedTask{ TaskName: "t", - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "not-the-result-youre-looking-for", }}, }, @@ -190,32 +190,32 @@ func TestValidatePipelineTaskResults_IncorrectResultName(t *testing.T) { }{{ desc: "invalid result reference in param", state: PipelineRunState{pt1, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt2", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "p1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.result1)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.result1)"), }}, }, }}, }, { desc: "invalid result reference in matrix", state: PipelineRunState{pt1, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt2", - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "p1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.result1)", "$(tasks.pt1.results.result2)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.result1)", "$(tasks.pt1.results.result2)"), }}}, }, }}, }, { desc: "invalid result reference in when expression", state: PipelineRunState{pt1, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt2", - WhenExpressions: []v1beta1.WhenExpression{{ + When: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, Values: []string{ @@ -238,7 +238,7 @@ func TestValidatePipelineTaskResults_IncorrectResultName(t *testing.T) { // with a name but no spec results in a validation error being returned. func TestValidatePipelineTaskResults_MissingTaskSpec(t *testing.T) { pt1 := &ResolvedPipelineTask{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", }, ResolvedTask: &resources.ResolvedTask{ @@ -247,20 +247,20 @@ func TestValidatePipelineTaskResults_MissingTaskSpec(t *testing.T) { }, } state := PipelineRunState{pt1, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt2", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "p1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.result1)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.result1)"), }}, }, }, { - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt3", - Matrix: &v1beta1.Matrix{ - Params: []v1beta1.Param{{ + Matrix: &v1.Matrix{ + Params: []v1.Param{{ Name: "p1", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.result1)", "$(tasks.pt1.results.result2)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.result1)", "$(tasks.pt1.results.result2)"), }}}, }, }} @@ -275,33 +275,33 @@ func TestValidatePipelineTaskResults_MissingTaskSpec(t *testing.T) { func TestValidatePipelineResults_ValidStates(t *testing.T) { for _, tc := range []struct { desc string - spec *v1beta1.PipelineSpec + spec *v1.PipelineSpec state PipelineRunState }{{ desc: "no result variables", - spec: &v1beta1.PipelineSpec{ - Results: []v1beta1.PipelineResult{{ + spec: &v1.PipelineSpec{ + Results: []v1.PipelineResult{{ Name: "foo-result", - Value: *v1beta1.NewStructuredValues("just a text pipeline result"), + Value: *v1.NewStructuredValues("just a text pipeline result"), }}, }, state: nil, }, { desc: "correct use of task and result names", - spec: &v1beta1.PipelineSpec{ - Results: []v1beta1.PipelineResult{{ + spec: &v1.PipelineSpec{ + Results: []v1.PipelineResult{{ Name: "foo-result", - Value: *v1beta1.NewStructuredValues("test $(tasks.pt1.results.result1) 123"), + Value: *v1.NewStructuredValues("test $(tasks.pt1.results.result1) 123"), }}, }, state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", }, ResolvedTask: &resources.ResolvedTask{ TaskName: "t", - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "result1", }}, }, @@ -319,10 +319,10 @@ func TestValidatePipelineResults_ValidStates(t *testing.T) { // TestValidatePipelineResults tests that a result variable used in a PipelineResult // with a misnamed PipelineTask is correctly caught by the validatePipelineResults func. func TestValidatePipelineResults_IncorrectTaskName(t *testing.T) { - spec := &v1beta1.PipelineSpec{ - Results: []v1beta1.PipelineResult{{ + spec := &v1.PipelineSpec{ + Results: []v1.PipelineResult{{ Name: "foo-result", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.result1)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.result1)"), }}, } state := PipelineRunState{} @@ -335,20 +335,20 @@ func TestValidatePipelineResults_IncorrectTaskName(t *testing.T) { // TestValidatePipelineResults tests that a result variable used in a PipelineResult // with a misnamed Result is correctly caught by the validatePipelineResults func. func TestValidatePipelineResults_IncorrectResultName(t *testing.T) { - spec := &v1beta1.PipelineSpec{ - Results: []v1beta1.PipelineResult{{ + spec := &v1.PipelineSpec{ + Results: []v1.PipelineResult{{ Name: "foo-result", - Value: *v1beta1.NewStructuredValues("$(tasks.pt1.results.result1)"), + Value: *v1.NewStructuredValues("$(tasks.pt1.results.result1)"), }}, } state := PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", }, ResolvedTask: &resources.ResolvedTask{ TaskName: "t", - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "not-the-result-youre-looking-for", }}, }, @@ -365,18 +365,18 @@ func TestValidatePipelineResults_IncorrectResultName(t *testing.T) { func TestValidateOptionalWorkspaces_ValidStates(t *testing.T) { for _, tc := range []struct { desc string - workspaces []v1beta1.PipelineWorkspaceDeclaration + workspaces []v1.PipelineWorkspaceDeclaration state PipelineRunState }{{ desc: "no workspaces declared", workspaces: nil, state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", Workspaces: nil, }, ResolvedTask: &resources.ResolvedTask{ - TaskSpec: &v1beta1.TaskSpec{ + TaskSpec: &v1.TaskSpec{ Workspaces: nil, }, }, @@ -385,13 +385,13 @@ func TestValidateOptionalWorkspaces_ValidStates(t *testing.T) { desc: "pipeline can omit workspace if task workspace is optional", workspaces: nil, state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{}, + Workspaces: []v1.WorkspacePipelineTaskBinding{}, }, ResolvedTask: &resources.ResolvedTask{ - TaskSpec: &v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + TaskSpec: &v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "foo", Optional: true, }}, @@ -400,21 +400,21 @@ func TestValidateOptionalWorkspaces_ValidStates(t *testing.T) { }}, }, { desc: "optional pipeline workspace matches optional task workspace", - workspaces: []v1beta1.PipelineWorkspaceDeclaration{{ + workspaces: []v1.PipelineWorkspaceDeclaration{{ Name: "ws1", Optional: true, }}, state: PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{{ + Workspaces: []v1.WorkspacePipelineTaskBinding{{ Name: "foo", Workspace: "ws1", }}, }, ResolvedTask: &resources.ResolvedTask{ - TaskSpec: &v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + TaskSpec: &v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "foo", Optional: true, }}, @@ -433,21 +433,21 @@ func TestValidateOptionalWorkspaces_ValidStates(t *testing.T) { // TestValidateOptionalWorkspaces tests that an error is generated if an optional pipeline // workspace is bound to a non-optional task workspace. func TestValidateOptionalWorkspaces_NonOptionalTaskWorkspace(t *testing.T) { - workspaces := []v1beta1.PipelineWorkspaceDeclaration{{ + workspaces := []v1.PipelineWorkspaceDeclaration{{ Name: "ws1", Optional: true, }} state := PipelineRunState{{ - PipelineTask: &v1beta1.PipelineTask{ + PipelineTask: &v1.PipelineTask{ Name: "pt1", - Workspaces: []v1beta1.WorkspacePipelineTaskBinding{{ + Workspaces: []v1.WorkspacePipelineTaskBinding{{ Name: "foo", Workspace: "ws1", }}, }, ResolvedTask: &resources.ResolvedTask{ - TaskSpec: &v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + TaskSpec: &v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "foo", Optional: false, }}, diff --git a/pkg/reconciler/pipelinerun/resources/validate_params.go b/pkg/reconciler/pipelinerun/resources/validate_params.go index a93181c3d39..bf258323031 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_params.go +++ b/pkg/reconciler/pipelinerun/resources/validate_params.go @@ -19,15 +19,15 @@ package resources import ( "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/list" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun" ) // ValidateParamTypesMatching validate that parameters in PipelineRun override corresponding parameters in Pipeline of the same type. -func ValidateParamTypesMatching(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) error { +func ValidateParamTypesMatching(p *v1.PipelineSpec, pr *v1.PipelineRun) error { // Build a map of parameter names/types declared in p. - paramTypes := make(map[string]v1beta1.ParamType) + paramTypes := make(map[string]v1.ParamType) for _, param := range p.Params { paramTypes[param.Name] = param.Type } @@ -51,7 +51,7 @@ func ValidateParamTypesMatching(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun // ValidateRequiredParametersProvided validates that all the parameters expected by the Pipeline are provided by the PipelineRun. // Extra Parameters are allowed, the Pipeline will use the Parameters it needs and ignore the other Parameters. -func ValidateRequiredParametersProvided(pipelineParameters *v1beta1.ParamSpecs, pipelineRunParameters *[]v1beta1.Param) error { +func ValidateRequiredParametersProvided(pipelineParameters *v1.ParamSpecs, pipelineRunParameters *[]v1.Param) error { // Build a list of parameter names declared in pr. var providedParams []string for _, param := range *pipelineRunParameters { @@ -76,7 +76,7 @@ func ValidateRequiredParametersProvided(pipelineParameters *v1beta1.ParamSpecs, } // ValidateObjectParamRequiredKeys validates that the required keys of all the object parameters expected by the Pipeline are provided by the PipelineRun. -func ValidateObjectParamRequiredKeys(pipelineParameters []v1beta1.ParamSpec, pipelineRunParameters []v1beta1.Param) error { +func ValidateObjectParamRequiredKeys(pipelineParameters []v1.ParamSpec, pipelineRunParameters []v1.Param) error { missings := taskrun.MissingKeysObjectParamNames(pipelineParameters, pipelineRunParameters) if len(missings) != 0 { return fmt.Errorf("PipelineRun missing object keys for parameters: %v", missings) diff --git a/pkg/reconciler/pipelinerun/resources/validate_params_test.go b/pkg/reconciler/pipelinerun/resources/validate_params_test.go index 4a92ed128ff..c09961168fd 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_params_test.go +++ b/pkg/reconciler/pipelinerun/resources/validate_params_test.go @@ -19,39 +19,39 @@ package resources import ( "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestValidateParamTypesMatching_Valid(t *testing.T) { - stringValue := *v1beta1.NewStructuredValues("stringValue") - arrayValue := *v1beta1.NewStructuredValues("arrayValue", "arrayValue") + stringValue := *v1.NewStructuredValues("stringValue") + arrayValue := *v1.NewStructuredValues("arrayValue", "arrayValue") for _, tc := range []struct { name string description string - pp []v1beta1.ParamSpec - prp []v1beta1.Param + pp []v1.ParamSpec + prp []v1.Param }{{ name: "proper param types", - pp: []v1beta1.ParamSpec{ - {Name: "correct-type-1", Type: v1beta1.ParamTypeString}, - {Name: "correct-type-2", Type: v1beta1.ParamTypeArray}, + pp: []v1.ParamSpec{ + {Name: "correct-type-1", Type: v1.ParamTypeString}, + {Name: "correct-type-2", Type: v1.ParamTypeArray}, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ {Name: "correct-type-1", Value: stringValue}, {Name: "correct-type-2", Value: arrayValue}, }, }, { name: "no params to get wrong", - pp: []v1beta1.ParamSpec{}, - prp: []v1beta1.Param{}, + pp: []v1.ParamSpec{}, + prp: []v1.Param{}, }} { t.Run(tc.name, func(t *testing.T) { - ps := &v1beta1.PipelineSpec{Params: tc.pp} - pr := &v1beta1.PipelineRun{ + ps := &v1.PipelineSpec{Params: tc.pp} + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1beta1.PipelineRunSpec{Params: tc.prp}, + Spec: v1.PipelineRunSpec{Params: tc.prp}, } if err := ValidateParamTypesMatching(ps, pr); err != nil { @@ -62,44 +62,44 @@ func TestValidateParamTypesMatching_Valid(t *testing.T) { } func TestValidateParamTypesMatching_Invalid(t *testing.T) { - stringValue := *v1beta1.NewStructuredValues("stringValue") - arrayValue := *v1beta1.NewStructuredValues("arrayValue", "arrayValue") + stringValue := *v1.NewStructuredValues("stringValue") + arrayValue := *v1.NewStructuredValues("arrayValue", "arrayValue") for _, tc := range []struct { name string description string - pp []v1beta1.ParamSpec - prp []v1beta1.Param + pp []v1.ParamSpec + prp []v1.Param }{{ name: "string-array mismatch", - pp: []v1beta1.ParamSpec{ - {Name: "correct-type-1", Type: v1beta1.ParamTypeString}, - {Name: "correct-type-2", Type: v1beta1.ParamTypeArray}, - {Name: "incorrect-type", Type: v1beta1.ParamTypeString}, + pp: []v1.ParamSpec{ + {Name: "correct-type-1", Type: v1.ParamTypeString}, + {Name: "correct-type-2", Type: v1.ParamTypeArray}, + {Name: "incorrect-type", Type: v1.ParamTypeString}, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ {Name: "correct-type-1", Value: stringValue}, {Name: "correct-type-2", Value: arrayValue}, {Name: "incorrect-type", Value: arrayValue}, }, }, { name: "array-string mismatch", - pp: []v1beta1.ParamSpec{ - {Name: "correct-type-1", Type: v1beta1.ParamTypeString}, - {Name: "correct-type-2", Type: v1beta1.ParamTypeArray}, - {Name: "incorrect-type", Type: v1beta1.ParamTypeArray}, + pp: []v1.ParamSpec{ + {Name: "correct-type-1", Type: v1.ParamTypeString}, + {Name: "correct-type-2", Type: v1.ParamTypeArray}, + {Name: "incorrect-type", Type: v1.ParamTypeArray}, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ {Name: "correct-type-1", Value: stringValue}, {Name: "correct-type-2", Value: arrayValue}, {Name: "incorrect-type", Value: stringValue}, }, }} { t.Run(tc.name, func(t *testing.T) { - ps := &v1beta1.PipelineSpec{Params: tc.pp} - pr := &v1beta1.PipelineRun{ + ps := &v1.PipelineSpec{Params: tc.pp} + pr := &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "pipeline"}, - Spec: v1beta1.PipelineRunSpec{Params: tc.prp}, + Spec: v1.PipelineRunSpec{Params: tc.prp}, } if err := ValidateParamTypesMatching(ps, pr); err == nil { @@ -110,36 +110,36 @@ func TestValidateParamTypesMatching_Invalid(t *testing.T) { } func TestValidateRequiredParametersProvided_Valid(t *testing.T) { - stringValue := *v1beta1.NewStructuredValues("stringValue") - arrayValue := *v1beta1.NewStructuredValues("arrayValue", "arrayValue") + stringValue := *v1.NewStructuredValues("stringValue") + arrayValue := *v1.NewStructuredValues("arrayValue", "arrayValue") for _, tc := range []struct { name string description string - pp v1beta1.ParamSpecs - prp []v1beta1.Param + pp v1.ParamSpecs + prp []v1.Param }{{ name: "required string params provided", - pp: []v1beta1.ParamSpec{ - {Name: "required-string-param", Type: v1beta1.ParamTypeString}, + pp: []v1.ParamSpec{ + {Name: "required-string-param", Type: v1.ParamTypeString}, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ {Name: "required-string-param", Value: stringValue}, }, }, { name: "required array params provided", - pp: []v1beta1.ParamSpec{ - {Name: "required-array-param", Type: v1beta1.ParamTypeArray}, + pp: []v1.ParamSpec{ + {Name: "required-array-param", Type: v1.ParamTypeArray}, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ {Name: "required-array-param", Value: arrayValue}, }, }, { name: "string params provided in default", - pp: []v1beta1.ParamSpec{ - {Name: "string-param", Type: v1beta1.ParamTypeString, Default: &stringValue}, + pp: []v1.ParamSpec{ + {Name: "string-param", Type: v1.ParamTypeString, Default: &stringValue}, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ {Name: "another-string-param", Value: stringValue}, }, }} { @@ -152,28 +152,28 @@ func TestValidateRequiredParametersProvided_Valid(t *testing.T) { } func TestValidateRequiredParametersProvided_Invalid(t *testing.T) { - stringValue := *v1beta1.NewStructuredValues("stringValue") - arrayValue := *v1beta1.NewStructuredValues("arrayValue", "arrayValue") + stringValue := *v1.NewStructuredValues("stringValue") + arrayValue := *v1.NewStructuredValues("arrayValue", "arrayValue") for _, tc := range []struct { name string description string - pp v1beta1.ParamSpecs - prp []v1beta1.Param + pp v1.ParamSpecs + prp []v1.Param }{{ name: "required string param missing", - pp: []v1beta1.ParamSpec{ - {Name: "required-string-param", Type: v1beta1.ParamTypeString}, + pp: []v1.ParamSpec{ + {Name: "required-string-param", Type: v1.ParamTypeString}, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ {Name: "another-string-param", Value: stringValue}, }, }, { name: "required array param missing", - pp: []v1beta1.ParamSpec{ - {Name: "required-array-param", Type: v1beta1.ParamTypeArray}, + pp: []v1.ParamSpec{ + {Name: "required-array-param", Type: v1.ParamTypeArray}, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ {Name: "another-array-param", Value: arrayValue}, }, }} { @@ -188,43 +188,43 @@ func TestValidateRequiredParametersProvided_Invalid(t *testing.T) { func TestValidateObjectParamRequiredKeys_Invalid(t *testing.T) { for _, tc := range []struct { name string - pp []v1beta1.ParamSpec - prp []v1beta1.Param + pp []v1.ParamSpec + prp []v1.Param }{{ name: "miss all required keys", - pp: []v1beta1.ParamSpec{ + pp: []v1.ParamSpec{ { Name: "an-object-param", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, }, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ { Name: "an-object-param", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "foo": "val1", })}, }, }, { name: "miss one of the required keys", - pp: []v1beta1.ParamSpec{ + pp: []v1.ParamSpec{ { Name: "an-object-param", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, }, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ { Name: "an-object-param", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "foo", })}, }, @@ -240,69 +240,69 @@ func TestValidateObjectParamRequiredKeys_Invalid(t *testing.T) { func TestValidateObjectParamRequiredKeys_Valid(t *testing.T) { for _, tc := range []struct { name string - pp []v1beta1.ParamSpec - prp []v1beta1.Param + pp []v1.ParamSpec + prp []v1.Param }{{ name: "some keys are provided by default, and the rest are provided in value", - pp: []v1beta1.ParamSpec{ + pp: []v1.ParamSpec{ { Name: "an-object-param", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, - Default: &v1beta1.ParamValue{ - Type: v1beta1.ParamTypeObject, + Default: &v1.ParamValue{ + Type: v1.ParamTypeObject, ObjectVal: map[string]string{ "key1": "val1", }, }, }, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ { Name: "an-object-param", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key2": "val2", })}, }, }, { name: "all keys are provided with a value", - pp: []v1beta1.ParamSpec{ + pp: []v1.ParamSpec{ { Name: "an-object-param", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, }, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ { Name: "an-object-param", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", })}, }, }, { name: "extra keys are provided", - pp: []v1beta1.ParamSpec{ + pp: []v1.ParamSpec{ { Name: "an-object-param", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {Type: "string"}, "key2": {Type: "string"}, }, }, }, - prp: []v1beta1.Param{ + prp: []v1.Param{ { Name: "an-object-param", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", "key3": "val3", diff --git a/pkg/reconciler/pipelinerun/timeout.go b/pkg/reconciler/pipelinerun/timeout.go index 07b8140dfc5..c4f3c1ba233 100644 --- a/pkg/reconciler/pipelinerun/timeout.go +++ b/pkg/reconciler/pipelinerun/timeout.go @@ -21,6 +21,7 @@ import ( "strings" "time" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" @@ -41,12 +42,12 @@ func init() { { Operation: "add", Path: "/spec/status", - Value: v1beta1.TaskRunSpecStatusCancelled, + Value: v1.TaskRunSpecStatusCancelled, }, { Operation: "add", Path: "/spec/statusMessage", - Value: v1beta1.TaskRunCancelledByPipelineTimeoutMsg, + Value: v1.TaskRunCancelledByPipelineTimeoutMsg, }}) if err != nil { log.Fatalf("failed to marshal TaskRun timeout patch bytes: %v", err) @@ -82,12 +83,12 @@ func init() { } // timeoutPipelineRun marks the PipelineRun as timed out and any resolved TaskRun(s) too. -func timeoutPipelineRun(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, clientSet clientset.Interface) error { +func timeoutPipelineRun(ctx context.Context, logger *zap.SugaredLogger, pr *v1.PipelineRun, clientSet clientset.Interface) error { errs := timeoutPipelineTasks(ctx, logger, pr, clientSet) // If we successfully timed out all the TaskRuns and Runs, we can consider the PipelineRun timed out. if len(errs) == 0 { - reason := v1beta1.PipelineRunReasonTimedOut.String() + reason := v1.PipelineRunReasonTimedOut.String() pr.Status.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, @@ -122,12 +123,12 @@ func timeoutRun(ctx context.Context, runName string, namespace string, clientSet } // timeoutPipelineTaskRuns patches `TaskRun` and `Run` with canceled status and an appropriate message -func timeoutPipelineTasks(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, clientSet clientset.Interface) []string { +func timeoutPipelineTasks(ctx context.Context, logger *zap.SugaredLogger, pr *v1.PipelineRun, clientSet clientset.Interface) []string { return timeoutPipelineTasksForTaskNames(ctx, logger, pr, clientSet, sets.NewString()) } // timeoutPipelineTasksForTaskNames patches `TaskRun`s and `Run`s for the given task names, or all if no task names are given, with canceled status and appropriate message -func timeoutPipelineTasksForTaskNames(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, clientSet clientset.Interface, taskNames sets.String) []string { +func timeoutPipelineTasksForTaskNames(ctx context.Context, logger *zap.SugaredLogger, pr *v1.PipelineRun, clientSet clientset.Interface, taskNames sets.String) []string { errs := []string{} trNames, customRunNames, runNames, err := getChildObjectsFromPRStatusForTaskNames(ctx, pr.Status, taskNames) @@ -138,7 +139,7 @@ func timeoutPipelineTasksForTaskNames(ctx context.Context, logger *zap.SugaredLo for _, taskRunName := range trNames { logger.Infof("cancelling TaskRun %s for timeout", taskRunName) - if _, err := clientSet.TektonV1beta1().TaskRuns(pr.Namespace).Patch(ctx, taskRunName, types.JSONPatchType, timeoutTaskRunPatchBytes, metav1.PatchOptions{}, ""); err != nil { + if _, err := clientSet.TektonV1().TaskRuns(pr.Namespace).Patch(ctx, taskRunName, types.JSONPatchType, timeoutTaskRunPatchBytes, metav1.PatchOptions{}, ""); err != nil { errs = append(errs, fmt.Errorf("Failed to patch TaskRun `%s` with cancellation: %s", taskRunName, err).Error()) continue } diff --git a/pkg/reconciler/pipelinerun/timeout_test.go b/pkg/reconciler/pipelinerun/timeout_test.go index 461168fc527..54aa29e57eb 100644 --- a/pkg/reconciler/pipelinerun/timeout_test.go +++ b/pkg/reconciler/pipelinerun/timeout_test.go @@ -18,6 +18,8 @@ import ( "testing" "github.com/tektoncd/pipeline/pkg/apis/config" + "github.com/tektoncd/pipeline/pkg/apis/pipeline" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" _ "github.com/tektoncd/pipeline/pkg/pipelinerunmetrics/fake" // Make sure the pipelinerunmetrics are setup @@ -31,43 +33,43 @@ import ( func TestTimeoutPipelineRun(t *testing.T) { testCases := []struct { - name string - useV1Beta1CustomTasks bool - pipelineRun *v1beta1.PipelineRun - taskRuns []*v1beta1.TaskRun - customRuns []*v1beta1.CustomRun - runs []*v1alpha1.Run - wantErr bool + name string + usev1CustomTasks bool + pipelineRun *v1.PipelineRun + taskRuns []*v1.TaskRun + customRuns []*v1beta1.CustomRun + runs []*v1alpha1.Run + wantErr bool }{{ name: "no-resolved-taskrun", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-timedout"}, - Spec: v1beta1.PipelineRunSpec{}, + Spec: v1.PipelineRunSpec{}, }, }, { name: "one-taskrun", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-timedout"}, - Spec: v1beta1.PipelineRunSpec{}, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{Kind: taskRun}, + Spec: v1.PipelineRunSpec{}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{Kind: "TaskRun"}, Name: "t1", PipelineTaskName: "task-1", }}, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t1"}}, }, }, { name: "multiple-taskruns", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-timedout"}, - Spec: v1beta1.PipelineRunSpec{}, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{Kind: taskRun}, + Spec: v1.PipelineRunSpec{}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{Kind: "TaskRun"}, Name: "t1", PipelineTaskName: "task-1", }, { @@ -77,18 +79,18 @@ func TestTimeoutPipelineRun(t *testing.T) { }}, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t1"}}, {ObjectMeta: metav1.ObjectMeta{Name: "t2"}}, }, }, { name: "multiple-runs", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-timedout"}, - Spec: v1beta1.PipelineRunSpec{}, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{Kind: customRun}, + Spec: v1.PipelineRunSpec{}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{Kind: "CustomRun"}, Name: "t1", PipelineTaskName: "task-1", }, { @@ -103,14 +105,14 @@ func TestTimeoutPipelineRun(t *testing.T) { {ObjectMeta: metav1.ObjectMeta{Name: "t2"}}, }, }, { - name: "multiple-runs-beta-custom-tasks", - useV1Beta1CustomTasks: true, - pipelineRun: &v1beta1.PipelineRun{ + name: "multiple-runs-beta-custom-tasks", + usev1CustomTasks: true, + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-timedout"}, - Spec: v1beta1.PipelineRunSpec{}, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ - TypeMeta: runtime.TypeMeta{Kind: customRun}, + Spec: v1.PipelineRunSpec{}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{Kind: "CustomRun"}, Name: "t1", PipelineTaskName: "task-1", }, { @@ -126,11 +128,11 @@ func TestTimeoutPipelineRun(t *testing.T) { }, }, { name: "multiple-taskruns-and-runs", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-timedout"}, - Spec: v1beta1.PipelineRunSpec{}, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{ + Spec: v1.PipelineRunSpec{}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{ { TypeMeta: runtime.TypeMeta{Kind: taskRun}, Name: "t1", @@ -160,7 +162,7 @@ func TestTimeoutPipelineRun(t *testing.T) { }, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t1"}}, {ObjectMeta: metav1.ObjectMeta{Name: "t2"}}, }, @@ -169,13 +171,13 @@ func TestTimeoutPipelineRun(t *testing.T) { {ObjectMeta: metav1.ObjectMeta{Name: "r2"}}, }, }, { - name: "child-references-beta-custom-tasks", - useV1Beta1CustomTasks: true, - pipelineRun: &v1beta1.PipelineRun{ + name: "child-references-beta-custom-tasks", + usev1CustomTasks: true, + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-timedout"}, - Spec: v1beta1.PipelineRunSpec{}, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{ + Spec: v1.PipelineRunSpec{}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{ { TypeMeta: runtime.TypeMeta{Kind: taskRun}, Name: "t1", @@ -188,16 +190,16 @@ func TestTimeoutPipelineRun(t *testing.T) { }, { TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: customRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: pipeline.CustomRunControllerName, }, Name: "r1", PipelineTaskName: "run-1", }, { TypeMeta: runtime.TypeMeta{ - APIVersion: v1beta1.SchemeGroupVersion.String(), - Kind: customRun, + APIVersion: v1.SchemeGroupVersion.String(), + Kind: pipeline.CustomRunControllerName, }, Name: "r2", PipelineTaskName: "run-2", @@ -205,7 +207,7 @@ func TestTimeoutPipelineRun(t *testing.T) { }, }}, }, - taskRuns: []*v1beta1.TaskRun{ + taskRuns: []*v1.TaskRun{ {ObjectMeta: metav1.ObjectMeta{Name: "t1"}}, {ObjectMeta: metav1.ObjectMeta{Name: "t2"}}, }, @@ -215,11 +217,11 @@ func TestTimeoutPipelineRun(t *testing.T) { }, }, { name: "unknown-kind-on-child-references", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-timedout"}, - Spec: v1beta1.PipelineRunSpec{}, - Status: v1beta1.PipelineRunStatus{PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ - ChildReferences: []v1beta1.ChildStatusReference{{ + Spec: v1.PipelineRunSpec{}, + Status: v1.PipelineRunStatus{PipelineRunStatusFields: v1.PipelineRunStatusFields{ + ChildReferences: []v1.ChildStatusReference{{ TypeMeta: runtime.TypeMeta{Kind: "InvalidKind"}, Name: "t1", PipelineTaskName: "task-1", @@ -232,7 +234,7 @@ func TestTimeoutPipelineRun(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { d := test.Data{ - PipelineRuns: []*v1beta1.PipelineRun{tc.pipelineRun}, + PipelineRuns: []*v1.PipelineRun{tc.pipelineRun}, TaskRuns: tc.taskRuns, CustomRuns: tc.customRuns, Runs: tc.runs, @@ -240,7 +242,7 @@ func TestTimeoutPipelineRun(t *testing.T) { ctx, _ := ttesting.SetupFakeContext(t) cfg := config.NewStore(logtesting.TestLogger(t)) cm := newFeatureFlagsConfigMap() - if tc.useV1Beta1CustomTasks { + if tc.usev1CustomTasks { cm = withCustomTaskVersion(cm, config.CustomTaskVersionBeta) } cfg.OnConfigChanged(cm) @@ -265,14 +267,14 @@ func TestTimeoutPipelineRun(t *testing.T) { } if tc.taskRuns != nil { for _, expectedTR := range tc.taskRuns { - tr, err := c.Pipeline.TektonV1beta1().TaskRuns("").Get(ctx, expectedTR.Name, metav1.GetOptions{}) + tr, err := c.Pipeline.TektonV1().TaskRuns("").Get(ctx, expectedTR.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("couldn't get expected TaskRun %s, got error %s", expectedTR.Name, err) } - if tr.Spec.Status != v1beta1.TaskRunSpecStatusCancelled { + if tr.Spec.Status != v1.TaskRunSpecStatusCancelled { t.Errorf("expected task %q to be marked as timed out, was %q", tr.Name, tr.Spec.Status) } - if tr.Spec.StatusMessage != v1beta1.TaskRunCancelledByPipelineTimeoutMsg { + if tr.Spec.StatusMessage != v1.TaskRunCancelledByPipelineTimeoutMsg { t.Errorf("expected task %s to have the timeout-specific status message, was %s", tr.Name, tr.Spec.StatusMessage) } } diff --git a/pkg/reconciler/pipelinerun/tracing.go b/pkg/reconciler/pipelinerun/tracing.go index b5c152302e8..c94461046e1 100644 --- a/pkg/reconciler/pipelinerun/tracing.go +++ b/pkg/reconciler/pipelinerun/tracing.go @@ -21,7 +21,7 @@ import ( "encoding/json" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/propagation" @@ -40,7 +40,7 @@ const ( // initialize tracing by creating the root span and injecting the // spanContext is propogated through annotations in the CR -func initTracing(ctx context.Context, tracerProvider trace.TracerProvider, pr *v1beta1.PipelineRun) context.Context { +func initTracing(ctx context.Context, tracerProvider trace.TracerProvider, pr *v1.PipelineRun) context.Context { logger := logging.FromContext(ctx) pro := otel.GetTextMapPropagator() diff --git a/pkg/reconciler/pipelinerun/tracing_test.go b/pkg/reconciler/pipelinerun/tracing_test.go index 3d95c45b5f7..1737a77ac27 100644 --- a/pkg/reconciler/pipelinerun/tracing_test.go +++ b/pkg/reconciler/pipelinerun/tracing_test.go @@ -17,7 +17,7 @@ import ( "context" "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/propagation" tracesdk "go.opentelemetry.io/otel/sdk/trace" @@ -30,14 +30,14 @@ func TestInitTracing(t *testing.T) { testcases := []struct { name string - pipelineRun *v1beta1.PipelineRun + pipelineRun *v1.PipelineRun tracerProvider trace.TracerProvider expectSpanContextStatus bool expectValidSpanContext bool parentTraceID string }{{ name: "with-tracerprovider-no-parent-trace", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "testns", @@ -48,7 +48,7 @@ func TestInitTracing(t *testing.T) { expectValidSpanContext: true, }, { name: "with-tracerprovider-with-parent-trace", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "testns", @@ -63,7 +63,7 @@ func TestInitTracing(t *testing.T) { parentTraceID: "00-0f57e147e992b304d977436289d10628-73d5909e31793992-01", }, { name: "without-tracerprovider", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "testns", @@ -74,7 +74,7 @@ func TestInitTracing(t *testing.T) { expectValidSpanContext: false, }, { name: "without-tracerprovider-existing-annotations", - pipelineRun: &v1beta1.PipelineRun{ + pipelineRun: &v1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "testns", diff --git a/pkg/reconciler/taskrun/controller.go b/pkg/reconciler/taskrun/controller.go index 040974f53e9..b3e242e15ba 100644 --- a/pkg/reconciler/taskrun/controller.go +++ b/pkg/reconciler/taskrun/controller.go @@ -21,11 +21,11 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" pipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client" + taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/taskrun" verificationpolicyinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/verificationpolicy" - taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun" - taskrunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun" + taskrunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1/taskrun" resolutionclient "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" resolutioninformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest" "github.com/tektoncd/pipeline/pkg/pod" @@ -51,7 +51,7 @@ func NewController(opts *pipeline.Options, clock clock.PassiveClock, tracerProvi kubeclientset := kubeclient.Get(ctx) pipelineclientset := pipelineclient.Get(ctx) taskRunInformer := taskruninformer.Get(ctx) - podInformer := filteredpodinformer.Get(ctx, v1beta1.ManagedByLabelKey) + podInformer := filteredpodinformer.Get(ctx, v1.ManagedByLabelKey) limitrangeInformer := limitrangeinformer.Get(ctx) verificationpolicyInformer := verificationpolicyinformer.Get(ctx) resolutionInformer := resolutioninformer.Get(ctx) @@ -89,7 +89,7 @@ func NewController(opts *pipeline.Options, clock clock.PassiveClock, tracerProvi taskRunInformer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue)) podInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ - FilterFunc: controller.FilterController(&v1beta1.TaskRun{}), + FilterFunc: controller.FilterController(&v1.TaskRun{}), Handler: controller.HandleAll(impl.EnqueueControllerOf), }) diff --git a/pkg/reconciler/taskrun/resources/apply.go b/pkg/reconciler/taskrun/resources/apply.go index bad25e43e41..f3245bdf772 100644 --- a/pkg/reconciler/taskrun/resources/apply.go +++ b/pkg/reconciler/taskrun/resources/apply.go @@ -24,7 +24,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/container" "github.com/tektoncd/pipeline/pkg/pod" "github.com/tektoncd/pipeline/pkg/substitution" @@ -42,13 +42,13 @@ var ( "params.%s", "params[%q]", "params['%s']", - // FIXME(vdemeester) Remove that with deprecating v1beta1 + // FIXME(vdemeester) Remove that with deprecating v1 "inputs.params.%s", } ) // ApplyParameters applies the params from a TaskRun.Input.Parameters to a TaskSpec -func ApplyParameters(ctx context.Context, spec *v1beta1.TaskSpec, tr *v1beta1.TaskRun, defaults ...v1beta1.ParamSpec) *v1beta1.TaskSpec { +func ApplyParameters(ctx context.Context, spec *v1.TaskSpec, tr *v1.TaskRun, defaults ...v1.ParamSpec) *v1.TaskSpec { // This assumes that the TaskRun inputs have been validated against what the Task requests. // stringReplacements is used for standard single-string stringReplacements, while arrayReplacements contains arrays @@ -60,7 +60,7 @@ func ApplyParameters(ctx context.Context, spec *v1beta1.TaskSpec, tr *v1beta1.Ta for _, p := range defaults { if p.Default != nil { switch p.Default.Type { - case v1beta1.ParamTypeArray: + case v1.ParamTypeArray: for _, pattern := range paramPatterns { // array indexing for param is beta feature if config.CheckAlphaOrBetaAPIFields(ctx) { @@ -70,7 +70,7 @@ func ApplyParameters(ctx context.Context, spec *v1beta1.TaskSpec, tr *v1beta1.Ta } arrayReplacements[fmt.Sprintf(pattern, p.Name)] = p.Default.ArrayVal } - case v1beta1.ParamTypeObject: + case v1.ParamTypeObject: for k, v := range p.Default.ObjectVal { stringReplacements[fmt.Sprintf(objectIndividualVariablePattern, p.Name, k)] = v } @@ -93,7 +93,7 @@ func ApplyParameters(ctx context.Context, spec *v1beta1.TaskSpec, tr *v1beta1.Ta return ApplyReplacements(spec, stringReplacements, arrayReplacements) } -func paramsFromTaskRun(ctx context.Context, tr *v1beta1.TaskRun) (map[string]string, map[string][]string) { +func paramsFromTaskRun(ctx context.Context, tr *v1.TaskRun) (map[string]string, map[string][]string) { // stringReplacements is used for standard single-string stringReplacements, while arrayReplacements contains arrays // that need to be further processed. stringReplacements := map[string]string{} @@ -101,7 +101,7 @@ func paramsFromTaskRun(ctx context.Context, tr *v1beta1.TaskRun) (map[string]str for _, p := range tr.Spec.Params { switch p.Value.Type { - case v1beta1.ParamTypeArray: + case v1.ParamTypeArray: for _, pattern := range paramPatterns { // array indexing for param is beta feature if config.CheckAlphaOrBetaAPIFields(ctx) { @@ -111,7 +111,7 @@ func paramsFromTaskRun(ctx context.Context, tr *v1beta1.TaskRun) (map[string]str } arrayReplacements[fmt.Sprintf(pattern, p.Name)] = p.Value.ArrayVal } - case v1beta1.ParamTypeObject: + case v1.ParamTypeObject: for k, v := range p.Value.ObjectVal { stringReplacements[fmt.Sprintf(objectIndividualVariablePattern, p.Name, k)] = v } @@ -125,7 +125,7 @@ func paramsFromTaskRun(ctx context.Context, tr *v1beta1.TaskRun) (map[string]str return stringReplacements, arrayReplacements } -func getContextReplacements(taskName string, tr *v1beta1.TaskRun) map[string]string { +func getContextReplacements(taskName string, tr *v1.TaskRun) map[string]string { return map[string]string{ "context.taskRun.name": tr.Name, "context.task.name": taskName, @@ -137,14 +137,14 @@ func getContextReplacements(taskName string, tr *v1beta1.TaskRun) map[string]str // ApplyContexts applies the substitution from $(context.(taskRun|task).*) with the specified values. // Uses "" as a default if a value is not available. -func ApplyContexts(spec *v1beta1.TaskSpec, taskName string, tr *v1beta1.TaskRun) *v1beta1.TaskSpec { +func ApplyContexts(spec *v1.TaskSpec, taskName string, tr *v1.TaskRun) *v1.TaskSpec { return ApplyReplacements(spec, getContextReplacements(taskName, tr), map[string][]string{}) } // ApplyWorkspaces applies the substitution from paths that the workspaces in declarations mounted to, the // volumes that bindings are realized with in the task spec and the PersistentVolumeClaim names for the // workspaces. -func ApplyWorkspaces(ctx context.Context, spec *v1beta1.TaskSpec, declarations []v1beta1.WorkspaceDeclaration, bindings []v1beta1.WorkspaceBinding, vols map[string]corev1.Volume) *v1beta1.TaskSpec { +func ApplyWorkspaces(ctx context.Context, spec *v1.TaskSpec, declarations []v1.WorkspaceDeclaration, bindings []v1.WorkspaceBinding, vols map[string]corev1.Volume) *v1.TaskSpec { stringReplacements := map[string]string{} bindNames := sets.NewString() @@ -185,7 +185,7 @@ func ApplyWorkspaces(ctx context.Context, spec *v1beta1.TaskSpec, declarations [ // it in the fields of the TaskSpec. A new updated TaskSpec is returned. Steps or Sidecars in the TaskSpec // that override the mountPath will receive that mountPath in place of the variable's value. Other Steps and // Sidecars will see either the workspace's declared mountPath or the default of /workspaces/. -func applyWorkspaceMountPath(variable string, spec *v1beta1.TaskSpec, declaration v1beta1.WorkspaceDeclaration) *v1beta1.TaskSpec { +func applyWorkspaceMountPath(variable string, spec *v1.TaskSpec, declaration v1.WorkspaceDeclaration) *v1.TaskSpec { stringReplacements := map[string]string{variable: ""} emptyArrayReplacements := map[string][]string{} defaultMountPath := declaration.GetMountPath() @@ -217,7 +217,7 @@ func applyWorkspaceMountPath(variable string, spec *v1beta1.TaskSpec, declaratio // ApplyTaskResults applies the substitution from values in results which are referenced in spec as subitems // of the replacementStr. -func ApplyTaskResults(spec *v1beta1.TaskSpec) *v1beta1.TaskSpec { +func ApplyTaskResults(spec *v1.TaskSpec) *v1.TaskSpec { stringReplacements := map[string]string{} patterns := []string{ @@ -236,7 +236,7 @@ func ApplyTaskResults(spec *v1beta1.TaskSpec) *v1beta1.TaskSpec { // ApplyStepExitCodePath replaces the occurrences of exitCode path with the absolute tekton internal path // Replace $(steps..exitCode.path) with pipeline.StepPath//exitCode -func ApplyStepExitCodePath(spec *v1beta1.TaskSpec) *v1beta1.TaskSpec { +func ApplyStepExitCodePath(spec *v1.TaskSpec) *v1.TaskSpec { stringReplacements := map[string]string{} for i, step := range spec.Steps { @@ -248,7 +248,7 @@ func ApplyStepExitCodePath(spec *v1beta1.TaskSpec) *v1beta1.TaskSpec { // ApplyCredentialsPath applies a substitution of the key $(credentials.path) with the path that credentials // from annotated secrets are written to. -func ApplyCredentialsPath(spec *v1beta1.TaskSpec, path string) *v1beta1.TaskSpec { +func ApplyCredentialsPath(spec *v1.TaskSpec, path string) *v1.TaskSpec { stringReplacements := map[string]string{ "credentials.path": path, } @@ -256,7 +256,7 @@ func ApplyCredentialsPath(spec *v1beta1.TaskSpec, path string) *v1beta1.TaskSpec } // ApplyReplacements replaces placeholders for declared parameters with the specified replacements. -func ApplyReplacements(spec *v1beta1.TaskSpec, stringReplacements map[string]string, arrayReplacements map[string][]string) *v1beta1.TaskSpec { +func ApplyReplacements(spec *v1.TaskSpec, stringReplacements map[string]string, arrayReplacements map[string][]string) *v1.TaskSpec { spec = spec.DeepCopy() // Apply variable expansion to steps fields. diff --git a/pkg/reconciler/taskrun/resources/apply_test.go b/pkg/reconciler/taskrun/resources/apply_test.go index 9f8c9a10b38..c792be8eaed 100644 --- a/pkg/reconciler/taskrun/resources/apply_test.go +++ b/pkg/reconciler/taskrun/resources/apply_test.go @@ -22,7 +22,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "github.com/tektoncd/pipeline/pkg/workspace" "github.com/tektoncd/pipeline/test/diff" @@ -34,8 +34,8 @@ import ( ) var ( - simpleTaskSpec = &v1beta1.TaskSpec{ - Sidecars: []v1beta1.Sidecar{{ + simpleTaskSpec = &v1.TaskSpec{ + Sidecars: []v1.Sidecar{{ Name: "foo", Image: `$(params["myimage"])`, Env: []corev1.EnvVar{{ @@ -43,14 +43,14 @@ var ( Value: "$(params['FOO'])", }}, }}, - StepTemplate: &v1beta1.StepTemplate{ + StepTemplate: &v1.StepTemplate{ Env: []corev1.EnvVar{{ Name: "template-var", Value: `$(params["FOO"])`, }}, Image: "$(params.myimage)", }, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "foo", Image: "$(params.myimage)", }, { @@ -177,8 +177,8 @@ var ( } // a taskspec for testing object var in all places i.e. Sidecars, StepTemplate, Steps and Volumns - objectParamTaskSpec = &v1beta1.TaskSpec{ - Sidecars: []v1beta1.Sidecar{{ + objectParamTaskSpec = &v1.TaskSpec{ + Sidecars: []v1.Sidecar{{ Name: "foo", Image: `$(params.myObject.key1)`, Env: []corev1.EnvVar{{ @@ -186,14 +186,14 @@ var ( Value: "$(params.myObject.key2)", }}, }}, - StepTemplate: &v1beta1.StepTemplate{ + StepTemplate: &v1.StepTemplate{ Image: "$(params.myObject.key1)", Env: []corev1.EnvVar{{ Name: "template-var", Value: `$(params.myObject.key2)`, }}, }, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "foo", Image: "$(params.myObject.key1)", WorkingDir: "path/to/$(params.myObject.key2)", @@ -298,8 +298,8 @@ var ( }}, } - simpleTaskSpecArrayIndexing = &v1beta1.TaskSpec{ - Sidecars: []v1beta1.Sidecar{{ + simpleTaskSpecArrayIndexing = &v1.TaskSpec{ + Sidecars: []v1.Sidecar{{ Name: "foo", Image: `$(params["myimage"][0])`, Env: []corev1.EnvVar{{ @@ -307,14 +307,14 @@ var ( Value: "$(params['FOO'][1])", }}, }}, - StepTemplate: &v1beta1.StepTemplate{ + StepTemplate: &v1.StepTemplate{ Env: []corev1.EnvVar{{ Name: "template-var", Value: `$(params["FOO"][1])`, }}, Image: "$(params.myimage[0])", }, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "foo", Image: "$(params.myimage[0])", }, { @@ -440,8 +440,8 @@ var ( }}, } - arrayParamTaskSpec = &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + arrayParamTaskSpec = &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "simple-image", Image: "some-image", }, { @@ -452,8 +452,8 @@ var ( }}, } - arrayAndStringParamTaskSpec = &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + arrayAndStringParamTaskSpec = &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "simple-image", Image: "some-image", }, { @@ -464,8 +464,8 @@ var ( }}, } - arrayAndObjectParamTaskSpec = &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + arrayAndObjectParamTaskSpec = &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "simple-image", Image: "some-image", }, { @@ -476,8 +476,8 @@ var ( }}, } - multipleArrayParamsTaskSpec = &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + multipleArrayParamsTaskSpec = &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "simple-image", Image: "some-image", }, { @@ -488,8 +488,8 @@ var ( }}, } - multipleArrayAndStringsParamsTaskSpec = &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + multipleArrayAndStringsParamsTaskSpec = &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "simple-image", Image: "image-$(params.string-param2)", }, { @@ -500,8 +500,8 @@ var ( }}, } - multipleArrayAndObjectParamsTaskSpec = &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + multipleArrayAndObjectParamsTaskSpec = &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "simple-image", Image: "image-$(params.myObject.key1)", }, { @@ -512,68 +512,68 @@ var ( }}, } - arrayTaskRun0Elements = &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + arrayTaskRun0Elements = &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "array-param", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeArray, + Value: v1.ParamValue{ + Type: v1.ParamTypeArray, ArrayVal: []string{}, }}, }, }, } - arrayTaskRun1Elements = &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + arrayTaskRun1Elements = &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "array-param", - Value: *v1beta1.NewStructuredValues("foo"), + Value: *v1.NewStructuredValues("foo"), }}, }, } - arrayTaskRun3Elements = &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + arrayTaskRun3Elements = &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "array-param", - Value: *v1beta1.NewStructuredValues("foo", "bar", "third"), + Value: *v1.NewStructuredValues("foo", "bar", "third"), }}, }, } - arrayTaskRunMultipleArrays = &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + arrayTaskRunMultipleArrays = &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "array-param", - Value: *v1beta1.NewStructuredValues("foo", "bar", "third"), + Value: *v1.NewStructuredValues("foo", "bar", "third"), }, { Name: "another-array-param", - Value: *v1beta1.NewStructuredValues("part1", "part2"), + Value: *v1.NewStructuredValues("part1", "part2"), }}, }, } - arrayTaskRunWith1StringParam = &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + arrayTaskRunWith1StringParam = &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "array-param", - Value: *v1beta1.NewStructuredValues("middlefirst", "middlesecond"), + Value: *v1.NewStructuredValues("middlefirst", "middlesecond"), }, { Name: "normal-param", - Value: *v1beta1.NewStructuredValues("foo"), + Value: *v1.NewStructuredValues("foo"), }}, }, } - arrayTaskRunWith1ObjectParam = &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + arrayTaskRunWith1ObjectParam = &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "array-param", - Value: *v1beta1.NewStructuredValues("middlefirst", "middlesecond"), + Value: *v1.NewStructuredValues("middlefirst", "middlesecond"), }, { Name: "myObject", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "object value1", "key2": "object value2", }), @@ -581,35 +581,35 @@ var ( }, } - arrayTaskRunMultipleArraysAndStrings = &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + arrayTaskRunMultipleArraysAndStrings = &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "array-param1", - Value: *v1beta1.NewStructuredValues("1-param1", "2-param1", "3-param1", "4-param1"), + Value: *v1.NewStructuredValues("1-param1", "2-param1", "3-param1", "4-param1"), }, { Name: "array-param2", - Value: *v1beta1.NewStructuredValues("1-param2", "2-param2", "2-param3"), + Value: *v1.NewStructuredValues("1-param2", "2-param2", "2-param3"), }, { Name: "string-param1", - Value: *v1beta1.NewStructuredValues("foo"), + Value: *v1.NewStructuredValues("foo"), }, { Name: "string-param2", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }}, }, } - arrayTaskRunMultipleArraysAndObject = &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + arrayTaskRunMultipleArraysAndObject = &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "array-param1", - Value: *v1beta1.NewStructuredValues("1-param1", "2-param1", "3-param1", "4-param1"), + Value: *v1.NewStructuredValues("1-param1", "2-param1", "3-param1", "4-param1"), }, { Name: "array-param2", - Value: *v1beta1.NewStructuredValues("1-param2", "2-param2", "3-param3"), + Value: *v1.NewStructuredValues("1-param2", "2-param2", "3-param3"), }, { Name: "myObject", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "value1", "key2": "value2", }), @@ -618,7 +618,7 @@ var ( } ) -func applyMutation(ts *v1beta1.TaskSpec, f func(*v1beta1.TaskSpec)) *v1beta1.TaskSpec { +func applyMutation(ts *v1.TaskSpec, f func(*v1.TaskSpec)) *v1.TaskSpec { ts = ts.DeepCopy() f(ts) return ts @@ -626,21 +626,21 @@ func applyMutation(ts *v1beta1.TaskSpec, f func(*v1beta1.TaskSpec)) *v1beta1.Tas func TestApplyArrayParameters(t *testing.T) { type args struct { - ts *v1beta1.TaskSpec - tr *v1beta1.TaskRun - dp []v1beta1.ParamSpec + ts *v1.TaskSpec + tr *v1.TaskRun + dp []v1.ParamSpec } tests := []struct { name string args args - want *v1beta1.TaskSpec + want *v1.TaskSpec }{{ name: "array parameter with 0 elements", args: args{ ts: arrayParamTaskSpec, tr: arrayTaskRun0Elements, }, - want: applyMutation(arrayParamTaskSpec, func(spec *v1beta1.TaskSpec) { + want: applyMutation(arrayParamTaskSpec, func(spec *v1.TaskSpec) { spec.Steps[1].Args = []string{"first", "second", "last"} }), }, { @@ -649,7 +649,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: arrayParamTaskSpec, tr: arrayTaskRun1Elements, }, - want: applyMutation(arrayParamTaskSpec, func(spec *v1beta1.TaskSpec) { + want: applyMutation(arrayParamTaskSpec, func(spec *v1.TaskSpec) { spec.Steps[1].Args = []string{"first", "second", "foo", "last"} }), }, { @@ -658,7 +658,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: arrayParamTaskSpec, tr: arrayTaskRun3Elements, }, - want: applyMutation(arrayParamTaskSpec, func(spec *v1beta1.TaskSpec) { + want: applyMutation(arrayParamTaskSpec, func(spec *v1.TaskSpec) { spec.Steps[1].Args = []string{"first", "second", "foo", "bar", "third", "last"} }), }, { @@ -667,7 +667,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: multipleArrayParamsTaskSpec, tr: arrayTaskRunMultipleArrays, }, - want: applyMutation(multipleArrayParamsTaskSpec, func(spec *v1beta1.TaskSpec) { + want: applyMutation(multipleArrayParamsTaskSpec, func(spec *v1.TaskSpec) { spec.Steps[1].Command = []string{"cmd", "part1", "part2"} spec.Steps[1].Args = []string{"first", "second", "foo", "bar", "third", "last"} }), @@ -677,7 +677,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: arrayAndStringParamTaskSpec, tr: arrayTaskRunWith1StringParam, }, - want: applyMutation(arrayAndStringParamTaskSpec, func(spec *v1beta1.TaskSpec) { + want: applyMutation(arrayAndStringParamTaskSpec, func(spec *v1.TaskSpec) { spec.Steps[1].Args = []string{"foo", "second", "middlefirst", "middlesecond", "last"} }), }, { @@ -686,7 +686,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: multipleArrayAndStringsParamsTaskSpec, tr: arrayTaskRunMultipleArraysAndStrings, }, - want: applyMutation(multipleArrayAndStringsParamsTaskSpec, func(spec *v1beta1.TaskSpec) { + want: applyMutation(multipleArrayAndStringsParamsTaskSpec, func(spec *v1.TaskSpec) { spec.Steps[0].Image = "image-bar" spec.Steps[1].Command = []string{"cmd", "1-param1", "2-param1", "3-param1", "4-param1"} spec.Steps[1].Args = []string{"1-param2", "2-param2", "2-param3", "second", "1-param1", "2-param1", "3-param1", "4-param1", "foo", "last"} @@ -697,7 +697,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: arrayAndObjectParamTaskSpec, tr: arrayTaskRunWith1ObjectParam, }, - want: applyMutation(arrayAndObjectParamTaskSpec, func(spec *v1beta1.TaskSpec) { + want: applyMutation(arrayAndObjectParamTaskSpec, func(spec *v1.TaskSpec) { spec.Steps[1].Args = []string{"object value1", "object value2", "middlefirst", "middlesecond", "last"} }), }, { @@ -706,7 +706,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: multipleArrayAndObjectParamsTaskSpec, tr: arrayTaskRunMultipleArraysAndObject, }, - want: applyMutation(multipleArrayAndObjectParamsTaskSpec, func(spec *v1beta1.TaskSpec) { + want: applyMutation(multipleArrayAndObjectParamsTaskSpec, func(spec *v1.TaskSpec) { spec.Steps[0].Image = "image-value1" spec.Steps[1].Command = []string{"cmd", "1-param1", "2-param1", "3-param1", "4-param1"} spec.Steps[1].Args = []string{"1-param2", "2-param2", "3-param3", "second", "1-param1", "2-param1", "3-param1", "4-param1", "value2", "last"} @@ -715,13 +715,13 @@ func TestApplyArrayParameters(t *testing.T) { name: "default array parameter", args: args{ ts: arrayParamTaskSpec, - tr: &v1beta1.TaskRun{}, - dp: []v1beta1.ParamSpec{{ + tr: &v1.TaskRun{}, + dp: []v1.ParamSpec{{ Name: "array-param", - Default: v1beta1.NewStructuredValues("defaulted", "value!"), + Default: v1.NewStructuredValues("defaulted", "value!"), }}, }, - want: applyMutation(arrayParamTaskSpec, func(spec *v1beta1.TaskSpec) { + want: applyMutation(arrayParamTaskSpec, func(spec *v1.TaskSpec) { spec.Steps[1].Args = []string{"first", "second", "defaulted", "value!", "last"} }), }} @@ -736,25 +736,25 @@ func TestApplyArrayParameters(t *testing.T) { } func TestApplyParameters(t *testing.T) { - tr := &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + tr := &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "myimage", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }, { Name: "FOO", - Value: *v1beta1.NewStructuredValues("world"), + Value: *v1.NewStructuredValues("world"), }}, }, } - dp := []v1beta1.ParamSpec{{ + dp := []v1.ParamSpec{{ Name: "something", - Default: v1beta1.NewStructuredValues("mydefault"), + Default: v1.NewStructuredValues("mydefault"), }, { Name: "somethingelse", - Default: v1beta1.NewStructuredValues(""), + Default: v1.NewStructuredValues(""), }} - want := applyMutation(simpleTaskSpec, func(spec *v1beta1.TaskSpec) { + want := applyMutation(simpleTaskSpec, func(spec *v1.TaskSpec) { spec.StepTemplate.Env[0].Value = "world" spec.StepTemplate.Image = "bar" @@ -803,25 +803,25 @@ func TestApplyParameters(t *testing.T) { } func TestApplyParameters_ArrayIndexing(t *testing.T) { - tr := &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + tr := &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "myimage", - Value: *v1beta1.NewStructuredValues("bar", "foo"), + Value: *v1.NewStructuredValues("bar", "foo"), }, { Name: "FOO", - Value: *v1beta1.NewStructuredValues("hello", "world"), + Value: *v1.NewStructuredValues("hello", "world"), }}, }, } - dp := []v1beta1.ParamSpec{{ + dp := []v1.ParamSpec{{ Name: "something", - Default: v1beta1.NewStructuredValues("mydefault", "mydefault2"), + Default: v1.NewStructuredValues("mydefault", "mydefault2"), }, { Name: "somethingelse", - Default: v1beta1.NewStructuredValues(""), + Default: v1.NewStructuredValues(""), }} - want := applyMutation(simpleTaskSpec, func(spec *v1beta1.TaskSpec) { + want := applyMutation(simpleTaskSpec, func(spec *v1.TaskSpec) { spec.StepTemplate.Env[0].Value = "world" spec.StepTemplate.Image = "bar" @@ -874,26 +874,26 @@ func TestApplyParameters_ArrayIndexing(t *testing.T) { func TestApplyObjectParameters(t *testing.T) { // define the taskrun to test values provided by taskrun can overwrite the values provided in spec's default - tr := &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - Params: []v1beta1.Param{{ + tr := &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + Params: []v1.Param{{ Name: "myObject", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "taskrun-value-for-key1", "key2": "taskrun-value-for-key2", }), }}, }, } - dp := []v1beta1.ParamSpec{{ + dp := []v1.ParamSpec{{ Name: "myObject", - Default: v1beta1.NewObject(map[string]string{ + Default: v1.NewObject(map[string]string{ "key1": "default-value-for-key1", "key2": "default-value-for-key2", }), }} - want := applyMutation(objectParamTaskSpec, func(spec *v1beta1.TaskSpec) { + want := applyMutation(objectParamTaskSpec, func(spec *v1.TaskSpec) { spec.Sidecars[0].Image = "taskrun-value-for-key1" spec.Sidecars[0].Env[0].Value = "taskrun-value-for-key2" @@ -940,8 +940,8 @@ func TestApplyObjectParameters(t *testing.T) { func TestApplyWorkspaces(t *testing.T) { names.TestingSeed() - ts := &v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + ts := &v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ Env: []corev1.EnvVar{{ Name: "template-var", Value: "$(workspaces.myws.volume)", @@ -953,7 +953,7 @@ func TestApplyWorkspaces(t *testing.T) { Value: "$(workspaces.otherws.claim)", }}, }, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "$(workspaces.myws.volume)", Image: "$(workspaces.otherws.volume)", WorkingDir: "$(workspaces.otherws.volume)", @@ -1013,20 +1013,20 @@ func TestApplyWorkspaces(t *testing.T) { } for _, tc := range []struct { name string - spec *v1beta1.TaskSpec - decls []v1beta1.WorkspaceDeclaration - binds []v1beta1.WorkspaceBinding - want *v1beta1.TaskSpec + spec *v1.TaskSpec + decls []v1.WorkspaceDeclaration + binds []v1.WorkspaceBinding + want *v1.TaskSpec }{{ name: "workspace-variable-replacement", spec: ts.DeepCopy(), - decls: []v1beta1.WorkspaceDeclaration{{ + decls: []v1.WorkspaceDeclaration{{ Name: "myws", }, { Name: "otherws", MountPath: "/foo", }}, - binds: []v1beta1.WorkspaceBinding{{ + binds: []v1.WorkspaceBinding{{ Name: "myws", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "foo", @@ -1035,7 +1035,7 @@ func TestApplyWorkspaces(t *testing.T) { Name: "otherws", EmptyDir: &corev1.EmptyDirVolumeSource{}, }}, - want: applyMutation(ts, func(spec *v1beta1.TaskSpec) { + want: applyMutation(ts, func(spec *v1.TaskSpec) { spec.StepTemplate.Env[0].Value = "ws-9l9zj" spec.StepTemplate.Env[1].Value = "foo" spec.StepTemplate.Env[2].Value = "" @@ -1062,31 +1062,31 @@ func TestApplyWorkspaces(t *testing.T) { }), }, { name: "optional-workspace-provided-variable-replacement", - spec: &v1beta1.TaskSpec{Steps: []v1beta1.Step{{ + spec: &v1.TaskSpec{Steps: []v1.Step{{ Script: `test "$(workspaces.ows.bound)" = "true" && echo "$(workspaces.ows.path)"`, }}}, - decls: []v1beta1.WorkspaceDeclaration{{ + decls: []v1.WorkspaceDeclaration{{ Name: "ows", Optional: true, }}, - binds: []v1beta1.WorkspaceBinding{{ + binds: []v1.WorkspaceBinding{{ Name: "ows", EmptyDir: &corev1.EmptyDirVolumeSource{}, }}, - want: &v1beta1.TaskSpec{Steps: []v1beta1.Step{{ + want: &v1.TaskSpec{Steps: []v1.Step{{ Script: `test "true" = "true" && echo "/workspace/ows"`, }}}, }, { name: "optional-workspace-omitted-variable-replacement", - spec: &v1beta1.TaskSpec{Steps: []v1beta1.Step{{ + spec: &v1.TaskSpec{Steps: []v1.Step{{ Script: `test "$(workspaces.ows.bound)" = "true" && echo "$(workspaces.ows.path)"`, }}}, - decls: []v1beta1.WorkspaceDeclaration{{ + decls: []v1.WorkspaceDeclaration{{ Name: "ows", Optional: true, }}, - binds: []v1beta1.WorkspaceBinding{}, // intentionally omitted ows binding - want: &v1beta1.TaskSpec{Steps: []v1beta1.Step{{ + binds: []v1.WorkspaceBinding{}, // intentionally omitted ows binding + want: &v1.TaskSpec{Steps: []v1.Step{{ Script: `test "false" = "true" && echo ""`, }}}, }} { @@ -1103,56 +1103,56 @@ func TestApplyWorkspaces(t *testing.T) { func TestApplyWorkspaces_IsolatedWorkspaces(t *testing.T) { for _, tc := range []struct { name string - spec *v1beta1.TaskSpec - decls []v1beta1.WorkspaceDeclaration - binds []v1beta1.WorkspaceBinding - want *v1beta1.TaskSpec + spec *v1.TaskSpec + decls []v1.WorkspaceDeclaration + binds []v1.WorkspaceBinding + want *v1.TaskSpec }{{ name: "step-workspace-with-custom-mountpath", - spec: &v1beta1.TaskSpec{Steps: []v1beta1.Step{{ + spec: &v1.TaskSpec{Steps: []v1.Step{{ Script: `echo "$(workspaces.ws.path)"`, - Workspaces: []v1beta1.WorkspaceUsage{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "ws", MountPath: "/foo", }}, }, { Script: `echo "$(workspaces.ws.path)"`, - }}, Sidecars: []v1beta1.Sidecar{{ + }}, Sidecars: []v1.Sidecar{{ Script: `echo "$(workspaces.ws.path)"`, }}}, - decls: []v1beta1.WorkspaceDeclaration{{ + decls: []v1.WorkspaceDeclaration{{ Name: "ws", }}, - want: &v1beta1.TaskSpec{Steps: []v1beta1.Step{{ + want: &v1.TaskSpec{Steps: []v1.Step{{ Script: `echo "/foo"`, - Workspaces: []v1beta1.WorkspaceUsage{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "ws", MountPath: "/foo", }}, }, { Script: `echo "/workspace/ws"`, - }}, Sidecars: []v1beta1.Sidecar{{ + }}, Sidecars: []v1.Sidecar{{ Script: `echo "/workspace/ws"`, }}}, }, { name: "sidecar-workspace-with-custom-mountpath", - spec: &v1beta1.TaskSpec{Steps: []v1beta1.Step{{ + spec: &v1.TaskSpec{Steps: []v1.Step{{ Script: `echo "$(workspaces.ws.path)"`, - }}, Sidecars: []v1beta1.Sidecar{{ + }}, Sidecars: []v1.Sidecar{{ Script: `echo "$(workspaces.ws.path)"`, - Workspaces: []v1beta1.WorkspaceUsage{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "ws", MountPath: "/bar", }}, }}}, - decls: []v1beta1.WorkspaceDeclaration{{ + decls: []v1.WorkspaceDeclaration{{ Name: "ws", }}, - want: &v1beta1.TaskSpec{Steps: []v1beta1.Step{{ + want: &v1.TaskSpec{Steps: []v1.Step{{ Script: `echo "/workspace/ws"`, - }}, Sidecars: []v1beta1.Sidecar{{ + }}, Sidecars: []v1.Sidecar{{ Script: `echo "/bar"`, - Workspaces: []v1beta1.WorkspaceUsage{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "ws", MountPath: "/bar", }}, @@ -1177,21 +1177,21 @@ func TestContext(t *testing.T) { for _, tc := range []struct { description string taskName string - tr v1beta1.TaskRun - spec v1beta1.TaskSpec - want v1beta1.TaskSpec + tr v1.TaskRun + spec v1.TaskSpec + want v1.TaskSpec }{{ description: "context taskName replacement without taskRun in spec container", taskName: "Task1", - tr: v1beta1.TaskRun{}, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + tr: v1.TaskRun{}, + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.task.name)-1", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "Task1-1", }}, @@ -1199,19 +1199,19 @@ func TestContext(t *testing.T) { }, { description: "context taskName replacement with taskRun in spec container", taskName: "Task1", - tr: v1beta1.TaskRun{ + tr: v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "taskrunName", }, }, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.task.name)-1", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "Task1-1", }}, @@ -1219,19 +1219,19 @@ func TestContext(t *testing.T) { }, { description: "context taskRunName replacement with defined taskRun in spec container", taskName: "Task1", - tr: v1beta1.TaskRun{ + tr: v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "taskrunName", }, }, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.taskRun.name)-1", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "taskrunName-1", }}, @@ -1239,15 +1239,15 @@ func TestContext(t *testing.T) { }, { description: "context taskRunName replacement with no defined taskRun name in spec container", taskName: "Task1", - tr: v1beta1.TaskRun{}, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + tr: v1.TaskRun{}, + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.taskRun.name)-1", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "-1", }}, @@ -1255,15 +1255,15 @@ func TestContext(t *testing.T) { }, { description: "context taskRun namespace replacement with no defined namepsace in spec container", taskName: "Task1", - tr: v1beta1.TaskRun{}, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + tr: v1.TaskRun{}, + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.taskRun.namespace)-1", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "-1", }}, @@ -1271,35 +1271,35 @@ func TestContext(t *testing.T) { }, { description: "context taskRun namespace replacement with defined namepsace in spec container", taskName: "Task1", - tr: v1beta1.TaskRun{ + tr: v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "taskrunName", Namespace: "trNamespace", }, }, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.taskRun.namespace)-1", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "trNamespace-1", }}, }, }, { description: "context taskRunName replacement with no defined taskName in spec container", - tr: v1beta1.TaskRun{}, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + tr: v1.TaskRun{}, + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.task.name)-1", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "-1", }}, @@ -1307,29 +1307,29 @@ func TestContext(t *testing.T) { }, { description: "context UID replacement", taskName: "Task1", - tr: v1beta1.TaskRun{ + tr: v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ UID: "UID-1", }, }, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.taskRun.uid)", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "UID-1", }}, }, }, { description: "context retry count replacement", - tr: v1beta1.TaskRun{ - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - RetriesStatus: []v1beta1.TaskRunStatus{{ + tr: v1.TaskRun{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + RetriesStatus: []v1.TaskRunStatus{{ Status: duckv1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -1347,29 +1347,29 @@ func TestContext(t *testing.T) { }, }, }, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.task.retry-count)-1", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "2-1", }}, }, }, { description: "context retry count replacement with task that never retries", - tr: v1beta1.TaskRun{}, - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + tr: v1.TaskRun{}, + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "$(context.task.retry-count)-1", }}, }, - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "ImageName", Image: "0-1", }}, @@ -1386,15 +1386,15 @@ func TestContext(t *testing.T) { func TestTaskResults(t *testing.T) { names.TestingSeed() - ts := &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{ + ts := &v1.TaskSpec{ + Results: []v1.TaskResult{{ Name: "current.date.unix.timestamp", Description: "The current date in unix timestamp format", }, { Name: "current-date-human-readable", Description: "The current date in humand readable format"}, }, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "print-date-unix-timestamp", Image: "bash:latest", Args: []string{"$(results[\"current.date.unix.timestamp\"].path)"}, @@ -1409,7 +1409,7 @@ func TestTaskResults(t *testing.T) { Script: "#!/usr/bin/env bash\ndate | tee $(results['current-date-human-readable'].path)", }}, } - want := applyMutation(ts, func(spec *v1beta1.TaskSpec) { + want := applyMutation(ts, func(spec *v1.TaskSpec) { spec.Steps[0].Script = "#!/usr/bin/env bash\ndate +%s | tee /tekton/results/current.date.unix.timestamp" spec.Steps[0].Args[0] = "/tekton/results/current.date.unix.timestamp" spec.Steps[1].Script = "#!/usr/bin/env bash\ndate | tee /tekton/results/current-date-human-readable" @@ -1423,8 +1423,8 @@ func TestTaskResults(t *testing.T) { func TestApplyStepExitCodePath(t *testing.T) { names.TestingSeed() - ts := &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts := &v1.TaskSpec{ + Steps: []v1.Step{{ Image: "bash:latest", Script: "#!/usr/bin/env bash\nexit 11", }, { @@ -1437,7 +1437,7 @@ func TestApplyStepExitCodePath(t *testing.T) { Script: "#!/usr/bin/env bash\ncat $(steps.step-failing-step.exitCode.path)", }}, } - expected := applyMutation(ts, func(spec *v1beta1.TaskSpec) { + expected := applyMutation(ts, func(spec *v1.TaskSpec) { spec.Steps[1].Script = "#!/usr/bin/env bash\ncat /tekton/steps/step-unnamed-0/exitCode" spec.Steps[2].Script = "#!/usr/bin/env bash\ncat /tekton/steps/step-failing-step/exitCode" }) @@ -1450,34 +1450,34 @@ func TestApplyStepExitCodePath(t *testing.T) { func TestApplyCredentialsPath(t *testing.T) { for _, tc := range []struct { description string - spec v1beta1.TaskSpec + spec v1.TaskSpec path string - want v1beta1.TaskSpec + want v1.TaskSpec }{{ description: "replacement in spec container", - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Command: []string{"cp"}, Args: []string{"-R", "$(credentials.path)/", "$HOME"}, }}, }, path: "/tekton/creds", - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Command: []string{"cp"}, Args: []string{"-R", "/tekton/creds/", "$HOME"}, }}, }, }, { description: "replacement in spec Script", - spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + spec: v1.TaskSpec{ + Steps: []v1.Step{{ Script: `cp -R "$(credentials.path)/" $HOME`, }}, }, path: "/tekton/home", - want: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + want: v1.TaskSpec{ + Steps: []v1.Step{{ Script: `cp -R "/tekton/home/" $HOME`, }}, }, diff --git a/pkg/reconciler/taskrun/resources/taskref.go b/pkg/reconciler/taskrun/resources/taskref.go index b8f343725c3..778d1b12bf9 100644 --- a/pkg/reconciler/taskrun/resources/taskref.go +++ b/pkg/reconciler/taskrun/resources/taskref.go @@ -22,14 +22,12 @@ import ( "fmt" "strings" - "github.com/google/go-containerregistry/pkg/authn/k8schain" "github.com/tektoncd/pipeline/pkg/apis/config" v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" "github.com/tektoncd/pipeline/pkg/remote" - "github.com/tektoncd/pipeline/pkg/remote/oci" "github.com/tektoncd/pipeline/pkg/remote/resolution" remoteresource "github.com/tektoncd/pipeline/pkg/resolution/resource" "github.com/tektoncd/pipeline/pkg/trustedresources" @@ -46,8 +44,8 @@ import ( var errEtcdLeaderChange = "etcdserver: leader changed" // GetTaskKind returns the referenced Task kind (Task, ClusterTask, ...) if the TaskRun is using TaskRef. -func GetTaskKind(taskrun *v1beta1.TaskRun) v1beta1.TaskKind { - kind := v1beta1.NamespacedTaskKind +func GetTaskKind(taskrun *v1.TaskRun) v1.TaskKind { + kind := v1.NamespacedTaskKind if taskrun.Spec.TaskRef != nil && taskrun.Spec.TaskRef.Kind != "" { kind = taskrun.Spec.TaskRef.Kind } @@ -58,16 +56,16 @@ func GetTaskKind(taskrun *v1beta1.TaskRun) v1beta1.TaskKind { // also requires a kubeclient, tektonclient, namespace, and service account in case it needs to find that task in // cluster or authorize against an external repositroy. It will figure out whether it needs to look in the cluster or in // a remote image to fetch the reference. It will also return the "kind" of the task being referenced. -func GetTaskFuncFromTaskRun(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, requester remoteresource.Requester, taskrun *v1beta1.TaskRun, verificationpolicies []*v1alpha1.VerificationPolicy) GetTask { +func GetTaskFuncFromTaskRun(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, requester remoteresource.Requester, taskrun *v1.TaskRun, verificationpolicies []*v1alpha1.VerificationPolicy) GetTask { // if the spec is already in the status, do not try to fetch it again, just use it as source of truth. // Same for the Source field in the Status.Provenance. if taskrun.Status.TaskSpec != nil { - return func(_ context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { - var configsource *v1beta1.ConfigSource + return func(_ context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { + var configsource *v1.ConfigSource if taskrun.Status.Provenance != nil { configsource = taskrun.Status.Provenance.ConfigSource } - return &v1beta1.Task{ + return &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: taskrun.Namespace, @@ -82,10 +80,10 @@ func GetTaskFuncFromTaskRun(ctx context.Context, k8s kubernetes.Interface, tekto // GetVerifiedTaskFunc is a wrapper of GetTaskFunc and return the function to verify the task // if there are matching verification policies func GetVerifiedTaskFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, requester remoteresource.Requester, - owner kmeta.OwnerRefable, taskref *v1beta1.TaskRef, trName string, namespace, saName string, verificationpolicies []*v1alpha1.VerificationPolicy) GetTask { + owner kmeta.OwnerRefable, taskref *v1.TaskRef, trName string, namespace, saName string, verificationpolicies []*v1alpha1.VerificationPolicy) GetTask { get := GetTaskFunc(ctx, k8s, tekton, requester, owner, taskref, trName, namespace, saName) - return func(context.Context, string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + return func(context.Context, string) (*v1.Task, *v1.ConfigSource, error) { t, s, err := get(ctx, taskref.Name) if err != nil { return nil, nil, fmt.Errorf("failed to get task: %w", err) @@ -106,36 +104,37 @@ func GetVerifiedTaskFunc(ctx context.Context, k8s kubernetes.Interface, tekton c // cluster or authorize against an external repositroy. It will figure out whether it needs to look in the cluster or in // a remote image to fetch the reference. It will also return the "kind" of the task being referenced. func GetTaskFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, requester remoteresource.Requester, - owner kmeta.OwnerRefable, tr *v1beta1.TaskRef, trName string, namespace, saName string) GetTask { - cfg := config.FromContextOrDefaults(ctx) - kind := v1beta1.NamespacedTaskKind + owner kmeta.OwnerRefable, tr *v1.TaskRef, trName string, namespace, saName string) GetTask { + // cfg := config.FromContextOrDefaults(ctx) + kind := v1.NamespacedTaskKind if tr != nil && tr.Kind != "" { kind = tr.Kind } switch { - case cfg.FeatureFlags.EnableTektonOCIBundles && tr != nil && tr.Bundle != "": - // Return an inline function that implements GetTask by calling Resolver.Get with the specified task type and - // casting it to a TaskObject. - return func(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { - // If there is a bundle url at all, construct an OCI resolver to fetch the task. - kc, err := k8schain.New(ctx, k8s, k8schain.Options{ - Namespace: namespace, - ServiceAccountName: saName, - }) - if err != nil { - return nil, nil, fmt.Errorf("failed to get keychain: %w", err) - } - resolver := oci.NewResolver(tr.Bundle, kc) - - return resolveTask(ctx, resolver, name, kind, k8s) - } + //TODO: to check can safely delete bundle part since it is replaced by bundle resovler in v1 + // case cfg.FeatureFlags.EnableTektonOCIBundles && tr != nil && tr.Bundle != "": + // // Return an inline function that implements GetTask by calling Resolver.Get with the specified task type and + // // casting it to a TaskObject. + // return func(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { + // // If there is a bundle url at all, construct an OCI resolver to fetch the task. + // kc, err := k8schain.New(ctx, k8s, k8schain.Options{ + // Namespace: namespace, + // ServiceAccountName: saName, + // }) + // if err != nil { + // return nil, nil, fmt.Errorf("failed to get keychain: %w", err) + // } + // resolver := oci.NewResolver(tr.Bundle, kc) + + // return resolveTask(ctx, resolver, name, kind, k8s) + // } case tr != nil && tr.Resolver != "" && requester != nil: // Return an inline function that implements GetTask by calling Resolver.Get with the specified task type and // casting it to a TaskObject. - return func(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { - var replacedParams []v1beta1.Param - if ownerAsTR, ok := owner.(*v1beta1.TaskRun); ok { + return func(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { + var replacedParams []v1.Param + if ownerAsTR, ok := owner.(*v1.TaskRun); ok { stringReplacements, arrayReplacements := paramsFromTaskRun(ctx, ownerAsTR) for k, v := range getContextReplacements("", ownerAsTR) { stringReplacements[k] = v @@ -165,8 +164,8 @@ func GetTaskFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset // resolveTask accepts an impl of remote.Resolver and attempts to // fetch a task with given name. An error is returned if the // remoteresource doesn't work or the returned data isn't a valid -// v1beta1.TaskObject. -func resolveTask(ctx context.Context, resolver remote.Resolver, name string, kind v1beta1.TaskKind, k8s kubernetes.Interface) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { +// *v1.Task. +func resolveTask(ctx context.Context, resolver remote.Resolver, name string, kind v1.TaskKind, k8s kubernetes.Interface) (*v1.Task, *v1.ConfigSource, error) { // Because the resolver will only return references with the same kind (eg ClusterTask), this will ensure we // don't accidentally return a Task with the same name but different kind. obj, configSource, err := resolver.Get(ctx, strings.TrimSuffix(strings.ToLower(string(kind)), "s"), name) @@ -181,27 +180,31 @@ func resolveTask(ctx context.Context, resolver remote.Resolver, name string, kin } // readRuntimeObjectAsTask tries to convert a generic runtime.Object -// into a v1beta1.TaskObject type so that its meta and spec fields +// into a *v1.Task type so that its meta and spec fields // can be read. v1 object will be converted to v1beta1 and returned. // An error is returned if the given object is not a // TaskObject or if there is an error validating or upgrading an // older TaskObject into its v1beta1 equivalent. // TODO(#5541): convert v1beta1 obj to v1 once we use v1 as the stored version -func readRuntimeObjectAsTask(ctx context.Context, obj runtime.Object) (v1beta1.TaskObject, error) { +func readRuntimeObjectAsTask(ctx context.Context, obj runtime.Object) (*v1.Task, error) { switch obj := obj.(type) { - case v1beta1.TaskObject: - return obj, nil - case *v1.Task: - t := &v1beta1.Task{ + case *v1beta1.ClusterTask: + //TODO + case *v1beta1.Task: + // TODO: confirm that this shall be deprecated? + t := &v1.Task{ TypeMeta: metav1.TypeMeta{ Kind: "Task", - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", }, } - if err := t.ConvertFrom(ctx, obj); err != nil { + if err := obj.ConvertTo(ctx, t); err != nil { return nil, err } return t, nil + + case *v1.Task: + return obj, nil } return nil, errors.New("resource is not a task") } @@ -209,7 +212,7 @@ func readRuntimeObjectAsTask(ctx context.Context, obj runtime.Object) (v1beta1.T // LocalTaskRefResolver uses the current cluster to resolve a task reference. type LocalTaskRefResolver struct { Namespace string - Kind v1beta1.TaskKind + Kind v1.TaskKind Tektonclient clientset.Interface } @@ -217,7 +220,8 @@ type LocalTaskRefResolver struct { // return an error if it can't find an appropriate Task for any reason. // TODO: if we want to set source for in-cluster task, set it here. // https://github.com/tektoncd/pipeline/issues/5522 -func (l *LocalTaskRefResolver) GetTask(ctx context.Context, name string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { +func (l *LocalTaskRefResolver) GetTask(ctx context.Context, name string) (*v1.Task, *v1.ConfigSource, error) { + // TODO to figure out whether we can delete the ClusterTaskKind check since we are only having ClusterTasks in v1beta1 if l.Kind == v1beta1.ClusterTaskKind { task, err := l.Tektonclient.TektonV1beta1().ClusterTasks().Get(ctx, name, metav1.GetOptions{}) if err != nil { @@ -230,7 +234,7 @@ func (l *LocalTaskRefResolver) GetTask(ctx context.Context, name string) (v1beta if l.Namespace == "" { return nil, nil, fmt.Errorf("must specify namespace to resolve reference to task %s", name) } - task, err := l.Tektonclient.TektonV1beta1().Tasks(l.Namespace).Get(ctx, name, metav1.GetOptions{}) + task, err := l.Tektonclient.TektonV1().Tasks(l.Namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { return nil, nil, err } diff --git a/pkg/reconciler/taskrun/resources/taskref_test.go b/pkg/reconciler/taskrun/resources/taskref_test.go index a65191fc4d4..c8a1b47f643 100644 --- a/pkg/reconciler/taskrun/resources/taskref_test.go +++ b/pkg/reconciler/taskrun/resources/taskref_test.go @@ -29,6 +29,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-containerregistry/pkg/registry" "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/fake" @@ -38,7 +39,6 @@ import ( "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/parse" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" fakek8s "k8s.io/client-go/kubernetes/fake" @@ -47,17 +47,17 @@ import ( ) var ( - simpleNamespacedTask = &v1beta1.Task{ + simpleNamespacedTask = &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "simple", Namespace: "default", }, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task", }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Image: "something", }}, }, @@ -67,7 +67,7 @@ var ( Name: "simple", }, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "ClusterTask", }, Spec: v1beta1.TaskSpec{ @@ -76,7 +76,7 @@ var ( }}, }, } - sampleConfigSource = &v1beta1.ConfigSource{ + sampleConfigSource = &v1.ConfigSource{ URI: "abc.com", Digest: map[string]string{ "sha1": "a123", @@ -88,36 +88,36 @@ var ( func TestGetTaskKind(t *testing.T) { testCases := []struct { name string - tr *v1beta1.TaskRun - expected v1beta1.TaskKind + tr *v1.TaskRun + expected v1.TaskKind }{ { name: "no task ref", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{}, + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{}, }, }, - expected: v1beta1.NamespacedTaskKind, + expected: v1.NamespacedTaskKind, }, { name: "no kind on task ref", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{Name: "whatever"}, + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{Name: "whatever"}, }, }, - expected: v1beta1.NamespacedTaskKind, + expected: v1.NamespacedTaskKind, }, { name: "kind on task ref", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{ + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{ Name: "whatever", Kind: "something-else", }, }, }, - expected: v1beta1.TaskKind("something-else"), + expected: v1.TaskKind("something-else"), }, } @@ -135,30 +135,30 @@ func TestLocalTaskRef(t *testing.T) { testcases := []struct { name string tasks []runtime.Object - ref *v1beta1.TaskRef + ref *v1.TaskRef expected runtime.Object wantErr bool }{ { name: "local-task", tasks: []runtime.Object{ - &v1beta1.Task{ + &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "simple", Namespace: "default", }, }, - &v1beta1.Task{ + &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "dummy", Namespace: "default", }, }, }, - ref: &v1beta1.TaskRef{ + ref: &v1.TaskRef{ Name: "simple", }, - expected: &v1beta1.Task{ + expected: &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "simple", Namespace: "default", @@ -180,7 +180,7 @@ func TestLocalTaskRef(t *testing.T) { }, }, }, - ref: &v1beta1.TaskRef{ + ref: &v1.TaskRef{ Name: "cluster-task", Kind: "ClusterTask", }, @@ -194,7 +194,7 @@ func TestLocalTaskRef(t *testing.T) { { name: "task-not-found", tasks: []runtime.Object{}, - ref: &v1beta1.TaskRef{ + ref: &v1.TaskRef{ Name: "simple", }, expected: nil, @@ -257,150 +257,150 @@ func TestGetTaskFunc(t *testing.T) { name string localTasks []runtime.Object remoteTasks []runtime.Object - ref *v1beta1.TaskRef + ref *v1.TaskRef expected runtime.Object - expectedKind v1beta1.TaskKind + expectedKind v1.TaskKind }{ { name: "remote-task", localTasks: []runtime.Object{simpleNamespacedTask}, remoteTasks: []runtime.Object{ - &v1beta1.Task{ + &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "simple", }, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task", }, }, - &v1beta1.Task{ + &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "dummy", }, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task", }, }, }, - ref: &v1beta1.TaskRef{ - Name: "simple", - Bundle: u.Host + "/remote-task", + ref: &v1.TaskRef{ + Name: "simple", + // Bundle: u.Host + "/remote-task", }, - expected: &v1beta1.Task{ + expected: &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "simple", }, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task", }, }, - expectedKind: v1beta1.NamespacedTaskKind, + expectedKind: v1.NamespacedTaskKind, }, { name: "remote-task-without-defaults", localTasks: []runtime.Object{}, remoteTasks: []runtime.Object{ - &v1beta1.Task{ + &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "simple", Namespace: "default", }, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task", }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Image: "something", }}, - Params: []v1beta1.ParamSpec{{ + Params: []v1.ParamSpec{{ Name: "foo", }, }, }, }}, - ref: &v1beta1.TaskRef{ - Name: "simple", - Bundle: u.Host + "/remote-task-without-defaults", + ref: &v1.TaskRef{ + Name: "simple", + // Bundle: u.Host + "/remote-task-without-defaults", }, - expected: &v1beta1.Task{ + expected: &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "simple", Namespace: "default", }, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task", }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Image: "something", }}, - Params: []v1beta1.ParamSpec{{ + Params: []v1.ParamSpec{{ Name: "foo", }}, }, }, - expectedKind: v1beta1.NamespacedTaskKind, + expectedKind: v1.NamespacedTaskKind, }, { name: "local-task", localTasks: []runtime.Object{simpleNamespacedTask}, remoteTasks: []runtime.Object{ - &v1beta1.Task{ + &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "simple", }, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task", }, }, - &v1beta1.Task{ + &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "dummy", }, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task", }, }, }, - ref: &v1beta1.TaskRef{ + ref: &v1.TaskRef{ Name: "simple", }, expected: simpleNamespacedTask, - expectedKind: v1beta1.NamespacedTaskKind, + expectedKind: v1.NamespacedTaskKind, }, { name: "remote-cluster-task", localTasks: []runtime.Object{ &v1beta1.ClusterTask{ - TypeMeta: metav1.TypeMeta{APIVersion: "v1beta1", Kind: "ClusterTask"}, + TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "ClusterTask"}, ObjectMeta: metav1.ObjectMeta{Name: "simple"}, Spec: v1beta1.TaskSpec{Params: []v1beta1.ParamSpec{{Name: "foo"}}}, }, }, remoteTasks: []runtime.Object{ &v1beta1.ClusterTask{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1", Kind: "ClusterTask"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1", Kind: "ClusterTask"}, ObjectMeta: metav1.ObjectMeta{Name: "simple"}, }, &v1beta1.ClusterTask{ - TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1beta1", Kind: "ClusterTask"}, + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1", Kind: "ClusterTask"}, ObjectMeta: metav1.ObjectMeta{Name: "dummy"}, }, }, - ref: &v1beta1.TaskRef{ + ref: &v1.TaskRef{ Name: "simple", - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: v1beta1.ClusterTaskKind, - Bundle: u.Host + "/remote-cluster-task", + // Bundle: u.Host + "/remote-cluster-task", }, expected: &v1beta1.ClusterTask{ ObjectMeta: metav1.ObjectMeta{Name: "simple"}, TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "ClusterTask", }, }, @@ -418,19 +418,19 @@ func TestGetTaskFunc(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "dummy"}, }, }, - ref: &v1beta1.TaskRef{ + ref: &v1.TaskRef{ Name: "simple", Kind: v1beta1.ClusterTaskKind, }, expected: simpleClusterTask, - expectedKind: v1beta1.ClusterTaskKind, + expectedKind: v1.ClusterTaskKind, }, } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { tektonclient := fake.NewSimpleClientset(tc.localTasks...) - kubeclient := fakek8s.NewSimpleClientset(&v1.ServiceAccount{ + kubeclient := fakek8s.NewSimpleClientset(&corev1.ServiceAccount{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "default", @@ -442,9 +442,9 @@ func TestGetTaskFunc(t *testing.T) { t.Fatalf("failed to upload test image: %s", err.Error()) } - trForFunc := &v1beta1.TaskRun{ + trForFunc := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Name: "some-tr"}, - Spec: v1beta1.TaskRunSpec{ + Spec: v1.TaskRunSpec{ TaskRef: tc.ref, }, } @@ -472,7 +472,7 @@ func TestGetTaskFuncFromTaskRunSpecAlreadyFetched(t *testing.T) { ctx, cancel := context.WithCancel(ctx) defer cancel() tektonclient := fake.NewSimpleClientset(simpleNamespacedTask) - kubeclient := fakek8s.NewSimpleClientset(&v1.ServiceAccount{ + kubeclient := fakek8s.NewSimpleClientset(&corev1.ServiceAccount{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "default", @@ -480,8 +480,8 @@ func TestGetTaskFuncFromTaskRunSpecAlreadyFetched(t *testing.T) { }) name := "anyname-really" - TaskSpec := v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + TaskSpec := v1.TaskSpec{ + Steps: []v1.Step{{ Image: "myimage", Script: ` #!/usr/bin/env bash @@ -490,24 +490,24 @@ echo hello }}, } - TaskRun := &v1beta1.TaskRun{ + TaskRun := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "default"}, - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{ + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{ // Using simple here to show that, it won't fetch the simple Taskspec, // which is different from the TaskSpec above Name: "simple", }, ServiceAccountName: "default", }, - Status: v1beta1.TaskRunStatus{TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Status: v1.TaskRunStatus{TaskRunStatusFields: v1.TaskRunStatusFields{ TaskSpec: &TaskSpec, - Provenance: &v1beta1.Provenance{ + Provenance: &v1.Provenance{ ConfigSource: sampleConfigSource.DeepCopy(), }, }}, } - expectedTask := &v1beta1.Task{ + expectedTask := &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: "default", @@ -536,7 +536,7 @@ func TestGetTaskFunc_RemoteResolution(t *testing.T) { cfg := config.FromContextOrDefaults(ctx) ctx = config.ToContext(ctx, cfg) task := parse.MustParseV1beta1Task(t, taskYAMLString) - taskRef := &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} + taskRef := &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git"}} testcases := []struct { name string @@ -560,9 +560,9 @@ func TestGetTaskFunc_RemoteResolution(t *testing.T) { t.Run(tc.name, func(t *testing.T) { resolved := test.NewResolvedResource([]byte(tc.taskYAML), nil /* annotations */, sampleConfigSource.DeepCopy(), nil /* data error */) requester := test.NewRequester(resolved, nil) - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "default"}, - Spec: v1beta1.TaskRunSpec{ + Spec: v1.TaskRunSpec{ TaskRef: taskRef, ServiceAccountName: "default", }, @@ -589,47 +589,47 @@ func TestGetTaskFunc_RemoteResolution_ReplacedParams(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) ctx = config.ToContext(ctx, cfg) - task := parse.MustParseV1beta1Task(t, taskYAMLString) - taskRef := &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ + task := parse.MustParseV1Task(t, taskYAMLString) + taskRef := &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("$(params.resolver-param)"), + Value: *v1.NewStructuredValues("$(params.resolver-param)"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("$(context.taskRun.name)"), + Value: *v1.NewStructuredValues("$(context.taskRun.name)"), }}, }, } taskYAML := strings.Join([]string{ "kind: Task", - "apiVersion: tekton.dev/v1beta1", + "apiVersion: tekton.dev/v1", taskYAMLString, }, "\n") resolved := test.NewResolvedResource([]byte(taskYAML), nil, sampleConfigSource.DeepCopy(), nil) requester := &test.Requester{ ResolvedResource: resolved, - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("test-task"), + Value: *v1.NewStructuredValues("test-task"), }}, } - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-task", Namespace: "default", }, - Spec: v1beta1.TaskRunSpec{ + Spec: v1.TaskRunSpec{ TaskRef: taskRef, ServiceAccountName: "default", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "resolver-param", - Value: *v1beta1.NewStructuredValues("bar"), + Value: *v1.NewStructuredValues("bar"), }}, }, } @@ -648,30 +648,30 @@ func TestGetTaskFunc_RemoteResolution_ReplacedParams(t *testing.T) { t.Errorf("configSources did not match: %s", diff.PrintWantGot(d)) } - taskRefNotMatching := &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ + taskRefNotMatching := &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "foo", - Value: *v1beta1.NewStructuredValues("$(params.resolver-param)"), + Value: *v1.NewStructuredValues("$(params.resolver-param)"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("$(context.taskRun.name)"), + Value: *v1.NewStructuredValues("$(context.taskRun.name)"), }}, }, } - trNotMatching := &v1beta1.TaskRun{ + trNotMatching := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "other-task", Namespace: "default", }, - Spec: v1beta1.TaskRunSpec{ + Spec: v1.TaskRunSpec{ TaskRef: taskRefNotMatching, ServiceAccountName: "default", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "resolver-param", - Value: *v1beta1.NewStructuredValues("banana"), + Value: *v1.NewStructuredValues("banana"), }}, }, } @@ -690,13 +690,13 @@ func TestGetPipelineFunc_RemoteResolutionInvalidData(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) ctx = config.ToContext(ctx, cfg) - taskRef := &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} + taskRef := &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git"}} resolvesTo := []byte("INVALID YAML") resource := test.NewResolvedResource(resolvesTo, nil, nil, nil) requester := test.NewRequester(resource, nil) - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "default"}, - Spec: v1beta1.TaskRunSpec{ + Spec: v1.TaskRunSpec{ TaskRef: taskRef, ServiceAccountName: "default", }, @@ -748,7 +748,7 @@ func TestGetVerifiedTaskFunc_Success(t *testing.T) { resolvedMatched := test.NewResolvedResource(signedTaskBytes, nil, matchPolicySource, nil) requesterMatched := test.NewRequester(resolvedMatched, nil) - taskRef := &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} + taskRef := &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git"}} testcases := []struct { name string @@ -810,10 +810,10 @@ func TestGetVerifiedTaskFunc_Success(t *testing.T) { } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { - ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy) - tr := &v1beta1.TaskRun{ + ctx = test.SetupTrustedResourceConfig(ctx, tc.resourceVerificationMode) + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"}, - Spec: v1beta1.TaskRunSpec{ + Spec: v1.TaskRunSpec{ TaskRef: taskRef, ServiceAccountName: "default", }, @@ -886,7 +886,7 @@ func TestGetVerifiedTaskFunc_VerifyError(t *testing.T) { resolvedModified := test.NewResolvedResource(modifiedTaskBytes, nil, matchPolicySource, nil) requesterModified := test.NewRequester(resolvedModified, nil) - taskRef := &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} + taskRef := &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git"}} testcases := []struct { name string @@ -940,10 +940,10 @@ func TestGetVerifiedTaskFunc_VerifyError(t *testing.T) { } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { - ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy) - tr := &v1beta1.TaskRun{ + ctx = test.SetupTrustedResourceConfig(ctx, tc.resourceVerificationMode) + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"}, - Spec: v1beta1.TaskRunSpec{ + Spec: v1.TaskRunSpec{ TaskRef: taskRef, ServiceAccountName: "default", }, @@ -982,23 +982,23 @@ func TestGetVerifiedTaskFunc_GetFuncError(t *testing.T) { requesterUnsigned := test.NewRequester(resolvedUnsigned, nil) resolvedUnsigned.DataErr = fmt.Errorf("resolution error") - trBundleError := &v1beta1.TaskRun{ + trBundleError := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"}, - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{ - Name: "taskName", - Bundle: "bundle", + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{ + Name: "taskName", + // Bundle: "bundle", }, ServiceAccountName: "default", }, } - trResolutionError := &v1beta1.TaskRun{ + trResolutionError := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"}, - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{ + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{ Name: "taskName", - ResolverRef: v1beta1.ResolverRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", }, }, @@ -1009,7 +1009,7 @@ func TestGetVerifiedTaskFunc_GetFuncError(t *testing.T) { testcases := []struct { name string requester *test.Requester - taskrun v1beta1.TaskRun + taskrun v1.TaskRun expectedErr error }{ { diff --git a/pkg/reconciler/taskrun/resources/taskspec.go b/pkg/reconciler/taskrun/resources/taskspec.go index 3b5653f9ff8..fbe5baece64 100644 --- a/pkg/reconciler/taskrun/resources/taskspec.go +++ b/pkg/reconciler/taskrun/resources/taskspec.go @@ -21,7 +21,7 @@ import ( "errors" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" resolutionutil "github.com/tektoncd/pipeline/pkg/internal/resolution" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -30,23 +30,23 @@ import ( // the TaskRun. type ResolvedTask struct { TaskName string - Kind v1beta1.TaskKind - TaskSpec *v1beta1.TaskSpec + Kind v1.TaskKind + TaskSpec *v1.TaskSpec } // GetTask is a function used to retrieve Tasks. -type GetTask func(context.Context, string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) +type GetTask func(context.Context, string) (*v1.Task, *v1.ConfigSource, error) // GetTaskRun is a function used to retrieve TaskRuns -type GetTaskRun func(string) (*v1beta1.TaskRun, error) +type GetTaskRun func(string) (*v1.TaskRun, error) // GetTaskData will retrieve the Task metadata and Spec associated with the // provided TaskRun. This can come from a reference Task or from the TaskRun's // metadata and embedded TaskSpec. -func GetTaskData(ctx context.Context, taskRun *v1beta1.TaskRun, getTask GetTask) (*resolutionutil.ResolvedObjectMeta, *v1beta1.TaskSpec, error) { +func GetTaskData(ctx context.Context, taskRun *v1.TaskRun, getTask GetTask) (*resolutionutil.ResolvedObjectMeta, *v1.TaskSpec, error) { taskMeta := metav1.ObjectMeta{} - var configSource *v1beta1.ConfigSource - taskSpec := v1beta1.TaskSpec{} + var configSource *v1.ConfigSource + taskSpec := v1.TaskSpec{} switch { case taskRun.Spec.TaskRef != nil && taskRun.Spec.TaskRef.Name != "": // Get related task for taskrun @@ -54,8 +54,8 @@ func GetTaskData(ctx context.Context, taskRun *v1beta1.TaskRun, getTask GetTask) if err != nil { return nil, nil, fmt.Errorf("error when listing tasks for taskRun %s: %w", taskRun.Name, err) } - taskMeta = t.TaskMetadata() - taskSpec = t.TaskSpec() + taskMeta = t.ObjectMeta + taskSpec = t.Spec configSource = source case taskRun.Spec.TaskSpec != nil: taskMeta = taskRun.ObjectMeta @@ -70,8 +70,8 @@ func GetTaskData(ctx context.Context, taskRun *v1beta1.TaskRun, getTask GetTask) case task == nil: return nil, nil, errors.New("resolution of remote resource completed successfully but no task was returned") default: - taskMeta = task.TaskMetadata() - taskSpec = task.TaskSpec() + taskMeta = task.ObjectMeta + taskSpec = task.Spec } configSource = source default: diff --git a/pkg/reconciler/taskrun/resources/taskspec_test.go b/pkg/reconciler/taskrun/resources/taskspec_test.go index 0b4e22cd1f6..62648951eb5 100644 --- a/pkg/reconciler/taskrun/resources/taskspec_test.go +++ b/pkg/reconciler/taskrun/resources/taskspec_test.go @@ -22,13 +22,13 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/test/diff" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var ( - sampleConfigSource = &v1beta1.ConfigSource{ + sampleConfigSource = &v1.ConfigSource{ URI: "abc.com", Digest: map[string]string{ "sha1": "a123", @@ -38,28 +38,28 @@ var ( ) func TestGetTaskSpec_Ref(t *testing.T) { - task := &v1beta1.Task{ + task := &v1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "orchestrate", }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", }}, }, } - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{ + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{ Name: "orchestrate", }, }, } - gt := func(ctx context.Context, n string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + gt := func(ctx context.Context, n string) (*v1.Task, *v1.ConfigSource, error) { return task, sampleConfigSource.DeepCopy(), nil } resolvedObjectMeta, taskSpec, err := GetTaskData(context.Background(), tr, gt) @@ -81,19 +81,19 @@ func TestGetTaskSpec_Ref(t *testing.T) { } func TestGetTaskSpec_Embedded(t *testing.T) { - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", }}, }, }, } - gt := func(ctx context.Context, n string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + gt := func(ctx context.Context, n string) (*v1.Task, *v1.ConfigSource, error) { return nil, nil, errors.New("shouldn't be called") } resolvedObjectMeta, taskSpec, err := GetTaskData(context.Background(), tr, gt) @@ -117,12 +117,12 @@ func TestGetTaskSpec_Embedded(t *testing.T) { } func TestGetTaskSpec_Invalid(t *testing.T) { - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, } - gt := func(ctx context.Context, n string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + gt := func(ctx context.Context, n string) (*v1.Task, *v1.ConfigSource, error) { return nil, nil, errors.New("shouldn't be called") } _, _, err := GetTaskData(context.Background(), tr, gt) @@ -132,17 +132,17 @@ func TestGetTaskSpec_Invalid(t *testing.T) { } func TestGetTaskSpec_Error(t *testing.T) { - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{ + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{ Name: "orchestrate", }, }, } - gt := func(ctx context.Context, n string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + gt := func(ctx context.Context, n string) (*v1.Task, *v1.ConfigSource, error) { return nil, nil, errors.New("something went wrong") } _, _, err := GetTaskData(context.Background(), tr, gt) @@ -152,18 +152,18 @@ func TestGetTaskSpec_Error(t *testing.T) { } func TestGetTaskData_ResolutionSuccess(t *testing.T) { - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ Resolver: "foo", - Params: []v1beta1.Param{{ + Params: []v1.Param{{ Name: "bar", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeString, + Value: v1.ParamValue{ + Type: v1.ParamTypeString, StringVal: "baz", }, }}, @@ -174,16 +174,16 @@ func TestGetTaskData_ResolutionSuccess(t *testing.T) { sourceMeta := metav1.ObjectMeta{ Name: "task", } - sourceSpec := v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + sourceSpec := v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", Image: "ubuntu", Script: `echo "hello world!"`, }}, } - getTask := func(ctx context.Context, n string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { - return &v1beta1.Task{ + getTask := func(ctx context.Context, n string) (*v1.Task, *v1.ConfigSource, error) { + return &v1.Task{ ObjectMeta: *sourceMeta.DeepCopy(), Spec: *sourceSpec.DeepCopy(), }, sampleConfigSource.DeepCopy(), nil @@ -207,19 +207,19 @@ func TestGetTaskData_ResolutionSuccess(t *testing.T) { } func TestGetPipelineData_ResolutionError(t *testing.T) { - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", }, }, }, } - getTask := func(ctx context.Context, n string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + getTask := func(ctx context.Context, n string) (*v1.Task, *v1.ConfigSource, error) { return nil, nil, errors.New("something went wrong") } ctx := context.Background() @@ -230,19 +230,19 @@ func TestGetPipelineData_ResolutionError(t *testing.T) { } func TestGetTaskData_ResolvedNilTask(t *testing.T) { - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, - Spec: v1beta1.TaskRunSpec{ - TaskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ + Spec: v1.TaskRunSpec{ + TaskRef: &v1.TaskRef{ + ResolverRef: v1.ResolverRef{ Resolver: "git", }, }, }, } - getTask := func(ctx context.Context, n string) (v1beta1.TaskObject, *v1beta1.ConfigSource, error) { + getTask := func(ctx context.Context, n string) (*v1.Task, *v1.ConfigSource, error) { return nil, nil, nil } ctx := context.Background() diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index 27828cda433..fcae8b4261e 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -29,11 +29,11 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - taskrunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun" + taskrunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1/taskrun" + listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1" alphalisters "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" - listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/internal/affinityassistant" "github.com/tektoncd/pipeline/pkg/internal/computeresources" resolutionutil "github.com/tektoncd/pipeline/pkg/internal/resolution" @@ -98,7 +98,7 @@ var ( // ReconcileKind compares the actual state with the desired, and attempts to // converge the two. It then updates the Status block of the Task Run // resource with the current status of the resource. -func (c *Reconciler) ReconcileKind(ctx context.Context, tr *v1beta1.TaskRun) pkgreconciler.Event { +func (c *Reconciler) ReconcileKind(ctx context.Context, tr *v1.TaskRun) pkgreconciler.Event { logger := logging.FromContext(ctx) ctx = cloudevent.ToContext(ctx, c.cloudEventClient) ctx = initTracing(ctx, c.tracerProvider, tr) @@ -153,7 +153,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, tr *v1beta1.TaskRun) pkg // If the TaskRun is cancelled, kill resources and update status if tr.IsCancelled() { message := fmt.Sprintf("TaskRun %q was cancelled. %s", tr.Name, tr.Spec.StatusMessage) - err := c.failTaskRun(ctx, tr, v1beta1.TaskRunReasonCancelled, message) + err := c.failTaskRun(ctx, tr, v1.TaskRunReasonCancelled, message) return c.finishReconcileUpdateEmitEvents(ctx, tr, before, err) } @@ -161,7 +161,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, tr *v1beta1.TaskRun) pkg // accordingly. if tr.HasTimedOut(ctx, c.Clock) { message := fmt.Sprintf("TaskRun %q failed to finish within %q", tr.Name, tr.GetTimeout(ctx)) - err := c.failTaskRun(ctx, tr, v1beta1.TaskRunReasonTimedOut, message) + err := c.failTaskRun(ctx, tr, v1.TaskRunReasonTimedOut, message) return c.finishReconcileUpdateEmitEvents(ctx, tr, before, err) } @@ -193,7 +193,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, tr *v1beta1.TaskRun) pkg if errors.Is(err, sidecarlogresults.ErrSizeExceeded) { cfg := config.FromContextOrDefaults(ctx) message := fmt.Sprintf("TaskRun %q failed: results exceeded size limit %d bytes", tr.Name, cfg.FeatureFlags.MaxResultSize) - err := c.failTaskRun(ctx, tr, v1beta1.TaskRunReasonResultLargerThanAllowedLimit, message) + err := c.failTaskRun(ctx, tr, v1.TaskRunReasonResultLargerThanAllowedLimit, message) return c.finishReconcileUpdateEmitEvents(ctx, tr, before, err) } } @@ -212,25 +212,25 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, tr *v1beta1.TaskRun) pkg return nil } -func (c *Reconciler) checkPodFailed(tr *v1beta1.TaskRun) (bool, v1beta1.TaskRunReason, string) { +func (c *Reconciler) checkPodFailed(tr *v1.TaskRun) (bool, v1.TaskRunReason, string) { for _, step := range tr.Status.Steps { if step.Waiting != nil && step.Waiting.Reason == "ImagePullBackOff" { image := step.ImageID message := fmt.Sprintf(`The step %q in TaskRun %q failed to pull the image %q. The pod errored with the message: "%s."`, step.Name, tr.Name, image, step.Waiting.Message) - return true, v1beta1.TaskRunReasonImagePullFailed, message + return true, v1.TaskRunReasonImagePullFailed, message } } for _, sidecar := range tr.Status.Sidecars { if sidecar.Waiting != nil && sidecar.Waiting.Reason == "ImagePullBackOff" { image := sidecar.ImageID message := fmt.Sprintf(`The sidecar %q in TaskRun %q failed to pull the image %q. The pod errored with the message: "%s."`, sidecar.Name, tr.Name, image, sidecar.Waiting.Message) - return true, v1beta1.TaskRunReasonImagePullFailed, message + return true, v1.TaskRunReasonImagePullFailed, message } } return false, "", "" } -func (c *Reconciler) durationAndCountMetrics(ctx context.Context, tr *v1beta1.TaskRun, beforeCondition *apis.Condition) { +func (c *Reconciler) durationAndCountMetrics(ctx context.Context, tr *v1.TaskRun, beforeCondition *apis.Condition) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "durationAndCountMetrics") defer span.End() logger := logging.FromContext(ctx) @@ -244,7 +244,7 @@ func (c *Reconciler) durationAndCountMetrics(ctx context.Context, tr *v1beta1.Ta } } -func (c *Reconciler) stopSidecars(ctx context.Context, tr *v1beta1.TaskRun) error { +func (c *Reconciler) stopSidecars(ctx context.Context, tr *v1.TaskRun) error { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "stopSidecars") defer span.End() logger := logging.FromContext(ctx) @@ -256,8 +256,8 @@ func (c *Reconciler) stopSidecars(ctx context.Context, tr *v1beta1.TaskRun) erro // do not continue if the TaskRun was canceled or timed out as this caused the pod to be deleted in failTaskRun condition := tr.Status.GetCondition(apis.ConditionSucceeded) if condition != nil { - reason := v1beta1.TaskRunReason(condition.Reason) - if reason == v1beta1.TaskRunReasonCancelled || reason == v1beta1.TaskRunReasonTimedOut { + reason := v1.TaskRunReason(condition.Reason) + if reason == v1.TaskRunReasonCancelled || reason == v1.TaskRunReasonTimedOut { return nil } } @@ -276,12 +276,12 @@ func (c *Reconciler) stopSidecars(ctx context.Context, tr *v1beta1.TaskRun) erro return controller.NewPermanentError(err) } else if err != nil { logger.Errorf("Error stopping sidecars for TaskRun %q: %v", tr.Name, err) - tr.Status.MarkResourceFailed(v1beta1.TaskRunReasonStopSidecarFailed, err) + tr.Status.MarkResourceFailed(v1.TaskRunReasonStopSidecarFailed, err) } return nil } -func (c *Reconciler) finishReconcileUpdateEmitEvents(ctx context.Context, tr *v1beta1.TaskRun, beforeCondition *apis.Condition, previousError error) error { +func (c *Reconciler) finishReconcileUpdateEmitEvents(ctx context.Context, tr *v1.TaskRun, beforeCondition *apis.Condition, previousError error) error { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "finishReconcileUpdateEmitEvents") defer span.End() logger := logging.FromContext(ctx) @@ -315,7 +315,7 @@ func (c *Reconciler) finishReconcileUpdateEmitEvents(ctx context.Context, tr *v1 // `prepare` returns spec and resources. In future we might store // them in the TaskRun.Status so we don't need to re-run `prepare` at every // reconcile (see https://github.com/tektoncd/pipeline/issues/2473). -func (c *Reconciler) prepare(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1.TaskSpec, *resources.ResolvedTask, error) { +func (c *Reconciler) prepare(ctx context.Context, tr *v1.TaskRun) (*v1.TaskSpec, *resources.ResolvedTask, error) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "prepare") defer span.End() logger := logging.FromContext(ctx) @@ -332,7 +332,7 @@ func (c *Reconciler) prepare(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1 switch { case errors.Is(err, remote.ErrRequestInProgress): message := fmt.Sprintf("TaskRun %s/%s awaiting remote resource", tr.Namespace, tr.Name) - tr.Status.MarkResourceOngoing(v1beta1.TaskRunReasonResolvingTaskRef, message) + tr.Status.MarkResourceOngoing(v1.TaskRunReasonResolvingTaskRef, message) return nil, nil, err case errors.Is(err, trustedresources.ErrResourceVerificationFailed): logger.Errorf("TaskRun %s/%s referred task failed signature verification", tr.Namespace, tr.Name) @@ -364,7 +364,7 @@ func (c *Reconciler) prepare(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1 return nil, nil, controller.NewPermanentError(err) } - if err := ValidateResolvedTask(ctx, tr.Spec.Params, &v1beta1.Matrix{}, rtr); err != nil { + if err := ValidateResolvedTask(ctx, tr.Spec.Params, &v1.Matrix{}, rtr); err != nil { logger.Errorf("TaskRun %q resources are invalid: %v", tr.Name, err) tr.Status.MarkResourceFailed(podconvert.ReasonFailedValidation, err) return nil, nil, controller.NewPermanentError(err) @@ -382,7 +382,7 @@ func (c *Reconciler) prepare(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1 return nil, nil, controller.NewPermanentError(err) } - var workspaceDeclarations []v1beta1.WorkspaceDeclaration + var workspaceDeclarations []v1.WorkspaceDeclaration // Propagating workspaces allows users to skip declarations // In order to validate the workspace bindings we create declarations based on // the workspaces provided in the task run spec. This logic is hidden behind the @@ -390,7 +390,7 @@ func (c *Reconciler) prepare(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1 // In addition, we only allow this feature for embedded taskSpec. if config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields != config.StableAPIFields && tr.Spec.TaskSpec != nil { for _, ws := range tr.Spec.Workspaces { - wspaceDeclaration := v1beta1.WorkspaceDeclaration{Name: ws.Name} + wspaceDeclaration := v1.WorkspaceDeclaration{Name: ws.Name} workspaceDeclarations = append(workspaceDeclarations, wspaceDeclaration) } workspaceDeclarations = append(workspaceDeclarations, taskSpec.Workspaces...) @@ -425,7 +425,7 @@ func (c *Reconciler) prepare(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1 // It reports errors back to Reconcile, it updates the taskrun status in case of // error but it does not sync updates back to etcd. It does not emit events. // `reconcile` consumes spec and resources returned by `prepare` -func (c *Reconciler) reconcile(ctx context.Context, tr *v1beta1.TaskRun, rtr *resources.ResolvedTask) error { +func (c *Reconciler) reconcile(ctx context.Context, tr *v1.TaskRun, rtr *resources.ResolvedTask) error { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "reconcile") defer span.End() @@ -533,20 +533,20 @@ func (c *Reconciler) reconcile(ctx context.Context, tr *v1beta1.TaskRun, rtr *re return nil } -func (c *Reconciler) updateTaskRunWithDefaultWorkspaces(ctx context.Context, tr *v1beta1.TaskRun, taskSpec *v1beta1.TaskSpec) error { +func (c *Reconciler) updateTaskRunWithDefaultWorkspaces(ctx context.Context, tr *v1.TaskRun, taskSpec *v1.TaskSpec) error { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "updateTaskRunWithDefaultWorkspaces") defer span.End() configMap := config.FromContextOrDefaults(ctx) defaults := configMap.Defaults if defaults.DefaultTaskRunWorkspaceBinding != "" { - var defaultWS v1beta1.WorkspaceBinding + var defaultWS v1.WorkspaceBinding if err := yaml.Unmarshal([]byte(defaults.DefaultTaskRunWorkspaceBinding), &defaultWS); err != nil { return fmt.Errorf("failed to unmarshal %v", defaults.DefaultTaskRunWorkspaceBinding) } - workspaceBindings := map[string]v1beta1.WorkspaceBinding{} + workspaceBindings := map[string]v1.WorkspaceBinding{} for _, tsWorkspace := range taskSpec.Workspaces { if !tsWorkspace.Optional { - workspaceBindings[tsWorkspace.Name] = v1beta1.WorkspaceBinding{ + workspaceBindings[tsWorkspace.Name] = v1.WorkspaceBinding{ Name: tsWorkspace.Name, SubPath: defaultWS.SubPath, VolumeClaimTemplate: defaultWS.VolumeClaimTemplate, @@ -562,7 +562,7 @@ func (c *Reconciler) updateTaskRunWithDefaultWorkspaces(ctx context.Context, tr workspaceBindings[trWorkspace.Name] = trWorkspace } - tr.Spec.Workspaces = []v1beta1.WorkspaceBinding{} + tr.Spec.Workspaces = []v1.WorkspaceBinding{} for _, wsBinding := range workspaceBindings { tr.Spec.Workspaces = append(tr.Spec.Workspaces, wsBinding) } @@ -570,7 +570,7 @@ func (c *Reconciler) updateTaskRunWithDefaultWorkspaces(ctx context.Context, tr return nil } -func (c *Reconciler) updateLabelsAndAnnotations(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1.TaskRun, error) { +func (c *Reconciler) updateLabelsAndAnnotations(ctx context.Context, tr *v1.TaskRun) (*v1.TaskRun, error) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "updateLabelsAndAnnotations") defer span.End() // Ensure the TaskRun is properly decorated with the version of the Tekton controller processing it. @@ -590,12 +590,12 @@ func (c *Reconciler) updateLabelsAndAnnotations(ctx context.Context, tr *v1beta1 newTr = newTr.DeepCopy() newTr.Labels = kmap.Union(newTr.Labels, tr.Labels) newTr.Annotations = kmap.Union(kmap.ExcludeKeys(newTr.Annotations, tknreconciler.KubectlLastAppliedAnnotationKey), tr.Annotations) - return c.PipelineClientSet.TektonV1beta1().TaskRuns(tr.Namespace).Update(ctx, newTr, metav1.UpdateOptions{}) + return c.PipelineClientSet.TektonV1().TaskRuns(tr.Namespace).Update(ctx, newTr, metav1.UpdateOptions{}) } return newTr, nil } -func (c *Reconciler) handlePodCreationError(tr *v1beta1.TaskRun, err error) error { +func (c *Reconciler) handlePodCreationError(tr *v1.TaskRun, err error) error { switch { case isResourceQuotaConflictError(err): // Requeue if it runs into ResourceQuotaConflictError Error i.e https://github.com/kubernetes/kubernetes/issues/67761 @@ -633,7 +633,7 @@ func (c *Reconciler) handlePodCreationError(tr *v1beta1.TaskRun, err error) erro // If a pod is associated to the TaskRun, it stops it // failTaskRun function may return an error in case the pod could not be deleted // failTaskRun may update the local TaskRun status, but it won't push the updates to etcd -func (c *Reconciler) failTaskRun(ctx context.Context, tr *v1beta1.TaskRun, reason v1beta1.TaskRunReason, message string) error { +func (c *Reconciler) failTaskRun(ctx context.Context, tr *v1.TaskRun, reason v1.TaskRunReason, message string) error { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "failTaskRun") defer span.End() logger := logging.FromContext(ctx) @@ -689,7 +689,7 @@ func (c *Reconciler) failTaskRun(ctx context.Context, tr *v1beta1.TaskRun, reaso // createPod creates a Pod based on the Task's configuration, with pvcName as a volumeMount // TODO(dibyom): Refactor resource setup/substitution logic to its own function in the resources package -func (c *Reconciler) createPod(ctx context.Context, ts *v1beta1.TaskSpec, tr *v1beta1.TaskRun, rtr *resources.ResolvedTask, workspaceVolumes map[string]corev1.Volume) (*corev1.Pod, error) { +func (c *Reconciler) createPod(ctx context.Context, ts *v1.TaskSpec, tr *v1.TaskRun, rtr *resources.ResolvedTask, workspaceVolumes map[string]corev1.Volume) (*corev1.Pod, error) { ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createPod") defer span.End() logger := logging.FromContext(ctx) @@ -748,9 +748,9 @@ func (c *Reconciler) createPod(ctx context.Context, ts *v1beta1.TaskSpec, tr *v1 } // applyParamsContextsResultsAndWorkspaces applies paramater, context, results and workspace substitutions to the TaskSpec. -func applyParamsContextsResultsAndWorkspaces(ctx context.Context, tr *v1beta1.TaskRun, rtr *resources.ResolvedTask, workspaceVolumes map[string]corev1.Volume) (*v1beta1.TaskSpec, error) { +func applyParamsContextsResultsAndWorkspaces(ctx context.Context, tr *v1.TaskRun, rtr *resources.ResolvedTask, workspaceVolumes map[string]corev1.Volume) (*v1.TaskSpec, error) { ts := rtr.TaskSpec.DeepCopy() - var defaults []v1beta1.ParamSpec + var defaults []v1.ParamSpec if len(ts.Params) > 0 { defaults = append(defaults, ts.Params...) } @@ -783,7 +783,7 @@ func applyParamsContextsResultsAndWorkspaces(ctx context.Context, tr *v1beta1.Ta } } if !skip { - ts.Workspaces = append(ts.Workspaces, v1beta1.WorkspaceDeclaration{Name: trw.Name}) + ts.Workspaces = append(ts.Workspaces, v1.WorkspaceDeclaration{Name: trw.Name}) } } } @@ -807,8 +807,8 @@ func isPodAdmissionFailed(err error) bool { // updateStoppedSidecarStatus updates SidecarStatus for sidecars that were // terminated by nop image -func updateStoppedSidecarStatus(pod *corev1.Pod, tr *v1beta1.TaskRun) error { - tr.Status.Sidecars = []v1beta1.SidecarState{} +func updateStoppedSidecarStatus(pod *corev1.Pod, tr *v1.TaskRun) error { + tr.Status.Sidecars = []v1.SidecarState{} for _, s := range pod.Status.ContainerStatuses { if !podconvert.IsContainerStep(s.Name) { var sidecarState corev1.ContainerState @@ -830,10 +830,10 @@ func updateStoppedSidecarStatus(pod *corev1.Pod, tr *v1beta1.TaskRun) error { sidecarState = s.State } - tr.Status.Sidecars = append(tr.Status.Sidecars, v1beta1.SidecarState{ + tr.Status.Sidecars = append(tr.Status.Sidecars, v1.SidecarState{ ContainerState: *sidecarState.DeepCopy(), Name: podconvert.TrimSidecarPrefix(s.Name), - ContainerName: s.Name, + Container: s.Name, ImageID: s.ImageID, }) } @@ -842,8 +842,8 @@ func updateStoppedSidecarStatus(pod *corev1.Pod, tr *v1beta1.TaskRun) error { } // applyVolumeClaimTemplates and return WorkspaceBindings were templates is translated to PersistentVolumeClaims -func applyVolumeClaimTemplates(workspaceBindings []v1beta1.WorkspaceBinding, owner metav1.OwnerReference) []v1beta1.WorkspaceBinding { - taskRunWorkspaceBindings := make([]v1beta1.WorkspaceBinding, 0, len(workspaceBindings)) +func applyVolumeClaimTemplates(workspaceBindings []v1.WorkspaceBinding, owner metav1.OwnerReference) []v1.WorkspaceBinding { + taskRunWorkspaceBindings := make([]v1.WorkspaceBinding, 0, len(workspaceBindings)) for _, wb := range workspaceBindings { if wb.VolumeClaimTemplate == nil { taskRunWorkspaceBindings = append(taskRunWorkspaceBindings, wb) @@ -851,7 +851,7 @@ func applyVolumeClaimTemplates(workspaceBindings []v1beta1.WorkspaceBinding, own } // apply template - b := v1beta1.WorkspaceBinding{ + b := v1.WorkspaceBinding{ Name: wb.Name, SubPath: wb.SubPath, PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ @@ -863,7 +863,7 @@ func applyVolumeClaimTemplates(workspaceBindings []v1beta1.WorkspaceBinding, own return taskRunWorkspaceBindings } -func storeTaskSpecAndMergeMeta(ctx context.Context, tr *v1beta1.TaskRun, ts *v1beta1.TaskSpec, meta *resolutionutil.ResolvedObjectMeta) error { +func storeTaskSpecAndMergeMeta(ctx context.Context, tr *v1.TaskRun, ts *v1.TaskSpec, meta *resolutionutil.ResolvedObjectMeta) error { // Only store the TaskSpec once, if it has never been set before. if tr.Status.TaskSpec == nil { tr.Status.TaskSpec = ts @@ -887,7 +887,7 @@ func storeTaskSpecAndMergeMeta(ctx context.Context, tr *v1beta1.TaskRun, ts *v1b cfg := config.FromContextOrDefaults(ctx) if cfg.FeatureFlags.EnableProvenanceInStatus { if tr.Status.Provenance == nil { - tr.Status.Provenance = &v1beta1.Provenance{} + tr.Status.Provenance = &v1.Provenance{} } // Store FeatureFlags in the Provenance. tr.Status.Provenance.FeatureFlags = cfg.FeatureFlags @@ -903,7 +903,7 @@ func storeTaskSpecAndMergeMeta(ctx context.Context, tr *v1beta1.TaskRun, ts *v1b // willOverwritePodSetAffinity returns a bool indicating whether the // affinity for pods will be overwritten with affinity assistant. -func willOverwritePodSetAffinity(taskRun *v1beta1.TaskRun) bool { +func willOverwritePodSetAffinity(taskRun *v1.TaskRun) bool { var podTemplate pod.Template if taskRun.Spec.PodTemplate != nil { podTemplate = *taskRun.Spec.PodTemplate @@ -926,8 +926,8 @@ func isResourceQuotaConflictError(err error) bool { } // retryTaskRun archives taskRun.Status to taskRun.Status.RetriesStatus, and set -// taskRun status to Unknown with Reason v1beta1.TaskRunReasonToBeRetried. -func retryTaskRun(tr *v1beta1.TaskRun, message string) { +// taskRun status to Unknown with Reason v1.TaskRunReasonToBeRetried. +func retryTaskRun(tr *v1.TaskRun, message string) { newStatus := tr.Status.DeepCopy() newStatus.RetriesStatus = nil tr.Status.RetriesStatus = append(tr.Status.RetriesStatus, *newStatus) @@ -935,5 +935,5 @@ func retryTaskRun(tr *v1beta1.TaskRun, message string) { tr.Status.CompletionTime = nil tr.Status.PodName = "" taskRunCondSet := apis.NewBatchConditionSet() - taskRunCondSet.Manage(&tr.Status).MarkUnknown(apis.ConditionSucceeded, v1beta1.TaskRunReasonToBeRetried.String(), message) + taskRunCondSet.Manage(&tr.Status).MarkUnknown(apis.ConditionSucceeded, v1.TaskRunReasonToBeRetried.String(), message) } diff --git a/pkg/reconciler/taskrun/taskrun_test.go b/pkg/reconciler/taskrun/taskrun_test.go index bc71a4c2fb2..0e0da65a816 100644 --- a/pkg/reconciler/taskrun/taskrun_test.go +++ b/pkg/reconciler/taskrun/taskrun_test.go @@ -36,6 +36,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resolutionutil "github.com/tektoncd/pipeline/pkg/internal/resolution" podconvert "github.com/tektoncd/pipeline/pkg/pod" @@ -53,7 +54,6 @@ import ( "github.com/tektoncd/pipeline/test/parse" "go.opentelemetry.io/otel/trace" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" k8sapierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -77,7 +77,7 @@ import ( const ( entrypointLocation = "/tekton/bin/entrypoint" workspaceDir = "/workspace" - currentAPIVersion = "tekton.dev/v1beta1" + currentAPIVersion = "tekton.dev/v1" ) var ( @@ -96,11 +96,11 @@ var ( }, cmp.Comparer(func(name1, name2 string) bool { return name1[:len(name1)-5] == name2[:len(name2)-5] })) - ignoreStartTime = cmpopts.IgnoreFields(v1beta1.TaskRunStatusFields{}, "StartTime") - ignoreCompletionTime = cmpopts.IgnoreFields(v1beta1.TaskRunStatusFields{}, "CompletionTime") + ignoreStartTime = cmpopts.IgnoreFields(v1.TaskRunStatusFields{}, "StartTime") + ignoreCompletionTime = cmpopts.IgnoreFields(v1.TaskRunStatusFields{}, "CompletionTime") ignoreObjectMeta = cmpopts.IgnoreFields(metav1.ObjectMeta{}, "Labels", "ResourceVersion", "Annotations") - ignoreStatusTaskSpec = cmpopts.IgnoreFields(v1beta1.TaskRunStatusFields{}, "TaskSpec") - ignoreTaskRunStatusFields = cmpopts.IgnoreFields(v1beta1.TaskRunStatusFields{}, "Steps", "Sidecars") + ignoreStatusTaskSpec = cmpopts.IgnoreFields(v1.TaskRunStatusFields{}, "TaskSpec") + ignoreTaskRunStatusFields = cmpopts.IgnoreFields(v1.TaskRunStatusFields{}, "Steps", "Sidecars") resourceQuantityCmp = cmp.Comparer(func(x, y resource.Quantity) bool { return x.Cmp(y) == 0 @@ -110,38 +110,38 @@ var ( volumeSort = cmpopts.SortSlices(func(i, j corev1.Volume) bool { return i.Name < j.Name }) volumeMountSort = cmpopts.SortSlices(func(i, j corev1.VolumeMount) bool { return i.Name < j.Name }) - simpleStep = v1beta1.Step{ + simpleStep = v1.Step{ Name: "simple-step", Image: "foo", Command: []string{"/mycmd"}, } - simpleTask = &v1beta1.Task{ + simpleTask = &v1.Task{ ObjectMeta: objectMeta("test-task", "foo"), - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{simpleStep}, + Spec: v1.TaskSpec{ + Steps: []v1.Step{simpleStep}, }, } - simpleTypedTask = &v1beta1.Task{ + simpleTypedTask = &v1.Task{ ObjectMeta: objectMeta("test-task", "foo"), TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task", }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{simpleStep}, + Spec: v1.TaskSpec{ + Steps: []v1.Step{simpleStep}, }, } - resultsTask = &v1beta1.Task{ + resultsTask = &v1.Task{ ObjectMeta: objectMeta("test-results-task", "foo"), - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{simpleStep}, - Results: []v1beta1.TaskResult{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{simpleStep}, + Results: []v1.TaskResult{{ Name: "aResult", - Type: v1beta1.ResultsTypeArray, + Type: v1.ResultsTypeArray, }, { Name: "objectResult", - Type: v1beta1.ResultsTypeObject, - Properties: map[string]v1beta1.PropertySpec{"url": {Type: "string"}, "commit": {Type: "string"}}, + Type: v1.ResultsTypeObject, + Properties: map[string]v1.PropertySpec{"url": {Type: "string"}, "commit": {Type: "string"}}, }, }, }, @@ -150,22 +150,27 @@ var ( clustertask = &v1beta1.ClusterTask{ ObjectMeta: metav1.ObjectMeta{Name: "test-cluster-task"}, Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{simpleStep}, + Steps: []v1beta1.Step{ + v1beta1.Step{ + Name: "simple-step", + Image: "foo", + Command: []string{"/mycmd"}, + }}, }, } - taskSidecar = &v1beta1.Task{ + taskSidecar = &v1.Task{ ObjectMeta: objectMeta("test-task-sidecar", "foo"), - Spec: v1beta1.TaskSpec{ - Sidecars: []v1beta1.Sidecar{{ + Spec: v1.TaskSpec{ + Sidecars: []v1.Sidecar{{ Name: "sidecar", Image: "image-id", }}, }, } - taskMultipleSidecars = &v1beta1.Task{ + taskMultipleSidecars = &v1.Task{ ObjectMeta: objectMeta("test-task-sidecar", "foo"), - Spec: v1beta1.TaskSpec{ - Sidecars: []v1beta1.Sidecar{ + Spec: v1.TaskSpec{ + Sidecars: []v1.Sidecar{ { Name: "sidecar", Image: "image-id", @@ -178,10 +183,10 @@ var ( }, } - saTask = &v1beta1.Task{ + saTask = &v1.Task{ ObjectMeta: objectMeta("test-with-sa", "foo"), - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "sa-step", Image: "foo", Command: []string{"/mycmd"}, @@ -189,30 +194,30 @@ var ( }, } - templatedTask = &v1beta1.Task{ + templatedTask = &v1.Task{ ObjectMeta: objectMeta("test-task-with-substitution", "foo"), - Spec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{ + Spec: v1.TaskSpec{ + Params: []v1.ParamSpec{ { Name: "myarg", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, { Name: "myarghasdefault", - Type: v1beta1.ParamTypeString, - Default: v1beta1.NewStructuredValues("dont see me"), + Type: v1.ParamTypeString, + Default: v1.NewStructuredValues("dont see me"), }, { Name: "myarghasdefault2", - Type: v1beta1.ParamTypeString, - Default: v1beta1.NewStructuredValues("thedefault"), + Type: v1.ParamTypeString, + Default: v1.NewStructuredValues("thedefault"), }, { Name: "configmapname", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, }, - Steps: []v1beta1.Step{ + Steps: []v1.Step{ { Image: "myimage", Name: "mycontainer", @@ -340,7 +345,7 @@ func init() { os.Setenv("KO_DATA_PATH", "./testdata/") } -func getRunName(tr *v1beta1.TaskRun) string { +func getRunName(tr *v1.TaskRun) string { return strings.Join([]string{tr.Namespace, tr.Name}, "/") } @@ -380,7 +385,7 @@ func initializeTaskRunControllerAssets(t *testing.T, d test.Data, opts pipeline. } func TestReconcile_ExplicitDefaultSA(t *testing.T) { - taskRunSuccess := parse.MustParseV1beta1TaskRun(t, ` + taskRunSuccess := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-success namespace: foo @@ -389,7 +394,7 @@ spec: apiVersion: a1 name: test-task `) - taskRunWithSaSuccess := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithSaSuccess := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-with-sa-run-success namespace: foo @@ -399,11 +404,11 @@ spec: apiVersion: a1 name: test-with-sa `) - taskruns := []*v1beta1.TaskRun{taskRunSuccess, taskRunWithSaSuccess} + taskruns := []*v1.TaskRun{taskRunSuccess, taskRunWithSaSuccess} defaultSAName := "pipelines" d := test.Data{ TaskRuns: taskruns, - Tasks: []*v1beta1.Task{simpleTask, saTask}, + Tasks: []*v1.Task{simpleTask, saTask}, ConfigMaps: []*corev1.ConfigMap{ { ObjectMeta: metav1.ObjectMeta{Name: config.GetDefaultsConfigName(), Namespace: system.Namespace()}, @@ -417,7 +422,7 @@ spec: } for _, tc := range []struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun wantPod *corev1.Pod }{{ name: "success", @@ -461,7 +466,7 @@ spec: t.Errorf("Expected actions to be logged in the kubeclient, got none") } - tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -469,8 +474,8 @@ spec: if condition == nil || condition.Status != corev1.ConditionUnknown { t.Errorf("Expected invalid TaskRun to have in progress status, but had %v", condition) } - if condition != nil && condition.Reason != v1beta1.TaskRunReasonRunning.String() { - t.Errorf("Expected reason %q but was %s", v1beta1.TaskRunReasonRunning.String(), condition.Reason) + if condition != nil && condition.Reason != v1.TaskRunReasonRunning.String() { + t.Errorf("Expected reason %q but was %s", v1.TaskRunReasonRunning.String(), condition.Reason) } if tr.Status.PodName == "" { @@ -499,7 +504,7 @@ spec: // TestReconcile_CloudEvents runs reconcile with a cloud event sink configured // to ensure that events are sent in different cases func TestReconcile_CloudEvents(t *testing.T) { - task := parse.MustParseV1beta1Task(t, ` + task := parse.MustParseV1Task(t, ` metadata: name: test-task namespace: foo @@ -513,7 +518,7 @@ spec: image: foo name: simple-step `) - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-not-started namespace: foo @@ -523,8 +528,8 @@ spec: name: test-task `) d := test.Data{ - Tasks: []*v1beta1.Task{task}, - TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1.Task{task}, + TaskRuns: []*v1.TaskRun{taskRun}, } d.ConfigMaps = []*corev1.ConfigMap{ @@ -566,7 +571,7 @@ spec: t.Errorf("Expected actions to be logged in the kubeclient, got none") } - tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -574,8 +579,8 @@ spec: if condition == nil || condition.Status != corev1.ConditionUnknown { t.Errorf("Expected fresh TaskRun to have in progress status, but had %v", condition) } - if condition != nil && condition.Reason != v1beta1.TaskRunReasonRunning.String() { - t.Errorf("Expected reason %q but was %s", v1beta1.TaskRunReasonRunning.String(), condition.Reason) + if condition != nil && condition.Reason != v1.TaskRunReasonRunning.String() { + t.Errorf("Expected reason %q but was %s", v1.TaskRunReasonRunning.String(), condition.Reason) } err = k8sevent.CheckEventsOrdered(t, testAssets.Recorder.Events, "reconcile-cloud-events", wantEvents) @@ -592,7 +597,7 @@ spec: } func TestReconcile(t *testing.T) { - taskRunSuccess := parse.MustParseV1beta1TaskRun(t, ` + taskRunSuccess := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-success namespace: foo @@ -601,7 +606,7 @@ spec: apiVersion: a1 name: test-task `) - taskRunWithSaSuccess := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithSaSuccess := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-with-sa-run-success namespace: foo @@ -611,7 +616,7 @@ spec: apiVersion: a1 name: test-with-sa `) - taskRunSubstitution := parse.MustParseV1beta1TaskRun(t, ` + taskRunSubstitution := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-substitution namespace: foo @@ -627,7 +632,7 @@ spec: apiVersion: a1 name: test-task-with-substitution `) - taskRunWithTaskSpec := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithTaskSpec := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-with-taskspec namespace: foo @@ -648,7 +653,7 @@ spec: name: mycontainer `) - taskRunWithClusterTask := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithClusterTask := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-with-cluster-task namespace: foo @@ -658,7 +663,7 @@ spec: name: test-cluster-task `) - taskRunWithLabels := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithLabels := parse.MustParseV1TaskRun(t, ` metadata: labels: TaskRunLabel: TaskRunValue @@ -670,7 +675,7 @@ spec: name: test-task `) - taskRunWithAnnotations := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithAnnotations := parse.MustParseV1TaskRun(t, ` metadata: annotations: TaskRunAnnotation: TaskRunValue @@ -681,7 +686,7 @@ spec: name: test-task `) - taskRunWithPod := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithPod := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-with-pod namespace: foo @@ -692,7 +697,7 @@ status: podName: some-pod-abcdethat-no-longer-exists `) - taskRunWithCredentialsVariable := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithCredentialsVariable := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-with-credentials-variable namespace: foo @@ -719,7 +724,7 @@ spec: t.Fatalf("failed to upload image with simple task: %s", err.Error()) } - taskRunBundle := parse.MustParseV1beta1TaskRun(t, fmt.Sprintf(` + taskRunBundle := parse.MustParseV1TaskRun(t, fmt.Sprintf(` metadata: name: test-taskrun-bundle namespace: foo @@ -729,7 +734,7 @@ spec: name: test-task `, ref)) - taskruns := []*v1beta1.TaskRun{ + taskruns := []*v1.TaskRun{ taskRunSuccess, taskRunWithSaSuccess, taskRunSubstitution, taskRunWithTaskSpec, taskRunWithClusterTask, taskRunWithLabels, taskRunWithAnnotations, taskRunWithPod, @@ -738,12 +743,12 @@ spec: d := test.Data{ TaskRuns: taskruns, - Tasks: []*v1beta1.Task{simpleTask, saTask, templatedTask}, + Tasks: []*v1.Task{simpleTask, saTask, templatedTask}, ClusterTasks: []*v1beta1.ClusterTask{clustertask}, } for _, tc := range []struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun wantPod *corev1.Pod wantEvents []string }{{ @@ -886,7 +891,7 @@ spec: t.Errorf("Expected actions to be logged in the kubeclient, got none") } - tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -894,8 +899,8 @@ spec: if condition == nil || condition.Status != corev1.ConditionUnknown { t.Errorf("Expected invalid TaskRun to have in progress status, but had %v", condition) } - if condition != nil && condition.Reason != v1beta1.TaskRunReasonRunning.String() { - t.Errorf("Expected reason %q but was %s", v1beta1.TaskRunReasonRunning.String(), condition.Reason) + if condition != nil && condition.Reason != v1.TaskRunReasonRunning.String() { + t.Errorf("Expected reason %q but was %s", v1.TaskRunReasonRunning.String(), condition.Reason) } if tr.Status.PodName == "" { @@ -929,7 +934,7 @@ spec: func TestAlphaReconcile(t *testing.T) { names.TestingSeed() - taskRunWithOutputConfig := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithOutputConfig := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-with-output-config namespace: foo @@ -944,7 +949,7 @@ spec: path: stdout.txt `) - taskRunWithOutputConfigAndWorkspace := parse.MustParseV1beta1TaskRun(t, ` + taskRunWithOutputConfigAndWorkspace := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-with-output-config-ws namespace: foo @@ -964,7 +969,7 @@ spec: path: stdout.txt `) - taskruns := []*v1beta1.TaskRun{ + taskruns := []*v1.TaskRun{ taskRunWithOutputConfig, taskRunWithOutputConfigAndWorkspace, } @@ -977,12 +982,12 @@ spec: d := test.Data{ ConfigMaps: cms, TaskRuns: taskruns, - Tasks: []*v1beta1.Task{simpleTask, saTask, templatedTask}, + Tasks: []*v1.Task{simpleTask, saTask, templatedTask}, ClusterTasks: []*v1beta1.ClusterTask{clustertask}, } for _, tc := range []struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun wantPod *corev1.Pod wantEvents []string }{{ @@ -1040,7 +1045,7 @@ spec: t.Errorf("Expected actions to be logged in the kubeclient, got none") } - tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -1048,8 +1053,8 @@ spec: if condition == nil || condition.Status != corev1.ConditionUnknown { t.Errorf("Expected invalid TaskRun to have in progress status, but had %v", condition) } - if condition != nil && condition.Reason != v1beta1.TaskRunReasonRunning.String() { - t.Errorf("Expected reason %q but was %s", v1beta1.TaskRunReasonRunning.String(), condition.Reason) + if condition != nil && condition.Reason != v1.TaskRunReasonRunning.String() { + t.Errorf("Expected reason %q but was %s", v1.TaskRunReasonRunning.String(), condition.Reason) } if tr.Status.PodName == "" { @@ -1093,7 +1098,7 @@ func addVolumeMounts(p *corev1.Pod, vms []corev1.VolumeMount) *corev1.Pod { // that when the request is successfully resolved the TaskRun begins running. func TestReconcileWithResolver(t *testing.T) { resolverName := "foobar" - tr := parse.MustParseV1beta1TaskRun(t, ` + tr := parse.MustParseV1TaskRun(t, ` metadata: name: tr namespace: default @@ -1104,7 +1109,7 @@ spec: `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{tr}, + TaskRuns: []*v1.TaskRun{tr}, ServiceAccounts: []*corev1.ServiceAccount{{ ObjectMeta: metav1.ObjectMeta{Name: tr.Spec.ServiceAccountName, Namespace: "foo"}, }}, @@ -1149,7 +1154,7 @@ spec: // Mock a successful resolution var taskBytes = []byte(` kind: Task - apiVersion: tekton.dev/v1beta1 + apiVersion: tekton.dev/v1 metadata: name: foo spec: @@ -1175,7 +1180,7 @@ spec: } } - updatedTR, err := clients.Pipeline.TektonV1beta1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) + updatedTR, err := clients.Pipeline.TektonV1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -1183,8 +1188,8 @@ spec: if condition == nil || condition.Status != corev1.ConditionUnknown { t.Errorf("Expected fresh TaskRun to have in progress status, but had %v", condition) } - if condition != nil && condition.Reason != v1beta1.TaskRunReasonRunning.String() { - t.Errorf("Expected reason %q but was %s", v1beta1.TaskRunReasonRunning.String(), condition.Reason) + if condition != nil && condition.Reason != v1.TaskRunReasonRunning.String() { + t.Errorf("Expected reason %q but was %s", v1.TaskRunReasonRunning.String(), condition.Reason) } } @@ -1193,7 +1198,7 @@ spec: // that when the request fails, the TaskRun fails. func TestReconcileWithFailingResolver(t *testing.T) { resolverName := "foobar" - tr := parse.MustParseV1beta1TaskRun(t, ` + tr := parse.MustParseV1TaskRun(t, ` metadata: name: tr namespace: default @@ -1204,7 +1209,7 @@ spec: `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{tr}, + TaskRuns: []*v1.TaskRun{tr}, ServiceAccounts: []*corev1.ServiceAccount{{ ObjectMeta: metav1.ObjectMeta{Name: tr.Spec.ServiceAccountName, Namespace: "foo"}, }}, @@ -1257,7 +1262,7 @@ spec: t.Fatalf("expected an error") } - updatedTR, err := clients.Pipeline.TektonV1beta1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) + updatedTR, err := clients.Pipeline.TektonV1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -1271,7 +1276,7 @@ spec: } func TestReconcile_SetsStartTime(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun namespace: foo @@ -1280,8 +1285,8 @@ spec: name: test-task `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -1293,7 +1298,7 @@ spec: t.Errorf("expected no error reconciling valid TaskRun but got %v", err) } - newTr, err := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + newTr, err := testAssets.Clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -1304,7 +1309,7 @@ spec: func TestReconcile_DoesntChangeStartTime(t *testing.T) { startTime := time.Date(2000, 1, 1, 1, 1, 1, 1, time.UTC) - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun namespace: foo @@ -1316,8 +1321,8 @@ status: `) taskRun.Status.StartTime = &metav1.Time{Time: startTime} d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{simpleTask}, Pods: []*corev1.Pod{{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", @@ -1338,7 +1343,7 @@ status: } func TestReconcileInvalidTaskRuns(t *testing.T) { - noTaskRun := parse.MustParseV1beta1TaskRun(t, ` + noTaskRun := parse.MustParseV1TaskRun(t, ` metadata: name: notaskrun namespace: foo @@ -1346,7 +1351,7 @@ spec: taskRef: name: notask `) - withWrongRef := parse.MustParseV1beta1TaskRun(t, ` + withWrongRef := parse.MustParseV1TaskRun(t, ` metadata: name: taskrun-with-wrong-ref namespace: foo @@ -1355,8 +1360,8 @@ spec: kind: ClusterTask name: taskrun-with-wrong-ref `) - taskRuns := []*v1beta1.TaskRun{noTaskRun, withWrongRef} - tasks := []*v1beta1.Task{simpleTask} + taskRuns := []*v1.TaskRun{noTaskRun, withWrongRef} + tasks := []*v1.Task{simpleTask} d := test.Data{ TaskRuns: taskRuns, @@ -1365,7 +1370,7 @@ spec: testcases := []struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun reason string wantEvents []string }{{ @@ -1417,7 +1422,7 @@ spec: t.Errorf(err.Error()) } - newTr, err := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) + newTr, err := testAssets.Clients.Pipeline.TektonV1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected TaskRun %s to exist but instead got error when getting it: %v", tc.taskRun.Name, err) } @@ -1435,7 +1440,7 @@ spec: func TestReconcileRetry(t *testing.T) { var ( - toBeCanceledTaskRun = parse.MustParseV1beta1TaskRun(t, ` + toBeCanceledTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-retry-canceled namespace: foo @@ -1452,7 +1457,7 @@ status: type: Succeeded message: "TaskRun \"test-taskrun-run-retry-canceled\" was cancelled. " `) - canceledTaskRun = parse.MustParseV1beta1TaskRun(t, ` + canceledTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-retry-canceled namespace: foo @@ -1470,7 +1475,7 @@ status: type: Succeeded message: "TaskRun \"test-taskrun-run-retry-canceled\" was cancelled. " `) - toBeTimedOutTaskRun = parse.MustParseV1beta1TaskRun(t, ` + toBeTimedOutTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-retry-timedout namespace: foo @@ -1487,7 +1492,7 @@ status: type: Succeeded message: TaskRun "test-taskrun-run-retry-timedout" failed to finish within "10s" `) - timedOutTaskRun = parse.MustParseV1beta1TaskRun(t, ` + timedOutTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-retry-timedout namespace: foo @@ -1511,7 +1516,7 @@ status: startTime: "2021-12-31T00:00:00Z" completionTime: "2022-01-01T00:00:00Z" `) - toFailOnPodFailureTaskRun = parse.MustParseV1beta1TaskRun(t, ` + toFailOnPodFailureTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-retry-pod-failure namespace: foo @@ -1528,7 +1533,7 @@ status: waiting: reason: "ImagePullBackOff" `) - failedOnPodFailureTaskRun = parse.MustParseV1beta1TaskRun(t, ` + failedOnPodFailureTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-retry-pod-failure namespace: foo @@ -1574,7 +1579,7 @@ status: Reason: "PodFailed", }}}, } - toFailOnPrepareTaskRun = parse.MustParseV1beta1TaskRun(t, ` + toFailOnPrepareTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-retry-prepare-failure namespace: foo @@ -1590,7 +1595,7 @@ status: type: Succeeded lastTransitionTime: "2022-01-01T00:00:00Z" `) - failedOnPrepareTaskRun = parse.MustParseV1beta1TaskRun(t, ` + failedOnPrepareTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-retry-prepare-failure namespace: foo @@ -1614,7 +1619,7 @@ status: completionTime: "2022-01-01T00:00:00Z" `) prepareError = fmt.Errorf("1 error occurred:\n\t* error when listing tasks for taskRun test-taskrun-run-retry-prepare-failure: failed to get task: tasks.tekton.dev \"test-task\" not found") - toFailOnReconcileFailureTaskRun = parse.MustParseV1beta1TaskRun(t, ` + toFailOnReconcileFailureTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-results-type-mismatched namespace: foo @@ -1629,7 +1634,7 @@ status: type: string value: aResultValue `) - failedOnReconcileFailureTaskRun = parse.MustParseV1beta1TaskRun(t, ` + failedOnReconcileFailureTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-results-type-mismatched namespace: foo @@ -1655,7 +1660,7 @@ status: podName: "test-taskrun-results-type-mismatched-pod" `) reconciliatonError = fmt.Errorf("1 error occurred:\n\t* Provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\"") - toBeRetriedTaskRun = parse.MustParseV1beta1TaskRun(t, ` + toBeRetriedTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-to-be-retried namespace: foo @@ -1674,7 +1679,7 @@ status: status: "False" type: Succeeded `) - retriedTaskRun = parse.MustParseV1beta1TaskRun(t, ` + retriedTaskRun = parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-to-be-retried namespace: foo @@ -1701,18 +1706,18 @@ status: for _, tc := range []struct { name string testData test.Data - task *v1beta1.Task - tr *v1beta1.TaskRun + task *v1.Task + tr *v1.TaskRun pod *corev1.Pod - wantTr *v1beta1.TaskRun + wantTr *v1.TaskRun wantReconcileError error wantCompletionTime bool wantStartTime bool }{{ name: "No Retry on Cancellation", testData: test.Data{ - TaskRuns: []*v1beta1.TaskRun{toBeCanceledTaskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{toBeCanceledTaskRun}, + Tasks: []*v1.Task{simpleTask}, }, tr: toBeCanceledTaskRun, wantTr: canceledTaskRun, @@ -1721,8 +1726,8 @@ status: }, { name: "Retry on TimedOut", testData: test.Data{ - TaskRuns: []*v1beta1.TaskRun{toBeTimedOutTaskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{toBeTimedOutTaskRun}, + Tasks: []*v1.Task{simpleTask}, }, tr: toBeTimedOutTaskRun, wantTr: timedOutTaskRun, @@ -1730,8 +1735,8 @@ status: }, { name: "Retry on TaskRun Pod Failure", testData: test.Data{ - TaskRuns: []*v1beta1.TaskRun{toFailOnPodFailureTaskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{toFailOnPodFailureTaskRun}, + Tasks: []*v1.Task{simpleTask}, Pods: []*corev1.Pod{failedPod}, }, tr: toFailOnPodFailureTaskRun, @@ -1740,7 +1745,7 @@ status: }, { name: "Retry on TaskRun Prepare Failure", testData: test.Data{ - TaskRuns: []*v1beta1.TaskRun{toFailOnPrepareTaskRun}, + TaskRuns: []*v1.TaskRun{toFailOnPrepareTaskRun}, }, tr: toFailOnPrepareTaskRun, wantTr: failedOnPrepareTaskRun, @@ -1749,8 +1754,8 @@ status: }, { name: "Retry on TaskRun Reconciliation Failure", testData: test.Data{ - TaskRuns: []*v1beta1.TaskRun{toFailOnReconcileFailureTaskRun}, - Tasks: []*v1beta1.Task{resultsTask}, + TaskRuns: []*v1.TaskRun{toFailOnReconcileFailureTaskRun}, + Tasks: []*v1.Task{resultsTask}, ConfigMaps: []*corev1.ConfigMap{{ ObjectMeta: metav1.ObjectMeta{Namespace: system.Namespace(), Name: config.GetFeatureFlagsConfigName()}, Data: map[string]string{ @@ -1765,8 +1770,8 @@ status: }, { name: "Start a ToBeRetried TaskRun", testData: test.Data{ - TaskRuns: []*v1beta1.TaskRun{toBeRetriedTaskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{toBeRetriedTaskRun}, + Tasks: []*v1.Task{simpleTask}, }, tr: toBeRetriedTaskRun, wantTr: retriedTaskRun, @@ -1788,7 +1793,7 @@ status: } } - reconciledTaskRun, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").Get(testAssets.Ctx, tc.tr.Name, metav1.GetOptions{}) + reconciledTaskRun, err := clients.Pipeline.TektonV1().TaskRuns("foo").Get(testAssets.Ctx, tc.tr.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("got %v; want nil", err) } @@ -1822,7 +1827,7 @@ status: } func TestReconcileGetTaskError(t *testing.T) { - tr := parse.MustParseV1beta1TaskRun(t, ` + tr := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-success namespace: foo @@ -1831,8 +1836,8 @@ spec: name: test-task `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{tr}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{tr}, + Tasks: []*v1.Task{simpleTask}, ClusterTasks: []*v1beta1.ClusterTask{}, } testAssets, cancel := getTaskRunController(t, d) @@ -1843,7 +1848,7 @@ spec: failingReactorActivated := true clients.Pipeline.PrependReactor("*", "tasks", func(action ktesting.Action) (handled bool, ret runtime.Object, err error) { - return failingReactorActivated, &v1beta1.Task{}, errors.New("etcdserver: leader changed") + return failingReactorActivated, &v1.Task{}, errors.New("etcdserver: leader changed") }) err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(tr)) if err == nil { @@ -1860,7 +1865,7 @@ spec: t.Errorf("unexpected error in TaskRun reconciliation: %v", err) } } - reconciledRun, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1().TaskRuns("foo").Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } @@ -1871,7 +1876,7 @@ spec: } func TestReconcileTaskRunWithPermanentError(t *testing.T) { - noTaskRun := parse.MustParseV1beta1TaskRun(t, ` + noTaskRun := parse.MustParseV1TaskRun(t, ` metadata: name: notaskrun namespace: foo @@ -1888,7 +1893,7 @@ status: startTime: "2022-01-01T00:00:00Z" `) - taskRuns := []*v1beta1.TaskRun{noTaskRun} + taskRuns := []*v1.TaskRun{noTaskRun} d := test.Data{ TaskRuns: taskRuns, } @@ -1913,7 +1918,7 @@ status: " got %d. Actions: %#v", len(actions), actions) } - newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(noTaskRun.Namespace).Get(context.Background(), noTaskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1().TaskRuns(noTaskRun.Namespace).Get(context.Background(), noTaskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected TaskRun %s to exist but instead got error when getting it: %v", noTaskRun.Name, err) } @@ -1929,7 +1934,7 @@ status: } func TestReconcilePodFetchError(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-success namespace: foo @@ -1940,8 +1945,8 @@ status: podName: will-not-be-found `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) @@ -1958,7 +1963,7 @@ status: } } -func makePod(taskRun *v1beta1.TaskRun, task *v1beta1.Task) (*corev1.Pod, error) { +func makePod(taskRun *v1.TaskRun, task *v1.Task) (*corev1.Pod, error) { // TODO(jasonhall): This avoids a circular dependency where // getTaskRunController takes a test.Data which must be populated with // a pod created from MakePod which requires a (fake) Kube client. When @@ -1988,7 +1993,7 @@ func makePod(taskRun *v1beta1.TaskRun, task *v1beta1.Task) (*corev1.Pod, error) func TestReconcilePodUpdateStatus(t *testing.T) { const taskLabel = "test-task" - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-success namespace: foo @@ -2004,8 +2009,8 @@ status: t.Fatalf("MakePod: %v", err) } d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{simpleTask}, Pods: []*corev1.Pod{pod}, } @@ -2019,14 +2024,14 @@ status: } else if ok, _ := controller.IsRequeueKey(err); !ok { t.Fatalf("Unexpected error when Reconcile() : %v", err) } - newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } if d := cmp.Diff(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionUnknown, - Reason: v1beta1.TaskRunReasonRunning.String(), + Reason: v1.TaskRunReasonRunning.String(), Message: "Not all Steps in the Task have finished executing", }, newTr.Status.GetCondition(apis.ConditionSucceeded), ignoreLastTransitionTime); d != "" { t.Fatalf("Did not get expected condition %s", diff.PrintWantGot(d)) @@ -2058,14 +2063,14 @@ status: t.Fatalf("Unexpected error when Reconcile(): %v", err) } - newTr, err = clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + newTr, err = clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Unexpected error fetching taskrun: %v", err) } if d := cmp.Diff(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, - Reason: v1beta1.TaskRunReasonSuccessful.String(), + Reason: v1.TaskRunReasonSuccessful.String(), Message: "All Steps have completed executing", }, newTr.Status.GetCondition(apis.ConditionSucceeded), ignoreLastTransitionTime); d != "" { t.Errorf("Did not get expected condition %s", diff.PrintWantGot(d)) @@ -2083,7 +2088,7 @@ status: } func TestReconcileOnCompletedTaskRun(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-success namespace: foo @@ -2099,10 +2104,10 @@ status: startTime: "2021-12-31T23:59:45Z" `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{ + TaskRuns: []*v1.TaskRun{ taskRun, }, - Tasks: []*v1beta1.Task{simpleTask}, + Tasks: []*v1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) @@ -2113,7 +2118,7 @@ status: if err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(taskRun)); err != nil { t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err) } - newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected completed TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -2123,7 +2128,7 @@ status: } func TestReconcileOnCancelledTaskRun(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-cancelled namespace: foo @@ -2143,8 +2148,8 @@ status: t.Fatalf("MakePod: %v", err) } d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{simpleTask}, Pods: []*corev1.Pod{pod}, } @@ -2156,7 +2161,7 @@ status: if err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(taskRun)); err != nil { t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err) } - newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected completed TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -2182,8 +2187,8 @@ status: // reconcile the completed TaskRun again without the pod as that was deleted d = test.Data{ - TaskRuns: []*v1beta1.TaskRun{newTr}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{newTr}, + Tasks: []*v1.Task{simpleTask}, } testAssets, cancel = getTaskRunController(t, d) @@ -2196,7 +2201,7 @@ status: } func TestReconcileOnTimedOutTaskRun(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-timedout namespace: foo @@ -2216,8 +2221,8 @@ status: t.Fatalf("MakePod: %v", err) } d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{simpleTask}, Pods: []*corev1.Pod{pod}, } @@ -2229,7 +2234,7 @@ status: if err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(taskRun)); err != nil { t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err) } - newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected completed TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -2237,7 +2242,7 @@ status: expectedStatus := &apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.TaskRunReasonCancelled.String(), + Reason: v1.TaskRunReasonCancelled.String(), Message: `TaskRun "test-taskrun-run-timedout" was cancelled. TaskRun cancelled as pipeline has been cancelled.`, } if d := cmp.Diff(expectedStatus, newTr.Status.GetCondition(apis.ConditionSucceeded), ignoreLastTransitionTime); d != "" { @@ -2255,8 +2260,8 @@ status: // reconcile the completed TaskRun again without the pod as that was deleted d = test.Data{ - TaskRuns: []*v1beta1.TaskRun{newTr}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{newTr}, + Tasks: []*v1.Task{simpleTask}, } testAssets, cancel = getTaskRunController(t, d) @@ -2269,7 +2274,7 @@ status: } func TestReconcilePodFailuresStepImagePullFailed(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-imagepull-fail namespace: foo @@ -2301,7 +2306,7 @@ status: `Warning Failed The step "unnamed-0" in TaskRun "test-imagepull-fail" failed to pull the image "whatever". The pod errored with the message: "Back-off pulling image "whatever".`, } d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, + TaskRuns: []*v1.TaskRun{taskRun}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -2311,7 +2316,7 @@ status: if err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(taskRun)); err != nil { t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err) } - newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected completed TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -2326,7 +2331,7 @@ status: } func TestReconcilePodFailuresSidecarImagePullFailed(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-imagepull-fail namespace: foo @@ -2373,7 +2378,7 @@ status: `Warning Failed The sidecar "unnamed-1" in TaskRun "test-imagepull-fail" failed to pull the image "whatever". The pod errored with the message: "Back-off pulling image "whatever".`, } d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, + TaskRuns: []*v1.TaskRun{taskRun}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -2383,7 +2388,7 @@ status: if err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(taskRun)); err != nil { t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err) } - newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected completed TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -2400,7 +2405,7 @@ status: func TestReconcileTimeouts(t *testing.T) { type testCase struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun expectedStatus *apis.Condition wantEvents []string } @@ -2408,7 +2413,7 @@ func TestReconcileTimeouts(t *testing.T) { testcases := []testCase{ { name: "taskrun with timeout", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-timeout namespace: foo @@ -2434,7 +2439,7 @@ status: }, }, { name: "taskrun with default timeout", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-default-timeout-60-minutes namespace: foo @@ -2458,7 +2463,7 @@ status: }, }, { name: "task run with nil timeout uses default", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-nil-timeout-default-60-minutes namespace: foo @@ -2487,8 +2492,8 @@ status: for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{tc.taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{tc.taskRun}, + Tasks: []*v1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -2498,7 +2503,7 @@ status: if err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(tc.taskRun)); err != nil { t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err) } - newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected completed TaskRun %s to exist but instead got error when getting it: %v", tc.taskRun.Name, err) } @@ -2515,7 +2520,7 @@ status: } func TestPropagatedWorkspaces(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-propagating-workspaces namespace: foo @@ -2534,7 +2539,7 @@ spec: `) for _, apiField := range []string{config.BetaAPIFields, config.AlphaAPIFields} { d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, + TaskRuns: []*v1.TaskRun{taskRun}, } d.ConfigMaps = []*corev1.ConfigMap{{ ObjectMeta: metav1.ObjectMeta{Namespace: system.Namespace(), Name: config.GetFeatureFlagsConfigName()}, @@ -2549,9 +2554,9 @@ spec: if err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(taskRun)); err == nil { t.Fatalf("Could not reconcile the taskrun: %v", err) } - getTaskRun, _ := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + getTaskRun, _ := testAssets.Clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) - want := []v1beta1.WorkspaceDeclaration{{ + want := []v1.WorkspaceDeclaration{{ Name: "tr-workspace", }} if c := cmp.Diff(want, getTaskRun.Status.TaskSpec.Workspaces); c != "" { @@ -2564,7 +2569,7 @@ func TestExpandMountPath(t *testing.T) { expectedMountPath := "/temppath/replaced" expectedReplacedArgs := fmt.Sprintf("replacedArgs - %s", expectedMountPath) // The task's Workspace has a parameter variable - simpleTask := parse.MustParseV1beta1Task(t, ` + simpleTask := parse.MustParseV1Task(t, ` metadata: name: test-task namespace: foo @@ -2588,7 +2593,7 @@ spec: readOnly: true `) - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-not-started namespace: foo @@ -2603,8 +2608,8 @@ spec: name: tr-workspace `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{simpleTask}, } d.ConfigMaps = []*corev1.ConfigMap{ { @@ -2636,7 +2641,7 @@ spec: rtr := &resources.ResolvedTask{ TaskName: "test-task", Kind: "Task", - TaskSpec: &v1beta1.TaskSpec{Steps: simpleTask.Spec.Steps, Workspaces: simpleTask.Spec.Workspaces}, + TaskSpec: &v1.TaskSpec{Steps: simpleTask.Spec.Steps, Workspaces: simpleTask.Spec.Workspaces}, } ctx := config.EnableAlphaAPIFields(context.Background()) workspaceVolumes := workspace.CreateVolumes(taskRun.Spec.Workspaces) @@ -2663,7 +2668,7 @@ spec: func TestExpandMountPath_DuplicatePaths(t *testing.T) { expectedError := "workspace mount path \"/temppath/duplicate\" must be unique: workspaces[1].mountpath" // The task has two workspaces, with different mount path strings. - simpleTask := parse.MustParseV1beta1Task(t, ` + simpleTask := parse.MustParseV1Task(t, ` metadata: name: test-task namespace: foo @@ -2693,7 +2698,7 @@ spec: `) // The parameter values will cause the two Workspaces to have duplicate mount path values after the parameters are expanded. - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-not-started namespace: foo @@ -2712,8 +2717,8 @@ spec: name: tr-workspace-two `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{simpleTask}, } d.ConfigMaps = []*corev1.ConfigMap{ @@ -2745,7 +2750,7 @@ spec: rtr := &resources.ResolvedTask{ TaskName: "test-task", Kind: "Task", - TaskSpec: &v1beta1.TaskSpec{Steps: simpleTask.Spec.Steps, Workspaces: simpleTask.Spec.Workspaces}, + TaskSpec: &v1.TaskSpec{Steps: simpleTask.Spec.Steps, Workspaces: simpleTask.Spec.Workspaces}, } workspaceVolumes := workspace.CreateVolumes(taskRun.Spec.Workspaces) @@ -2762,7 +2767,7 @@ spec: } func TestHandlePodCreationError(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-pod-creation-failed spec: @@ -2775,8 +2780,8 @@ status: startTime: "2022-01-01T00:00:00Z" `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{simpleTask}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -2867,7 +2872,7 @@ status: } func TestReconcile_Single_SidecarState(t *testing.T) { runningState := corev1.ContainerStateRunning{StartedAt: metav1.Time{Time: now}} - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-sidecars spec: @@ -2883,8 +2888,8 @@ status: `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{taskSidecar}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{taskSidecar}, } testAssets, cancel := getTaskRunController(t, d) @@ -2895,15 +2900,15 @@ status: t.Errorf("expected no error reconciling valid TaskRun but got %v", err) } - getTaskRun, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + getTaskRun, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected completed TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } - expected := v1beta1.SidecarState{ - Name: "sidecar", - ImageID: "image-id", - ContainerName: "sidecar-sidecar", + expected := v1.SidecarState{ + Name: "sidecar", + ImageID: "image-id", + Container: "sidecar-sidecar", ContainerState: corev1.ContainerState{ Running: &runningState, }, @@ -2917,7 +2922,7 @@ status: func TestReconcile_Multiple_SidecarStates(t *testing.T) { runningState := corev1.ContainerStateRunning{StartedAt: metav1.Time{Time: now}} waitingState := corev1.ContainerStateWaiting{Reason: "PodInitializing"} - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-sidecars spec: @@ -2938,8 +2943,8 @@ status: `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{taskRun}, - Tasks: []*v1beta1.Task{taskMultipleSidecars}, + TaskRuns: []*v1.TaskRun{taskRun}, + Tasks: []*v1.Task{taskMultipleSidecars}, } testAssets, cancel := getTaskRunController(t, d) @@ -2950,24 +2955,24 @@ status: t.Errorf("expected no error reconciling valid TaskRun but got %v", err) } - getTaskRun, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + getTaskRun, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected completed TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } - expected := []v1beta1.SidecarState{ + expected := []v1.SidecarState{ { - Name: "sidecar1", - ImageID: "image-id", - ContainerName: "sidecar-sidecar1", + Name: "sidecar1", + ImageID: "image-id", + Container: "sidecar-sidecar1", ContainerState: corev1.ContainerState{ Running: &runningState, }, }, { - Name: "sidecar2", - ImageID: "image-id", - ContainerName: "sidecar-sidecar2", + Name: "sidecar2", + ImageID: "image-id", + Container: "sidecar-sidecar2", ContainerState: corev1.ContainerState{ Waiting: &waitingState, }, @@ -2984,7 +2989,7 @@ status: // TestReconcileWorkspaceMissing tests a reconcile of a TaskRun that does // not include a Workspace that the Task is expecting. func TestReconcileWorkspaceMissing(t *testing.T) { - taskWithWorkspace := parse.MustParseV1beta1Task(t, ` + taskWithWorkspace := parse.MustParseV1Task(t, ` metadata: name: test-task-with-workspace namespace: foo @@ -2994,7 +2999,7 @@ spec: name: ws1 readOnly: true `) - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-missing-workspace namespace: foo @@ -3004,8 +3009,8 @@ spec: name: test-task-with-workspace `) d := test.Data{ - Tasks: []*v1beta1.Task{taskWithWorkspace}, - TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1.Task{taskWithWorkspace}, + TaskRuns: []*v1.TaskRun{taskRun}, ClusterTasks: nil, } testAssets, cancel := getTaskRunController(t, d) @@ -3020,7 +3025,7 @@ spec: t.Fatalf("Expected to see a permanent error when reconciling invalid TaskRun, got %s instead", err) } - tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -3039,7 +3044,7 @@ spec: // TestReconcileValidDefaultWorkspace tests a reconcile of a TaskRun that does // not include a Workspace that the Task is expecting and it uses the default Workspace instead. func TestReconcileValidDefaultWorkspace(t *testing.T) { - taskWithWorkspace := parse.MustParseV1beta1Task(t, ` + taskWithWorkspace := parse.MustParseV1Task(t, ` metadata: name: test-task-with-workspace namespace: foo @@ -3054,7 +3059,7 @@ spec: name: ws1 readOnly: true `) - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-default-workspace namespace: foo @@ -3064,8 +3069,8 @@ spec: name: test-task-with-workspace `) d := test.Data{ - Tasks: []*v1beta1.Task{taskWithWorkspace}, - TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1.Task{taskWithWorkspace}, + TaskRuns: []*v1.TaskRun{taskRun}, ClusterTasks: nil, } @@ -3087,7 +3092,7 @@ spec: t.Errorf("Expected no error reconciling valid TaskRun but got %v", err) } - tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -3103,7 +3108,7 @@ spec: // not include a Workspace that the Task is expecting, and gets an error updating // the TaskRun with an invalid default workspace. func TestReconcileInvalidDefaultWorkspace(t *testing.T) { - taskWithWorkspace := parse.MustParseV1beta1Task(t, ` + taskWithWorkspace := parse.MustParseV1Task(t, ` metadata: name: test-task-with-workspace namespace: foo @@ -3118,7 +3123,7 @@ spec: name: ws1 readOnly: true `) - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-default-workspace namespace: foo @@ -3128,8 +3133,8 @@ spec: name: test-task-with-workspace `) d := test.Data{ - Tasks: []*v1beta1.Task{taskWithWorkspace}, - TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1.Task{taskWithWorkspace}, + TaskRuns: []*v1.TaskRun{taskRun}, ClusterTasks: nil, } @@ -3164,7 +3169,7 @@ spec: // injected in place of the omitted optional workspace. func TestReconcileValidDefaultWorkspaceOmittedOptionalWorkspace(t *testing.T) { optionalWorkspaceMountPath := "/foo/bar/baz" - taskWithOptionalWorkspace := parse.MustParseV1beta1Task(t, ` + taskWithOptionalWorkspace := parse.MustParseV1Task(t, ` metadata: name: test-task-with-optional-workspace namespace: default @@ -3179,7 +3184,7 @@ spec: name: optional-ws optional: true `) - taskRunOmittingWorkspace := parse.MustParseV1beta1TaskRun(t, ` + taskRunOmittingWorkspace := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun namespace: default @@ -3189,8 +3194,8 @@ spec: `) d := test.Data{ - Tasks: []*v1beta1.Task{taskWithOptionalWorkspace}, - TaskRuns: []*v1beta1.TaskRun{taskRunOmittingWorkspace}, + Tasks: []*v1.Task{taskWithOptionalWorkspace}, + TaskRuns: []*v1.TaskRun{taskRunOmittingWorkspace}, } d.ConfigMaps = append(d.ConfigMaps, &corev1.ConfigMap{ @@ -3211,7 +3216,7 @@ spec: t.Errorf("Unexpected reconcile error for TaskRun %q: %v", taskRunOmittingWorkspace.Name, err) } - tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRunOmittingWorkspace.Namespace).Get(testAssets.Ctx, taskRunOmittingWorkspace.Name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1().TaskRuns(taskRunOmittingWorkspace.Namespace).Get(testAssets.Ctx, taskRunOmittingWorkspace.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Error getting TaskRun %q: %v", taskRunOmittingWorkspace.Name, err) } @@ -3239,7 +3244,7 @@ spec: // Affinity Assistant is validated and that the validation fails for a TaskRun that is incompatible with // Affinity Assistant; e.g. using more than one PVC-backed workspace. func TestReconcileWithWorkspacesIncompatibleWithAffinityAssistant(t *testing.T) { - taskWithTwoWorkspaces := parse.MustParseV1beta1Task(t, ` + taskWithTwoWorkspaces := parse.MustParseV1Task(t, ` metadata: name: test-task-two-workspaces namespace: foo @@ -3251,7 +3256,7 @@ spec: - description: another workspace name: ws2 `) - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: annotations: pipeline.tekton.dev/affinity-assistant: dummy-affinity-assistant @@ -3272,8 +3277,8 @@ spec: `) d := test.Data{ - Tasks: []*v1beta1.Task{taskWithTwoWorkspaces}, - TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1.Task{taskWithTwoWorkspaces}, + TaskRuns: []*v1.TaskRun{taskRun}, ClusterTasks: nil, } testAssets, cancel := getTaskRunController(t, d) @@ -3282,12 +3287,12 @@ spec: createServiceAccount(t, testAssets, "default", "foo") _ = testAssets.Controller.Reconciler.Reconcile(testAssets.Ctx, getRunName(taskRun)) - _, err := clients.Pipeline.TektonV1beta1().Tasks(taskRun.Namespace).Get(testAssets.Ctx, taskWithTwoWorkspaces.Name, metav1.GetOptions{}) + _, err := clients.Pipeline.TektonV1().Tasks(taskRun.Namespace).Get(testAssets.Ctx, taskWithTwoWorkspaces.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("krux: %v", err) } - ttt, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + ttt, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("expected TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -3306,7 +3311,7 @@ spec: // TestReconcileWorkspaceWithVolumeClaimTemplate tests a reconcile of a TaskRun that has // a Workspace with VolumeClaimTemplate and check that it is translated to a created PersistentVolumeClaim. func TestReconcileWorkspaceWithVolumeClaimTemplate(t *testing.T) { - taskWithWorkspace := parse.MustParseV1beta1Task(t, ` + taskWithWorkspace := parse.MustParseV1Task(t, ` metadata: name: test-task-with-workspace namespace: foo @@ -3321,7 +3326,7 @@ spec: name: ws1 readOnly: true `) - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-missing-workspace namespace: foo @@ -3337,8 +3342,8 @@ spec: name: mypvc `) d := test.Data{ - Tasks: []*v1beta1.Task{taskWithWorkspace}, - TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1.Task{taskWithWorkspace}, + TaskRuns: []*v1.TaskRun{taskRun}, ClusterTasks: nil, } testAssets, cancel := getTaskRunController(t, d) @@ -3352,7 +3357,7 @@ spec: t.Errorf("expected no error reconciling valid TaskRun but got %v", err) } - ttt, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) + ttt, err := clients.Pipeline.TektonV1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("expected TaskRun %s to exist but instead got error when getting it: %v", taskRun.Name, err) } @@ -3376,15 +3381,15 @@ spec: func TestFailTaskRun(t *testing.T) { testCases := []struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun pod *corev1.Pod - reason v1beta1.TaskRunReason + reason v1.TaskRunReason message string expectedStatus apis.Condition - expectedStepStates []v1beta1.StepState + expectedStepStates []v1.StepState }{{ name: "no-pod-scheduled", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-failed namespace: foo @@ -3408,7 +3413,7 @@ status: }, }, { name: "pod-scheduled", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-failed namespace: foo @@ -3436,7 +3441,7 @@ status: }, }, { name: "step-status-update-cancel", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-cancel namespace: foo @@ -3458,27 +3463,27 @@ status: Namespace: "foo", Name: "foo-is-bar", }}, - reason: v1beta1.TaskRunReasonCancelled, + reason: v1.TaskRunReasonCancelled, message: "TaskRun test-taskrun-run-cancel was cancelled. Test cancellation message.", expectedStatus: apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.TaskRunReasonCancelled.String(), + Reason: v1.TaskRunReasonCancelled.String(), Message: "TaskRun test-taskrun-run-cancel was cancelled. Test cancellation message.", }, - expectedStepStates: []v1beta1.StepState{ + expectedStepStates: []v1.StepState{ { ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, - Reason: v1beta1.TaskRunReasonCancelled.String(), + Reason: v1.TaskRunReasonCancelled.String(), }, }, }, }, }, { name: "step-status-update-timeout", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-timeout namespace: foo @@ -3499,27 +3504,27 @@ status: Namespace: "foo", Name: "foo-is-bar", }}, - reason: v1beta1.TaskRunReasonTimedOut, + reason: v1.TaskRunReasonTimedOut, message: "TaskRun test-taskrun-run-timeout failed to finish within 10s", expectedStatus: apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), Message: "TaskRun test-taskrun-run-timeout failed to finish within 10s", }, - expectedStepStates: []v1beta1.StepState{ + expectedStepStates: []v1.StepState{ { ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), }, }, }, }, }, { name: "step-status-update-multiple-steps", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-timeout-multiple-steps namespace: foo @@ -3547,15 +3552,15 @@ status: Namespace: "foo", Name: "foo-is-bar", }}, - reason: v1beta1.TaskRunReasonTimedOut, + reason: v1.TaskRunReasonTimedOut, message: "TaskRun test-taskrun-run-timeout-multiple-steps failed to finish within 10s", expectedStatus: apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), Message: "TaskRun test-taskrun-run-timeout-multiple-steps failed to finish within 10s", }, - expectedStepStates: []v1beta1.StepState{ + expectedStepStates: []v1.StepState{ { ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ @@ -3568,7 +3573,7 @@ status: ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), }, }, }, @@ -3576,14 +3581,14 @@ status: ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), }, }, }, }, }, { name: "step-status-update-multiple-steps-waiting-state", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-timeout-multiple-steps-waiting namespace: foo @@ -3608,20 +3613,20 @@ status: Namespace: "foo", Name: "foo-is-bar", }}, - reason: v1beta1.TaskRunReasonTimedOut, + reason: v1.TaskRunReasonTimedOut, message: "TaskRun test-taskrun-run-timeout-multiple-steps-waiting failed to finish within 10s", expectedStatus: apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), Message: "TaskRun test-taskrun-run-timeout-multiple-steps-waiting failed to finish within 10s", }, - expectedStepStates: []v1beta1.StepState{ + expectedStepStates: []v1.StepState{ { ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), }, }, }, @@ -3629,7 +3634,7 @@ status: ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), }, }, }, @@ -3637,14 +3642,14 @@ status: ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), }, }, }, }, }, { name: "step-status-update-with-multiple-steps-and-some-continue-on-error", - taskRun: parse.MustParseV1beta1TaskRun(t, ` + taskRun: parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-run-ignore-step-error namespace: foo @@ -3669,15 +3674,15 @@ status: Namespace: "foo", Name: "foo-is-bar", }}, - reason: v1beta1.TaskRunReasonTimedOut, + reason: v1.TaskRunReasonTimedOut, message: "TaskRun test-taskrun-run-timeout-multiple-steps failed to finish within 10s", expectedStatus: apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), Message: "TaskRun test-taskrun-run-timeout-multiple-steps failed to finish within 10s", }, - expectedStepStates: []v1beta1.StepState{ + expectedStepStates: []v1.StepState{ { ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ @@ -3690,7 +3695,7 @@ status: ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, - Reason: v1beta1.TaskRunReasonTimedOut.String(), + Reason: v1.TaskRunReasonTimedOut.String(), }, }, }, @@ -3700,7 +3705,7 @@ status: for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{tc.taskRun}, + TaskRuns: []*v1.TaskRun{tc.taskRun}, } if tc.pod != nil { d.Pods = []*corev1.Pod{tc.pod} @@ -3742,7 +3747,7 @@ status: } func Test_storeTaskSpecAndConfigSource(t *testing.T) { - tr := parse.MustParseV1beta1TaskRun(t, ` + tr := parse.MustParseV1TaskRun(t, ` metadata: annotations: io.annotation: value @@ -3754,7 +3759,7 @@ spec: name: foo-task `) - configSource := &v1beta1.ConfigSource{ + configSource := &v1.ConfigSource{ URI: "https://abc.com.git", Digest: map[string]string{ "sha1": "xyz", @@ -3762,18 +3767,18 @@ spec: EntryPoint: "foo/bar", } - ts := v1beta1.TaskSpec{ + ts := v1.TaskSpec{ Description: "foo-task", } - ts1 := v1beta1.TaskSpec{ + ts1 := v1.TaskSpec{ Description: "bar-task", } want := tr.DeepCopy() - want.Status = v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + want.Status = v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ TaskSpec: ts.DeepCopy(), - Provenance: &v1beta1.Provenance{ + Provenance: &v1.Provenance{ ConfigSource: configSource.DeepCopy(), FeatureFlags: &config.FeatureFlags{ RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars, @@ -3791,7 +3796,7 @@ spec: want.ObjectMeta.Labels["tekton.dev/task"] = tr.ObjectMeta.Name type args struct { - taskSpec *v1beta1.TaskSpec + taskSpec *v1.TaskSpec resolvedObjectMeta *resolutionutil.ResolvedObjectMeta } @@ -3799,7 +3804,7 @@ spec: name string reconcile1Args *args reconcile2Args *args - wantTaskRun *v1beta1.TaskRun + wantTaskRun *v1.TaskRun }{ { name: "spec and source are available in the same reconcile", @@ -3864,14 +3869,14 @@ func Test_storeTaskSpec_metadata(t *testing.T) { wantedlabels := map[string]string{"lbl1": "value1", "lbl2": "value2", "lbl3": "value3"} wantedannotations := map[string]string{"io.annotation.1": "value1", "io.annotation.2": "value2", "io.annotation.3": "value3"} - tr := &v1beta1.TaskRun{ + tr := &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Labels: taskrunlabels, Annotations: taskrunannotations}, } resolvedMeta := resolutionutil.ResolvedObjectMeta{ ObjectMeta: &metav1.ObjectMeta{Labels: tasklabels, Annotations: taskannotations}, } - if err := storeTaskSpecAndMergeMeta(context.Background(), tr, &v1beta1.TaskSpec{}, &resolvedMeta); err != nil { + if err := storeTaskSpecAndMergeMeta(context.Background(), tr, &v1.TaskSpec{}, &resolvedMeta); err != nil { t.Errorf("storeTaskSpecAndMergeMeta error = %v", err) } if d := cmp.Diff(tr.ObjectMeta.Labels, wantedlabels); d != "" { @@ -3928,8 +3933,8 @@ func TestWillOverwritePodAffinity(t *testing.T) { for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { - tr := &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ + tr := &v1.TaskRun{ + Spec: v1.TaskRunSpec{ PodTemplate: &pod.Template{}, }, ObjectMeta: metav1.ObjectMeta{ @@ -3948,7 +3953,7 @@ func TestWillOverwritePodAffinity(t *testing.T) { } func TestPodAdoption(t *testing.T) { - tr := parse.MustParseV1beta1TaskRun(t, ` + tr := parse.MustParseV1TaskRun(t, ` metadata: labels: mylabel: myvalue @@ -3964,7 +3969,7 @@ spec: `) d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{tr}, + TaskRuns: []*v1.TaskRun{tr}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -3980,7 +3985,7 @@ spec: } // Get the updated TaskRun. - reconciledRun, err := clients.Pipeline.TektonV1beta1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Error getting updated TaskRun: %v", err) } @@ -3994,7 +3999,7 @@ spec: // Add a label to the TaskRun. This tests a scenario in issue 3656 which could prevent the reconciler // from finding a Pod when the pod name is missing from the status. reconciledRun.ObjectMeta.Labels["bah"] = "humbug" - reconciledRun, err = clients.Pipeline.TektonV1beta1().TaskRuns(tr.Namespace).Update(testAssets.Ctx, reconciledRun, metav1.UpdateOptions{}) + reconciledRun, err = clients.Pipeline.TektonV1().TaskRuns(tr.Namespace).Update(testAssets.Ctx, reconciledRun, metav1.UpdateOptions{}) if err != nil { t.Fatalf("Unexpected error when updating status: %v", err) } @@ -4002,8 +4007,8 @@ spec: // The label update triggers another reconcile. Depending on timing, the TaskRun passed to the reconcile may or may not // have the updated status with the name of the created pod. Clear the status because we want to test the case where the // status does not have the pod name. - reconciledRun.Status = v1beta1.TaskRunStatus{} - if _, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").UpdateStatus(testAssets.Ctx, reconciledRun, metav1.UpdateOptions{}); err != nil { + reconciledRun.Status = v1.TaskRunStatus{} + if _, err := clients.Pipeline.TektonV1().TaskRuns("foo").UpdateStatus(testAssets.Ctx, reconciledRun, metav1.UpdateOptions{}); err != nil { t.Fatalf("Unexpected error when updating status: %v", err) } @@ -4015,7 +4020,7 @@ spec: } // Get the updated TaskRun. - reconciledRun, err = clients.Pipeline.TektonV1beta1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) + reconciledRun, err = clients.Pipeline.TektonV1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Error getting updated TaskRun after second reconcile: %v", err) } @@ -4027,7 +4032,7 @@ spec: } func TestStopSidecars_ClientGetPodForTaskSpecWithSidecars(t *testing.T) { - tr := parse.MustParseV1beta1TaskRun(t, ` + tr := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun namespace: foo @@ -4051,7 +4056,7 @@ status: d := test.Data{ Pods: []*corev1.Pod{pod}, - TaskRuns: []*v1beta1.TaskRun{tr}, + TaskRuns: []*v1.TaskRun{tr}, } testAssets, cancel := getTaskRunController(t, d) @@ -4078,8 +4083,18 @@ status: } } +<<<<<<< Updated upstream func TestStopSidecars_WithInjectedSidecarsNoTaskSpecSidecars(t *testing.T) { taskRun := parse.MustParseV1beta1TaskRun(t, ` +======= +func TestStopSidecars_NoClientGetPodForTaskSpecWithoutRunningSidecars(t *testing.T) { + for _, tc := range []struct { + desc string + tr *v1.TaskRun + }{{ + desc: "no sidecars", + tr: parse.MustParseV1TaskRun(t, ` +>>>>>>> Stashed changes metadata: name: test-taskrun-injected-sidecars namespace: foo @@ -4093,7 +4108,36 @@ status: reason: Build succeeded status: "True" type: Succeeded +<<<<<<< Updated upstream `) +======= + podName: test-taskrun-pod + startTime: "2000-01-01T01:01:01Z" +`), + }, { + desc: "sidecars are terminated", + tr: parse.MustParseV1TaskRun(t, ` +metadata: + name: test-taskrun + namespace: foo +status: + conditions: + - status: "True" + type: Succeeded + podName: test-taskrun-pod + sidecars: + - terminated: + exitCode: 0 + finishedAt: "2000-01-01T01:01:01Z" + startedAt: "2000-01-01T01:01:01Z" + startTime: "2000-01-01T01:01:01Z" +`), + }} { + t.Run(tc.desc, func(t *testing.T) { + d := test.Data{ + TaskRuns: []*v1.TaskRun{tc.tr}, + } +>>>>>>> Stashed changes pod := &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ @@ -4163,17 +4207,17 @@ status: func Test_validateTaskSpecRequestResources_ValidResources(t *testing.T) { tcs := []struct { name string - taskSpec *v1beta1.TaskSpec + taskSpec *v1.TaskSpec }{{ name: "no requested resources", - taskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{ + taskSpec: &v1.TaskSpec{ + Steps: []v1.Step{ { Image: "image", Command: []string{"cmd"}, }}, - StepTemplate: &v1beta1.StepTemplate{ - Resources: corev1.ResourceRequirements{ + StepTemplate: &v1.StepTemplate{ + ComputeResources: corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("4"), corev1.ResourceMemory: resource.MustParse("8Gi"), @@ -4183,11 +4227,11 @@ func Test_validateTaskSpecRequestResources_ValidResources(t *testing.T) { }, }, { name: "no limit configured", - taskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + taskSpec: &v1.TaskSpec{ + Steps: []v1.Step{{ Image: "image", Command: []string{"cmd"}, - Resources: corev1.ResourceRequirements{ + ComputeResources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("8"), corev1.ResourceMemory: resource.MustParse("4Gi"), @@ -4197,11 +4241,11 @@ func Test_validateTaskSpecRequestResources_ValidResources(t *testing.T) { }, }, { name: "request less or equal than step limit but larger than steptemplate limit", - taskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + taskSpec: &v1.TaskSpec{ + Steps: []v1.Step{{ Image: "image", Command: []string{"cmd"}, - Resources: corev1.ResourceRequirements{ + ComputeResources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("8"), corev1.ResourceMemory: resource.MustParse("4Gi"), @@ -4212,8 +4256,8 @@ func Test_validateTaskSpecRequestResources_ValidResources(t *testing.T) { }, }, }}, - StepTemplate: &v1beta1.StepTemplate{ - Resources: corev1.ResourceRequirements{ + StepTemplate: &v1.StepTemplate{ + ComputeResources: corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("4"), corev1.ResourceMemory: resource.MustParse("4Gi"), @@ -4223,11 +4267,11 @@ func Test_validateTaskSpecRequestResources_ValidResources(t *testing.T) { }, }, { name: "request less or equal than step limit", - taskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + taskSpec: &v1.TaskSpec{ + Steps: []v1.Step{{ Image: "image", Command: []string{"cmd"}, - Resources: corev1.ResourceRequirements{ + ComputeResources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("8"), corev1.ResourceMemory: resource.MustParse("4Gi"), @@ -4241,19 +4285,19 @@ func Test_validateTaskSpecRequestResources_ValidResources(t *testing.T) { }, }, { name: "request less or equal than steptemplate limit", - taskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + taskSpec: &v1.TaskSpec{ + Steps: []v1.Step{{ Image: "image", Command: []string{"cmd"}, - Resources: corev1.ResourceRequirements{ + ComputeResources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("8"), corev1.ResourceMemory: resource.MustParse("4Gi"), }, }, }}, - StepTemplate: &v1beta1.StepTemplate{ - Resources: corev1.ResourceRequirements{ + StepTemplate: &v1.StepTemplate{ + ComputeResources: corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("8"), corev1.ResourceMemory: resource.MustParse("8Gi"), @@ -4275,14 +4319,14 @@ func Test_validateTaskSpecRequestResources_ValidResources(t *testing.T) { func Test_validateTaskSpecRequestResources_InvalidResources(t *testing.T) { tcs := []struct { name string - taskSpec *v1beta1.TaskSpec + taskSpec *v1.TaskSpec }{{ name: "step request larger than step limit", - taskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + taskSpec: &v1.TaskSpec{ + Steps: []v1.Step{{ Image: "image", Command: []string{"cmd"}, - Resources: corev1.ResourceRequirements{ + ComputeResources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("8"), corev1.ResourceMemory: resource.MustParse("8Gi"), @@ -4295,19 +4339,19 @@ func Test_validateTaskSpecRequestResources_InvalidResources(t *testing.T) { }}}, }, { name: "step request larger than steptemplate limit", - taskSpec: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + taskSpec: &v1.TaskSpec{ + Steps: []v1.Step{{ Image: "image", Command: []string{"cmd"}, - Resources: corev1.ResourceRequirements{ + ComputeResources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("8"), corev1.ResourceMemory: resource.MustParse("8Gi"), }, }, }}, - StepTemplate: &v1beta1.StepTemplate{ - Resources: corev1.ResourceRequirements{ + StepTemplate: &v1.StepTemplate{ + ComputeResources: corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("8"), corev1.ResourceMemory: resource.MustParse("4Gi"), @@ -4522,7 +4566,7 @@ func objectMeta(name, ns string) metav1.ObjectMeta { } func TestReconcile_validateLargerResultsSidecarLogs_invalid(t *testing.T) { - taskRun := parse.MustParseV1beta1TaskRun(t, ` + taskRun := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-larger-results-sidecar-logs namespace: foo @@ -4544,13 +4588,13 @@ status: name: mycontainer `) - taskruns := []*v1beta1.TaskRun{ + taskruns := []*v1.TaskRun{ taskRun, } for _, tc := range []struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun maxResultSize string expectError bool reason string @@ -4570,7 +4614,7 @@ status: t.Run(tc.name, func(t *testing.T) { d := test.Data{ TaskRuns: taskruns, - Tasks: []*v1beta1.Task{}, + Tasks: []*v1.Task{}, ConfigMaps: []*corev1.ConfigMap{{ ObjectMeta: metav1.ObjectMeta{Namespace: system.Namespace(), Name: config.GetFeatureFlagsConfigName()}, Data: map[string]string{ @@ -4582,7 +4626,7 @@ status: testAssets, cancel := getTaskRunController(t, d) defer cancel() clientset := fakekubeclientset.NewSimpleClientset() - pod := &v1.Pod{ + pod := &corev1.Pod{ TypeMeta: metav1.TypeMeta{ Kind: "Pod", APIVersion: "v1", @@ -4591,15 +4635,15 @@ status: Name: "test-taskrun-larger-results-sidecar-logs-pod", Namespace: "foo", }, - Spec: v1.PodSpec{ - Containers: []v1.Container{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ { Name: "sidecar-tekton-log-results", Image: "image", }, }, }, - Status: v1.PodStatus{ + Status: corev1.PodStatus{ Phase: corev1.PodRunning, }, } @@ -4617,7 +4661,7 @@ status: t.Error("expected to get an error but did not") } - tr, err := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) + tr, err := testAssets.Clients.Pipeline.TektonV1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -4630,7 +4674,7 @@ status: } func TestReconcile_validateTaskRunResults_valid(t *testing.T) { - taskRunResultsTypeMatched := parse.MustParseV1beta1TaskRun(t, ` + taskRunResultsTypeMatched := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-results-type-valid namespace: foo @@ -4644,7 +4688,7 @@ status: value: aResultValue `) - taskRunResultsObjectValid := parse.MustParseV1beta1TaskRun(t, ` + taskRunResultsObjectValid := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-results-object-valid namespace: foo @@ -4660,13 +4704,13 @@ status: commit: xyz `) - taskruns := []*v1beta1.TaskRun{ + taskruns := []*v1.TaskRun{ taskRunResultsTypeMatched, taskRunResultsObjectValid, } d := test.Data{ TaskRuns: taskruns, - Tasks: []*v1beta1.Task{resultsTask}, + Tasks: []*v1.Task{resultsTask}, ConfigMaps: []*corev1.ConfigMap{{ ObjectMeta: metav1.ObjectMeta{Namespace: system.Namespace(), Name: config.GetFeatureFlagsConfigName()}, Data: map[string]string{ @@ -4676,7 +4720,7 @@ status: } for _, tc := range []struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun }{{ name: "taskrun results type valid", taskRun: taskRunResultsTypeMatched, @@ -4696,7 +4740,7 @@ status: t.Errorf("Error reconciling TaskRun. Got error %v", err) } - tr, err := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) + tr, err := testAssets.Clients.Pipeline.TektonV1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -4709,7 +4753,7 @@ status: } func TestReconcile_validateTaskRunResults_invalid(t *testing.T) { - taskRunResultsTypeMismatched := parse.MustParseV1beta1TaskRun(t, ` + taskRunResultsTypeMismatched := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-results-type-mismatched namespace: foo @@ -4726,7 +4770,7 @@ status: value: objectResultValue `) - taskRunResultsObjectMissKey := parse.MustParseV1beta1TaskRun(t, ` + taskRunResultsObjectMissKey := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-results-object-miss-key namespace: foo @@ -4746,13 +4790,13 @@ status: url: abc `) - taskruns := []*v1beta1.TaskRun{ + taskruns := []*v1.TaskRun{ taskRunResultsTypeMismatched, taskRunResultsObjectMissKey, } d := test.Data{ TaskRuns: taskruns, - Tasks: []*v1beta1.Task{resultsTask}, + Tasks: []*v1.Task{resultsTask}, ConfigMaps: []*corev1.ConfigMap{{ ObjectMeta: metav1.ObjectMeta{Namespace: system.Namespace(), Name: config.GetFeatureFlagsConfigName()}, Data: map[string]string{ @@ -4762,10 +4806,10 @@ status: } for _, tc := range []struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun wantFailedReason string expectedError error - expectedResults []v1beta1.TaskRunResult + expectedResults []v1.TaskRunResult }{{ name: "taskrun results type mismatched", taskRun: taskRunResultsTypeMismatched, @@ -4777,15 +4821,15 @@ status: taskRun: taskRunResultsObjectMissKey, wantFailedReason: podconvert.ReasonFailedValidation, expectedError: fmt.Errorf("1 error occurred:\n\t* missing keys for these results which are required in TaskResult's properties map[objectResult:[commit]]"), - expectedResults: []v1beta1.TaskRunResult{ + expectedResults: []v1.TaskRunResult{ { Name: "aResult", Type: "array", - Value: *v1beta1.NewArrayOrString("1", "2"), + Value: *v1.NewStructuredValues("1", "2"), }, { Name: "objectResult", Type: "object", - Value: *v1beta1.NewObject(map[string]string{"url": "abc"}), + Value: *v1.NewObject(map[string]string{"url": "abc"}), }}, }} { t.Run(tc.name, func(t *testing.T) { @@ -4797,11 +4841,11 @@ status: if d := cmp.Diff(strings.TrimSuffix(err.Error(), "\n\n"), tc.expectedError.Error()); d != "" { t.Errorf("Expected: %v, but Got: %v", tc.expectedError, err) } - tr, err := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) + tr, err := testAssets.Clients.Pipeline.TektonV1().TaskRuns(tc.taskRun.Namespace).Get(testAssets.Ctx, tc.taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } - if d := cmp.Diff(tr.Status.TaskRunResults, tc.expectedResults); d != "" { + if d := cmp.Diff(tr.Status.Results, tc.expectedResults); d != "" { t.Errorf("got unexpected results %s", diff.PrintWantGot(d)) } condition := tr.Status.GetCondition(apis.ConditionSucceeded) @@ -4813,7 +4857,7 @@ status: } func TestReconcile_ReplacementsInStatusTaskSpec(t *testing.T) { - task := parse.MustParseV1beta1Task(t, ` + task := parse.MustParseV1Task(t, ` metadata: name: test-task-with-replacements namespace: foo @@ -4827,7 +4871,7 @@ spec: image: myimage name: mycontainer `) - tr := parse.MustParseV1beta1TaskRun(t, ` + tr := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun-with-replacements namespace: foo @@ -4841,13 +4885,13 @@ status: podName: the-pod `) - expectedStatusSpec := &v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{ + expectedStatusSpec := &v1.TaskSpec{ + Params: []v1.ParamSpec{{ Name: "myarg", - Default: v1beta1.NewStructuredValues("mydefault"), - Type: v1beta1.ParamTypeString, + Default: v1.NewStructuredValues("mydefault"), + Type: v1.ParamTypeString, }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Script: "echo foo", Image: "myimage", Name: "mycontainer", @@ -4855,8 +4899,8 @@ status: } d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{tr}, - Tasks: []*v1beta1.Task{task}, + TaskRuns: []*v1.TaskRun{tr}, + Tasks: []*v1.Task{task}, Pods: []*corev1.Pod{{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", @@ -4873,7 +4917,7 @@ status: t.Errorf("expected no error. Got error %v", err) } - updatedTR, err := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) + updatedTR, err := testAssets.Clients.Pipeline.TektonV1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -4888,7 +4932,7 @@ func TestReconcile_verifyResolvedTask_Success(t *testing.T) { ctx, cancel := context.WithCancel(ctx) defer cancel() - ts := parse.MustParseV1beta1Task(t, ` + ts := parse.MustParseV1Task(t, ` metadata: name: test-task namespace: foo @@ -4902,7 +4946,7 @@ spec: image: myimage name: mycontainer `) - tr := parse.MustParseV1beta1TaskRun(t, ` + tr := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun namespace: foo @@ -4932,8 +4976,8 @@ status: } d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{tr}, - Tasks: []*v1beta1.Task{signedTask}, + TaskRuns: []*v1.TaskRun{tr}, + Tasks: []*v1.Task{signedTask}, ConfigMaps: cms, VerificationPolicies: vps, } @@ -4953,7 +4997,7 @@ func TestReconcile_verifyResolvedTask_Error(t *testing.T) { ctx, cancel := context.WithCancel(ctx) defer cancel() - ts := parse.MustParseV1beta1Task(t, ` + ts := parse.MustParseV1Task(t, ` metadata: name: test-task namespace: foo @@ -4967,7 +5011,7 @@ spec: image: myimage name: mycontainer `) - tr := parse.MustParseV1beta1TaskRun(t, ` + tr := parse.MustParseV1TaskRun(t, ` metadata: name: test-taskrun namespace: foo @@ -5004,18 +5048,18 @@ status: testCases := []struct { name string - taskrun []*v1beta1.TaskRun - task []*v1beta1.Task + taskrun []*v1.TaskRun + task []*v1.Task expectedError error }{ { name: "unsigned task fails verification", - task: []*v1beta1.Task{ts}, + task: []*v1.Task{ts}, expectedError: trustedresources.ErrResourceVerificationFailed, }, { name: "modified task fails verification", - task: []*v1beta1.Task{tamperedTask}, + task: []*v1.Task{tamperedTask}, expectedError: trustedresources.ErrResourceVerificationFailed, }, } @@ -5023,7 +5067,7 @@ status: for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { d := test.Data{ - TaskRuns: []*v1beta1.TaskRun{tr}, + TaskRuns: []*v1.TaskRun{tr}, Tasks: tc.task, ConfigMaps: cms, VerificationPolicies: vps, @@ -5037,7 +5081,7 @@ status: if !errors.Is(err, tc.expectedError) { t.Errorf("Reconcile got %v but want %v", err, tc.expectedError) } - tr, err := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) + tr, err := testAssets.Clients.Pipeline.TektonV1().TaskRuns(tr.Namespace).Get(testAssets.Ctx, tr.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } diff --git a/pkg/reconciler/taskrun/tracing.go b/pkg/reconciler/taskrun/tracing.go index 881631d945e..d5e26a3a984 100644 --- a/pkg/reconciler/taskrun/tracing.go +++ b/pkg/reconciler/taskrun/tracing.go @@ -20,7 +20,7 @@ import ( "context" "encoding/json" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/propagation" @@ -37,7 +37,7 @@ const ( // initialize tracing by creating the root span and injecting the // spanContext is propogated through annotations in the CR -func initTracing(ctx context.Context, tracerProvider trace.TracerProvider, tr *v1beta1.TaskRun) context.Context { +func initTracing(ctx context.Context, tracerProvider trace.TracerProvider, tr *v1.TaskRun) context.Context { logger := logging.FromContext(ctx) pro := otel.GetTextMapPropagator() diff --git a/pkg/reconciler/taskrun/tracing_test.go b/pkg/reconciler/taskrun/tracing_test.go index 0da9e81049b..d2381abfd95 100644 --- a/pkg/reconciler/taskrun/tracing_test.go +++ b/pkg/reconciler/taskrun/tracing_test.go @@ -17,7 +17,7 @@ import ( "context" "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/propagation" tracesdk "go.opentelemetry.io/otel/sdk/trace" @@ -30,14 +30,14 @@ func TestInitTracing(t *testing.T) { testcases := []struct { name string - taskRun *v1beta1.TaskRun + taskRun *v1.TaskRun tracerProvider trace.TracerProvider expectSpanContextStatus bool expectValidSpanContext bool parentTraceID string }{{ name: "with-tracerprovider-no-parent-trace", - taskRun: &v1beta1.TaskRun{ + taskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "testns", @@ -48,7 +48,7 @@ func TestInitTracing(t *testing.T) { expectValidSpanContext: true, }, { name: "with-tracerprovider-with-parent-trace", - taskRun: &v1beta1.TaskRun{ + taskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "testns", @@ -63,7 +63,7 @@ func TestInitTracing(t *testing.T) { parentTraceID: "00-0f57e147e992b304d977436289d10628-73d5909e31793992-01", }, { name: "without-tracerprovider", - taskRun: &v1beta1.TaskRun{ + taskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "testns", @@ -74,7 +74,7 @@ func TestInitTracing(t *testing.T) { expectValidSpanContext: false, }, { name: "without-tracerprovider-existing-annotations", - taskRun: &v1beta1.TaskRun{ + taskRun: &v1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "testns", diff --git a/pkg/reconciler/taskrun/validate_taskrun.go b/pkg/reconciler/taskrun/validate_taskrun.go index 28ac12a8471..d3fc5d6b689 100644 --- a/pkg/reconciler/taskrun/validate_taskrun.go +++ b/pkg/reconciler/taskrun/validate_taskrun.go @@ -23,13 +23,14 @@ import ( "strings" "github.com/hashicorp/go-multierror" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/list" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "k8s.io/apimachinery/pkg/util/sets" ) +<<<<<<< Updated upstream // validateParams validates that all Pipeline Task, Matrix.Params and Matrix.Include parameters all have values, match the specified // type and object params have all the keys required func validateParams(ctx context.Context, paramSpecs []v1beta1.ParamSpec, params v1beta1.Params, matrixParams v1beta1.Params) error { @@ -37,6 +38,15 @@ func validateParams(ctx context.Context, paramSpecs []v1beta1.ParamSpec, params providedParams := params providedParams = append(providedParams, matrixParams...) providedParamsNames := providedParams.ExtractNames() +======= +func validateParams(ctx context.Context, paramSpecs []v1.ParamSpec, params []v1.Param, matrix *v1.Matrix) error { + neededParamsNames, neededParamsTypes := neededParamsNamesAndTypes(paramSpecs) + var matrixParams []v1.Param + if matrix != nil { + matrixParams = matrix.Params + } + providedParamsNames := providedParamsNames(append(params, matrixParams...)) +>>>>>>> Stashed changes if missingParamsNames := missingParamsNames(neededParamsNames, providedParamsNames, paramSpecs); len(missingParamsNames) != 0 { return fmt.Errorf("missing values for these params which have no default values: %s", missingParamsNames) } @@ -49,10 +59,17 @@ func validateParams(ctx context.Context, paramSpecs []v1beta1.ParamSpec, params return nil } +<<<<<<< Updated upstream // neededParamsNamesAndTypes returns the needed parameter names and types based on the paramSpec func neededParamsNamesAndTypes(paramSpecs []v1beta1.ParamSpec) (sets.String, map[string]v1beta1.ParamType) { neededParamsNames := sets.String{} neededParamsTypes := make(map[string]v1beta1.ParamType) +======= +func neededParamsNamesAndTypes(paramSpecs []v1.ParamSpec) ([]string, map[string]v1.ParamType) { + var neededParamsNames []string + neededParamsTypes := make(map[string]v1.ParamType) + neededParamsNames = make([]string, 0, len(paramSpecs)) +>>>>>>> Stashed changes for _, inputResourceParam := range paramSpecs { neededParamsNames.Insert(inputResourceParam.Name) neededParamsTypes[inputResourceParam.Name] = inputResourceParam.Type @@ -60,10 +77,23 @@ func neededParamsNamesAndTypes(paramSpecs []v1beta1.ParamSpec) (sets.String, map return neededParamsNames, neededParamsTypes } +<<<<<<< Updated upstream // missingParamsNames returns a slice of missing parameter names that have not been declared with a default value // in the paramSpec func missingParamsNames(neededParams sets.String, providedParams sets.String, paramSpecs []v1beta1.ParamSpec) []string { missingParamsNames := neededParams.Difference(providedParams) +======= +func providedParamsNames(params []v1.Param) []string { + providedParamsNames := make([]string, 0, len(params)) + for _, param := range params { + providedParamsNames = append(providedParamsNames, param.Name) + } + return providedParamsNames +} + +func missingParamsNames(neededParams []string, providedParams []string, paramSpecs []v1.ParamSpec) []string { + missingParamsNames := list.DiffLeft(neededParams, providedParams) +>>>>>>> Stashed changes var missingParamsNamesWithNoDefaults []string for _, inputResourceParam := range paramSpecs { if missingParamsNames.Has(inputResourceParam.Name) && inputResourceParam.Default == nil { @@ -72,7 +102,12 @@ func missingParamsNames(neededParams sets.String, providedParams sets.String, pa } return missingParamsNamesWithNoDefaults } +<<<<<<< Updated upstream func wrongTypeParamsNames(params []v1beta1.Param, matrix []v1beta1.Param, neededParamsTypes map[string]v1beta1.ParamType) []string { +======= + +func wrongTypeParamsNames(params []v1.Param, matrix []v1.Param, neededParamsTypes map[string]v1.ParamType) []string { +>>>>>>> Stashed changes // TODO(#4723): validate that $(task.taskname.result.resultname) is invalid for array and object type. // It should be used to refer string and need to add [*] to refer to array or object. var wrongTypeParamNames []string @@ -86,7 +121,7 @@ func wrongTypeParamsNames(params []v1beta1.Param, matrix []v1beta1.Param, needed // to pass array result to array param, yet in yaml format this will be // unmarshalled to string for ParamValues. So we need to check and skip this validation. // Please refer issue #4879 for more details and examples. - if param.Value.Type == v1beta1.ParamTypeString && (neededParamsTypes[param.Name] == v1beta1.ParamTypeArray || neededParamsTypes[param.Name] == v1beta1.ParamTypeObject) && v1beta1.VariableSubstitutionRegex.MatchString(param.Value.StringVal) { + if param.Value.Type == v1.ParamTypeString && (neededParamsTypes[param.Name] == v1.ParamTypeArray || neededParamsTypes[param.Name] == v1.ParamTypeObject) && v1.VariableSubstitutionRegex.MatchString(param.Value.StringVal) { continue } if param.Value.Type != neededParamsTypes[param.Name] { @@ -99,7 +134,7 @@ func wrongTypeParamsNames(params []v1beta1.Param, matrix []v1beta1.Param, needed // passed to the task that aren't being used. continue } - if neededParamsTypes[param.Name] != v1beta1.ParamTypeString { + if neededParamsTypes[param.Name] != v1.ParamTypeString { wrongTypeParamNames = append(wrongTypeParamNames, param.Name) } } @@ -107,12 +142,12 @@ func wrongTypeParamsNames(params []v1beta1.Param, matrix []v1beta1.Param, needed } // MissingKeysObjectParamNames checks if all required keys of object type param definitions are provided in params or param definitions' defaults. -func MissingKeysObjectParamNames(paramSpecs []v1beta1.ParamSpec, params []v1beta1.Param) map[string][]string { +func MissingKeysObjectParamNames(paramSpecs []v1.ParamSpec, params []v1.Param) map[string][]string { neededKeys := make(map[string][]string) providedKeys := make(map[string][]string) for _, spec := range paramSpecs { - if spec.Type == v1beta1.ParamTypeObject { + if spec.Type == v1.ParamTypeObject { // collect required keys from properties section for key := range spec.Properties { neededKeys[spec.Name] = append(neededKeys[spec.Name], key) @@ -129,7 +164,7 @@ func MissingKeysObjectParamNames(paramSpecs []v1beta1.ParamSpec, params []v1beta // collect provided keys from run level value for _, p := range params { - if p.Value.Type == v1beta1.ParamTypeObject { + if p.Value.Type == v1.ParamTypeObject { for key := range p.Value.ObjectVal { providedKeys[p.Name] = append(providedKeys[p.Name], key) } @@ -156,28 +191,34 @@ func findMissingKeys(neededKeys, providedKeys map[string][]string) map[string][] return missings } +<<<<<<< Updated upstream // ValidateResolvedTask validates that all parameters declared in the TaskSpec are present in the taskrun // It also validates that all parameters have values, parameter types match the specified type and // object params have all the keys required func ValidateResolvedTask(ctx context.Context, params []v1beta1.Param, matrix *v1beta1.Matrix, rtr *resources.ResolvedTask) error { if err := validateParams(ctx, rtr.TaskSpec.Params, params, matrix.GetAllParams()); err != nil { +======= +// ValidateResolvedTask validates task inputs, params and output matches taskrun +func ValidateResolvedTask(ctx context.Context, params []v1.Param, matrix *v1.Matrix, rtr *resources.ResolvedTask) error { + if err := validateParams(ctx, rtr.TaskSpec.Params, params, matrix); err != nil { +>>>>>>> Stashed changes return fmt.Errorf("invalid input params for task %s: %w", rtr.TaskName, err) } return nil } -func validateTaskSpecRequestResources(taskSpec *v1beta1.TaskSpec) error { +func validateTaskSpecRequestResources(taskSpec *v1.TaskSpec) error { if taskSpec != nil { for _, step := range taskSpec.Steps { - for k, request := range step.Resources.Requests { + for k, request := range step.ComputeResources.Requests { // First validate the limit in step - if limit, ok := step.Resources.Limits[k]; ok { + if limit, ok := step.ComputeResources.Limits[k]; ok { if (&limit).Cmp(request) == -1 { return fmt.Errorf("Invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String()) } } else if taskSpec.StepTemplate != nil { // If step doesn't configure the limit, validate the limit in stepTemplate - if limit, ok := taskSpec.StepTemplate.Resources.Limits[k]; ok { + if limit, ok := taskSpec.StepTemplate.ComputeResources.Limits[k]; ok { if (&limit).Cmp(request) == -1 { return fmt.Errorf("Invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String()) } @@ -191,19 +232,19 @@ func validateTaskSpecRequestResources(taskSpec *v1beta1.TaskSpec) error { } // validateOverrides validates that all stepOverrides map to valid steps, and likewise for sidecarOverrides -func validateOverrides(ts *v1beta1.TaskSpec, trs *v1beta1.TaskRunSpec) error { +func validateOverrides(ts *v1.TaskSpec, trs *v1.TaskRunSpec) error { stepErr := validateStepOverrides(ts, trs) sidecarErr := validateSidecarOverrides(ts, trs) return multierror.Append(stepErr, sidecarErr).ErrorOrNil() } -func validateStepOverrides(ts *v1beta1.TaskSpec, trs *v1beta1.TaskRunSpec) error { +func validateStepOverrides(ts *v1.TaskSpec, trs *v1.TaskRunSpec) error { var err error stepNames := sets.NewString() for _, step := range ts.Steps { stepNames.Insert(step.Name) } - for _, stepOverride := range trs.StepOverrides { + for _, stepOverride := range trs.StepSpecs { if !stepNames.Has(stepOverride.Name) { err = multierror.Append(err, fmt.Errorf("invalid StepOverride: No Step named %s", stepOverride.Name)) } @@ -211,13 +252,13 @@ func validateStepOverrides(ts *v1beta1.TaskSpec, trs *v1beta1.TaskRunSpec) error return err } -func validateSidecarOverrides(ts *v1beta1.TaskSpec, trs *v1beta1.TaskRunSpec) error { +func validateSidecarOverrides(ts *v1.TaskSpec, trs *v1.TaskRunSpec) error { var err error sidecarNames := sets.NewString() for _, sidecar := range ts.Sidecars { sidecarNames.Insert(sidecar.Name) } - for _, sidecarOverride := range trs.SidecarOverrides { + for _, sidecarOverride := range trs.SidecarSpecs { if !sidecarNames.Has(sidecarOverride.Name) { err = multierror.Append(err, fmt.Errorf("invalid SidecarOverride: No Sidecar named %s", sidecarOverride.Name)) } @@ -226,8 +267,8 @@ func validateSidecarOverrides(ts *v1beta1.TaskSpec, trs *v1beta1.TaskRunSpec) er } // validateResults checks the emitted results type and object properties against the ones defined in spec. -func validateTaskRunResults(tr *v1beta1.TaskRun, resolvedTaskSpec *v1beta1.TaskSpec) error { - specResults := []v1beta1.TaskResult{} +func validateTaskRunResults(tr *v1.TaskRun, resolvedTaskSpec *v1.TaskSpec) error { + specResults := []v1.TaskResult{} if tr.Spec.TaskSpec != nil { specResults = append(specResults, tr.Spec.TaskSpec.Results...) } @@ -254,10 +295,10 @@ func validateTaskRunResults(tr *v1beta1.TaskRun, resolvedTaskSpec *v1beta1.TaskS } // mismatchedTypesResults checks and returns all the mismatched types of emitted results against specified results. -func mismatchedTypesResults(tr *v1beta1.TaskRun, specResults []v1beta1.TaskResult) map[string]string { +func mismatchedTypesResults(tr *v1.TaskRun, specResults []v1.TaskResult) map[string]string { neededTypes := make(map[string]string) mismatchedTypes := make(map[string]string) - var filteredResults []v1beta1.TaskRunResult + var filteredResults []v1.TaskRunResult // collect needed types for results for _, r := range specResults { neededTypes[r.Name] = string(r.Type) @@ -265,7 +306,7 @@ func mismatchedTypesResults(tr *v1beta1.TaskRun, specResults []v1beta1.TaskResul // collect mismatched types for results, and correct results in filteredResults // TODO(#6097): Validate if the emitted results are defined in taskspec - for _, trr := range tr.Status.TaskRunResults { + for _, trr := range tr.Status.Results { needed, ok := neededTypes[trr.Name] if ok && needed != string(trr.Type) { mismatchedTypes[trr.Name] = fmt.Sprintf("task result is expected to be \"%v\" type but was initialized to a different type \"%v\"", needed, trr.Type) @@ -274,17 +315,17 @@ func mismatchedTypesResults(tr *v1beta1.TaskRun, specResults []v1beta1.TaskResul } } // remove the mismatched results - tr.Status.TaskRunResults = filteredResults + tr.Status.Results = filteredResults return mismatchedTypes } // missingKeysofObjectResults checks and returns the missing keys of object results. -func missingKeysofObjectResults(tr *v1beta1.TaskRun, specResults []v1beta1.TaskResult) map[string][]string { +func missingKeysofObjectResults(tr *v1.TaskRun, specResults []v1.TaskResult) map[string][]string { neededKeys := make(map[string][]string) providedKeys := make(map[string][]string) // collect needed keys for object results for _, r := range specResults { - if string(r.Type) == string(v1beta1.ParamTypeObject) { + if string(r.Type) == string(v1.ParamTypeObject) { for key := range r.Properties { neededKeys[r.Name] = append(neededKeys[r.Name], key) } @@ -292,8 +333,8 @@ func missingKeysofObjectResults(tr *v1beta1.TaskRun, specResults []v1beta1.TaskR } // collect provided keys for object results - for _, trr := range tr.Status.TaskRunResults { - if trr.Value.Type == v1beta1.ParamTypeObject { + for _, trr := range tr.Status.Results { + if trr.Value.Type == v1.ParamTypeObject { for key := range trr.Value.ObjectVal { providedKeys[trr.Name] = append(providedKeys[trr.Name], key) } diff --git a/pkg/reconciler/taskrun/validate_taskrun_test.go b/pkg/reconciler/taskrun/validate_taskrun_test.go index b5545026410..02037032294 100644 --- a/pkg/reconciler/taskrun/validate_taskrun_test.go +++ b/pkg/reconciler/taskrun/validate_taskrun_test.go @@ -22,54 +22,69 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +<<<<<<< Updated upstream "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" +======= + "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" +>>>>>>> Stashed changes "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "github.com/tektoncd/pipeline/test/diff" ) func TestValidateResolvedTask_ValidParams(t *testing.T) { ctx := context.Background() - task := &v1beta1.Task{ + task := &v1.Task{ ObjectMeta: metav1.ObjectMeta{Name: "foo"}, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Image: "myimage", Command: []string{"mycmd"}, }}, - Params: []v1beta1.ParamSpec{ + Params: []v1.ParamSpec{ { Name: "foo", +<<<<<<< Updated upstream Type: v1beta1.ParamTypeString, }, { Name: "bar", Type: v1beta1.ParamTypeString, }, { +======= + Type: v1.ParamTypeString, + }, + { + Name: "bar", + Type: v1.ParamTypeString, + }, + { +>>>>>>> Stashed changes Name: "zoo", - Type: v1beta1.ParamTypeString, + Type: v1.ParamTypeString, }, { Name: "include", Type: v1beta1.ParamTypeString, }, { Name: "arrayResultRef", - Type: v1beta1.ParamTypeArray, + Type: v1.ParamTypeArray, }, { Name: "myObjWithoutDefault", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {}, "key2": {}, }, }, { Name: "myObjWithDefault", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {}, "key2": {}, "key3": {}, }, - Default: &v1beta1.ParamValue{ - Type: v1beta1.ParamTypeObject, + Default: &v1.ParamValue{ + Type: v1.ParamTypeObject, ObjectVal: map[string]string{ "key1": "val1-default", "key2": "val2-default", // key2 is also provided and will be overridden by taskrun @@ -83,29 +98,34 @@ func TestValidateResolvedTask_ValidParams(t *testing.T) { rtr := &resources.ResolvedTask{ TaskSpec: &task.Spec, } +<<<<<<< Updated upstream p := v1beta1.Params{{ +======= + p := []v1.Param{{ +>>>>>>> Stashed changes Name: "foo", - Value: *v1beta1.NewStructuredValues("somethinggood"), + Value: *v1.NewStructuredValues("somethinggood"), }, { Name: "bar", - Value: *v1beta1.NewStructuredValues("somethinggood"), + Value: *v1.NewStructuredValues("somethinggood"), }, { Name: "arrayResultRef", - Value: *v1beta1.NewStructuredValues("$(results.resultname[*])"), + Value: *v1.NewStructuredValues("$(results.resultname[*])"), }, { Name: "myObjWithoutDefault", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "key2": "val2", "extra_key": "val3", }), }, { Name: "myObjWithDefault", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key2": "val2", "key3": "val3", }), }} +<<<<<<< Updated upstream m := &v1beta1.Matrix{ Params: []v1beta1.Param{{ Name: "zoo", @@ -221,10 +241,35 @@ func TestValidateResolvedTask_ExtraValidParams(t *testing.T) { } }) } +======= + m := []v1.Param{{ + Name: "zoo", + Value: *v1.NewStructuredValues("a", "b", "c"), + }} + if err := ValidateResolvedTask(ctx, p, &v1.Matrix{Params: m}, rtr); err != nil { + t.Fatalf("Did not expect to see error when validating TaskRun with correct params but saw %v", err) + } + + t.Run("alpha-extra-params", func(t *testing.T) { + ctx := config.ToContext(ctx, &config.Config{FeatureFlags: &config.FeatureFlags{EnableAPIFields: "alpha"}}) + extra := v1.Param{ + Name: "extra", + Value: *v1.NewStructuredValues("i am an extra param"), + } + extraarray := v1.Param{ + Name: "extraarray", + Value: *v1.NewStructuredValues("i", "am", "an", "extra", "array", "param"), + } + if err := ValidateResolvedTask(ctx, append(p, extra), &v1.Matrix{Params: append(m, extraarray)}, rtr); err != nil { + t.Fatalf("Did not expect to see error when validating TaskRun with correct params but saw %v", err) + } + }) +>>>>>>> Stashed changes } func TestValidateResolvedTask_InvalidParams(t *testing.T) { ctx := context.Background() +<<<<<<< Updated upstream tcs := []struct { name string task v1beta1.Task @@ -402,21 +447,121 @@ func TestValidateResolvedTask_InvalidParams(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: v1beta1.TaskSpec{ Params: []v1beta1.ParamSpec{{ +======= + task := &v1.Task{ + ObjectMeta: metav1.ObjectMeta{Name: "foo"}, + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ + Image: "myimage", + Command: []string{"mycmd"}, + }}, + Params: []v1.ParamSpec{ + { + Name: "foo", + Type: v1.ParamTypeString, + }, { + Name: "bar", + Type: v1.ParamTypeArray, + }, + { +>>>>>>> Stashed changes Name: "myObjWithoutDefault", - Type: v1beta1.ParamTypeObject, - Properties: map[string]v1beta1.PropertySpec{ + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ "key1": {}, "key2": {}, }, +<<<<<<< Updated upstream }}, }, }, params: v1beta1.Params{{ +======= + }, { + Name: "myObjWithDefault", + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ + "key1": {}, + "key2": {}, + "key3": {}, + }, + Default: &v1.ParamValue{ + Type: v1.ParamTypeObject, + ObjectVal: map[string]string{ + "key1": "default", + // key2 is not provided by default nor taskrun, which is why error is epected. + // key3 is provided by taskrun + }, + }, + }, + }, + }, + } + tcs := []struct { + name string + rtr *resources.ResolvedTask + params []v1.Param + matrix *v1.Matrix + }{{ + name: "missing-params", + rtr: &resources.ResolvedTask{ + TaskSpec: &task.Spec, + }, + params: []v1.Param{{ + Name: "foobar", + Value: *v1.NewStructuredValues("somethingfun"), + }}, + matrix: &v1.Matrix{ + Params: []v1.Param{{ + Name: "barfoo", + Value: *v1.NewStructuredValues("bar", "foo"), + }}, + }, + }, { + name: "invalid-type-in-params", + rtr: &resources.ResolvedTask{ + TaskSpec: &task.Spec, + }, + params: []v1.Param{{ + Name: "foo", + Value: *v1.NewStructuredValues("bar", "foo"), + }}, + }, { + name: "invalid-type-in-matrix", + rtr: &resources.ResolvedTask{ + TaskSpec: &task.Spec, + }, + matrix: &v1.Matrix{ + Params: []v1.Param{{ + Name: "bar", + Value: *v1.NewStructuredValues("bar", "foo"), + }}}, + }, { + name: "missing object param keys", + rtr: &resources.ResolvedTask{ + TaskSpec: &task.Spec, + }, + params: []v1.Param{{ + Name: "foo", + Value: *v1.NewStructuredValues("test"), + }, { + Name: "bar", + Value: *v1.NewStructuredValues("a", "b"), + }, { +>>>>>>> Stashed changes Name: "myObjWithoutDefault", - Value: *v1beta1.NewObject(map[string]string{ + Value: *v1.NewObject(map[string]string{ "key1": "val1", "misskey": "val2", }), +<<<<<<< Updated upstream +======= + }, { + Name: "myObjWithDefault", + Value: *v1.NewObject(map[string]string{ + "key3": "val3", + }), +>>>>>>> Stashed changes }}, matrix: &v1beta1.Matrix{}, wantErr: "invalid input params for task : missing keys for these params which are required in ParamSpec's properties map[myObjWithoutDefault:[key2]]", @@ -437,51 +582,51 @@ func TestValidateResolvedTask_InvalidParams(t *testing.T) { func TestValidateOverrides(t *testing.T) { tcs := []struct { name string - ts *v1beta1.TaskSpec - trs *v1beta1.TaskRunSpec + ts *v1.TaskSpec + trs *v1.TaskRunSpec wantErr bool }{{ name: "valid stepOverrides", - ts: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", }, { Name: "step2", }}, }, - trs: &v1beta1.TaskRunSpec{ - StepOverrides: []v1beta1.TaskRunStepOverride{{ + trs: &v1.TaskRunSpec{ + StepSpecs: []v1.TaskRunStepSpec{{ Name: "step1", }}, }, }, { name: "valid sidecarOverrides", - ts: &v1beta1.TaskSpec{ - Sidecars: []v1beta1.Sidecar{{ + ts: &v1.TaskSpec{ + Sidecars: []v1.Sidecar{{ Name: "step1", }, { Name: "step2", }}, }, - trs: &v1beta1.TaskRunSpec{ - SidecarOverrides: []v1beta1.TaskRunSidecarOverride{{ + trs: &v1.TaskRunSpec{ + SidecarSpecs: []v1.TaskRunSidecarSpec{{ Name: "step1", }}, }, }, { name: "invalid stepOverrides", - ts: &v1beta1.TaskSpec{}, - trs: &v1beta1.TaskRunSpec{ - StepOverrides: []v1beta1.TaskRunStepOverride{{ + ts: &v1.TaskSpec{}, + trs: &v1.TaskRunSpec{ + StepSpecs: []v1.TaskRunStepSpec{{ Name: "step1", }}, }, wantErr: true, }, { name: "invalid sidecarOverrides", - ts: &v1beta1.TaskSpec{}, - trs: &v1beta1.TaskRunSpec{ - SidecarOverrides: []v1beta1.TaskRunSidecarOverride{{ + ts: &v1.TaskSpec{}, + trs: &v1.TaskRunSpec{ + SidecarSpecs: []v1.TaskRunSidecarSpec{{ Name: "step1", }}, }, @@ -500,313 +645,313 @@ func TestValidateOverrides(t *testing.T) { func TestValidateResult(t *testing.T) { tcs := []struct { name string - tr *v1beta1.TaskRun - rtr *v1beta1.TaskSpec + tr *v1.TaskRun + rtr *v1.TaskSpec wantErr bool }{{ name: "valid taskrun spec results", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }, { Name: "array-result", - Type: v1beta1.ResultsTypeArray, + Type: v1.ResultsTypeArray, }, { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Properties: map[string]v1beta1.PropertySpec{"hello": {Type: "string"}}, + Type: v1.ResultsTypeObject, + Properties: map[string]v1.PropertySpec{"hello": {Type: "string"}}, }, }, }, }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("hello"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("hello"), }, { Name: "array-result", - Type: v1beta1.ResultsTypeArray, - Value: *v1beta1.NewStructuredValues("hello", "world"), + Type: v1.ResultsTypeArray, + Value: *v1.NewStructuredValues("hello", "world"), }, { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Value: *v1beta1.NewObject(map[string]string{"hello": "world"}), + Type: v1.ResultsTypeObject, + Value: *v1.NewObject(map[string]string{"hello": "world"}), }, }, }, }, }, - rtr: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{}, + rtr: &v1.TaskSpec{ + Results: []v1.TaskResult{}, }, wantErr: false, }, { name: "valid taskspec results", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }, { Name: "array-result", - Type: v1beta1.ResultsTypeArray, + Type: v1.ResultsTypeArray, }, { Name: "object-result", - Type: v1beta1.ResultsTypeObject, + Type: v1.ResultsTypeObject, }, }, }, }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("hello"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("hello"), }, { Name: "array-result", - Type: v1beta1.ResultsTypeArray, - Value: *v1beta1.NewStructuredValues("hello", "world"), + Type: v1.ResultsTypeArray, + Value: *v1.NewStructuredValues("hello", "world"), }, { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Value: *v1beta1.NewObject(map[string]string{"hello": "world"}), + Type: v1.ResultsTypeObject, + Value: *v1.NewObject(map[string]string{"hello": "world"}), }, }, }, }, }, - rtr: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{}, + rtr: &v1.TaskSpec{ + Results: []v1.TaskResult{}, }, wantErr: false, }, { name: "invalid taskrun spec results types", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }, { Name: "array-result", - Type: v1beta1.ResultsTypeArray, + Type: v1.ResultsTypeArray, }, { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Properties: map[string]v1beta1.PropertySpec{"hello": {Type: "string"}}, + Type: v1.ResultsTypeObject, + Properties: map[string]v1.PropertySpec{"hello": {Type: "string"}}, }, }, }, }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeArray, - Value: *v1beta1.NewStructuredValues("hello", "world"), + Type: v1.ResultsTypeArray, + Value: *v1.NewStructuredValues("hello", "world"), }, { Name: "array-result", - Type: v1beta1.ResultsTypeObject, - Value: *v1beta1.NewObject(map[string]string{"hello": "world"}), + Type: v1.ResultsTypeObject, + Value: *v1.NewObject(map[string]string{"hello": "world"}), }, { Name: "object-result", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("hello"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("hello"), }, }, }, }, }, - rtr: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{}, + rtr: &v1.TaskSpec{ + Results: []v1.TaskResult{}, }, wantErr: true, }, { name: "invalid taskspec results types", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{}, + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{}, }, }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeArray, - Value: *v1beta1.NewStructuredValues("hello", "world"), + Type: v1.ResultsTypeArray, + Value: *v1.NewStructuredValues("hello", "world"), }, { Name: "array-result", - Type: v1beta1.ResultsTypeObject, - Value: *v1beta1.NewObject(map[string]string{"hello": "world"}), + Type: v1.ResultsTypeObject, + Value: *v1.NewObject(map[string]string{"hello": "world"}), }, { Name: "object-result", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("hello"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("hello"), }, }, }, }, }, - rtr: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + rtr: &v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }, { Name: "array-result", - Type: v1beta1.ResultsTypeArray, + Type: v1.ResultsTypeArray, }, { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Properties: map[string]v1beta1.PropertySpec{"hello": {Type: "string"}}, + Type: v1.ResultsTypeObject, + Properties: map[string]v1.PropertySpec{"hello": {Type: "string"}}, }, }, }, wantErr: true, }, { name: "invalid taskrun spec results object properties", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Properties: map[string]v1beta1.PropertySpec{"world": {Type: "string"}}, + Type: v1.ResultsTypeObject, + Properties: map[string]v1.PropertySpec{"world": {Type: "string"}}, }, }, }, }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{ { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Value: *v1beta1.NewObject(map[string]string{"hello": "world"}), + Type: v1.ResultsTypeObject, + Value: *v1.NewObject(map[string]string{"hello": "world"}), }, }, }, }, }, - rtr: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{}, + rtr: &v1.TaskSpec{ + Results: []v1.TaskResult{}, }, wantErr: true, }, { name: "invalid taskspec results object properties", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{}, + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{}, }, }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{ { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Value: *v1beta1.NewObject(map[string]string{"hello": "world"}), + Type: v1.ResultsTypeObject, + Value: *v1.NewObject(map[string]string{"hello": "world"}), }, }, }, }, }, - rtr: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + rtr: &v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Properties: map[string]v1beta1.PropertySpec{"world": {Type: "string"}}, + Type: v1.ResultsTypeObject, + Properties: map[string]v1.PropertySpec{"world": {Type: "string"}}, }, }, }, wantErr: true, }, { name: "invalid taskrun spec results types with other valid types", - tr: &v1beta1.TaskRun{ - Spec: v1beta1.TaskRunSpec{ - TaskSpec: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{ + tr: &v1.TaskRun{ + Spec: v1.TaskRunSpec{ + TaskSpec: &v1.TaskSpec{ + Results: []v1.TaskResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeString, + Type: v1.ResultsTypeString, }, { Name: "array-result-1", - Type: v1beta1.ResultsTypeArray, + Type: v1.ResultsTypeArray, }, { Name: "array-result-2", - Type: v1beta1.ResultsTypeArray, + Type: v1.ResultsTypeArray, }, { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Properties: map[string]v1beta1.PropertySpec{"hello": {Type: "string"}}, + Type: v1.ResultsTypeObject, + Properties: map[string]v1.PropertySpec{"hello": {Type: "string"}}, }, }, }, }, - Status: v1beta1.TaskRunStatus{ - TaskRunStatusFields: v1beta1.TaskRunStatusFields{ - TaskRunResults: []v1beta1.TaskRunResult{ + Status: v1.TaskRunStatus{ + TaskRunStatusFields: v1.TaskRunStatusFields{ + Results: []v1.TaskRunResult{ { Name: "string-result", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues("hello"), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues("hello"), }, { Name: "array-result-1", - Type: v1beta1.ResultsTypeObject, - Value: *v1beta1.NewObject(map[string]string{"hello": "world"}), + Type: v1.ResultsTypeObject, + Value: *v1.NewObject(map[string]string{"hello": "world"}), }, { Name: "array-result-2", - Type: v1beta1.ResultsTypeString, - Value: *v1beta1.NewStructuredValues(""), + Type: v1.ResultsTypeString, + Value: *v1.NewStructuredValues(""), }, { Name: "object-result", - Type: v1beta1.ResultsTypeObject, - Value: *v1beta1.NewObject(map[string]string{"hello": "world"}), + Type: v1.ResultsTypeObject, + Value: *v1.NewObject(map[string]string{"hello": "world"}), }, }, }, }, }, - rtr: &v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{}, + rtr: &v1.TaskSpec{ + Results: []v1.TaskResult{}, }, wantErr: true, }} diff --git a/pkg/reconciler/testing/logger.go b/pkg/reconciler/testing/logger.go index a69aa30d164..501fa16fd89 100644 --- a/pkg/reconciler/testing/logger.go +++ b/pkg/reconciler/testing/logger.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" "go.uber.org/zap" "go.uber.org/zap/zaptest" @@ -59,7 +59,7 @@ func TestLogger(t *testing.T) *zap.SugaredLogger { func setupFakeContextWithLabelKey(t zaptest.TestingT) (context.Context, context.CancelFunc, []controller.Informer) { ctx, c := context.WithCancel(logtesting.TestContextWithLogger(t)) ctx = controller.WithEventRecorder(ctx, record.NewFakeRecorder(1000)) - ctx = filteredinformerfactory.WithSelectors(ctx, v1beta1.ManagedByLabelKey) + ctx = filteredinformerfactory.WithSelectors(ctx, v1.ManagedByLabelKey) ctx, is := injection.Fake.SetupInformers(ctx, &rest.Config{}) return ctx, c, is } @@ -68,7 +68,7 @@ func setupFakeContextWithLabelKey(t zaptest.TestingT) (context.Context, context. // The provided context includes the FilteredInformerFactory LabelKey. func setupDefaultContextWithLabelKey(t zaptest.TestingT) (context.Context, context.CancelFunc, []controller.Informer) { ctx, c := context.WithCancel(logtesting.TestContextWithLogger(t)) - ctx = filteredinformerfactory.WithSelectors(ctx, v1beta1.ManagedByLabelKey) + ctx = filteredinformerfactory.WithSelectors(ctx, v1.ManagedByLabelKey) ctx, is := injection.Default.SetupInformers(ctx, &rest.Config{}) return ctx, c, is } diff --git a/pkg/reconciler/volumeclaim/pvchandler.go b/pkg/reconciler/volumeclaim/pvchandler.go index 4e587ccebc4..ac4ff7450a7 100644 --- a/pkg/reconciler/volumeclaim/pvchandler.go +++ b/pkg/reconciler/volumeclaim/pvchandler.go @@ -21,7 +21,7 @@ import ( "crypto/sha256" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -38,7 +38,7 @@ const ( // PvcHandler is used to create PVCs for workspaces type PvcHandler interface { - CreatePersistentVolumeClaimsForWorkspaces(ctx context.Context, wb []v1beta1.WorkspaceBinding, ownerReference metav1.OwnerReference, namespace string) error + CreatePersistentVolumeClaimsForWorkspaces(ctx context.Context, wb []v1.WorkspaceBinding, ownerReference metav1.OwnerReference, namespace string) error } type defaultPVCHandler struct { @@ -55,7 +55,7 @@ func NewPVCHandler(clientset clientset.Interface, logger *zap.SugaredLogger) Pvc // where claim-name is provided by the user in the volumeClaimTemplate, and owner-name is the name of the // resource with the volumeClaimTemplate declared, a PipelineRun or TaskRun. If the PVC did not exist, a new PVC // with that name is created with the provided OwnerReference. -func (c *defaultPVCHandler) CreatePersistentVolumeClaimsForWorkspaces(ctx context.Context, wb []v1beta1.WorkspaceBinding, ownerReference metav1.OwnerReference, namespace string) error { +func (c *defaultPVCHandler) CreatePersistentVolumeClaimsForWorkspaces(ctx context.Context, wb []v1.WorkspaceBinding, ownerReference metav1.OwnerReference, namespace string) error { var errs []error for _, claim := range getPersistentVolumeClaims(wb, ownerReference, namespace) { _, err := c.clientset.CoreV1().PersistentVolumeClaims(claim.Namespace).Get(ctx, claim.Name, metav1.GetOptions{}) @@ -81,7 +81,7 @@ func (c *defaultPVCHandler) CreatePersistentVolumeClaimsForWorkspaces(ctx contex return errorutils.NewAggregate(errs) } -func getPersistentVolumeClaims(workspaceBindings []v1beta1.WorkspaceBinding, ownerReference metav1.OwnerReference, namespace string) map[string]*corev1.PersistentVolumeClaim { +func getPersistentVolumeClaims(workspaceBindings []v1.WorkspaceBinding, ownerReference metav1.OwnerReference, namespace string) map[string]*corev1.PersistentVolumeClaim { claims := make(map[string]*corev1.PersistentVolumeClaim) for _, workspaceBinding := range workspaceBindings { if workspaceBinding.VolumeClaimTemplate == nil { @@ -102,7 +102,7 @@ func getPersistentVolumeClaims(workspaceBindings []v1beta1.WorkspaceBinding, own // workspaceBinding name and ownerReference UID - because it is first used for creating a PVC and later, // possibly several TaskRuns to lookup the PVC to mount. // We use ownerReference UID over ownerReference name to distinguish runs with the same name. -func GetPersistentVolumeClaimName(claim *corev1.PersistentVolumeClaim, wb v1beta1.WorkspaceBinding, owner metav1.OwnerReference) string { +func GetPersistentVolumeClaimName(claim *corev1.PersistentVolumeClaim, wb v1.WorkspaceBinding, owner metav1.OwnerReference) string { if claim.Name == "" { return fmt.Sprintf("%s-%s", "pvc", getPersistentVolumeClaimIdentity(wb.Name, string(owner.UID))) } diff --git a/pkg/reconciler/volumeclaim/pvchandler_test.go b/pkg/reconciler/volumeclaim/pvchandler_test.go index 7c4f09cd0a2..4bcb2665e74 100644 --- a/pkg/reconciler/volumeclaim/pvchandler_test.go +++ b/pkg/reconciler/volumeclaim/pvchandler_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -50,7 +50,7 @@ func TestCreatePersistentVolumeClaimsForWorkspaces(t *testing.T) { claimName1 := "pvc1" ws1 := "myws1" ownerName := "taskrun1" - workspaces := []v1beta1.WorkspaceBinding{{ + workspaces := []v1.WorkspaceBinding{{ Name: ws1, VolumeClaimTemplate: &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ @@ -130,7 +130,7 @@ func TestCreatePersistentVolumeClaimsForWorkspacesWithoutMetadata(t *testing.T) // workspace with volumeClaimTemplate without metadata workspaceName := "ws-with-volume-claim-template-without-metadata" ownerName := "taskrun1" - workspaces := []v1beta1.WorkspaceBinding{{ + workspaces := []v1.WorkspaceBinding{{ Name: workspaceName, VolumeClaimTemplate: &corev1.PersistentVolumeClaim{ Spec: corev1.PersistentVolumeClaimSpec{}, @@ -171,7 +171,7 @@ func TestCreatePersistentVolumeClaimsForWorkspacesWithoutMetadata(t *testing.T) func TestCreateExistPersistentVolumeClaims(t *testing.T) { workspaceName := "ws-with-volume-claim-template" ownerName := "taskrun1" - workspaces := []v1beta1.WorkspaceBinding{{ + workspaces := []v1.WorkspaceBinding{{ Name: workspaceName, VolumeClaimTemplate: &corev1.PersistentVolumeClaim{ Spec: corev1.PersistentVolumeClaimSpec{}, diff --git a/pkg/remote/oci/resolver.go b/pkg/remote/oci/resolver.go index d55f4a88d1f..07d5b281937 100644 --- a/pkg/remote/oci/resolver.go +++ b/pkg/remote/oci/resolver.go @@ -28,7 +28,7 @@ import ( imgname "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" ociremote "github.com/google/go-containerregistry/pkg/v1/remote" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme" "github.com/tektoncd/pipeline/pkg/remote" "k8s.io/apimachinery/pkg/runtime" @@ -89,7 +89,7 @@ func (o *Resolver) List(ctx context.Context) ([]remote.ResolvedObject, error) { } // Get retrieves a specific object with the given Kind and name -func (o *Resolver) Get(ctx context.Context, kind, name string) (runtime.Object, *v1beta1.ConfigSource, error) { +func (o *Resolver) Get(ctx context.Context, kind, name string) (runtime.Object, *pipelinev1.ConfigSource, error) { timeoutCtx, cancel := context.WithTimeout(ctx, o.timeout) defer cancel() img, err := o.retrieveImage(timeoutCtx) diff --git a/pkg/remote/resolution/resolver.go b/pkg/remote/resolution/resolver.go index 925f735864e..318805c85ad 100644 --- a/pkg/remote/resolution/resolver.go +++ b/pkg/remote/resolution/resolver.go @@ -18,7 +18,7 @@ import ( "errors" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme" "github.com/tektoncd/pipeline/pkg/remote" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" @@ -35,7 +35,7 @@ type Resolver struct { requester remoteresource.Requester owner kmeta.OwnerRefable resolverName string - params []v1beta1.Param + params []v1.Param targetName string targetNamespace string } @@ -44,7 +44,7 @@ var _ remote.Resolver = &Resolver{} // NewResolver returns an implementation of remote.Resolver capable // of performing asynchronous remote resolution. -func NewResolver(requester remoteresource.Requester, owner kmeta.OwnerRefable, resolverName string, targetName string, targetNamespace string, params []v1beta1.Param) remote.Resolver { +func NewResolver(requester remoteresource.Requester, owner kmeta.OwnerRefable, resolverName string, targetName string, targetNamespace string, params []v1.Param) remote.Resolver { return &Resolver{ requester: requester, owner: owner, @@ -56,7 +56,7 @@ func NewResolver(requester remoteresource.Requester, owner kmeta.OwnerRefable, r } // Get implements remote.Resolver. -func (resolver *Resolver) Get(ctx context.Context, _, _ string) (runtime.Object, *v1beta1.ConfigSource, error) { +func (resolver *Resolver) Get(ctx context.Context, _, _ string) (runtime.Object, *v1.ConfigSource, error) { resolverName := remoteresource.ResolverName(resolver.resolverName) req, err := buildRequest(resolver.resolverName, resolver.owner, resolver.targetName, resolver.targetNamespace, resolver.params) if err != nil { @@ -88,7 +88,7 @@ func (resolver *Resolver) List(_ context.Context) ([]remote.ResolvedObject, erro return nil, nil } -func buildRequest(resolverName string, owner kmeta.OwnerRefable, name string, namespace string, params []v1beta1.Param) (*resolutionRequest, error) { +func buildRequest(resolverName string, owner kmeta.OwnerRefable, name string, namespace string, params []v1.Param) (*resolutionRequest, error) { if name == "" { name = owner.GetObjectMeta().GetName() namespace = owner.GetObjectMeta().GetNamespace() diff --git a/pkg/remote/resolver.go b/pkg/remote/resolver.go index 8f706f565f8..8de55dda112 100644 --- a/pkg/remote/resolver.go +++ b/pkg/remote/resolver.go @@ -16,7 +16,7 @@ package remote import ( "context" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -32,5 +32,5 @@ type ResolvedObject struct { // - Get: retrieves a specific object with the given Kind and name, and the source identifying where the resource came from. type Resolver interface { List(ctx context.Context) ([]ResolvedObject, error) - Get(ctx context.Context, kind, name string) (runtime.Object, *v1beta1.ConfigSource, error) + Get(ctx context.Context, kind, name string) (runtime.Object, *v1.ConfigSource, error) } diff --git a/pkg/resolution/resolver/bundle/bundle.go b/pkg/resolution/resolver/bundle/bundle.go index ea23787587a..fe9abaa7c1f 100644 --- a/pkg/resolution/resolver/bundle/bundle.go +++ b/pkg/resolution/resolver/bundle/bundle.go @@ -24,8 +24,7 @@ import ( "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/remote" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" ) @@ -47,7 +46,7 @@ type RequestOptions struct { type ResolvedResource struct { data []byte annotations map[string]string - source *pipelinev1beta1.ConfigSource + source *pipelinev1.ConfigSource } var _ framework.ResolvedResource = &ResolvedResource{} @@ -65,7 +64,7 @@ func (br *ResolvedResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (br *ResolvedResource) Source() *pipelinev1beta1.ConfigSource { +func (br *ResolvedResource) Source() *pipelinev1.ConfigSource { return br.source } @@ -122,7 +121,7 @@ func GetEntry(ctx context.Context, keychain authn.Keychain, opts RequestOptions) ResolverAnnotationName: lName, ResolverAnnotationAPIVersion: l.Annotations[BundleAnnotationAPIVersion], }, - source: &v1beta1.ConfigSource{ + source: &pipelinev1.ConfigSource{ URI: uri, Digest: map[string]string{ h.Algorithm: h.Hex, diff --git a/pkg/resolution/resolver/bundle/params.go b/pkg/resolution/resolver/bundle/params.go index 729fb030114..207a959ad4b 100644 --- a/pkg/resolution/resolver/bundle/params.go +++ b/pkg/resolution/resolver/bundle/params.go @@ -18,7 +18,7 @@ import ( "fmt" "github.com/google/go-containerregistry/pkg/name" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" ) @@ -39,11 +39,11 @@ const ParamKind = "kind" // OptionsFromParams parses the params from a resolution request and // converts them into options to pass as part of a bundle request. -func OptionsFromParams(ctx context.Context, params []pipelinev1beta1.Param) (RequestOptions, error) { +func OptionsFromParams(ctx context.Context, params []pipelinev1.Param) (RequestOptions, error) { opts := RequestOptions{} conf := framework.GetResolverConfigFromContext(ctx) - paramsMap := make(map[string]pipelinev1beta1.ParamValue) + paramsMap := make(map[string]pipelinev1.ParamValue) for _, p := range params { paramsMap[p.Name] = p.Value } diff --git a/pkg/resolution/resolver/bundle/resolver.go b/pkg/resolution/resolver/bundle/resolver.go index 5a9ae84f3a5..3cd270a00b6 100644 --- a/pkg/resolution/resolver/bundle/resolver.go +++ b/pkg/resolution/resolver/bundle/resolver.go @@ -23,7 +23,7 @@ import ( "github.com/google/go-containerregistry/pkg/authn/k8schain" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" "k8s.io/client-go/kubernetes" @@ -74,7 +74,7 @@ func (r *Resolver) GetSelector(context.Context) map[string]string { } // ValidateParams ensures parameters from a request are as expected. -func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { +func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1.Param) error { if r.isDisabled(ctx) { return errors.New(disabledError) } @@ -85,7 +85,7 @@ func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1. } // Resolve uses the given params to resolve the requested file or resource. -func (r *Resolver) Resolve(ctx context.Context, params []pipelinev1beta1.Param) (framework.ResolvedResource, error) { +func (r *Resolver) Resolve(ctx context.Context, params []pipelinev1.Param) (framework.ResolvedResource, error) { if r.isDisabled(ctx) { return nil, errors.New(disabledError) } diff --git a/pkg/resolution/resolver/bundle/resolver_test.go b/pkg/resolution/resolver/bundle/resolver_test.go index b950dd27872..73ab9b713ad 100644 --- a/pkg/resolution/resolver/bundle/resolver_test.go +++ b/pkg/resolution/resolver/bundle/resolver_test.go @@ -28,6 +28,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-containerregistry/pkg/registry" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" @@ -57,36 +58,36 @@ func TestGetSelector(t *testing.T) { func TestValidateParams(t *testing.T) { resolver := Resolver{} - paramsWithTask := []pipelinev1beta1.Param{{ + paramsWithTask := []pipelinev1.Param{{ Name: ParamKind, - Value: *pipelinev1beta1.NewStructuredValues("task"), + Value: *pipelinev1.NewStructuredValues("task"), }, { Name: ParamName, - Value: *pipelinev1beta1.NewStructuredValues("foo"), + Value: *pipelinev1.NewStructuredValues("foo"), }, { Name: ParamBundle, - Value: *pipelinev1beta1.NewStructuredValues("bar"), + Value: *pipelinev1.NewStructuredValues("bar"), }, { Name: ParamServiceAccount, - Value: *pipelinev1beta1.NewStructuredValues("baz"), + Value: *pipelinev1.NewStructuredValues("baz"), }} if err := resolver.ValidateParams(context.Background(), paramsWithTask); err != nil { t.Fatalf("unexpected error validating params: %v", err) } - paramsWithPipeline := []pipelinev1beta1.Param{{ + paramsWithPipeline := []pipelinev1.Param{{ Name: ParamKind, - Value: *pipelinev1beta1.NewStructuredValues("pipeline"), + Value: *pipelinev1.NewStructuredValues("pipeline"), }, { Name: ParamName, - Value: *pipelinev1beta1.NewStructuredValues("foo"), + Value: *pipelinev1.NewStructuredValues("foo"), }, { Name: ParamBundle, - Value: *pipelinev1beta1.NewStructuredValues("bar"), + Value: *pipelinev1.NewStructuredValues("bar"), }, { Name: ParamServiceAccount, - Value: *pipelinev1beta1.NewStructuredValues("baz"), + Value: *pipelinev1.NewStructuredValues("baz"), }} if err := resolver.ValidateParams(context.Background(), paramsWithPipeline); err != nil { t.Fatalf("unexpected error validating params: %v", err) @@ -98,18 +99,18 @@ func TestValidateParamsDisabled(t *testing.T) { var err error - params := []pipelinev1beta1.Param{{ + params := []pipelinev1.Param{{ Name: ParamKind, - Value: *pipelinev1beta1.NewStructuredValues("task"), + Value: *pipelinev1.NewStructuredValues("task"), }, { Name: ParamName, - Value: *pipelinev1beta1.NewStructuredValues("foo"), + Value: *pipelinev1.NewStructuredValues("foo"), }, { Name: ParamBundle, - Value: *pipelinev1beta1.NewStructuredValues("bar"), + Value: *pipelinev1.NewStructuredValues("bar"), }, { Name: ParamServiceAccount, - Value: *pipelinev1beta1.NewStructuredValues("baz"), + Value: *pipelinev1.NewStructuredValues("baz"), }} err = resolver.ValidateParams(resolverDisabledContext(), params) if err == nil { @@ -126,30 +127,30 @@ func TestValidateParamsMissing(t *testing.T) { var err error - paramsMissingBundle := []pipelinev1beta1.Param{{ + paramsMissingBundle := []pipelinev1.Param{{ Name: ParamKind, - Value: *pipelinev1beta1.NewStructuredValues("task"), + Value: *pipelinev1.NewStructuredValues("task"), }, { Name: ParamName, - Value: *pipelinev1beta1.NewStructuredValues("foo"), + Value: *pipelinev1.NewStructuredValues("foo"), }, { Name: ParamServiceAccount, - Value: *pipelinev1beta1.NewStructuredValues("baz"), + Value: *pipelinev1.NewStructuredValues("baz"), }} err = resolver.ValidateParams(context.Background(), paramsMissingBundle) if err == nil { t.Fatalf("expected missing kind err") } - paramsMissingName := []pipelinev1beta1.Param{{ + paramsMissingName := []pipelinev1.Param{{ Name: ParamKind, - Value: *pipelinev1beta1.NewStructuredValues("task"), + Value: *pipelinev1.NewStructuredValues("task"), }, { Name: ParamBundle, - Value: *pipelinev1beta1.NewStructuredValues("bar"), + Value: *pipelinev1.NewStructuredValues("bar"), }, { Name: ParamServiceAccount, - Value: *pipelinev1beta1.NewStructuredValues("baz"), + Value: *pipelinev1.NewStructuredValues("baz"), }} err = resolver.ValidateParams(context.Background(), paramsMissingName) if err == nil { @@ -162,18 +163,18 @@ func TestResolveDisabled(t *testing.T) { var err error - params := []pipelinev1beta1.Param{{ + params := []pipelinev1.Param{{ Name: ParamKind, - Value: *pipelinev1beta1.NewStructuredValues("task"), + Value: *pipelinev1.NewStructuredValues("task"), }, { Name: ParamName, - Value: *pipelinev1beta1.NewStructuredValues("foo"), + Value: *pipelinev1.NewStructuredValues("foo"), }, { Name: ParamBundle, - Value: *pipelinev1beta1.NewStructuredValues("bar"), + Value: *pipelinev1.NewStructuredValues("bar"), }, { Name: ParamServiceAccount, - Value: *pipelinev1beta1.NewStructuredValues("baz"), + Value: *pipelinev1.NewStructuredValues("baz"), }} _, err = resolver.Resolve(resolverDisabledContext(), params) if err == nil { @@ -441,7 +442,7 @@ func TestResolve(t *testing.T) { expectedStatus.Annotations[ResolverAnnotationName] = tc.args.name expectedStatus.Annotations[ResolverAnnotationAPIVersion] = "v1beta1" - expectedStatus.Source = &pipelinev1beta1.ConfigSource{ + expectedStatus.Source = &pipelinev1.ConfigSource{ URI: testImages[tc.imageName].uri, Digest: map[string]string{ testImages[tc.imageName].algo: testImages[tc.imageName].hex, @@ -474,18 +475,18 @@ func createRequest(p *params) *v1beta1.ResolutionRequest { }, }, Spec: v1beta1.ResolutionRequestSpec{ - Params: []pipelinev1beta1.Param{{ + Params: []pipelinev1.Param{{ Name: ParamBundle, - Value: *pipelinev1beta1.NewStructuredValues(p.bundle), + Value: *pipelinev1.NewStructuredValues(p.bundle), }, { Name: ParamName, - Value: *pipelinev1beta1.NewStructuredValues(p.name), + Value: *pipelinev1.NewStructuredValues(p.name), }, { Name: ParamKind, - Value: *pipelinev1beta1.NewStructuredValues(p.kind), + Value: *pipelinev1.NewStructuredValues(p.kind), }, { Name: ParamServiceAccount, - Value: *pipelinev1beta1.NewStructuredValues(p.serviceAccount), + Value: *pipelinev1.NewStructuredValues(p.serviceAccount), }}, }, } diff --git a/pkg/resolution/resolver/cluster/resolver.go b/pkg/resolution/resolver/cluster/resolver.go index 355455b70fb..04d089ad08c 100644 --- a/pkg/resolution/resolver/cluster/resolver.go +++ b/pkg/resolution/resolver/cluster/resolver.go @@ -25,7 +25,7 @@ import ( "strings" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" pipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client" @@ -79,7 +79,7 @@ func (r *Resolver) GetSelector(_ context.Context) map[string]string { // ValidateParams returns an error if the given parameter map is not // valid for a resource request targeting the cluster resolver. -func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { +func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1.Param) error { if r.isDisabled(ctx) { return errors.New(disabledError) } @@ -90,7 +90,7 @@ func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1. // Resolve performs the work of fetching a resource from a namespace with the given // parameters. -func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1beta1.Param) (framework.ResolvedResource, error) { +func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1.Param) (framework.ResolvedResource, error) { if r.isDisabled(ctx) { return nil, errors.New(disabledError) } @@ -210,12 +210,12 @@ func (r *ResolvedClusterResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (r ResolvedClusterResource) Source() *pipelinev1beta1.ConfigSource { +func (r ResolvedClusterResource) Source() *pipelinev1.ConfigSource { h := sha256.New() h.Write(r.Spec) sha256CheckSum := hex.EncodeToString(h.Sum(nil)) - return &v1beta1.ConfigSource{ + return &pipelinev1.ConfigSource{ URI: r.Identifier, Digest: map[string]string{ "sha256": sha256CheckSum, @@ -223,10 +223,10 @@ func (r ResolvedClusterResource) Source() *pipelinev1beta1.ConfigSource { } } -func populateParamsWithDefaults(ctx context.Context, origParams []pipelinev1beta1.Param) (map[string]string, error) { +func populateParamsWithDefaults(ctx context.Context, origParams []pipelinev1.Param) (map[string]string, error) { conf := framework.GetResolverConfigFromContext(ctx) - paramsMap := make(map[string]pipelinev1beta1.ParamValue) + paramsMap := make(map[string]pipelinev1.ParamValue) for _, p := range origParams { paramsMap[p.Name] = p.Value } diff --git a/pkg/resolution/resolver/cluster/resolver_test.go b/pkg/resolution/resolver/cluster/resolver_test.go index 7518f8874d7..bafabfea633 100644 --- a/pkg/resolution/resolver/cluster/resolver_test.go +++ b/pkg/resolution/resolver/cluster/resolver_test.go @@ -28,6 +28,7 @@ import ( "github.com/google/go-cmp/cmp" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" @@ -58,15 +59,15 @@ func TestGetSelector(t *testing.T) { func TestValidateParams(t *testing.T) { resolver := Resolver{} - params := []pipelinev1beta1.Param{{ + params := []pipelinev1.Param{{ Name: KindParam, - Value: *pipelinev1beta1.NewStructuredValues("task"), + Value: *pipelinev1.NewStructuredValues("task"), }, { Name: NamespaceParam, - Value: *pipelinev1beta1.NewStructuredValues("foo"), + Value: *pipelinev1.NewStructuredValues("foo"), }, { Name: NameParam, - Value: *pipelinev1beta1.NewStructuredValues("baz"), + Value: *pipelinev1.NewStructuredValues("baz"), }} ctx := framework.InjectResolverConfigToContext(context.Background(), map[string]string{ @@ -84,15 +85,15 @@ func TestValidateParamsNotEnabled(t *testing.T) { var err error - params := []pipelinev1beta1.Param{{ + params := []pipelinev1.Param{{ Name: KindParam, - Value: *pipelinev1beta1.NewStructuredValues("task"), + Value: *pipelinev1.NewStructuredValues("task"), }, { Name: NamespaceParam, - Value: *pipelinev1beta1.NewStructuredValues("foo"), + Value: *pipelinev1.NewStructuredValues("foo"), }, { Name: NameParam, - Value: *pipelinev1beta1.NewStructuredValues("baz"), + Value: *pipelinev1.NewStructuredValues("baz"), }} err = resolver.ValidateParams(resolverDisabledContext(), params) if err == nil { @@ -165,11 +166,11 @@ func TestValidateParamsFailure(t *testing.T) { ctx = framework.InjectResolverConfigToContext(ctx, tc.conf) } - var asParams []pipelinev1beta1.Param + var asParams []pipelinev1.Param for k, v := range tc.params { - asParams = append(asParams, pipelinev1beta1.Param{ + asParams = append(asParams, pipelinev1.Param{ Name: k, - Value: *pipelinev1beta1.NewStructuredValues(v), + Value: *pipelinev1.NewStructuredValues(v), }) } err := resolver.ValidateParams(ctx, asParams) @@ -186,7 +187,7 @@ func TestValidateParamsFailure(t *testing.T) { func TestResolve(t *testing.T) { defaultNS := "pipeline-ns" - exampleTask := &pipelinev1beta1.Task{ + exampleTask := &pipelinev1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "example-task", Namespace: "task-ns", @@ -195,10 +196,10 @@ func TestResolve(t *testing.T) { }, TypeMeta: metav1.TypeMeta{ Kind: string(pipelinev1beta1.NamespacedTaskKind), - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", }, - Spec: pipelinev1beta1.TaskSpec{ - Steps: []pipelinev1beta1.Step{{ + Spec: pipelinev1.TaskSpec{ + Steps: []pipelinev1.Step{{ Name: "some-step", Image: "some-image", Command: []string{"something"}, @@ -214,7 +215,7 @@ func TestResolve(t *testing.T) { t.Fatalf("couldn't marshal task spec: %v", err) } - examplePipeline := &pipelinev1beta1.Pipeline{ + examplePipeline := &pipelinev1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: "example-pipeline", Namespace: defaultNS, @@ -225,12 +226,12 @@ func TestResolve(t *testing.T) { Kind: "Pipeline", APIVersion: "tekton.dev/v1beta1", }, - Spec: pipelinev1beta1.PipelineSpec{ - Tasks: []pipelinev1beta1.PipelineTask{{ + Spec: pipelinev1.PipelineSpec{ + Tasks: []pipelinev1.PipelineTask{{ Name: "some-pipeline-task", - TaskRef: &pipelinev1beta1.TaskRef{ + TaskRef: &pipelinev1.TaskRef{ Name: "some-task", - Kind: pipelinev1beta1.NamespacedTaskKind, + Kind: pipelinev1.NamespacedTaskKind, }, }}, }, @@ -263,8 +264,8 @@ func TestResolve(t *testing.T) { Status: duckv1.Status{}, ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString(taskAsYAML), - Source: &pipelinev1beta1.ConfigSource{ - URI: "/apis/tekton.dev/v1beta1/namespaces/task-ns/task/example-task@a123", + Source: &pipelinev1.ConfigSource{ + URI: "/apis/tekton.dev/v1/namespaces/task-ns/task/example-task@a123", Digest: map[string]string{ "sha256": sha256CheckSum(taskSpec), }, @@ -280,8 +281,8 @@ func TestResolve(t *testing.T) { Status: duckv1.Status{}, ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString(pipelineAsYAML), - Source: &pipelinev1beta1.ConfigSource{ - URI: "/apis/tekton.dev/v1beta1/namespaces/pipeline-ns/pipeline/example-pipeline@b123", + Source: &pipelinev1.ConfigSource{ + URI: "/apis/tekton.dev/v1/namespaces/pipeline-ns/pipeline/example-pipeline@b123", Digest: map[string]string{ "sha256": sha256CheckSum(pipelineSpec), }, @@ -296,8 +297,8 @@ func TestResolve(t *testing.T) { Status: duckv1.Status{}, ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString(pipelineAsYAML), - Source: &pipelinev1beta1.ConfigSource{ - URI: "/apis/tekton.dev/v1beta1/namespaces/pipeline-ns/pipeline/example-pipeline@b123", + Source: &pipelinev1.ConfigSource{ + URI: "/apis/tekton.dev/v1/namespaces/pipeline-ns/pipeline/example-pipeline@b123", Digest: map[string]string{ "sha256": sha256CheckSum(pipelineSpec), }, @@ -312,8 +313,8 @@ func TestResolve(t *testing.T) { Status: duckv1.Status{}, ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString(taskAsYAML), - Source: &pipelinev1beta1.ConfigSource{ - URI: "/apis/tekton.dev/v1beta1/namespaces/task-ns/task/example-task@a123", + Source: &pipelinev1.ConfigSource{ + URI: "/apis/tekton.dev/v1/namespaces/task-ns/task/example-task@a123", Digest: map[string]string{ "sha256": sha256CheckSum(taskSpec), }, @@ -389,9 +390,9 @@ func TestResolve(t *testing.T) { "enable-cluster-resolver": "true", }, }}, - Pipelines: []*pipelinev1beta1.Pipeline{examplePipeline}, + Pipelines: []*pipelinev1.Pipeline{examplePipeline}, ResolutionRequests: []*v1beta1.ResolutionRequest{request}, - Tasks: []*pipelinev1beta1.Task{exampleTask}, + Tasks: []*pipelinev1.Task{exampleTask}, } resolver := &Resolver{} @@ -401,7 +402,7 @@ func TestResolve(t *testing.T) { expectedStatus = tc.expectedStatus.DeepCopy() if tc.expectedErr == nil { - reqParams := make(map[string]pipelinev1beta1.ParamValue) + reqParams := make(map[string]pipelinev1.ParamValue) for _, p := range request.Spec.Params { reqParams[p.Name] = p.Value } @@ -439,22 +440,22 @@ func createRequest(kind, name, namespace string) *v1beta1.ResolutionRequest { }, }, Spec: v1beta1.ResolutionRequestSpec{ - Params: []pipelinev1beta1.Param{{ + Params: []pipelinev1.Param{{ Name: NameParam, - Value: *pipelinev1beta1.NewStructuredValues(name), + Value: *pipelinev1.NewStructuredValues(name), }}, }, } if kind != "" { - rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + rr.Spec.Params = append(rr.Spec.Params, pipelinev1.Param{ Name: KindParam, - Value: *pipelinev1beta1.NewStructuredValues(kind), + Value: *pipelinev1.NewStructuredValues(kind), }) } if namespace != "" { - rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + rr.Spec.Params = append(rr.Spec.Params, pipelinev1.Param{ Name: NamespaceParam, - Value: *pipelinev1beta1.NewStructuredValues(namespace), + Value: *pipelinev1.NewStructuredValues(namespace), }) } diff --git a/pkg/resolution/resolver/framework/fakeresolver.go b/pkg/resolution/resolver/framework/fakeresolver.go index f8fc4cd58ad..ab8441af0d6 100644 --- a/pkg/resolution/resolver/framework/fakeresolver.go +++ b/pkg/resolution/resolver/framework/fakeresolver.go @@ -23,7 +23,7 @@ import ( "strings" "time" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" ) @@ -50,7 +50,7 @@ var _ Resolver = &FakeResolver{} type FakeResolvedResource struct { Content string AnnotationMap map[string]string - ContentSource *pipelinev1beta1.ConfigSource + ContentSource *pipelinev1.ConfigSource ErrorWith string WaitFor time.Duration } @@ -67,7 +67,7 @@ func (f *FakeResolvedResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (f *FakeResolvedResource) Source() *pipelinev1beta1.ConfigSource { +func (f *FakeResolvedResource) Source() *pipelinev1.ConfigSource { return f.ContentSource } @@ -102,8 +102,8 @@ func (r *FakeResolver) GetSelector(_ context.Context) map[string]string { // ValidateParams returns an error if the given parameter map is not // valid for a resource request targeting the fake resolver. -func (r *FakeResolver) ValidateParams(_ context.Context, params []pipelinev1beta1.Param) error { - paramsMap := make(map[string]pipelinev1beta1.ParamValue) +func (r *FakeResolver) ValidateParams(_ context.Context, params []pipelinev1.Param) error { + paramsMap := make(map[string]pipelinev1.ParamValue) for _, p := range params { paramsMap[p.Name] = p.Value } @@ -131,8 +131,8 @@ func (r *FakeResolver) ValidateParams(_ context.Context, params []pipelinev1beta // Resolve performs the work of fetching a file from the fake resolver given a map of // parameters. -func (r *FakeResolver) Resolve(_ context.Context, params []pipelinev1beta1.Param) (ResolvedResource, error) { - paramsMap := make(map[string]pipelinev1beta1.ParamValue) +func (r *FakeResolver) Resolve(_ context.Context, params []pipelinev1.Param) (ResolvedResource, error) { + paramsMap := make(map[string]pipelinev1.ParamValue) for _, p := range params { paramsMap[p.Name] = p.Value } diff --git a/pkg/resolution/resolver/framework/interface.go b/pkg/resolution/resolver/framework/interface.go index 979ec54bee5..a4855461e35 100644 --- a/pkg/resolution/resolver/framework/interface.go +++ b/pkg/resolution/resolver/framework/interface.go @@ -20,7 +20,7 @@ import ( "context" "time" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" ) // Resolver is the interface to implement for type-specific resource @@ -41,7 +41,7 @@ type Resolver interface { // ValidateParams is given the parameters from a resource // request and should return an error if any are missing or invalid. - ValidateParams(context.Context, []pipelinev1beta1.Param) error + ValidateParams(context.Context, []pipelinev1.Param) error // Resolve receives the parameters passed via a resource request // and returns the resolved data along with any annotations @@ -49,7 +49,7 @@ type Resolver interface { // should be returned instead. If a resolution.Error // is returned then its Reason and Message are used as part of the // response to the request. - Resolve(context.Context, []pipelinev1beta1.Param) (ResolvedResource, error) + Resolve(context.Context, []pipelinev1.Param) (ResolvedResource, error) } // ConfigWatcher is the interface to implement if your resolver accepts @@ -96,5 +96,5 @@ type TimedResolution interface { type ResolvedResource interface { Data() []byte Annotations() map[string]string - Source() *pipelinev1beta1.ConfigSource + Source() *pipelinev1.ConfigSource } diff --git a/pkg/resolution/resolver/framework/reconciler.go b/pkg/resolution/resolver/framework/reconciler.go index 8f1242a3fd2..3b03e5721b7 100644 --- a/pkg/resolution/resolver/framework/reconciler.go +++ b/pkg/resolution/resolver/framework/reconciler.go @@ -24,7 +24,7 @@ import ( "fmt" "time" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" rrclient "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" rrv1beta1 "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1beta1" @@ -194,9 +194,9 @@ func (r *Reconciler) MarkFailed(ctx context.Context, rr *v1beta1.ResolutionReque // a ResolutionRequest with its data and annotations once successfully // resolved. type statusDataPatch struct { - Annotations map[string]string `json:"annotations"` - Data string `json:"data"` - Source *pipelinev1beta1.ConfigSource `json:"source"` + Annotations map[string]string `json:"annotations"` + Data string `json:"data"` + Source *pipelinev1.ConfigSource `json:"source"` } func (r *Reconciler) writeResolvedData(ctx context.Context, rr *v1beta1.ResolutionRequest, resource ResolvedResource) error { diff --git a/pkg/resolution/resolver/framework/reconciler_test.go b/pkg/resolution/resolver/framework/reconciler_test.go index f8f583ac895..736a3715186 100644 --- a/pkg/resolution/resolver/framework/reconciler_test.go +++ b/pkg/resolution/resolver/framework/reconciler_test.go @@ -26,7 +26,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" @@ -78,9 +78,9 @@ func TestReconcile(t *testing.T) { }, }, Spec: v1beta1.ResolutionRequestSpec{ - Params: []pipelinev1beta1.Param{{ + Params: []pipelinev1.Param{{ Name: FakeParamName, - Value: *pipelinev1beta1.NewStructuredValues("bar"), + Value: *pipelinev1.NewStructuredValues("bar"), }}, }, Status: v1beta1.ResolutionRequestStatus{}, @@ -102,9 +102,9 @@ func TestReconcile(t *testing.T) { }, }, Spec: v1beta1.ResolutionRequestSpec{ - Params: []pipelinev1beta1.Param{{ + Params: []pipelinev1.Param{{ Name: FakeParamName, - Value: *pipelinev1beta1.NewStructuredValues("bar"), + Value: *pipelinev1.NewStructuredValues("bar"), }}, }, Status: v1beta1.ResolutionRequestStatus{}, @@ -113,7 +113,7 @@ func TestReconcile(t *testing.T) { "bar": { Content: "some content", AnnotationMap: map[string]string{"foo": "bar"}, - ContentSource: &pipelinev1beta1.ConfigSource{ + ContentSource: &pipelinev1.ConfigSource{ URI: "https://abc.com", Digest: map[string]string{ "sha1": "xyz", @@ -130,7 +130,7 @@ func TestReconcile(t *testing.T) { }, ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString([]byte("some content")), - Source: &pipelinev1beta1.ConfigSource{ + Source: &pipelinev1.ConfigSource{ URI: "https://abc.com", Digest: map[string]string{ "sha1": "xyz", @@ -155,9 +155,9 @@ func TestReconcile(t *testing.T) { }, }, Spec: v1beta1.ResolutionRequestSpec{ - Params: []pipelinev1beta1.Param{{ + Params: []pipelinev1.Param{{ Name: FakeParamName, - Value: *pipelinev1beta1.NewStructuredValues("bar"), + Value: *pipelinev1.NewStructuredValues("bar"), }}, }, Status: v1beta1.ResolutionRequestStatus{}, @@ -184,9 +184,9 @@ func TestReconcile(t *testing.T) { }, }, Spec: v1beta1.ResolutionRequestSpec{ - Params: []pipelinev1beta1.Param{{ + Params: []pipelinev1.Param{{ Name: FakeParamName, - Value: *pipelinev1beta1.NewStructuredValues("bar"), + Value: *pipelinev1.NewStructuredValues("bar"), }}, }, Status: v1beta1.ResolutionRequestStatus{}, diff --git a/pkg/resolution/resolver/git/resolver.go b/pkg/resolution/resolver/git/resolver.go index 6befbfdffd3..6452b153755 100644 --- a/pkg/resolution/resolver/git/resolver.go +++ b/pkg/resolution/resolver/git/resolver.go @@ -34,7 +34,7 @@ import ( "github.com/jenkins-x/go-scm/scm" "github.com/jenkins-x/go-scm/scm/factory" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" "go.uber.org/zap" @@ -110,7 +110,7 @@ func (r *Resolver) GetSelector(_ context.Context) map[string]string { // ValidateParams returns an error if the given parameter map is not // valid for a resource request targeting the gitresolver. -func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { +func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1.Param) error { if r.isDisabled(ctx) { return errors.New(disabledError) } @@ -124,7 +124,7 @@ func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1. // Resolve performs the work of fetching a file from git given a map of // parameters. -func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1beta1.Param) (framework.ResolvedResource, error) { +func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1.Param) (framework.ResolvedResource, error) { if r.isDisabled(ctx) { return nil, errors.New(disabledError) } @@ -337,8 +337,8 @@ func (r *resolvedGitResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (r *resolvedGitResource) Source() *pipelinev1beta1.ConfigSource { - return &pipelinev1beta1.ConfigSource{ +func (r *resolvedGitResource) Source() *pipelinev1.ConfigSource { + return &pipelinev1.ConfigSource{ URI: spdxGit(r.URL), Digest: map[string]string{ "sha1": r.Revision, @@ -414,7 +414,7 @@ func (r *Resolver) getAPIToken(ctx context.Context) ([]byte, error) { return secretVal, nil } -func populateDefaultParams(ctx context.Context, params []pipelinev1beta1.Param) (map[string]string, error) { +func populateDefaultParams(ctx context.Context, params []pipelinev1.Param) (map[string]string, error) { conf := framework.GetResolverConfigFromContext(ctx) paramsMap := make(map[string]string) diff --git a/pkg/resolution/resolver/git/resolver_test.go b/pkg/resolution/resolver/git/resolver_test.go index 59b9c1a63f6..7bc6da0fdeb 100644 --- a/pkg/resolution/resolver/git/resolver_test.go +++ b/pkg/resolution/resolver/git/resolver_test.go @@ -34,7 +34,7 @@ import ( "github.com/jenkins-x/go-scm/scm/driver/fake" "github.com/jenkins-x/go-scm/scm/factory" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" @@ -525,7 +525,7 @@ func TestResolve(t *testing.T) { } // status.source - expectedStatus.Source = &pipelinev1beta1.ConfigSource{ + expectedStatus.Source = &pipelinev1.ConfigSource{ URI: "git+" + expectedStatus.Annotations[AnnotationKeyURL], Digest: map[string]string{ "sha1": tc.expectedCommitSHA, @@ -705,33 +705,33 @@ func createRequest(args *params) *v1beta1.ResolutionRequest { }, }, Spec: v1beta1.ResolutionRequestSpec{ - Params: []pipelinev1beta1.Param{{ + Params: []pipelinev1.Param{{ Name: pathParam, - Value: *pipelinev1beta1.NewStructuredValues(args.pathInRepo), + Value: *pipelinev1.NewStructuredValues(args.pathInRepo), }}, }, } if args.revision != "" { - rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + rr.Spec.Params = append(rr.Spec.Params, pipelinev1.Param{ Name: revisionParam, - Value: *pipelinev1beta1.NewStructuredValues(args.revision), + Value: *pipelinev1.NewStructuredValues(args.revision), }) } if args.url != "" { - rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + rr.Spec.Params = append(rr.Spec.Params, pipelinev1.Param{ Name: urlParam, - Value: *pipelinev1beta1.NewStructuredValues(args.url), + Value: *pipelinev1.NewStructuredValues(args.url), }) } else { - rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + rr.Spec.Params = append(rr.Spec.Params, pipelinev1.Param{ Name: repoParam, - Value: *pipelinev1beta1.NewStructuredValues(args.repo), + Value: *pipelinev1.NewStructuredValues(args.repo), }) - rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + rr.Spec.Params = append(rr.Spec.Params, pipelinev1.Param{ Name: orgParam, - Value: *pipelinev1beta1.NewStructuredValues(args.org), + Value: *pipelinev1.NewStructuredValues(args.org), }) } @@ -750,13 +750,13 @@ func createError(msg string) error { } } -func toParams(m map[string]string) []pipelinev1beta1.Param { - var params []pipelinev1beta1.Param +func toParams(m map[string]string) []pipelinev1.Param { + var params []pipelinev1.Param for k, v := range m { - params = append(params, pipelinev1beta1.Param{ + params = append(params, pipelinev1.Param{ Name: k, - Value: *pipelinev1beta1.NewStructuredValues(v), + Value: *pipelinev1.NewStructuredValues(v), }) } diff --git a/pkg/resolution/resolver/hub/resolver.go b/pkg/resolution/resolver/hub/resolver.go index 8de2b27ad11..a0197ebb83b 100644 --- a/pkg/resolution/resolver/hub/resolver.go +++ b/pkg/resolution/resolver/hub/resolver.go @@ -25,7 +25,7 @@ import ( "strings" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" ) @@ -75,7 +75,7 @@ func (r *Resolver) GetSelector(context.Context) map[string]string { } // ValidateParams ensures parameters from a request are as expected. -func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { +func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1.Param) error { if r.isDisabled(ctx) { return errors.New(disabledError) } @@ -108,7 +108,7 @@ type artifactHubResponse struct { } // Resolve uses the given params to resolve the requested file or resource. -func (r *Resolver) Resolve(ctx context.Context, params []pipelinev1beta1.Param) (framework.ResolvedResource, error) { +func (r *Resolver) Resolve(ctx context.Context, params []pipelinev1.Param) (framework.ResolvedResource, error) { if r.isDisabled(ctx) { return nil, errors.New(disabledError) } @@ -174,12 +174,12 @@ func (*ResolvedHubResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (rr *ResolvedHubResource) Source() *pipelinev1beta1.ConfigSource { +func (rr *ResolvedHubResource) Source() *pipelinev1.ConfigSource { h := sha256.New() h.Write(rr.Content) sha256CheckSum := hex.EncodeToString(h.Sum(nil)) - return &pipelinev1beta1.ConfigSource{ + return &pipelinev1.ConfigSource{ URI: rr.URL, Digest: map[string]string{ "sha256": sha256CheckSum, @@ -298,7 +298,7 @@ func (r *Resolver) validateParams(ctx context.Context, paramsMap map[string]stri return nil } -func populateDefaultParams(ctx context.Context, params []pipelinev1beta1.Param) (map[string]string, error) { +func populateDefaultParams(ctx context.Context, params []pipelinev1.Param) (map[string]string, error) { conf := framework.GetResolverConfigFromContext(ctx) paramsMap := make(map[string]string) for _, p := range params { diff --git a/pkg/resolution/resolver/hub/resolver_test.go b/pkg/resolution/resolver/hub/resolver_test.go index 67799fe0c39..47411232145 100644 --- a/pkg/resolution/resolver/hub/resolver_test.go +++ b/pkg/resolution/resolver/hub/resolver_test.go @@ -24,7 +24,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" frtesting "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework/testing" @@ -419,13 +419,13 @@ func resolverDisabledContext() context.Context { return frtesting.ContextWithHubResolverDisabled(context.Background()) } -func toParams(m map[string]string) []pipelinev1beta1.Param { - var params []pipelinev1beta1.Param +func toParams(m map[string]string) []pipelinev1.Param { + var params []pipelinev1.Param for k, v := range m { - params = append(params, pipelinev1beta1.Param{ + params = append(params, pipelinev1.Param{ Name: k, - Value: *pipelinev1beta1.NewStructuredValues(v), + Value: *pipelinev1.NewStructuredValues(v), }) } diff --git a/pkg/resolution/resource/crd_resource.go b/pkg/resolution/resource/crd_resource.go index 54b23943e3b..eb335b0351f 100644 --- a/pkg/resolution/resource/crd_resource.go +++ b/pkg/resolution/resource/crd_resource.go @@ -22,7 +22,7 @@ import ( "errors" "fmt" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" rrclient "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" rrlisters "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1beta1" @@ -160,6 +160,6 @@ func (r readOnlyResolutionRequest) Data() ([]byte, error) { return decodedBytes, nil } -func (r readOnlyResolutionRequest) Source() *pipelinev1beta1.ConfigSource { +func (r readOnlyResolutionRequest) Source() *pipelinev1.ConfigSource { return r.req.Status.Source } diff --git a/pkg/resolution/resource/name.go b/pkg/resolution/resource/name.go index be92a45ff42..b5d7a845d95 100644 --- a/pkg/resolution/resource/name.go +++ b/pkg/resolution/resource/name.go @@ -22,6 +22,7 @@ import ( "hash/fnv" "sort" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) @@ -35,7 +36,7 @@ func nameHasher() hash.Hash { // will have the format {prefix}-{hash} where {prefix} is // given and {hash} is nameHasher(base) + nameHasher(param1) + // nameHasher(param2) + ... -func GenerateDeterministicName(prefix, base string, params []v1beta1.Param) (string, error) { +func GenerateDeterministicName(prefix, base string, params []v1.Param) (string, error) { hasher := nameHasher() if _, err := hasher.Write([]byte(base)); err != nil { return "", err diff --git a/pkg/resolution/resource/request.go b/pkg/resolution/resource/request.go index 40e1d34caad..d9a566a95f2 100644 --- a/pkg/resolution/resource/request.go +++ b/pkg/resolution/resource/request.go @@ -16,7 +16,9 @@ limitations under the License. package resource -import "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" +import ( + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" +) var _ Request = &BasicRequest{} @@ -24,12 +26,12 @@ var _ Request = &BasicRequest{} type BasicRequest struct { name string namespace string - params []v1beta1.Param + params []v1.Param } // NewRequest returns an instance of a BasicRequest with the given name, // namespace and params. -func NewRequest(name, namespace string, params []v1beta1.Param) Request { +func NewRequest(name, namespace string, params []v1.Param) Request { return &BasicRequest{name, namespace, params} } @@ -46,6 +48,6 @@ func (req *BasicRequest) Namespace() string { } // Params are the map of parameters associated with this request -func (req *BasicRequest) Params() []v1beta1.Param { +func (req *BasicRequest) Params() []v1.Param { return req.params } diff --git a/pkg/resolution/resource/resource.go b/pkg/resolution/resource/resource.go index c2adeec563c..620b4819c8c 100644 --- a/pkg/resolution/resource/resource.go +++ b/pkg/resolution/resource/resource.go @@ -19,7 +19,7 @@ package resource import ( "context" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -44,7 +44,7 @@ type Requester interface { type Request interface { Name() string Namespace() string - Params() []pipelinev1beta1.Param + Params() []pipelinev1.Param } // OwnedRequest is implemented by any type implementing Request that also needs @@ -59,5 +59,5 @@ type OwnedRequest interface { type ResolvedResource interface { Data() ([]byte, error) Annotations() map[string]string - Source() *pipelinev1beta1.ConfigSource + Source() *pipelinev1.ConfigSource } diff --git a/pkg/taskrunmetrics/metrics.go b/pkg/taskrunmetrics/metrics.go index ec87ff3d7f8..7d92f33451f 100644 --- a/pkg/taskrunmetrics/metrics.go +++ b/pkg/taskrunmetrics/metrics.go @@ -25,8 +25,8 @@ import ( "github.com/pkg/errors" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" + listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1" "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" @@ -281,7 +281,7 @@ func nilInsertTag(task, taskrun string) []tag.Mutator { // DurationAndCount logs the duration of TaskRun execution and // count for number of TaskRuns succeed or failed // returns an error if its failed to log the metrics -func (r *Recorder) DurationAndCount(ctx context.Context, tr *v1beta1.TaskRun, beforeCondition *apis.Condition) error { +func (r *Recorder) DurationAndCount(ctx context.Context, tr *v1.TaskRun, beforeCondition *apis.Condition) error { if !r.initialized { return fmt.Errorf("ignoring the metrics recording for %s , failed to initialize the metrics recorder", tr.Name) } @@ -397,7 +397,7 @@ func (r *Recorder) ReportRunningTaskRuns(ctx context.Context, lister listers.Tas // RecordPodLatency logs the duration required to schedule the pod for TaskRun // returns an error if its failed to log the metrics -func (r *Recorder) RecordPodLatency(ctx context.Context, pod *corev1.Pod, tr *v1beta1.TaskRun) error { +func (r *Recorder) RecordPodLatency(ctx context.Context, pod *corev1.Pod, tr *v1.TaskRun) error { r.mutex.Lock() defer r.mutex.Unlock() @@ -432,7 +432,7 @@ func (r *Recorder) RecordPodLatency(ctx context.Context, pod *corev1.Pod, tr *v1 // CloudEvents logs the number of cloud events sent for TaskRun // returns an error if it fails to log the metrics -func (r *Recorder) CloudEvents(ctx context.Context, tr *v1beta1.TaskRun) error { +func (r *Recorder) CloudEvents(ctx context.Context, tr *v1.TaskRun) error { r.mutex.Lock() defer r.mutex.Unlock() @@ -480,7 +480,7 @@ func (r *Recorder) CloudEvents(ctx context.Context, tr *v1beta1.TaskRun) error { // IsPartOfPipeline return true if TaskRun is a part of a Pipeline. // It also return the name of Pipeline and PipelineRun -func IsPartOfPipeline(tr *v1beta1.TaskRun) (bool, string, string) { +func IsPartOfPipeline(tr *v1.TaskRun) (bool, string, string) { pipelineLabel, hasPipelineLabel := tr.Labels[pipeline.PipelineLabelKey] pipelineRunLabel, hasPipelineRunLabel := tr.Labels[pipeline.PipelineRunLabelKey] @@ -491,10 +491,10 @@ func IsPartOfPipeline(tr *v1beta1.TaskRun) (bool, string, string) { return false, "", "" } -func sentCloudEvents(tr *v1beta1.TaskRun) int64 { +func sentCloudEvents(tr *v1.TaskRun) int64 { var sent int64 for _, event := range tr.Status.CloudEvents { - if event.Status.Condition != v1beta1.CloudEventConditionUnknown { + if event.Status.Condition != v1.CloudEventConditionUnknown { sent += 1 + int64(event.Status.RetryCount) } } diff --git a/pkg/trustedresources/verify_test.go b/pkg/trustedresources/verify_test.go index 70c2731aae1..f6e238c9506 100644 --- a/pkg/trustedresources/verify_test.go +++ b/pkg/trustedresources/verify_test.go @@ -27,6 +27,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/sigstore/sigstore/pkg/signature" "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/trustedresources/verifier" @@ -87,7 +88,7 @@ func TestVerifyInterface_Task_Error(t *testing.T) { tcs := []struct { name string - task *v1beta1.Task + task *v1.Task expectedError error }{{ name: "Unsigned Task Fail Verification", @@ -368,7 +369,7 @@ func TestVerifyPipeline_Success(t *testing.T) { mismatchedSource := "wrong source" tcs := []struct { name string - pipeline v1beta1.PipelineObject + pipeline v1.PipelineObject source string verificationNoMatchPolicy string }{{ @@ -421,7 +422,7 @@ func TestVerifyPipeline_Error(t *testing.T) { mismatchedSource := "wrong source" tcs := []struct { name string - pipeline v1beta1.PipelineObject + pipeline v1.PipelineObject source string verificationPolicy []*v1alpha1.VerificationPolicy }{{ diff --git a/pkg/workspace/apply.go b/pkg/workspace/apply.go index 26b688c42d1..8619db5a55c 100644 --- a/pkg/workspace/apply.go +++ b/pkg/workspace/apply.go @@ -21,7 +21,7 @@ import ( "fmt" "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/names" "github.com/tektoncd/pipeline/pkg/substitution" corev1 "k8s.io/api/core/v1" @@ -47,7 +47,7 @@ func (nvm nameVolumeMap) setVolumeSource(workspaceName string, volumeName string // wb and the value is a newly-created Volume to use. If the same Volume is bound twice, the // resulting volumes will both have the same name to prevent the same Volume from being attached // to a pod twice. The names of the returned volumes will be a short random string starting "ws-". -func CreateVolumes(wb []v1beta1.WorkspaceBinding) map[string]corev1.Volume { +func CreateVolumes(wb []v1.WorkspaceBinding) map[string]corev1.Volume { pvcs := map[string]corev1.Volume{} v := make(nameVolumeMap) for _, w := range wb { @@ -82,7 +82,7 @@ func CreateVolumes(wb []v1beta1.WorkspaceBinding) map[string]corev1.Volume { return v } -func getDeclaredWorkspace(name string, w []v1beta1.WorkspaceDeclaration) (*v1beta1.WorkspaceDeclaration, error) { +func getDeclaredWorkspace(name string, w []v1.WorkspaceDeclaration) (*v1.WorkspaceDeclaration, error) { for _, workspace := range w { if workspace.Name == name { return &workspace, nil @@ -95,7 +95,7 @@ func getDeclaredWorkspace(name string, w []v1beta1.WorkspaceDeclaration) (*v1bet // Apply will update the StepTemplate, Sidecars and Volumes declaration in ts so that the workspaces // specified through wb combined with the declared workspaces in ts will be available for // all Step and Sidecar containers in the resulting pod. -func Apply(ctx context.Context, ts v1beta1.TaskSpec, wb []v1beta1.WorkspaceBinding, v map[string]corev1.Volume) (*v1beta1.TaskSpec, error) { +func Apply(ctx context.Context, ts v1.TaskSpec, wb []v1.WorkspaceBinding, v map[string]corev1.Volume) (*v1.TaskSpec, error) { // If there are no bound workspaces, we don't need to do anything if len(wb) == 0 { return &ts, nil @@ -105,7 +105,7 @@ func Apply(ctx context.Context, ts v1beta1.TaskSpec, wb []v1beta1.WorkspaceBindi // Initialize StepTemplate if it hasn't been already if ts.StepTemplate == nil { - ts.StepTemplate = &v1beta1.StepTemplate{} + ts.StepTemplate = &v1.StepTemplate{} } isolatedWorkspaces := sets.NewString() @@ -136,7 +136,7 @@ func Apply(ctx context.Context, ts v1beta1.TaskSpec, wb []v1beta1.WorkspaceBindi } } if addWorkspace { - ts.Workspaces = append(ts.Workspaces, v1beta1.WorkspaceDeclaration{Name: wb[i].Name}) + ts.Workspaces = append(ts.Workspaces, v1.WorkspaceDeclaration{Name: wb[i].Name}) } } w, err := getDeclaredWorkspace(wb[i].Name, ts.Workspaces) @@ -175,7 +175,7 @@ func Apply(ctx context.Context, ts v1beta1.TaskSpec, wb []v1beta1.WorkspaceBindi // mountAsSharedWorkspace takes a volumeMount and adds it to all the steps and sidecars in // a TaskSpec. -func mountAsSharedWorkspace(ts v1beta1.TaskSpec, volumeMount corev1.VolumeMount) { +func mountAsSharedWorkspace(ts v1.TaskSpec, volumeMount corev1.VolumeMount) { ts.StepTemplate.VolumeMounts = append(ts.StepTemplate.VolumeMounts, volumeMount) for i := range ts.Sidecars { @@ -185,7 +185,7 @@ func mountAsSharedWorkspace(ts v1beta1.TaskSpec, volumeMount corev1.VolumeMount) // mountAsIsolatedWorkspace takes a volumeMount and adds it only to the steps and sidecars // that have requested access to it. -func mountAsIsolatedWorkspace(ts v1beta1.TaskSpec, workspaceName string, volumeMount corev1.VolumeMount) { +func mountAsIsolatedWorkspace(ts v1.TaskSpec, workspaceName string, volumeMount corev1.VolumeMount) { for i := range ts.Steps { step := &ts.Steps[i] for _, workspaceUsage := range step.Workspaces { @@ -216,7 +216,7 @@ func mountAsIsolatedWorkspace(ts v1beta1.TaskSpec, workspaceName string, volumeM // AddSidecarVolumeMount is a helper to add a volumeMount to the sidecar unless its // MountPath would conflict with another of the sidecar's existing volume mounts. -func AddSidecarVolumeMount(sidecar *v1beta1.Sidecar, volumeMount corev1.VolumeMount) { +func AddSidecarVolumeMount(sidecar *v1.Sidecar, volumeMount corev1.VolumeMount) { for j := range sidecar.VolumeMounts { if sidecar.VolumeMounts[j].MountPath == volumeMount.MountPath { return @@ -225,7 +225,7 @@ func AddSidecarVolumeMount(sidecar *v1beta1.Sidecar, volumeMount corev1.VolumeMo sidecar.VolumeMounts = append(sidecar.VolumeMounts, volumeMount) } -func findWorkspaceSubstitutionLocationsInSidecars(sidecars []v1beta1.Sidecar) sets.String { +func findWorkspaceSubstitutionLocationsInSidecars(sidecars []v1.Sidecar) sets.String { locationsToCheck := sets.NewString() for _, sidecar := range sidecars { locationsToCheck.Insert(sidecar.Script) @@ -241,7 +241,7 @@ func findWorkspaceSubstitutionLocationsInSidecars(sidecars []v1beta1.Sidecar) se return locationsToCheck } -func findWorkspaceSubstitutionLocationsInSteps(steps []v1beta1.Step) sets.String { +func findWorkspaceSubstitutionLocationsInSteps(steps []v1.Step) sets.String { locationsToCheck := sets.NewString() for _, step := range steps { locationsToCheck.Insert(step.Script) @@ -257,7 +257,7 @@ func findWorkspaceSubstitutionLocationsInSteps(steps []v1beta1.Step) sets.String return locationsToCheck } -func findWorkspaceSubstitutionLocationsInStepTemplate(stepTemplate *v1beta1.StepTemplate) sets.String { +func findWorkspaceSubstitutionLocationsInStepTemplate(stepTemplate *v1.StepTemplate) sets.String { locationsToCheck := sets.NewString() if stepTemplate != nil { @@ -272,7 +272,7 @@ func findWorkspaceSubstitutionLocationsInStepTemplate(stepTemplate *v1beta1.Step } // FindWorkspacesUsedByTask returns a set of all the workspaces that the TaskSpec uses. -func FindWorkspacesUsedByTask(ts v1beta1.TaskSpec) (sets.String, error) { +func FindWorkspacesUsedByTask(ts v1.TaskSpec) (sets.String, error) { locationsToCheck := sets.NewString() locationsToCheck.Insert(findWorkspaceSubstitutionLocationsInSteps(ts.Steps).List()...) locationsToCheck.Insert(findWorkspaceSubstitutionLocationsInSidecars(ts.Sidecars).List()...) diff --git a/pkg/workspace/apply_test.go b/pkg/workspace/apply_test.go index 516392ae997..d6cfb5cf647 100644 --- a/pkg/workspace/apply_test.go +++ b/pkg/workspace/apply_test.go @@ -6,12 +6,11 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/workspace" "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" ) @@ -19,11 +18,11 @@ func TestCreateVolumes(t *testing.T) { names.TestingSeed() for _, tc := range []struct { name string - workspaces []v1beta1.WorkspaceBinding + workspaces []v1.WorkspaceBinding expectedVolumes map[string]corev1.Volume }{{ name: "binding a single workspace with a PVC", - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -42,7 +41,7 @@ func TestCreateVolumes(t *testing.T) { }, }, { name: "binding a single workspace with emptyDir", - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", EmptyDir: &corev1.EmptyDirVolumeSource{ Medium: corev1.StorageMediumMemory, @@ -61,7 +60,7 @@ func TestCreateVolumes(t *testing.T) { }, }, { name: "binding a single workspace with configMap", - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ @@ -92,7 +91,7 @@ func TestCreateVolumes(t *testing.T) { }, }, { name: "binding a single workspace with secret", - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", Secret: &corev1.SecretVolumeSource{ SecretName: "foobarsecret", @@ -119,7 +118,7 @@ func TestCreateVolumes(t *testing.T) { }, }, { name: "binding a single workspace with projected", - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", Projected: &corev1.ProjectedVolumeSource{ Sources: []corev1.VolumeProjection{{ @@ -178,11 +177,11 @@ func TestCreateVolumes(t *testing.T) { }, }, { name: "0 workspace bindings", - workspaces: []v1beta1.WorkspaceBinding{}, + workspaces: []v1.WorkspaceBinding{}, expectedVolumes: map[string]corev1.Volume{}, }, { name: "binding multiple workspaces", - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -214,7 +213,7 @@ func TestCreateVolumes(t *testing.T) { }, }, { name: "multiple workspaces binding to the same volume with diff subpaths doesnt duplicate", - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -260,25 +259,25 @@ func TestApply(t *testing.T) { names.TestingSeed() for _, tc := range []struct { name string - ts v1beta1.TaskSpec - workspaces []v1beta1.WorkspaceBinding - expectedTaskSpec v1beta1.TaskSpec + ts v1.TaskSpec + workspaces []v1.WorkspaceBinding + expectedTaskSpec v1.TaskSpec }{{ name: "binding a single workspace with a PVC", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", }, SubPath: "/foo/bar/baz", }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-9l9zj", MountPath: "/workspace/custom", @@ -293,26 +292,26 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }}, }, }, { name: "binding a single workspace with emptyDir", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }, }}, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", EmptyDir: &corev1.EmptyDirVolumeSource{ Medium: corev1.StorageMediumMemory, }, SubPath: "/foo/bar/baz", }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-mz4c7", MountPath: "/workspace/custom", @@ -327,18 +326,18 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }}, }, }, { name: "binding a single workspace with projected", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }, }}, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", Projected: &corev1.ProjectedVolumeSource{ Sources: []corev1.VolumeProjection{{ @@ -365,8 +364,8 @@ func TestApply(t *testing.T) { }, SubPath: "/foo/bar/baz", }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-mssqb", MountPath: "/workspace/custom", @@ -401,14 +400,14 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }}, }, }, { name: "task spec already has volumes and stepTemplate", - ts: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + ts: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "awesome-volume", MountPath: "/", @@ -420,19 +419,19 @@ func TestApply(t *testing.T) { EmptyDir: &corev1.EmptyDirVolumeSource{}, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", EmptyDir: &corev1.EmptyDirVolumeSource{ Medium: corev1.StorageMediumMemory, }, SubPath: "/foo/bar/baz", }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "awesome-volume", MountPath: "/", @@ -455,33 +454,33 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }}, }, }, { name: "0 workspace bindings", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "foo", }}, }, - workspaces: []v1beta1.WorkspaceBinding{}, - expectedTaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + workspaces: []v1.WorkspaceBinding{}, + expectedTaskSpec: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "foo", }}, }, }, { name: "binding multiple workspaces", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }, { Name: "even-more-custom", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -493,8 +492,8 @@ func TestApply(t *testing.T) { ClaimName: "myotherpvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-6nl7g", MountPath: "/workspace/custom", @@ -520,21 +519,21 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom"}, { Name: "even-more-custom", }}, }, }, { name: "multiple workspaces binding to the same volume with diff subpaths doesnt duplicate", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }, { Name: "custom2", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -547,8 +546,8 @@ func TestApply(t *testing.T) { }, SubPath: "/very/professional/work/space", }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-vr6ds", MountPath: "/workspace/custom", @@ -567,7 +566,7 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", }, { Name: "custom2", @@ -575,20 +574,20 @@ func TestApply(t *testing.T) { }, }, { name: "non default mount path", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-twkr2", MountPath: "/my/fancy/mount/path", @@ -602,28 +601,28 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", }}, }, }, { name: "readOnly true marks volume mount readOnly", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", ReadOnly: true, }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-mnq6l", MountPath: "/my/fancy/mount/path", @@ -638,7 +637,7 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", ReadOnly: true, @@ -646,22 +645,22 @@ func TestApply(t *testing.T) { }, }, { name: "binding a single workspace with CSI", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/workspace/csi", ReadOnly: true, }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", CSI: &corev1.CSIVolumeSource{ Driver: "secrets-store.csi.k8s.io", }, SubPath: "/foo/bar/baz", }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-hvpvf", MountPath: "/workspace/csi", @@ -677,7 +676,7 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/workspace/csi", ReadOnly: true, @@ -701,24 +700,24 @@ func TestApply_PropagatedWorkspacesFromWorkspaceBindingToDeclarations(t *testing names.TestingSeed() for _, tc := range []struct { name string - ts v1beta1.TaskSpec - workspaces []v1beta1.WorkspaceBinding - expectedTaskSpec v1beta1.TaskSpec + ts v1.TaskSpec + workspaces []v1.WorkspaceBinding + expectedTaskSpec v1.TaskSpec apiField string }{{ name: "propagate workspaces alpha enabled", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "workspace1", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "workspace2", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ + expectedTaskSpec: v1.TaskSpec{ Volumes: []corev1.Volume{{ Name: "ws-9l9zj", VolumeSource: corev1.VolumeSource{ @@ -727,7 +726,7 @@ func TestApply_PropagatedWorkspacesFromWorkspaceBindingToDeclarations(t *testing }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "workspace1", MountPath: "", ReadOnly: false, @@ -736,25 +735,25 @@ func TestApply_PropagatedWorkspacesFromWorkspaceBindingToDeclarations(t *testing MountPath: "", ReadOnly: false, }}, - StepTemplate: &v1beta1.StepTemplate{ - VolumeMounts: []v1.VolumeMount{{Name: "ws-9l9zj", MountPath: "/workspace/workspace2"}}, + StepTemplate: &v1.StepTemplate{ + VolumeMounts: []corev1.VolumeMount{{Name: "ws-9l9zj", MountPath: "/workspace/workspace2"}}, }, }, apiField: config.AlphaAPIFields, }, { name: "propagate workspaces beta enabled", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "workspace1", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "workspace2", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ + expectedTaskSpec: v1.TaskSpec{ Volumes: []corev1.Volume{{ Name: "ws-mz4c7", VolumeSource: corev1.VolumeSource{ @@ -763,7 +762,7 @@ func TestApply_PropagatedWorkspacesFromWorkspaceBindingToDeclarations(t *testing }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "workspace1", MountPath: "", ReadOnly: false, @@ -772,8 +771,8 @@ func TestApply_PropagatedWorkspacesFromWorkspaceBindingToDeclarations(t *testing MountPath: "", ReadOnly: false, }}, - StepTemplate: &v1beta1.StepTemplate{ - VolumeMounts: []v1.VolumeMount{{Name: "ws-mz4c7", MountPath: "/workspace/workspace2"}}, + StepTemplate: &v1.StepTemplate{ + VolumeMounts: []corev1.VolumeMount{{Name: "ws-mz4c7", MountPath: "/workspace/workspace2"}}, }, }, apiField: config.BetaAPIFields, @@ -800,30 +799,30 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { names.TestingSeed() for _, tc := range []struct { name string - ts v1beta1.TaskSpec - workspaces []v1beta1.WorkspaceBinding - expectedTaskSpec v1beta1.TaskSpec + ts v1.TaskSpec + workspaces []v1.WorkspaceBinding + expectedTaskSpec v1.TaskSpec }{{ name: "workspace isolated to step does not appear in step template or sidecars", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Workspaces: []v1beta1.WorkspaceUsage{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", }}, }}, - Sidecars: []v1beta1.Sidecar{{Name: "foo"}}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Sidecars: []v1.Sidecar{{Name: "foo"}}, + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "source", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "testpvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{}, + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{}, Volumes: []corev1.Volume{{ Name: "ws-9l9zj", VolumeSource: corev1.VolumeSource{ @@ -832,43 +831,43 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { }, }, }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-9l9zj", MountPath: "/workspace/source", }}, - Workspaces: []v1beta1.WorkspaceUsage{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", }}, }}, - Sidecars: []v1beta1.Sidecar{{Name: "foo"}}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Sidecars: []v1.Sidecar{{Name: "foo"}}, + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, }, { name: "workspace isolated to sidecar does not appear in steps", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step1", }}, - Sidecars: []v1beta1.Sidecar{{ - Workspaces: []v1beta1.WorkspaceUsage{{ + Sidecars: []v1.Sidecar{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", }}, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "source", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "testpvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{}, + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{}, Volumes: []corev1.Volume{{ Name: "ws-mz4c7", VolumeSource: corev1.VolumeSource{ @@ -877,49 +876,49 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { }, }, }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ Name: "step1", }}, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-mz4c7", MountPath: "/workspace/source", }}, - Workspaces: []v1beta1.WorkspaceUsage{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", }}, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, }, { name: "workspace isolated to one step and one sidecar does not appear in step template", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Workspaces: []v1beta1.WorkspaceUsage{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", }}, }, { Name: "step2", }}, - Sidecars: []v1beta1.Sidecar{{ - Workspaces: []v1beta1.WorkspaceUsage{{ + Sidecars: []v1.Sidecar{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", }}, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "source", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "testpvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{}, + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{}, Volumes: []corev1.Volume{{ Name: "ws-mssqb", VolumeSource: corev1.VolumeSource{ @@ -928,47 +927,47 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { }, }, }}, - Steps: []v1beta1.Step{{ + Steps: []v1.Step{{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-mssqb", MountPath: "/workspace/source", }}, - Workspaces: []v1beta1.WorkspaceUsage{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", }}, }, { Name: "step2", }}, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-mssqb", MountPath: "/workspace/source", }}, - Workspaces: []v1beta1.WorkspaceUsage{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", }}, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, }, { name: "workspaces are mounted to sidecars by default", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{}}, - Sidecars: []v1beta1.Sidecar{{}}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{}}, + Sidecars: []v1.Sidecar{{}}, + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "source", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "testpvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-78c5n", MountPath: "/workspace/source", }}, @@ -981,44 +980,44 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { }, }, }}, - Steps: []v1beta1.Step{{}}, - Sidecars: []v1beta1.Sidecar{{ + Steps: []v1.Step{{}}, + Sidecars: []v1.Sidecar{{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-78c5n", MountPath: "/workspace/source", }}, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, }, { name: "isolated workspaces custom mountpaths appear in volumemounts", - ts: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ - Workspaces: []v1beta1.WorkspaceUsage{{ + ts: v1.TaskSpec{ + Steps: []v1.Step{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", MountPath: "/foo", }}, }}, - Sidecars: []v1beta1.Sidecar{{ - Workspaces: []v1beta1.WorkspaceUsage{{ + Sidecars: []v1.Sidecar{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", MountPath: "/bar", }}, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "source", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "testpvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{}, + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{}, Volumes: []corev1.Volume{{ Name: "ws-6nl7g", VolumeSource: corev1.VolumeSource{ @@ -1027,8 +1026,8 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { }, }, }}, - Steps: []v1beta1.Step{{ - Workspaces: []v1beta1.WorkspaceUsage{{ + Steps: []v1.Step{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", MountPath: "/foo", }}, @@ -1037,8 +1036,8 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { MountPath: "/foo", }}, }}, - Sidecars: []v1beta1.Sidecar{{ - Workspaces: []v1beta1.WorkspaceUsage{{ + Sidecars: []v1.Sidecar{{ + Workspaces: []v1.WorkspaceUsage{{ Name: "source", MountPath: "/bar", }}, @@ -1047,19 +1046,19 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { MountPath: "/bar", }}, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "source", }}, }, }, { name: "existing sidecar volumeMounts are not displaced by workspace binding", - ts: v1beta1.TaskSpec{ - Workspaces: []v1beta1.WorkspaceDeclaration{{ + ts: v1.TaskSpec{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", ReadOnly: true, }}, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ Name: "conflicting volume mount sidecar", VolumeMounts: []corev1.VolumeMount{{ Name: "mount-path-conflicts", @@ -1067,21 +1066,21 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { }}, }}, }, - workspaces: []v1beta1.WorkspaceBinding{{ + workspaces: []v1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", }, }}, - expectedTaskSpec: v1beta1.TaskSpec{ - StepTemplate: &v1beta1.StepTemplate{ + expectedTaskSpec: v1.TaskSpec{ + StepTemplate: &v1.StepTemplate{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-j2tds", MountPath: "/my/fancy/mount/path", ReadOnly: true, }}, }, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ Name: "conflicting volume mount sidecar", VolumeMounts: []corev1.VolumeMount{{ Name: "mount-path-conflicts", @@ -1096,7 +1095,7 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { }, }, }}, - Workspaces: []v1beta1.WorkspaceDeclaration{{ + Workspaces: []v1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", ReadOnly: true, @@ -1123,12 +1122,12 @@ func TestApply_IsolatedWorkspaces(t *testing.T) { func TestApplyWithMissingWorkspaceDeclaration(t *testing.T) { names.TestingSeed() - ts := v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{}}, - Sidecars: []v1beta1.Sidecar{{}}, - Workspaces: []v1beta1.WorkspaceDeclaration{}, // Intentionally missing workspace declaration + ts := v1.TaskSpec{ + Steps: []v1.Step{{}}, + Sidecars: []v1.Sidecar{{}}, + Workspaces: []v1.WorkspaceDeclaration{}, // Intentionally missing workspace declaration } - bindings := []v1beta1.WorkspaceBinding{{ + bindings := []v1.WorkspaceBinding{{ Name: "source", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "testpvc", @@ -1146,14 +1145,14 @@ func TestAddSidecarVolumeMount(t *testing.T) { for _, tc := range []struct { sidecarMounts []corev1.VolumeMount volumeMount corev1.VolumeMount - expectedSidecar v1beta1.Sidecar + expectedSidecar v1.Sidecar }{{ sidecarMounts: nil, volumeMount: corev1.VolumeMount{ Name: "foo", MountPath: "/workspace/foo", }, - expectedSidecar: v1beta1.Sidecar{ + expectedSidecar: v1.Sidecar{ VolumeMounts: []corev1.VolumeMount{{ Name: "foo", MountPath: "/workspace/foo", @@ -1165,7 +1164,7 @@ func TestAddSidecarVolumeMount(t *testing.T) { Name: "foo", MountPath: "/workspace/foo", }, - expectedSidecar: v1beta1.Sidecar{ + expectedSidecar: v1.Sidecar{ VolumeMounts: []corev1.VolumeMount{{ Name: "foo", MountPath: "/workspace/foo", @@ -1180,7 +1179,7 @@ func TestAddSidecarVolumeMount(t *testing.T) { Name: "workspace1", MountPath: "/workspace/bar", }, - expectedSidecar: v1beta1.Sidecar{ + expectedSidecar: v1.Sidecar{ VolumeMounts: []corev1.VolumeMount{{ Name: "bar", MountPath: "/workspace/bar", @@ -1195,7 +1194,7 @@ func TestAddSidecarVolumeMount(t *testing.T) { Name: "foo", MountPath: "/workspace/foo", }, - expectedSidecar: v1beta1.Sidecar{ + expectedSidecar: v1.Sidecar{ VolumeMounts: []corev1.VolumeMount{{ Name: "bar", MountPath: "/workspace/bar", @@ -1205,7 +1204,7 @@ func TestAddSidecarVolumeMount(t *testing.T) { }}, }, }} { - sidecar := v1beta1.Sidecar{} + sidecar := v1.Sidecar{} sidecar.VolumeMounts = tc.sidecarMounts workspace.AddSidecarVolumeMount(&sidecar, tc.volumeMount) if d := cmp.Diff(tc.expectedSidecar, sidecar); d != "" { @@ -1217,26 +1216,26 @@ func TestAddSidecarVolumeMount(t *testing.T) { func TestFindWorkspacesUsedByTask(t *testing.T) { tests := []struct { name string - ts *v1beta1.TaskSpec + ts *v1.TaskSpec want sets.String }{{ name: "completespec", - ts: &v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + ts: &v1.TaskSpec{ + Steps: []v1.Step{{ Name: "step-name", Image: "step-image", Script: "$(workspaces.step-script.path)", Command: []string{"$(workspaces.step-command.path)"}, Args: []string{"$(workspaces.step-args.path)"}, }}, - Sidecars: []v1beta1.Sidecar{{ + Sidecars: []v1.Sidecar{{ Name: "sidecar-name", Image: "sidecar-image", Script: "$(workspaces.sidecar-script.path)", Command: []string{"$(workspaces.sidecar-command.path)"}, Args: []string{"$(workspaces.sidecar-args.path)"}, }}, - StepTemplate: &v1beta1.StepTemplate{ + StepTemplate: &v1.StepTemplate{ Image: "steptemplate-image", Command: []string{"$(workspaces.steptemplate-command.path)"}, Args: []string{"$(workspaces.steptemplate-args.path)"}, diff --git a/pkg/workspace/validate.go b/pkg/workspace/validate.go index ab9ee42db3f..c8caa2ccd63 100644 --- a/pkg/workspace/validate.go +++ b/pkg/workspace/validate.go @@ -20,13 +20,13 @@ import ( "context" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "k8s.io/apimachinery/pkg/util/sets" ) // ValidateBindings will return an error if the bound workspaces in binds don't satisfy the declared // workspaces in decls. -func ValidateBindings(ctx context.Context, decls []v1beta1.WorkspaceDeclaration, binds []v1beta1.WorkspaceBinding) error { +func ValidateBindings(ctx context.Context, decls []v1.WorkspaceDeclaration, binds []v1.WorkspaceBinding) error { // This will also be validated at webhook time but in case the webhook isn't invoked for some // reason we'll invoke the same validation here. for _, b := range binds { @@ -66,7 +66,7 @@ func ValidateBindings(ctx context.Context, decls []v1beta1.WorkspaceDeclaration, // // This is only useful to validate that WorkspaceBindings in TaskRuns are compatible // with affinity rules enforced by the AffinityAssistant. -func ValidateOnlyOnePVCIsUsed(wb []v1beta1.WorkspaceBinding) error { +func ValidateOnlyOnePVCIsUsed(wb []v1.WorkspaceBinding) error { workspaceVolumes := make(map[string]bool) for _, w := range wb { if w.PersistentVolumeClaim != nil { diff --git a/pkg/workspace/validate_test.go b/pkg/workspace/validate_test.go index 4adc62f4e68..6c9587940a7 100644 --- a/pkg/workspace/validate_test.go +++ b/pkg/workspace/validate_test.go @@ -21,29 +21,29 @@ import ( "errors" "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" corev1 "k8s.io/api/core/v1" ) func TestValidateBindingsValid(t *testing.T) { for _, tc := range []struct { name string - declarations []v1beta1.WorkspaceDeclaration - bindings []v1beta1.WorkspaceBinding + declarations []v1.WorkspaceDeclaration + bindings []v1.WorkspaceBinding }{{ name: "no bindings provided or required", declarations: nil, bindings: nil, }, { name: "empty list of bindings provided and required", - declarations: []v1beta1.WorkspaceDeclaration{}, - bindings: []v1beta1.WorkspaceBinding{}, + declarations: []v1.WorkspaceDeclaration{}, + bindings: []v1.WorkspaceBinding{}, }, { name: "Successfully bound with PVC", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "beth", }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "beth", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "pool-party", @@ -51,30 +51,30 @@ func TestValidateBindingsValid(t *testing.T) { }}, }, { name: "Successfully bound with emptyDir", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "beth", }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "beth", EmptyDir: &corev1.EmptyDirVolumeSource{}, }}, }, { name: "Included optional workspace", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "beth", Optional: true, }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "beth", EmptyDir: &corev1.EmptyDirVolumeSource{}, }}, }, { name: "Omitted optional workspace", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "beth", Optional: true, }}, - bindings: []v1beta1.WorkspaceBinding{}, + bindings: []v1.WorkspaceBinding{}, }} { t.Run(tc.name, func(t *testing.T) { if err := ValidateBindings(context.Background(), tc.declarations, tc.bindings); err != nil { @@ -87,14 +87,14 @@ func TestValidateBindingsValid(t *testing.T) { func TestValidateBindingsInvalid(t *testing.T) { for _, tc := range []struct { name string - declarations []v1beta1.WorkspaceDeclaration - bindings []v1beta1.WorkspaceBinding + declarations []v1.WorkspaceDeclaration + bindings []v1.WorkspaceBinding }{{ name: "Didn't provide binding matching declared workspace", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "beth", }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "kate", EmptyDir: &corev1.EmptyDirVolumeSource{}, }, { @@ -103,21 +103,21 @@ func TestValidateBindingsInvalid(t *testing.T) { }}, }, { name: "Provided a binding that wasn't needed", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "randall", }, { Name: "beth", }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "beth", EmptyDir: &corev1.EmptyDirVolumeSource{}, }}, }, { name: "Provided both pvc and emptydir", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "beth", }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "beth", EmptyDir: &corev1.EmptyDirVolumeSource{}, PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ @@ -126,28 +126,28 @@ func TestValidateBindingsInvalid(t *testing.T) { }}, }, { name: "Provided neither pvc nor emptydir", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "beth", }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "beth", }}, }, { name: "Provided pvc without claim name", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "beth", }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "beth", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{}, }}, }, { name: "Mismatch between declarations and bindings", - declarations: []v1beta1.WorkspaceDeclaration{{ + declarations: []v1.WorkspaceDeclaration{{ Name: "Notbeth", Optional: true, }}, - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ Name: "beth", EmptyDir: &corev1.EmptyDirVolumeSource{}, }}, @@ -163,20 +163,20 @@ func TestValidateBindingsInvalid(t *testing.T) { func TestValidateOnlyOnePVCIsUsed_Valid(t *testing.T) { for _, tc := range []struct { name string - bindings []v1beta1.WorkspaceBinding + bindings []v1.WorkspaceBinding }{{ name: "an error is not returned when no bindings are given", - bindings: []v1beta1.WorkspaceBinding{}, + bindings: []v1.WorkspaceBinding{}, }, { name: "an error is not returned when volume claims are not used", - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ EmptyDir: &corev1.EmptyDirVolumeSource{}, }, { Secret: &corev1.SecretVolumeSource{}, }}, }, { name: "an error is not returned when one PV claim is used in two bindings", - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "foo", }, @@ -187,7 +187,7 @@ func TestValidateOnlyOnePVCIsUsed_Valid(t *testing.T) { }}, }, { name: "an error is not returned when one PV claim is used in two bindings with different subpaths", - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ SubPath: "/pathA", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "foo", @@ -211,11 +211,11 @@ func TestValidateOnlyOnePVCIsUsed_Invalid(t *testing.T) { validationError := errors.New("more than one PersistentVolumeClaim is bound") for _, tc := range []struct { name string - bindings []v1beta1.WorkspaceBinding + bindings []v1.WorkspaceBinding wantErr error }{{ name: "an error is returned when two different PV claims are used", - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "foo", }, @@ -227,7 +227,7 @@ func TestValidateOnlyOnePVCIsUsed_Invalid(t *testing.T) { wantErr: validationError, }, { name: "an error is returned when a PVC and volume claim template are mixed", - bindings: []v1beta1.WorkspaceBinding{{ + bindings: []v1.WorkspaceBinding{{ PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "foo", }, diff --git a/test/controller.go b/test/controller.go index f21d81730c8..da24facecf3 100644 --- a/test/controller.go +++ b/test/controller.go @@ -24,21 +24,23 @@ import ( // Link in the fakes so they get injected into injection.Fake "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" fakepipelineclientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/fake" + informersv1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1" informersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1" informersv1beta1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1" fakepipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client/fake" + fakepipelineinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/pipeline/fake" + fakepipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/pipelinerun/fake" + faketaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/task/fake" + faketaskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/taskrun/fake" fakeruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/run/fake" fakeverificationpolicyinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/verificationpolicy/fake" fakeclustertaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask/fake" fakecustomruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/customrun/fake" - fakepipelineinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/pipeline/fake" - fakepipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/pipelinerun/fake" - faketaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/task/fake" - faketaskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun/fake" fakeresolutionclientset "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/fake" resolutioninformersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution/v1beta1" fakeresolutionrequestclient "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client/fake" @@ -67,10 +69,10 @@ import ( // Data represents the desired state of the system (i.e. existing resources) to seed controllers // with. type Data struct { - PipelineRuns []*v1beta1.PipelineRun - Pipelines []*v1beta1.Pipeline - TaskRuns []*v1beta1.TaskRun - Tasks []*v1beta1.Task + PipelineRuns []*v1.PipelineRun + Pipelines []*v1.Pipeline + TaskRuns []*v1.TaskRun + Tasks []*v1.Task ClusterTasks []*v1beta1.ClusterTask Runs []*v1alpha1.Run CustomRuns []*v1beta1.CustomRun @@ -94,12 +96,12 @@ type Clients struct { // Informers holds references to informers which are useful for reconciler tests. type Informers struct { - PipelineRun informersv1beta1.PipelineRunInformer - Pipeline informersv1beta1.PipelineInformer - TaskRun informersv1beta1.TaskRunInformer + PipelineRun informersv1.PipelineRunInformer + Pipeline informersv1.PipelineInformer + TaskRun informersv1.TaskRunInformer Run informersv1alpha1.RunInformer CustomRun informersv1beta1.CustomRunInformer - Task informersv1beta1.TaskInformer + Task informersv1.TaskInformer ClusterTask informersv1beta1.ClusterTaskInformer Pod coreinformers.PodInformer ConfigMap coreinformers.ConfigMapInformer @@ -200,28 +202,28 @@ func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers c.Pipeline.PrependReactor("*", "pipelineruns", AddToInformer(t, i.PipelineRun.Informer().GetIndexer())) for _, pr := range d.PipelineRuns { pr := pr.DeepCopy() // Avoid assumptions that the informer's copy is modified. - if _, err := c.Pipeline.TektonV1beta1().PipelineRuns(pr.Namespace).Create(ctx, pr, metav1.CreateOptions{}); err != nil { + if _, err := c.Pipeline.TektonV1().PipelineRuns(pr.Namespace).Create(ctx, pr, metav1.CreateOptions{}); err != nil { t.Fatal(err) } } c.Pipeline.PrependReactor("*", "pipelines", AddToInformer(t, i.Pipeline.Informer().GetIndexer())) for _, p := range d.Pipelines { p := p.DeepCopy() // Avoid assumptions that the informer's copy is modified. - if _, err := c.Pipeline.TektonV1beta1().Pipelines(p.Namespace).Create(ctx, p, metav1.CreateOptions{}); err != nil { + if _, err := c.Pipeline.TektonV1().Pipelines(p.Namespace).Create(ctx, p, metav1.CreateOptions{}); err != nil { t.Fatal(err) } } c.Pipeline.PrependReactor("*", "taskruns", AddToInformer(t, i.TaskRun.Informer().GetIndexer())) for _, tr := range d.TaskRuns { tr := tr.DeepCopy() // Avoid assumptions that the informer's copy is modified. - if _, err := c.Pipeline.TektonV1beta1().TaskRuns(tr.Namespace).Create(ctx, tr, metav1.CreateOptions{}); err != nil { + if _, err := c.Pipeline.TektonV1().TaskRuns(tr.Namespace).Create(ctx, tr, metav1.CreateOptions{}); err != nil { t.Fatal(err) } } c.Pipeline.PrependReactor("*", "tasks", AddToInformer(t, i.Task.Informer().GetIndexer())) for _, ta := range d.Tasks { ta := ta.DeepCopy() // Avoid assumptions that the informer's copy is modified. - if _, err := c.Pipeline.TektonV1beta1().Tasks(ta.Namespace).Create(ctx, ta, metav1.CreateOptions{}); err != nil { + if _, err := c.Pipeline.TektonV1().Tasks(ta.Namespace).Create(ctx, ta, metav1.CreateOptions{}); err != nil { t.Fatal(err) } } diff --git a/test/resolution.go b/test/resolution.go index 43a7380d582..0b73bed045b 100644 --- a/test/resolution.go +++ b/test/resolution.go @@ -7,8 +7,7 @@ import ( "strings" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" resolution "github.com/tektoncd/pipeline/pkg/resolution/resource" "github.com/tektoncd/pipeline/test/diff" ) @@ -28,7 +27,7 @@ func NewRequester(resource resolution.ResolvedResource, err error) *Requester { // NewResolvedResource creates a mock resolved resource that is // populated with the given data and annotations or returns the given // error from its Data() method. -func NewResolvedResource(data []byte, annotations map[string]string, source *v1beta1.ConfigSource, dataErr error) *ResolvedResource { +func NewResolvedResource(data []byte, annotations map[string]string, source *pipelinev1.ConfigSource, dataErr error) *ResolvedResource { return &ResolvedResource{ ResolvedData: data, ResolvedAnnotations: annotations, @@ -46,7 +45,7 @@ type Requester struct { // An error to return when a request is submitted. SubmitErr error // Params that should match those on the request in order to return the resolved resource - Params []pipelinev1beta1.Param + Params []pipelinev1.Param } // Submit implements resolution.Requester, accepting the name of a @@ -56,7 +55,7 @@ func (r *Requester) Submit(ctx context.Context, resolverName resolution.Resolver if len(r.Params) == 0 { return r.ResolvedResource, r.SubmitErr } - reqParams := make(map[string]pipelinev1beta1.ParamValue) + reqParams := make(map[string]pipelinev1.ParamValue) for _, p := range req.Params() { reqParams[p.Name] = p.Value } @@ -87,7 +86,7 @@ type ResolvedResource struct { // Annotations to return when resolution is complete. ResolvedAnnotations map[string]string // ResolvedSource to return the source reference of the remote data - ResolvedSource *pipelinev1beta1.ConfigSource + ResolvedSource *pipelinev1.ConfigSource } // Data implements resolution.ResolvedResource and returns the mock @@ -104,6 +103,6 @@ func (r *ResolvedResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (r *ResolvedResource) Source() *pipelinev1beta1.ConfigSource { +func (r *ResolvedResource) Source() *pipelinev1.ConfigSource { return r.ResolvedSource } diff --git a/test/trustedresources.go b/test/trustedresources.go index 76435775b16..62e2cf1a642 100644 --- a/test/trustedresources.go +++ b/test/trustedresources.go @@ -34,10 +34,9 @@ import ( "github.com/sigstore/sigstore/pkg/cryptoutils" "github.com/sigstore/sigstore/pkg/signature" "github.com/tektoncd/pipeline/pkg/apis/config" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" fakek8s "k8s.io/client-go/kubernetes/fake" "knative.dev/pkg/logging" @@ -55,18 +54,18 @@ var ( ) // GetUnsignedTask returns unsigned task with given name -func GetUnsignedTask(name string) *v1beta1.Task { - return &v1beta1.Task{ +func GetUnsignedTask(name string) *v1.Task { + return &v1.Task{ TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Task"}, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, Annotations: map[string]string{"foo": "bar"}, }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: v1.TaskSpec{ + Steps: []v1.Step{{ Image: "ubuntu", Name: "echo", }}, @@ -75,18 +74,18 @@ func GetUnsignedTask(name string) *v1beta1.Task { } // GetUnsignedPipeline returns unsigned pipeline with given name -func GetUnsignedPipeline(name string) *v1beta1.Pipeline { - return &v1beta1.Pipeline{ +func GetUnsignedPipeline(name string) *v1.Pipeline { + return &v1.Pipeline{ TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", + APIVersion: "tekton.dev/v1", Kind: "Pipeline"}, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, Annotations: map[string]string{"foo": "bar"}, }, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{ + Spec: v1.PipelineSpec{ + Tasks: []v1.PipelineTask{ { Name: "task", }, @@ -131,7 +130,7 @@ func SetupVerificationPolicies(t *testing.T) (signature.SignerVerifier, *ecdsa.P t.Fatalf("failed to generate keys %v", err) } - secret := &v1.Secret{ + secret := &corev1.Secret{ Data: map[string][]byte{"cosign.pub": pub}, ObjectMeta: metav1.ObjectMeta{ Name: "verification-secrets", @@ -163,7 +162,7 @@ func SetupVerificationPolicies(t *testing.T) (signature.SignerVerifier, *ecdsa.P { Name: "pubkey", Key: &v1alpha1.KeyRef{ - SecretRef: &v1.SecretReference{ + SecretRef: &corev1.SecretReference{ Name: secret.Name, Namespace: secret.Namespace, }, @@ -204,7 +203,7 @@ func SetupMatchAllVerificationPolicies(t *testing.T, namespace string) (signatur t.Fatalf("failed to generate keys %v", err) } - secret := &v1.Secret{ + secret := &corev1.Secret{ Data: map[string][]byte{"cosign.pub": pub}, ObjectMeta: metav1.ObjectMeta{ Name: "verification-secrets", @@ -305,7 +304,7 @@ func signInterface(signer signature.Signer, i interface{}) ([]byte, error) { } // GetSignedPipeline signed the given pipeline and rename it with given name -func GetSignedPipeline(unsigned *v1beta1.Pipeline, signer signature.Signer, name string) (*v1beta1.Pipeline, error) { +func GetSignedPipeline(unsigned *v1.Pipeline, signer signature.Signer, name string) (*v1.Pipeline, error) { signedPipeline := unsigned.DeepCopy() signedPipeline.Name = name if signedPipeline.Annotations == nil { @@ -320,7 +319,7 @@ func GetSignedPipeline(unsigned *v1beta1.Pipeline, signer signature.Signer, name } // GetSignedTask signed the given task and rename it with given name -func GetSignedTask(unsigned *v1beta1.Task, signer signature.Signer, name string) (*v1beta1.Task, error) { +func GetSignedTask(unsigned *v1.Task, signer signature.Signer, name string) (*v1.Task, error) { signedTask := unsigned.DeepCopy() signedTask.Name = name if signedTask.Annotations == nil {