diff --git a/internal/builder/v1alpha1/task.go b/internal/builder/v1alpha1/task.go index aa430dc7602..9b14748b435 100644 --- a/internal/builder/v1alpha1/task.go +++ b/internal/builder/v1alpha1/task.go @@ -22,7 +22,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" @@ -76,9 +75,6 @@ type TaskRunInputsOp func(*v1alpha1.TaskRunInputs) // TaskRunOutputsOp is an operation which modify a TaskRunOutputs struct. type TaskRunOutputsOp func(*v1alpha1.TaskRunOutputs) -// ResolvedTaskResourcesOp is an operation which modify a ResolvedTaskResources struct. -type ResolvedTaskResourcesOp func(*resources.ResolvedTaskResources) - // StepStateOp is an operation which modifies a StepState struct. type StepStateOp func(*v1alpha1.StepState) @@ -932,45 +928,3 @@ func TaskRunWorkspaceVolumeClaimTemplate(name, subPath string, volumeClaimTempla }) } } - -// ResolvedTaskResources creates a ResolvedTaskResources with default values. -// Any number of ResolvedTaskResources modifier can be passed to transform it. -func ResolvedTaskResources(ops ...ResolvedTaskResourcesOp) *resources.ResolvedTaskResources { - resources := &resources.ResolvedTaskResources{} - for _, op := range ops { - op(resources) - } - return resources -} - -// ResolvedTaskResourcesTaskSpec sets a TaskSpec to the ResolvedTaskResources. -// Any number of TaskSpec modifier can be passed to transform it. -func ResolvedTaskResourcesTaskSpec(ops ...TaskSpecOp) ResolvedTaskResourcesOp { - return func(r *resources.ResolvedTaskResources) { - spec := &v1alpha1.TaskSpec{} - for _, op := range ops { - op(spec) - } - r.TaskSpec = spec - } -} - -// ResolvedTaskResourcesInputs adds an input PipelineResource, with specified name, to the ResolvedTaskResources. -func ResolvedTaskResourcesInputs(name string, resource *v1alpha1.PipelineResource) ResolvedTaskResourcesOp { - return func(r *resources.ResolvedTaskResources) { - if r.Inputs == nil { - r.Inputs = map[string]*v1alpha1.PipelineResource{} - } - r.Inputs[name] = resource - } -} - -// ResolvedTaskResourcesOutputs adds an output PipelineResource, with specified name, to the ResolvedTaskResources. -func ResolvedTaskResourcesOutputs(name string, resource *v1alpha1.PipelineResource) ResolvedTaskResourcesOp { - return func(r *resources.ResolvedTaskResources) { - if r.Outputs == nil { - r.Outputs = map[string]*v1alpha1.PipelineResource{} - } - r.Outputs[name] = resource - } -} diff --git a/internal/builder/v1alpha1/task_test.go b/internal/builder/v1alpha1/task_test.go index 7ea83830f19..cb612e22b13 100644 --- a/internal/builder/v1alpha1/task_test.go +++ b/internal/builder/v1alpha1/task_test.go @@ -25,7 +25,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" @@ -421,40 +420,3 @@ func TestTaskRunWithPodTemplate(t *testing.T) { t.Fatalf("TaskRun diff -want, +got: %v", d) } } - -func TestResolvedTaskResources(t *testing.T) { - resolvedTaskResources := tb.ResolvedTaskResources( - tb.ResolvedTaskResourcesTaskSpec( - tb.Step("image", tb.StepCommand("/mycmd")), - ), - tb.ResolvedTaskResourcesInputs("foo", tb.PipelineResource("bar", tb.PipelineResourceNamespace("baz"))), - tb.ResolvedTaskResourcesOutputs("qux", tb.PipelineResource("quux", tb.PipelineResourceNamespace("quuz"))), - ) - expectedResolvedTaskResources := &resources.ResolvedTaskResources{ - TaskSpec: &v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Image: "image", - Command: []string{"/mycmd"}, - }}}, - }}, - Inputs: map[string]*v1alpha1.PipelineResource{ - "foo": { - ObjectMeta: metav1.ObjectMeta{ - Name: "bar", - Namespace: "baz", - }, - }, - }, - Outputs: map[string]*v1alpha1.PipelineResource{ - "qux": { - ObjectMeta: metav1.ObjectMeta{ - Name: "quux", - Namespace: "quuz", - }, - }, - }, - } - if d := cmp.Diff(expectedResolvedTaskResources, resolvedTaskResources); d != "" { - t.Fatalf("ResolvedTaskResources diff -want, +got: %v", d) - } -} diff --git a/pkg/apis/pipeline/v1beta1/condition_types.go b/pkg/apis/pipeline/v1beta1/condition_types.go index 9b2b5717827..24a5d97c78a 100644 --- a/pkg/apis/pipeline/v1beta1/condition_types.go +++ b/pkg/apis/pipeline/v1beta1/condition_types.go @@ -20,8 +20,31 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + "knative.dev/pkg/apis" ) +// ConditionCheck represents a single evaluation of a Condition step. +type ConditionCheck TaskRun + +func NewConditionCheck(tr *TaskRun) *ConditionCheck { + if tr == nil { + return nil + } + + cc := ConditionCheck(*tr) + return &cc +} + +// IsDone returns true if the ConditionCheck's status indicates that it is done. +func (cc *ConditionCheck) IsDone() bool { + return !cc.Status.GetCondition(apis.ConditionSucceeded).IsUnknown() +} + +// IsSuccessful returns true if the ConditionCheck's status indicates that it is done. +func (cc *ConditionCheck) IsSuccessful() bool { + return cc.Status.GetCondition(apis.ConditionSucceeded).IsTrue() +} + // ConditionCheckStatus defines the observed state of ConditionCheck type ConditionCheckStatus struct { duckv1beta1.Status `json:",inline"` diff --git a/pkg/apis/pipeline/v1beta1/container_replacements.go b/pkg/apis/pipeline/v1beta1/container_replacements.go new file mode 100644 index 00000000000..900845ed4c0 --- /dev/null +++ b/pkg/apis/pipeline/v1beta1/container_replacements.go @@ -0,0 +1,72 @@ +/* + Copyright 2019 The Tekton Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package v1beta1 + +import ( + "github.com/tektoncd/pipeline/pkg/substitution" + corev1 "k8s.io/api/core/v1" +) + +func ApplyContainerReplacements(step *corev1.Container, stringReplacements map[string]string, arrayReplacements map[string][]string) { + step.Name = substitution.ApplyReplacements(step.Name, stringReplacements) + step.Image = substitution.ApplyReplacements(step.Image, stringReplacements) + + // Use ApplyArrayReplacements here, as additional args may be added via an array parameter. + var newArgs []string + for _, a := range step.Args { + newArgs = append(newArgs, substitution.ApplyArrayReplacements(a, stringReplacements, arrayReplacements)...) + } + step.Args = newArgs + + for ie, e := range step.Env { + step.Env[ie].Value = substitution.ApplyReplacements(e.Value, stringReplacements) + if step.Env[ie].ValueFrom != nil { + if e.ValueFrom.SecretKeyRef != nil { + step.Env[ie].ValueFrom.SecretKeyRef.LocalObjectReference.Name = substitution.ApplyReplacements(e.ValueFrom.SecretKeyRef.LocalObjectReference.Name, stringReplacements) + step.Env[ie].ValueFrom.SecretKeyRef.Key = substitution.ApplyReplacements(e.ValueFrom.SecretKeyRef.Key, stringReplacements) + } + if e.ValueFrom.ConfigMapKeyRef != nil { + step.Env[ie].ValueFrom.ConfigMapKeyRef.LocalObjectReference.Name = substitution.ApplyReplacements(e.ValueFrom.ConfigMapKeyRef.LocalObjectReference.Name, stringReplacements) + step.Env[ie].ValueFrom.ConfigMapKeyRef.Key = substitution.ApplyReplacements(e.ValueFrom.ConfigMapKeyRef.Key, stringReplacements) + } + } + } + + for ie, e := range step.EnvFrom { + step.EnvFrom[ie].Prefix = substitution.ApplyReplacements(e.Prefix, stringReplacements) + if e.ConfigMapRef != nil { + step.EnvFrom[ie].ConfigMapRef.LocalObjectReference.Name = substitution.ApplyReplacements(e.ConfigMapRef.LocalObjectReference.Name, stringReplacements) + } + if e.SecretRef != nil { + step.EnvFrom[ie].SecretRef.LocalObjectReference.Name = substitution.ApplyReplacements(e.SecretRef.LocalObjectReference.Name, stringReplacements) + } + } + step.WorkingDir = substitution.ApplyReplacements(step.WorkingDir, stringReplacements) + + // Use ApplyArrayReplacements here, as additional commands may be added via an array parameter. + var newCommand []string + for _, c := range step.Command { + newCommand = append(newCommand, substitution.ApplyArrayReplacements(c, stringReplacements, arrayReplacements)...) + } + step.Command = newCommand + + for iv, v := range step.VolumeMounts { + step.VolumeMounts[iv].Name = substitution.ApplyReplacements(v.Name, stringReplacements) + step.VolumeMounts[iv].MountPath = substitution.ApplyReplacements(v.MountPath, stringReplacements) + step.VolumeMounts[iv].SubPath = substitution.ApplyReplacements(v.SubPath, stringReplacements) + } +} diff --git a/pkg/apis/pipeline/v1beta1/container_replacements_test.go b/pkg/apis/pipeline/v1beta1/container_replacements_test.go new file mode 100644 index 00000000000..9c81d50309f --- /dev/null +++ b/pkg/apis/pipeline/v1beta1/container_replacements_test.go @@ -0,0 +1,147 @@ +/* + Copyright 2019 The Tekton Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package v1beta1_test + +import ( + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + corev1 "k8s.io/api/core/v1" +) + +func TestApplyContainerReplacements(t *testing.T) { + replacements := map[string]string{ + "replace.me": "replaced!", + } + + arrayReplacements := map[string][]string{ + "array.replace.me": {"val1", "val2"}, + } + + s := corev1.Container{ + Name: "$(replace.me)", + Image: "$(replace.me)", + Command: []string{"$(array.replace.me)"}, + Args: []string{"$(array.replace.me)"}, + WorkingDir: "$(replace.me)", + EnvFrom: []corev1.EnvFromSource{{ + ConfigMapRef: &corev1.ConfigMapEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "$(replace.me)", + }, + }, + SecretRef: &corev1.SecretEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "$(replace.me)", + }, + }, + }}, + Env: []corev1.EnvVar{{ + Name: "not_me", + Value: "$(replace.me)", + ValueFrom: &corev1.EnvVarSource{ + ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "$(replace.me)", + }, + Key: "$(replace.me)", + }, + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "$(replace.me)", + }, + Key: "$(replace.me)", + }, + }, + }}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "$(replace.me)", + MountPath: "$(replace.me)", + SubPath: "$(replace.me)", + }}, + } + + expected := corev1.Container{ + Name: "replaced!", + Image: "replaced!", + Command: []string{"val1", "val2"}, + Args: []string{"val1", "val2"}, + WorkingDir: "replaced!", + EnvFrom: []corev1.EnvFromSource{{ + ConfigMapRef: &corev1.ConfigMapEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "replaced!", + }, + }, + SecretRef: &corev1.SecretEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "replaced!", + }, + }, + }}, + Env: []corev1.EnvVar{{ + Name: "not_me", + Value: "replaced!", + ValueFrom: &corev1.EnvVarSource{ + ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "replaced!", + }, + Key: "replaced!", + }, + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "replaced!", + }, + Key: "replaced!", + }, + }, + }}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "replaced!", + MountPath: "replaced!", + SubPath: "replaced!", + }}, + } + + v1beta1.ApplyContainerReplacements(&s, replacements, arrayReplacements) + if d := cmp.Diff(s, expected); d != "" { + t.Errorf("Container replacements failed: %s", d) + } +} + +func TestApplyContainerReplacements_NotDefined(t *testing.T) { + s := corev1.Container{ + Name: "$(params.not.defined)", + } + replacements := map[string]string{ + "replace.me": "replaced!", + } + + arrayReplacements := map[string][]string{ + "array.replace.me": {"val1", "val2"}, + } + + expected := corev1.Container{ + Name: "$(params.not.defined)", + } + v1beta1.ApplyContainerReplacements(&s, replacements, arrayReplacements) + if d := cmp.Diff(s, expected); d != "" { + t.Errorf("Unexpected container replacement: %s", d) + } +} diff --git a/pkg/apis/pipeline/v1beta1/param_types_test.go b/pkg/apis/pipeline/v1beta1/param_types_test.go index c23d5e61cad..4728f8d6b72 100644 --- a/pkg/apis/pipeline/v1beta1/param_types_test.go +++ b/pkg/apis/pipeline/v1beta1/param_types_test.go @@ -23,7 +23,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) diff --git a/pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go b/pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go index 9651b89a35b..d8c1ff26d8f 100644 --- a/pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go +++ b/pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go @@ -22,7 +22,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/apis/pipeline/v1beta1/resource_paths.go b/pkg/apis/pipeline/v1beta1/resource_paths.go new file mode 100644 index 00000000000..e29e750b267 --- /dev/null +++ b/pkg/apis/pipeline/v1beta1/resource_paths.go @@ -0,0 +1,40 @@ +/* + Copyright 2019 The Tekton Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package v1beta1 + +import "path/filepath" + +// InputResourcePath returns the path where the given input resource +// will get mounted in a Pod +func InputResourcePath(r ResourceDeclaration) string { + return path("/workspace", r) +} + +// OutputResourcePath returns the path to the output resouce in a Pod +func OutputResourcePath(r ResourceDeclaration) string { + return path("/workspace/output", r) +} + +func path(root string, r ResourceDeclaration) string { + if r.TargetPath != "" { + if filepath.IsAbs(r.TargetPath) { + return r.TargetPath + } + return filepath.Join("/workspace", r.TargetPath) + } + return filepath.Join(root, r.Name) +} diff --git a/pkg/apis/pipeline/v1beta1/resource_paths_test.go b/pkg/apis/pipeline/v1beta1/resource_paths_test.go new file mode 100644 index 00000000000..346dab77eb5 --- /dev/null +++ b/pkg/apis/pipeline/v1beta1/resource_paths_test.go @@ -0,0 +1,81 @@ +/* + Copyright 2019 The Tekton Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package v1beta1_test + +import ( + "testing" + + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" +) + +func TestInputResourcePath(t *testing.T) { + tcs := []struct { + name string + resource v1beta1.ResourceDeclaration + expected string + }{{ + name: "default_path", + resource: v1beta1.ResourceDeclaration{ + Name: "foo", + }, + expected: "/workspace/foo", + }, { + name: "with target path", + resource: v1beta1.ResourceDeclaration{ + Name: "foo", + TargetPath: "bar", + }, + expected: "/workspace/bar", + }} + + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + if actual := v1beta1.InputResourcePath(tc.resource); actual != tc.expected { + t.Errorf("Unexpected input resource path: %s", actual) + } + }) + } +} + +func TestOutputResourcePath(t *testing.T) { + tcs := []struct { + name string + resource v1beta1.ResourceDeclaration + expected string + }{{ + name: "default_path", + resource: v1beta1.ResourceDeclaration{ + Name: "foo", + }, + expected: "/workspace/output/foo", + }, { + name: "with target path", + resource: v1beta1.ResourceDeclaration{ + Name: "foo", + TargetPath: "bar", + }, + expected: "/workspace/bar", + }} + + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + if actual := v1beta1.OutputResourcePath(tc.resource); actual != tc.expected { + t.Errorf("Unexpected output resource path: %s", actual) + } + }) + } +} diff --git a/pkg/apis/pipeline/v1beta1/resource_types.go b/pkg/apis/pipeline/v1beta1/resource_types.go index 5cd4528f142..def3199e78a 100644 --- a/pkg/apis/pipeline/v1beta1/resource_types.go +++ b/pkg/apis/pipeline/v1beta1/resource_types.go @@ -138,6 +138,23 @@ type PipelineResourceRef struct { APIVersion string `json:"apiVersion,omitempty"` } +// PipelineResourceInterface interface to be implemented by different PipelineResource types +type PipelineResourceInterface interface { + // GetName returns the name of this PipelineResource instance. + GetName() string + // GetType returns the type of this PipelineResource (often a super type, e.g. in the case of storage). + GetType() PipelineResourceType + // Replacements returns all the attributes that this PipelineResource has that + // can be used for variable replacement. + Replacements() map[string]string + // GetOutputTaskModifier returns the TaskModifier instance that should be used on a Task + // in order to add this kind of resource when it is being used as an output. + GetOutputTaskModifier(ts *TaskSpec, path string) (TaskModifier, error) + // GetInputTaskModifier returns the TaskModifier instance that should be used on a Task + // in order to add this kind of resource when it is being used as an input. + GetInputTaskModifier(ts *TaskSpec, path string) (TaskModifier, error) +} + // TaskModifier is an interface to be implemented by different PipelineResources type TaskModifier interface { GetStepsToPrepend() []Step diff --git a/pkg/apis/pipeline/v1beta1/step_replacements.go b/pkg/apis/pipeline/v1beta1/step_replacements.go new file mode 100644 index 00000000000..188035bc6a9 --- /dev/null +++ b/pkg/apis/pipeline/v1beta1/step_replacements.go @@ -0,0 +1,26 @@ +/* + Copyright 2019 The Tekton Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package v1beta1 + +import ( + "github.com/tektoncd/pipeline/pkg/substitution" +) + +func ApplyStepReplacements(step *Step, stringReplacements map[string]string, arrayReplacements map[string][]string) { + step.Script = substitution.ApplyReplacements(step.Script, stringReplacements) + ApplyContainerReplacements(&step.Container, stringReplacements, arrayReplacements) +} diff --git a/pkg/apis/pipeline/v1beta1/step_replacements_test.go b/pkg/apis/pipeline/v1beta1/step_replacements_test.go new file mode 100644 index 00000000000..8f03671e430 --- /dev/null +++ b/pkg/apis/pipeline/v1beta1/step_replacements_test.go @@ -0,0 +1,131 @@ +/* + Copyright 2019 The Tekton Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package v1beta1_test + +import ( + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + corev1 "k8s.io/api/core/v1" +) + +func TestApplyStepReplacements(t *testing.T) { + replacements := map[string]string{ + "replace.me": "replaced!", + } + + arrayReplacements := map[string][]string{ + "array.replace.me": {"val1", "val2"}, + } + + s := v1beta1.Step{ + Script: "$(replace.me)", + Container: corev1.Container{ + Name: "$(replace.me)", + Image: "$(replace.me)", + Command: []string{"$(array.replace.me)"}, + Args: []string{"$(array.replace.me)"}, + WorkingDir: "$(replace.me)", + EnvFrom: []corev1.EnvFromSource{{ + ConfigMapRef: &corev1.ConfigMapEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "$(replace.me)", + }, + }, + SecretRef: &corev1.SecretEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "$(replace.me)", + }, + }, + }}, + Env: []corev1.EnvVar{{ + Name: "not_me", + Value: "$(replace.me)", + ValueFrom: &corev1.EnvVarSource{ + ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "$(replace.me)", + }, + Key: "$(replace.me)", + }, + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "$(replace.me)", + }, + Key: "$(replace.me)", + }, + }, + }}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "$(replace.me)", + MountPath: "$(replace.me)", + SubPath: "$(replace.me)", + }}, + }, + } + + expected := v1beta1.Step{ + Script: "replaced!", + Container: corev1.Container{ + Name: "replaced!", + Image: "replaced!", + Command: []string{"val1", "val2"}, + Args: []string{"val1", "val2"}, + WorkingDir: "replaced!", + EnvFrom: []corev1.EnvFromSource{{ + ConfigMapRef: &corev1.ConfigMapEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "replaced!", + }, + }, + SecretRef: &corev1.SecretEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "replaced!", + }, + }, + }}, + Env: []corev1.EnvVar{{ + Name: "not_me", + Value: "replaced!", + ValueFrom: &corev1.EnvVarSource{ + ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "replaced!", + }, + Key: "replaced!", + }, + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "replaced!", + }, + Key: "replaced!", + }, + }, + }}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "replaced!", + MountPath: "replaced!", + SubPath: "replaced!", + }}, + }, + } + v1beta1.ApplyStepReplacements(&s, replacements, arrayReplacements) + if d := cmp.Diff(s, expected); d != "" { + t.Errorf("Container replacements failed: %s", d) + } +} diff --git a/pkg/apis/pipeline/v1beta1/task_validation_test.go b/pkg/apis/pipeline/v1beta1/task_validation_test.go index ecdeb9596cf..70e17434005 100644 --- a/pkg/apis/pipeline/v1beta1/task_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/task_validation_test.go @@ -22,7 +22,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" corev1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" diff --git a/pkg/apis/pipeline/v1beta1/taskrun_defaults.go b/pkg/apis/pipeline/v1beta1/taskrun_defaults.go index 16542877869..7dae7ec2f6f 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_defaults.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_defaults.go @@ -27,8 +27,21 @@ import ( var _ apis.Defaultable = (*TaskRun)(nil) +const managedByLabelKey = "app.kubernetes.io/managed-by" + func (tr *TaskRun) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, tr.ObjectMeta) tr.Spec.SetDefaults(ctx) + + // If the TaskRun doesn't have a managed-by label, apply the default + // specified in the config. + cfg := config.FromContextOrDefaults(ctx) + if tr.ObjectMeta.Labels == nil { + tr.ObjectMeta.Labels = map[string]string{} + } + if _, found := tr.ObjectMeta.Labels[managedByLabelKey]; !found { + tr.ObjectMeta.Labels[managedByLabelKey] = cfg.Defaults.DefaultManagedByLabelValue + } } func (trs *TaskRunSpec) SetDefaults(ctx context.Context) { diff --git a/pkg/apis/pipeline/v1beta1/taskrun_defaults_test.go b/pkg/apis/pipeline/v1beta1/taskrun_defaults_test.go index e4a4f0e0b2e..3451900788b 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_defaults_test.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_defaults_test.go @@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ - package v1beta1_test import ( @@ -133,6 +132,9 @@ func TestTaskRunDefaulting(t *testing.T) { name: "empty no context", in: &v1beta1.TaskRun{}, want: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "tekton-pipelines"}, + }, Spec: v1beta1.TaskRunSpec{ Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute}, }, @@ -145,6 +147,9 @@ func TestTaskRunDefaulting(t *testing.T) { }, }, want: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "tekton-pipelines"}, + }, Spec: v1beta1.TaskRunSpec{ TaskRef: &v1beta1.TaskRef{Name: "foo", Kind: v1beta1.NamespacedTaskKind}, Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute}, @@ -158,6 +163,9 @@ func TestTaskRunDefaulting(t *testing.T) { }, }, want: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "tekton-pipelines"}, + }, Spec: v1beta1.TaskRunSpec{ TaskRef: &v1beta1.TaskRef{Name: "foo", Kind: v1beta1.NamespacedTaskKind}, Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute}, @@ -172,6 +180,9 @@ func TestTaskRunDefaulting(t *testing.T) { }, }, want: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "tekton-pipelines"}, + }, Spec: v1beta1.TaskRunSpec{ TaskRef: &v1beta1.TaskRef{Name: "foo", Kind: v1beta1.NamespacedTaskKind}, Timeout: &metav1.Duration{Duration: 5 * time.Minute}, @@ -197,10 +208,150 @@ func TestTaskRunDefaulting(t *testing.T) { }, }, want: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "tekton-pipelines"}, + }, + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{Name: "foo", Kind: v1beta1.NamespacedTaskKind}, + Timeout: &metav1.Duration{Duration: 5 * time.Minute}, + ServiceAccountName: "tekton", + }, + }, + wc: func(ctx context.Context) context.Context { + s := config.NewStore(logtesting.TestLogger(t)) + s.OnConfigChanged(&corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: config.GetDefaultsConfigName(), + }, + Data: map[string]string{ + "default-timeout-minutes": "5", + "default-service-account": "tekton", + }, + }) + return s.ToContext(ctx) + }, + }, { + name: "TaskRun managed-by set in config", + in: &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{Name: "foo"}, + }, + }, + want: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "something-else"}, + }, + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{Name: "foo", Kind: v1beta1.NamespacedTaskKind}, + Timeout: &metav1.Duration{Duration: 5 * time.Minute}, + }, + }, + wc: func(ctx context.Context) context.Context { + s := config.NewStore(logtesting.TestLogger(t)) + s.OnConfigChanged(&corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: config.GetDefaultsConfigName(), + }, + Data: map[string]string{ + "default-timeout-minutes": "5", + "default-managed-by-label-value": "something-else", + }, + }) + return s.ToContext(ctx) + }, + }, { + name: "TaskRun managed-by set in request and config (request wins)", + in: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "user-specified"}, + }, + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{Name: "foo"}, + }, + }, + want: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "user-specified"}, + }, + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{Name: "foo", Kind: v1beta1.NamespacedTaskKind}, + Timeout: &metav1.Duration{Duration: 5 * time.Minute}, + }, + }, + wc: func(ctx context.Context) context.Context { + s := config.NewStore(logtesting.TestLogger(t)) + s.OnConfigChanged(&corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: config.GetDefaultsConfigName(), + }, + Data: map[string]string{ + "default-timeout-minutes": "5", + "default-managed-by-label-value": "something-else", + }, + }) + return s.ToContext(ctx) + }, + }, { + name: "TaskRef pod template is coming from default config pod template", + in: &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{Name: "foo"}, + }, + }, + want: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "tekton-pipelines"}, + }, + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{Name: "foo", Kind: v1beta1.NamespacedTaskKind}, + Timeout: &metav1.Duration{Duration: 5 * time.Minute}, + ServiceAccountName: "tekton", + PodTemplate: &v1beta1.PodTemplate{ + NodeSelector: map[string]string{ + "label": "value", + }, + }, + }, + }, + wc: func(ctx context.Context) context.Context { + s := config.NewStore(logtesting.TestLogger(t)) + s.OnConfigChanged(&corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: config.GetDefaultsConfigName(), + }, + Data: map[string]string{ + "default-timeout-minutes": "5", + "default-service-account": "tekton", + "default-pod-template": "nodeSelector: { 'label': 'value' }", + }, + }) + return s.ToContext(ctx) + }, + }, { + name: "TaskRef pod template takes precedence over default config pod template", + in: &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{Name: "foo"}, + PodTemplate: &v1beta1.PodTemplate{ + NodeSelector: map[string]string{ + "label2": "value2", + }, + }, + }, + }, + want: &v1beta1.TaskRun{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app.kubernetes.io/managed-by": "tekton-pipelines"}, + }, Spec: v1beta1.TaskRunSpec{ TaskRef: &v1beta1.TaskRef{Name: "foo", Kind: v1beta1.NamespacedTaskKind}, Timeout: &metav1.Duration{Duration: 5 * time.Minute}, ServiceAccountName: "tekton", + PodTemplate: &v1beta1.PodTemplate{ + NodeSelector: map[string]string{ + "label2": "value2", + }, + }, }, }, wc: func(ctx context.Context) context.Context { @@ -212,6 +363,7 @@ func TestTaskRunDefaulting(t *testing.T) { Data: map[string]string{ "default-timeout-minutes": "5", "default-service-account": "tekton", + "default-pod-template": "nodeSelector: { 'label': 'value' }", }, }) return s.ToContext(ctx) @@ -225,9 +377,8 @@ func TestTaskRunDefaulting(t *testing.T) { ctx = tc.wc(ctx) } got.SetDefaults(ctx) - if !cmp.Equal(got, tc.want, ignoreUnexportedResources) { - t.Errorf("SetDefaults (-want, +got) = %v", - cmp.Diff(got, tc.want, ignoreUnexportedResources)) + if d := cmp.Diff(tc.want, got, ignoreUnexportedResources); d != "" { + t.Errorf("SetDefaults (-want, +got) = %v", d) } }) } diff --git a/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go b/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go index ded5c83216b..d6afc4d1eb1 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go @@ -22,7 +22,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" diff --git a/pkg/apis/resource/resource.go b/pkg/apis/resource/resource.go index df1fda2e546..d633b58d507 100644 --- a/pkg/apis/resource/resource.go +++ b/pkg/apis/resource/resource.go @@ -20,7 +20,7 @@ import ( "fmt" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/cloudevent" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/cluster" @@ -33,7 +33,7 @@ import ( // FromType returns an instance of the correct PipelineResource object type which can be // used to add input and output containers as well as volumes to a TaskRun's pod in order to realize // a PipelineResource in a pod. -func FromType(r *resourcev1alpha1.PipelineResource, images pipeline.Images) (pipelinev1alpha1.PipelineResourceInterface, error) { +func FromType(r *resourcev1alpha1.PipelineResource, images pipeline.Images) (pipelinev1beta1.PipelineResourceInterface, error) { switch r.Spec.Type { case resourcev1alpha1.PipelineResourceTypeGit: return git.NewResource(images.GitImage, r) diff --git a/pkg/apis/resource/v1alpha1/cloudevent/cloud_event_resource.go b/pkg/apis/resource/v1alpha1/cloudevent/cloud_event_resource.go index 122e5d28bdd..d2fcede62af 100644 --- a/pkg/apis/resource/v1alpha1/cloudevent/cloud_event_resource.go +++ b/pkg/apis/resource/v1alpha1/cloudevent/cloud_event_resource.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" ) @@ -81,11 +81,11 @@ func (s *Resource) Replacements() map[string]string { } // GetInputTaskModifier returns the TaskModifier to be used when this resource is an input. -func (s *Resource) GetInputTaskModifier(_ *v1alpha1.TaskSpec, _ string) (v1alpha1.TaskModifier, error) { - return &v1alpha1.InternalTaskModifier{}, nil +func (s *Resource) GetInputTaskModifier(_ *v1beta1.TaskSpec, _ string) (v1beta1.TaskModifier, error) { + return &v1beta1.InternalTaskModifier{}, nil } // GetOutputTaskModifier returns a No-op TaskModifier. -func (s *Resource) GetOutputTaskModifier(_ *v1alpha1.TaskSpec, _ string) (v1alpha1.TaskModifier, error) { - return &v1alpha1.InternalTaskModifier{}, nil +func (s *Resource) GetOutputTaskModifier(_ *v1beta1.TaskSpec, _ string) (v1beta1.TaskModifier, error) { + return &v1beta1.InternalTaskModifier{}, nil } diff --git a/pkg/apis/resource/v1alpha1/cloudevent/cloud_event_resource_test.go b/pkg/apis/resource/v1alpha1/cloudevent/cloud_event_resource_test.go index 129cfb844ee..8b9d7e8f7ed 100644 --- a/pkg/apis/resource/v1alpha1/cloudevent/cloud_event_resource_test.go +++ b/pkg/apis/resource/v1alpha1/cloudevent/cloud_event_resource_test.go @@ -20,8 +20,8 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/cloudevent" ) @@ -95,7 +95,7 @@ func TestCloudEvent_InputContainerSpec(t *testing.T) { TargetURI: "http://fake-uri", Type: resourcev1alpha1.PipelineResourceTypeCloudEvent, } - d, e := r.GetInputTaskModifier(&pipelinev1alpha1.TaskSpec{}, "") + d, e := r.GetInputTaskModifier(&v1beta1.TaskSpec{}, "") if d.GetStepsToPrepend() != nil { t.Errorf("Did not expect a download container for Resource") } @@ -110,7 +110,7 @@ func TestCloudEvent_OutputContainerSpec(t *testing.T) { TargetURI: "http://fake-uri", Type: resourcev1alpha1.PipelineResourceTypeCloudEvent, } - d, e := r.GetOutputTaskModifier(&pipelinev1alpha1.TaskSpec{}, "") + d, e := r.GetOutputTaskModifier(&v1beta1.TaskSpec{}, "") if d.GetStepsToAppend() != nil { t.Errorf("Did not expect an upload container for Resource") } diff --git a/pkg/apis/resource/v1alpha1/cluster/cluster_resource.go b/pkg/apis/resource/v1alpha1/cluster/cluster_resource.go index 5736c32b7ca..b07c7f5f7ed 100644 --- a/pkg/apis/resource/v1alpha1/cluster/cluster_resource.go +++ b/pkg/apis/resource/v1alpha1/cluster/cluster_resource.go @@ -23,7 +23,7 @@ import ( "strconv" "strings" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" @@ -158,12 +158,12 @@ func (s Resource) String() string { } // GetOutputTaskModifier returns a No-op TaskModifier. -func (s *Resource) GetOutputTaskModifier(_ *v1alpha1.TaskSpec, _ string) (v1alpha1.TaskModifier, error) { - return &v1alpha1.InternalTaskModifier{}, nil +func (s *Resource) GetOutputTaskModifier(_ *v1beta1.TaskSpec, _ string) (v1beta1.TaskModifier, error) { + return &v1beta1.InternalTaskModifier{}, nil } // GetInputTaskModifier returns the TaskModifier to be used when this resource is an input. -func (s *Resource) GetInputTaskModifier(ts *v1alpha1.TaskSpec, path string) (v1alpha1.TaskModifier, error) { +func (s *Resource) GetInputTaskModifier(ts *v1beta1.TaskSpec, path string) (v1beta1.TaskModifier, error) { var envVars []corev1.EnvVar for _, sec := range s.Secrets { ev := corev1.EnvVar{ @@ -179,7 +179,7 @@ func (s *Resource) GetInputTaskModifier(ts *v1alpha1.TaskSpec, path string) (v1a } envVars = append(envVars, ev) } - step := v1alpha1.Step{Container: corev1.Container{ + step := v1beta1.Step{Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix("kubeconfig"), Image: s.KubeconfigWriterImage, Command: []string{"/ko-app/kubeconfigwriter"}, @@ -188,7 +188,7 @@ func (s *Resource) GetInputTaskModifier(ts *v1alpha1.TaskSpec, path string) (v1a }, Env: envVars, }} - return &v1alpha1.InternalTaskModifier{ - StepsToPrepend: []v1alpha1.Step{step}, + return &v1beta1.InternalTaskModifier{ + StepsToPrepend: []v1beta1.Step{step}, }, nil } diff --git a/pkg/apis/resource/v1alpha1/cluster/cluster_resource_test.go b/pkg/apis/resource/v1alpha1/cluster/cluster_resource_test.go index bfd755b3cd6..2bba1f62d81 100644 --- a/pkg/apis/resource/v1alpha1/cluster/cluster_resource_test.go +++ b/pkg/apis/resource/v1alpha1/cluster/cluster_resource_test.go @@ -20,8 +20,8 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/cluster" "github.com/tektoncd/pipeline/test/names" @@ -170,8 +170,8 @@ func TestClusterResource_GetInputTaskModifier(t *testing.T) { KubeconfigWriterImage: "override-with-kubeconfig-writer:latest", } - ts := pipelinev1alpha1.TaskSpec{} - wantSteps := []pipelinev1alpha1.Step{{Container: corev1.Container{ + ts := v1beta1.TaskSpec{} + wantSteps := []v1beta1.Step{{Container: corev1.Container{ Name: "kubeconfig-9l9zj", Image: "override-with-kubeconfig-writer:latest", Command: []string{"/ko-app/kubeconfigwriter"}, diff --git a/pkg/apis/resource/v1alpha1/git/git_resource.go b/pkg/apis/resource/v1alpha1/git/git_resource.go index bd117216622..5e0f16df3a0 100644 --- a/pkg/apis/resource/v1alpha1/git/git_resource.go +++ b/pkg/apis/resource/v1alpha1/git/git_resource.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" @@ -146,7 +146,7 @@ func (s *Resource) Replacements() map[string]string { } // GetInputTaskModifier returns the TaskModifier to be used when this resource is an input. -func (s *Resource) GetInputTaskModifier(_ *v1alpha1.TaskSpec, path string) (v1alpha1.TaskModifier, error) { +func (s *Resource) GetInputTaskModifier(_ *v1beta1.TaskSpec, path string) (v1beta1.TaskModifier, error) { args := []string{ "-url", s.URL, "-revision", s.Revision, @@ -183,7 +183,7 @@ func (s *Resource) GetInputTaskModifier(_ *v1alpha1.TaskSpec, path string) (v1al env = append(env, corev1.EnvVar{Name: "NO_PROXY", Value: s.NOProxy}) } - step := v1alpha1.Step{ + step := v1beta1.Step{ Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(gitSource + "-" + s.Name), Image: s.GitImage, @@ -195,12 +195,12 @@ func (s *Resource) GetInputTaskModifier(_ *v1alpha1.TaskSpec, path string) (v1al }, } - return &v1alpha1.InternalTaskModifier{ - StepsToPrepend: []v1alpha1.Step{step}, + return &v1beta1.InternalTaskModifier{ + StepsToPrepend: []v1beta1.Step{step}, }, nil } // GetOutputTaskModifier returns a No-op TaskModifier. -func (s *Resource) GetOutputTaskModifier(_ *v1alpha1.TaskSpec, _ string) (v1alpha1.TaskModifier, error) { - return &v1alpha1.InternalTaskModifier{}, nil +func (s *Resource) GetOutputTaskModifier(_ *v1beta1.TaskSpec, _ string) (v1beta1.TaskModifier, error) { + return &v1beta1.InternalTaskModifier{}, nil } diff --git a/pkg/apis/resource/v1alpha1/git/git_resource_test.go b/pkg/apis/resource/v1alpha1/git/git_resource_test.go index 87590867cdc..72cbaed1cf9 100644 --- a/pkg/apis/resource/v1alpha1/git/git_resource_test.go +++ b/pkg/apis/resource/v1alpha1/git/git_resource_test.go @@ -20,9 +20,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/git" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" @@ -667,13 +667,13 @@ func TestGitResource_GetDownloadTaskModifier(t *testing.T) { }, }} { t.Run(tc.desc, func(t *testing.T) { - ts := pipelinev1alpha1.TaskSpec{} + ts := v1beta1.TaskSpec{} modifier, err := tc.gitResource.GetInputTaskModifier(&ts, "/test/test") if err != nil { t.Fatalf("Unexpected error getting GetDownloadTaskModifier: %s", err) } - if diff := cmp.Diff([]pipelinev1alpha1.Step{{Container: tc.want}}, modifier.GetStepsToPrepend()); diff != "" { + if diff := cmp.Diff([]v1beta1.Step{{Container: tc.want}}, modifier.GetStepsToPrepend()); diff != "" { t.Errorf("Mismatch of GitResource DownloadContainerSpec: %s", diff) } }) diff --git a/pkg/apis/resource/v1alpha1/image/image_resource.go b/pkg/apis/resource/v1alpha1/image/image_resource.go index 68b02bae2df..955928b7a8c 100644 --- a/pkg/apis/resource/v1alpha1/image/image_resource.go +++ b/pkg/apis/resource/v1alpha1/image/image_resource.go @@ -21,7 +21,7 @@ import ( "fmt" "strings" - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" ) @@ -77,13 +77,13 @@ func (s *Resource) Replacements() map[string]string { } // GetInputTaskModifier returns the TaskModifier to be used when this resource is an input. -func (s *Resource) GetInputTaskModifier(_ *pipelinev1alpha1.TaskSpec, _ string) (pipelinev1alpha1.TaskModifier, error) { - return &pipelinev1alpha1.InternalTaskModifier{}, nil +func (s *Resource) GetInputTaskModifier(_ *pipelinev1beta1.TaskSpec, _ string) (pipelinev1beta1.TaskModifier, error) { + return &pipelinev1beta1.InternalTaskModifier{}, nil } // GetOutputTaskModifier returns a No-op TaskModifier. -func (s *Resource) GetOutputTaskModifier(_ *pipelinev1alpha1.TaskSpec, _ string) (pipelinev1alpha1.TaskModifier, error) { - return &pipelinev1alpha1.InternalTaskModifier{}, nil +func (s *Resource) GetOutputTaskModifier(_ *pipelinev1beta1.TaskSpec, _ string) (pipelinev1beta1.TaskModifier, error) { + return &pipelinev1beta1.InternalTaskModifier{}, nil } func (s Resource) String() string { diff --git a/pkg/apis/resource/v1alpha1/image/image_resource_test.go b/pkg/apis/resource/v1alpha1/image/image_resource_test.go index d120233b49e..ed0f0e14afa 100644 --- a/pkg/apis/resource/v1alpha1/image/image_resource_test.go +++ b/pkg/apis/resource/v1alpha1/image/image_resource_test.go @@ -21,7 +21,7 @@ import ( "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/image" ) diff --git a/pkg/apis/resource/v1alpha1/pullrequest/pull_request_resource.go b/pkg/apis/resource/v1alpha1/pullrequest/pull_request_resource.go index c91fc385505..12a58767b89 100644 --- a/pkg/apis/resource/v1alpha1/pullrequest/pull_request_resource.go +++ b/pkg/apis/resource/v1alpha1/pullrequest/pull_request_resource.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" @@ -110,20 +110,20 @@ func (s *Resource) Replacements() map[string]string { } // GetInputTaskModifier returns the TaskModifier to be used when this resource is an input. -func (s *Resource) GetInputTaskModifier(ts *pipelinev1alpha1.TaskSpec, sourcePath string) (pipelinev1alpha1.TaskModifier, error) { - return &pipelinev1alpha1.InternalTaskModifier{ +func (s *Resource) GetInputTaskModifier(ts *pipelinev1beta1.TaskSpec, sourcePath string) (pipelinev1beta1.TaskModifier, error) { + return &pipelinev1beta1.InternalTaskModifier{ StepsToPrepend: s.getSteps("download", sourcePath), }, nil } // GetOutputTaskModifier returns a No-op TaskModifier. -func (s *Resource) GetOutputTaskModifier(ts *pipelinev1alpha1.TaskSpec, sourcePath string) (pipelinev1alpha1.TaskModifier, error) { - return &pipelinev1alpha1.InternalTaskModifier{ +func (s *Resource) GetOutputTaskModifier(ts *pipelinev1beta1.TaskSpec, sourcePath string) (pipelinev1beta1.TaskModifier, error) { + return &pipelinev1beta1.InternalTaskModifier{ StepsToAppend: s.getSteps("upload", sourcePath), }, nil } -func (s *Resource) getSteps(mode string, sourcePath string) []pipelinev1alpha1.Step { +func (s *Resource) getSteps(mode string, sourcePath string) []pipelinev1beta1.Step { args := []string{"-url", s.URL, "-path", sourcePath, "-mode", mode} if s.Provider != "" { args = append(args, []string{"-provider", s.Provider}...) @@ -150,7 +150,7 @@ func (s *Resource) getSteps(mode string, sourcePath string) []pipelinev1alpha1.S } } - return []pipelinev1alpha1.Step{{Container: corev1.Container{ + return []pipelinev1beta1.Step{{Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(prSource + "-" + s.Name), Image: s.PRImage, Command: []string{"/ko-app/pullrequest-init"}, diff --git a/pkg/apis/resource/v1alpha1/pullrequest/pull_request_resource_test.go b/pkg/apis/resource/v1alpha1/pullrequest/pull_request_resource_test.go index f95f87b8778..f8a83f595fd 100644 --- a/pkg/apis/resource/v1alpha1/pullrequest/pull_request_resource_test.go +++ b/pkg/apis/resource/v1alpha1/pullrequest/pull_request_resource_test.go @@ -20,9 +20,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - pipelinev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/pullrequest" "github.com/tektoncd/pipeline/test/names" @@ -65,7 +65,7 @@ func TestPullRequest_NewResource_error(t *testing.T) { type testcase struct { in *pullrequest.Resource - out []pipelinev1alpha1.Step + out []v1beta1.Step } const workspace = "/workspace" @@ -78,7 +78,7 @@ func containerTestCases(mode string) []testcase { PRImage: "override-with-pr:latest", InsecureSkipTLSVerify: false, }, - out: []pipelinev1alpha1.Step{{Container: corev1.Container{ + out: []v1beta1.Step{{Container: corev1.Container{ Name: "pr-source-nocreds-9l9zj", Image: "override-with-pr:latest", WorkingDir: pipeline.WorkspaceDir, @@ -99,7 +99,7 @@ func containerTestCases(mode string) []testcase { PRImage: "override-with-pr:latest", Provider: "github", }, - out: []pipelinev1alpha1.Step{{Container: corev1.Container{ + out: []v1beta1.Step{{Container: corev1.Container{ Name: "pr-source-creds-mz4c7", Image: "override-with-pr:latest", WorkingDir: pipeline.WorkspaceDir, @@ -124,7 +124,7 @@ func containerTestCases(mode string) []testcase { PRImage: "override-with-pr:latest", InsecureSkipTLSVerify: true, }, - out: []pipelinev1alpha1.Step{{Container: corev1.Container{ + out: []v1beta1.Step{{Container: corev1.Container{ Name: "pr-source-nocreds-mssqb", Image: "override-with-pr:latest", WorkingDir: pipeline.WorkspaceDir, @@ -140,7 +140,7 @@ func TestPullRequest_GetDownloadSteps(t *testing.T) { for _, tc := range containerTestCases("download") { t.Run(tc.in.GetName(), func(t *testing.T) { - ts := pipelinev1alpha1.TaskSpec{} + ts := v1beta1.TaskSpec{} got, err := tc.in.GetInputTaskModifier(&ts, workspace) if err != nil { t.Fatal(err) @@ -157,7 +157,7 @@ func TestPullRequest_GetOutputSteps(t *testing.T) { for _, tc := range containerTestCases("upload") { t.Run(tc.in.GetName(), func(t *testing.T) { - ts := pipelinev1alpha1.TaskSpec{} + ts := v1beta1.TaskSpec{} got, err := tc.in.GetOutputTaskModifier(&ts, workspace) if err != nil { t.Fatal(err) diff --git a/pkg/apis/resource/v1alpha1/storage/artifact_bucket.go b/pkg/apis/resource/v1alpha1/storage/artifact_bucket.go index ef3b2bd36f0..0c23798b29b 100644 --- a/pkg/apis/resource/v1alpha1/storage/artifact_bucket.go +++ b/pkg/apis/resource/v1alpha1/storage/artifact_bucket.go @@ -20,7 +20,7 @@ import ( "fmt" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" @@ -49,15 +49,15 @@ func (b *ArtifactBucket) GetType() string { } // StorageBasePath returns the path to be used to store artifacts in a pipelinerun temporary storage -func (b *ArtifactBucket) StorageBasePath(pr *v1alpha1.PipelineRun) string { +func (b *ArtifactBucket) StorageBasePath(pr *v1beta1.PipelineRun) string { return fmt.Sprintf("%s-%s-bucket", pr.Name, pr.Namespace) } // GetCopyFromStorageToSteps returns a container used to download artifacts from temporary storage -func (b *ArtifactBucket) GetCopyFromStorageToSteps(name, sourcePath, destinationPath string) []v1alpha1.Step { +func (b *ArtifactBucket) GetCopyFromStorageToSteps(name, sourcePath, destinationPath string) []v1beta1.Step { envVars, secretVolumeMount := getSecretEnvVarsAndVolumeMounts("bucket", secretVolumeMountPath, b.Secrets) - return []v1alpha1.Step{{Container: corev1.Container{ + return []v1beta1.Step{{Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("artifact-dest-mkdir-%s", name)), Image: b.ShellImage, Command: []string{"mkdir", "-p", destinationPath}, @@ -72,10 +72,10 @@ func (b *ArtifactBucket) GetCopyFromStorageToSteps(name, sourcePath, destination } // GetCopyToStorageFromSteps returns a container used to upload artifacts for temporary storage -func (b *ArtifactBucket) GetCopyToStorageFromSteps(name, sourcePath, destinationPath string) []v1alpha1.Step { +func (b *ArtifactBucket) GetCopyToStorageFromSteps(name, sourcePath, destinationPath string) []v1beta1.Step { envVars, secretVolumeMount := getSecretEnvVarsAndVolumeMounts("bucket", secretVolumeMountPath, b.Secrets) - return []v1alpha1.Step{{Container: corev1.Container{ + return []v1beta1.Step{{Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("artifact-copy-to-%s", name)), Image: b.GsutilImage, Command: []string{"gsutil"}, diff --git a/pkg/apis/resource/v1alpha1/storage/artifact_pvc.go b/pkg/apis/resource/v1alpha1/storage/artifact_pvc.go index ca6ee3e6e70..02bdbaec932 100644 --- a/pkg/apis/resource/v1alpha1/storage/artifact_pvc.go +++ b/pkg/apis/resource/v1alpha1/storage/artifact_pvc.go @@ -19,7 +19,7 @@ package storage import ( "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" ) @@ -43,13 +43,13 @@ func (p *ArtifactPVC) GetType() string { } // StorageBasePath returns the path to be used to store artifacts in a pipelinerun temporary storage. -func (p *ArtifactPVC) StorageBasePath(pr *v1alpha1.PipelineRun) string { +func (p *ArtifactPVC) StorageBasePath(pr *v1beta1.PipelineRun) string { return pvcDir } // GetCopyFromStorageToSteps returns a container used to download artifacts from temporary storage. -func (p *ArtifactPVC) GetCopyFromStorageToSteps(name, sourcePath, destinationPath string) []v1alpha1.Step { - return []v1alpha1.Step{{Container: corev1.Container{ +func (p *ArtifactPVC) GetCopyFromStorageToSteps(name, sourcePath, destinationPath string) []v1beta1.Step { + return []v1beta1.Step{{Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("source-copy-%s", name)), Image: p.ShellImage, Command: []string{"cp", "-r", fmt.Sprintf("%s/.", sourcePath), destinationPath}, @@ -57,8 +57,8 @@ func (p *ArtifactPVC) GetCopyFromStorageToSteps(name, sourcePath, destinationPat } // GetCopyToStorageFromSteps returns a container used to upload artifacts for temporary storage. -func (p *ArtifactPVC) GetCopyToStorageFromSteps(name, sourcePath, destinationPath string) []v1alpha1.Step { - return []v1alpha1.Step{{Container: corev1.Container{ +func (p *ArtifactPVC) GetCopyToStorageFromSteps(name, sourcePath, destinationPath string) []v1beta1.Step { + return []v1beta1.Step{{Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("source-mkdir-%s", name)), Image: p.ShellImage, Command: []string{"mkdir", "-p", destinationPath}, diff --git a/pkg/apis/resource/v1alpha1/storage/artifact_pvc_test.go b/pkg/apis/resource/v1alpha1/storage/artifact_pvc_test.go index ba2c0f652f9..720826d6015 100644 --- a/pkg/apis/resource/v1alpha1/storage/artifact_pvc_test.go +++ b/pkg/apis/resource/v1alpha1/storage/artifact_pvc_test.go @@ -20,7 +20,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" @@ -34,7 +34,7 @@ func TestPVCGetCopyFromContainerSpec(t *testing.T) { Name: "pipelinerun-pvc", ShellImage: "busybox", } - want := []v1alpha1.Step{{Container: corev1.Container{ + want := []v1beta1.Step{{Container: corev1.Container{ Name: "source-copy-workspace-9l9zj", Image: "busybox", @@ -54,7 +54,7 @@ func TestPVCGetCopyToContainerSpec(t *testing.T) { Name: "pipelinerun-pvc", ShellImage: "busybox", } - want := []v1alpha1.Step{{Container: corev1.Container{ + want := []v1beta1.Step{{Container: corev1.Container{ Name: "source-mkdir-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/destination"}, @@ -90,7 +90,7 @@ func TestPVCGetPvcMount(t *testing.T) { func TestPVCGetMakeStep(t *testing.T) { names.TestingSeed() - want := v1alpha1.Step{Container: corev1.Container{ + want := v1beta1.Step{Container: corev1.Container{ Name: "create-dir-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/destination"}, @@ -105,7 +105,7 @@ func TestStorageBasePath(t *testing.T) { pvc := storage.ArtifactPVC{ Name: "pipelinerun-pvc", } - pipelinerun := &v1alpha1.PipelineRun{ + pipelinerun := &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "pipelineruntest", diff --git a/pkg/apis/resource/v1alpha1/storage/build_gcs.go b/pkg/apis/resource/v1alpha1/storage/build_gcs.go index 03b39181d4f..dc540230346 100644 --- a/pkg/apis/resource/v1alpha1/storage/build_gcs.go +++ b/pkg/apis/resource/v1alpha1/storage/build_gcs.go @@ -21,7 +21,7 @@ import ( "strings" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" @@ -129,14 +129,14 @@ func (s *BuildGCSResource) Replacements() map[string]string { } // GetInputTaskModifier returns a TaskModifier that prepends a step to a Task to fetch the archive or manifest. -func (s *BuildGCSResource) GetInputTaskModifier(ts *v1alpha1.TaskSpec, sourcePath string) (v1alpha1.TaskModifier, error) { +func (s *BuildGCSResource) GetInputTaskModifier(ts *v1beta1.TaskSpec, sourcePath string) (v1beta1.TaskModifier, error) { args := []string{"--type", string(s.ArtifactType), "--location", s.Location} // dest_dir is the destination directory for GCS files to be copies" if sourcePath != "" { args = append(args, "--dest_dir", sourcePath) } - steps := []v1alpha1.Step{ + steps := []v1beta1.Step{ CreateDirStep(s.ShellImage, s.Name, sourcePath), {Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("storage-fetch-%s", s.Name)), @@ -147,15 +147,15 @@ func (s *BuildGCSResource) GetInputTaskModifier(ts *v1alpha1.TaskSpec, sourcePat volumes := getStorageVolumeSpec(s, *ts) - return &v1alpha1.InternalTaskModifier{ + return &v1beta1.InternalTaskModifier{ StepsToPrepend: steps, Volumes: volumes, }, nil } // GetOutputTaskModifier returns a No-op TaskModifier. -func (s *BuildGCSResource) GetOutputTaskModifier(ts *v1alpha1.TaskSpec, sourcePath string) (v1alpha1.TaskModifier, error) { - return &v1alpha1.InternalTaskModifier{}, nil +func (s *BuildGCSResource) GetOutputTaskModifier(ts *v1beta1.TaskSpec, sourcePath string) (v1beta1.TaskModifier, error) { + return &v1beta1.InternalTaskModifier{}, nil } func getArtifactType(val string) (GCSArtifactType, error) { diff --git a/pkg/apis/resource/v1alpha1/storage/build_gcs_test.go b/pkg/apis/resource/v1alpha1/storage/build_gcs_test.go index 591303bc234..a9f7cd0214f 100644 --- a/pkg/apis/resource/v1alpha1/storage/build_gcs_test.go +++ b/pkg/apis/resource/v1alpha1/storage/build_gcs_test.go @@ -20,9 +20,10 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" @@ -44,32 +45,32 @@ var images = pipeline.Images{ func TestBuildGCSResource_Invalid(t *testing.T) { for _, tc := range []struct { name string - pipelineResource *v1alpha1.PipelineResource + pipelineResource *resourcev1alpha1.PipelineResource }{{ name: "no location params", pipelineResource: tb.PipelineResource("buildgcs-resource-with-no-location-param", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("NotLocation", "doesntmatter"), tb.PipelineResourceSpecParam("type", "build-gcs"), )), }, { name: "location param with empty value", pipelineResource: tb.PipelineResource("buildgcs-resource-with-empty-location-param", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", ""), tb.PipelineResourceSpecParam("type", "build-gcs"), )), }, { name: "no artifactType params", pipelineResource: tb.PipelineResource("buildgcs-resource-with-no-artifactType-param", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gs://test"), tb.PipelineResourceSpecParam("type", "build-gcs"), )), }, { name: "artifactType param with empty value", pipelineResource: tb.PipelineResource("buildgcs-resource-with-empty-artifactType-param", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gs://test"), tb.PipelineResourceSpecParam("type", "build-gcs"), tb.PipelineResourceSpecParam("ArtifactType", ""), @@ -77,7 +78,7 @@ func TestBuildGCSResource_Invalid(t *testing.T) { }, { name: "artifactType param with invalid value", pipelineResource: tb.PipelineResource("buildgcs-resource-with-invalid-artifactType-param", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gs://test"), tb.PipelineResourceSpecParam("type", "build-gcs"), tb.PipelineResourceSpecParam("ArtifactType", "invalid-type"), @@ -85,7 +86,7 @@ func TestBuildGCSResource_Invalid(t *testing.T) { }, { name: "artifactType param with secrets value", pipelineResource: tb.PipelineResource("buildgcs-resource-with-invalid-artifactType-param-and-secrets", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gs://test"), tb.PipelineResourceSpecParam("type", "build-gcs"), tb.PipelineResourceSpecParam("ArtifactType", "invalid-type"), @@ -103,7 +104,7 @@ func TestBuildGCSResource_Invalid(t *testing.T) { func TestNewBuildGCSResource_Valid(t *testing.T) { pr := tb.PipelineResource("build-gcs-resource", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gs://fake-bucket"), tb.PipelineResourceSpecParam("type", "build-gcs"), tb.PipelineResourceSpecParam("ArtifactType", "Manifest"), @@ -111,7 +112,7 @@ func TestNewBuildGCSResource_Valid(t *testing.T) { expectedGCSResource := &storage.BuildGCSResource{ Name: "build-gcs-resource", Location: "gs://fake-bucket", - Type: v1alpha1.PipelineResourceTypeStorage, + Type: resourcev1alpha1.PipelineResourceTypeStorage, ArtifactType: "Manifest", ShellImage: "busybox", BuildGCSFetcherImage: "gcr.io/cloud-builders/gcs-fetcher:latest", @@ -130,7 +131,7 @@ func TestBuildGCS_GetReplacements(t *testing.T) { r := &storage.BuildGCSResource{ Name: "gcs-resource", Location: "gs://fake-bucket", - Type: v1alpha1.PipelineResourceTypeBuildGCS, + Type: resourcev1alpha1.PipelineResourceTypeBuildGCS, } expectedReplacementMap := map[string]string{ "name": "gcs-resource", @@ -157,7 +158,7 @@ func TestBuildGCS_GetInputSteps(t *testing.T) { ShellImage: "busybox", BuildGCSFetcherImage: "gcr.io/cloud-builders/gcs-fetcher:latest", } - wantSteps := []v1alpha1.Step{{Container: corev1.Container{ + wantSteps := []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-gcs-valid-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace"}, @@ -169,7 +170,7 @@ func TestBuildGCS_GetInputSteps(t *testing.T) { }}} names.TestingSeed() - ts := v1alpha1.TaskSpec{} + ts := v1beta1.TaskSpec{} got, err := resource.GetInputTaskModifier(&ts, "/workspace") if err != nil { t.Fatalf("GetDownloadSteps: %v", err) @@ -183,7 +184,7 @@ func TestBuildGCS_GetInputSteps(t *testing.T) { func TestBuildGCS_InvalidArtifactType(t *testing.T) { pr := tb.PipelineResource("build-gcs-resource", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gs://fake-bucket"), tb.PipelineResourceSpecParam("type", "build-gcs"), tb.PipelineResourceSpecParam("ArtifactType", "InVaLiD"), diff --git a/pkg/apis/resource/v1alpha1/storage/gcs.go b/pkg/apis/resource/v1alpha1/storage/gcs.go index 3d39f9116fa..4851c8857e4 100644 --- a/pkg/apis/resource/v1alpha1/storage/gcs.go +++ b/pkg/apis/resource/v1alpha1/storage/gcs.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" @@ -109,7 +109,7 @@ func (s *GCSResource) Replacements() map[string]string { } // GetOutputTaskModifier returns the TaskModifier to be used when this resource is an output. -func (s *GCSResource) GetOutputTaskModifier(ts *v1alpha1.TaskSpec, path string) (v1alpha1.TaskModifier, error) { +func (s *GCSResource) GetOutputTaskModifier(ts *v1beta1.TaskSpec, path string) (v1beta1.TaskModifier, error) { var args []string if s.TypeDir { args = []string{"rsync", "-d", "-r", path, s.Location} @@ -119,7 +119,7 @@ func (s *GCSResource) GetOutputTaskModifier(ts *v1alpha1.TaskSpec, path string) envVars, secretVolumeMount := getSecretEnvVarsAndVolumeMounts(s.Name, gcsSecretVolumeMountPath, s.Secrets) - step := v1alpha1.Step{Container: corev1.Container{ + step := v1beta1.Step{Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("upload-%s", s.Name)), Image: s.GsutilImage, Command: []string{"gsutil"}, @@ -130,14 +130,14 @@ func (s *GCSResource) GetOutputTaskModifier(ts *v1alpha1.TaskSpec, path string) volumes := getStorageVolumeSpec(s, *ts) - return &v1alpha1.InternalTaskModifier{ - StepsToAppend: []v1alpha1.Step{step}, + return &v1beta1.InternalTaskModifier{ + StepsToAppend: []v1beta1.Step{step}, Volumes: volumes, }, nil } // GetInputTaskModifier returns the TaskModifier to be used when this resource is an input. -func (s *GCSResource) GetInputTaskModifier(ts *v1alpha1.TaskSpec, path string) (v1alpha1.TaskModifier, error) { +func (s *GCSResource) GetInputTaskModifier(ts *v1beta1.TaskSpec, path string) (v1beta1.TaskModifier, error) { if path == "" { return nil, fmt.Errorf("GCSResource: Expect Destination Directory param to be set %s", s.Name) } @@ -149,7 +149,7 @@ func (s *GCSResource) GetInputTaskModifier(ts *v1alpha1.TaskSpec, path string) ( } envVars, secretVolumeMount := getSecretEnvVarsAndVolumeMounts(s.Name, gcsSecretVolumeMountPath, s.Secrets) - steps := []v1alpha1.Step{ + steps := []v1beta1.Step{ CreateDirStep(s.ShellImage, s.Name, path), { Script: script, @@ -164,7 +164,7 @@ func (s *GCSResource) GetInputTaskModifier(ts *v1alpha1.TaskSpec, path string) ( volumes := getStorageVolumeSpec(s, *ts) - return &v1alpha1.InternalTaskModifier{ + return &v1beta1.InternalTaskModifier{ StepsToPrepend: steps, Volumes: volumes, }, nil diff --git a/pkg/apis/resource/v1alpha1/storage/gcs_test.go b/pkg/apis/resource/v1alpha1/storage/gcs_test.go index cc872d57bda..155288834dc 100644 --- a/pkg/apis/resource/v1alpha1/storage/gcs_test.go +++ b/pkg/apis/resource/v1alpha1/storage/gcs_test.go @@ -20,8 +20,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" @@ -30,16 +31,16 @@ import ( func TestInvalidNewStorageResource(t *testing.T) { for _, tc := range []struct { name string - pipelineResource *v1alpha1.PipelineResource + pipelineResource *resourcev1alpha1.PipelineResource }{{ name: "wrong-resource-type", pipelineResource: tb.PipelineResource("gcs-resource", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeGit), + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeGit), ), }, { name: "unimplemented type", pipelineResource: tb.PipelineResource("gcs-resource", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeStorage, + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gs://fake-bucket"), tb.PipelineResourceSpecParam("type", "non-existent-type"), ), @@ -47,14 +48,14 @@ func TestInvalidNewStorageResource(t *testing.T) { }, { name: "no type", pipelineResource: tb.PipelineResource("gcs-resource", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeStorage, + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gs://fake-bucket"), ), ), }, { name: "no location params", pipelineResource: tb.PipelineResource("gcs-resource", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeStorage, + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("NotLocation", "doesntmatter"), tb.PipelineResourceSpecParam("type", "gcs"), ), @@ -62,7 +63,7 @@ func TestInvalidNewStorageResource(t *testing.T) { }, { name: "location param with empty value", pipelineResource: tb.PipelineResource("gcs-resource", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeStorage, + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", ""), tb.PipelineResourceSpecParam("type", "gcs"), ), @@ -79,7 +80,7 @@ func TestInvalidNewStorageResource(t *testing.T) { func TestValidNewGCSResource(t *testing.T) { pr := tb.PipelineResource("gcs-resource", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gs://fake-bucket"), tb.PipelineResourceSpecParam("type", "gcs"), tb.PipelineResourceSpecParam("dir", "anything"), @@ -88,9 +89,9 @@ func TestValidNewGCSResource(t *testing.T) { expectedGCSResource := &storage.GCSResource{ Name: "gcs-resource", Location: "gs://fake-bucket", - Type: v1alpha1.PipelineResourceTypeStorage, + Type: resourcev1alpha1.PipelineResourceTypeStorage, TypeDir: true, - Secrets: []v1alpha1.SecretParam{{ + Secrets: []resourcev1alpha1.SecretParam{{ SecretName: "secretName", SecretKey: "secretKey", FieldName: "GOOGLE_APPLICATION_CREDENTIALS", @@ -112,7 +113,7 @@ func TestGCSGetReplacements(t *testing.T) { gcsResource := &storage.GCSResource{ Name: "gcs-resource", Location: "gs://fake-bucket", - Type: v1alpha1.PipelineResourceTypeGCS, + Type: resourcev1alpha1.PipelineResourceTypeGCS, } expectedReplacementMap := map[string]string{ "name": "gcs-resource", @@ -126,7 +127,7 @@ func TestGCSGetReplacements(t *testing.T) { func TestGetParams(t *testing.T) { pr := tb.PipelineResource("gcs-resource", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeStorage, + resourcev1alpha1.PipelineResourceTypeStorage, tb.PipelineResourceSpecParam("Location", "gcs://some-bucket.zip"), tb.PipelineResourceSpecParam("type", "gcs"), tb.PipelineResourceSpecSecretParam("test-field-name", "test-secret-name", "test-secret-key"), @@ -135,7 +136,7 @@ func TestGetParams(t *testing.T) { if err != nil { t.Fatalf("Error creating storage resource: %s", err.Error()) } - expectedSp := []v1alpha1.SecretParam{{ + expectedSp := []resourcev1alpha1.SecretParam{{ SecretKey: "test-secret-key", SecretName: "test-secret-name", FieldName: "test-field-name", @@ -151,7 +152,7 @@ func TestGetInputSteps(t *testing.T) { for _, tc := range []struct { name string gcsResource *storage.GCSResource - wantSteps []v1alpha1.Step + wantSteps []v1beta1.Step wantErr bool }{{ name: "valid download protected buckets", @@ -159,7 +160,7 @@ func TestGetInputSteps(t *testing.T) { Name: "gcs-valid", Location: "gs://some-bucket", TypeDir: true, - Secrets: []v1alpha1.SecretParam{{ + Secrets: []resourcev1alpha1.SecretParam{{ SecretName: "secretName", FieldName: "GOOGLE_APPLICATION_CREDENTIALS", SecretKey: "key.json", @@ -167,7 +168,7 @@ func TestGetInputSteps(t *testing.T) { ShellImage: "busybox", GsutilImage: "google/cloud-sdk", }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-gcs-valid-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace"}, @@ -197,7 +198,7 @@ gsutil rsync -d -r gs://some-bucket /workspace gcsResource: &storage.GCSResource{ Name: "gcs-valid", Location: "gs://some-bucket", - Secrets: []v1alpha1.SecretParam{{ + Secrets: []resourcev1alpha1.SecretParam{{ SecretName: "secretName", FieldName: "fieldName", SecretKey: "key.json", @@ -209,7 +210,7 @@ gsutil rsync -d -r gs://some-bucket /workspace ShellImage: "busybox", GsutilImage: "google/cloud-sdk", }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-gcs-valid-mssqb", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace"}, @@ -236,7 +237,7 @@ gsutil cp gs://some-bucket /workspace }}, }} { t.Run(tc.name, func(t *testing.T) { - ts := v1alpha1.TaskSpec{} + ts := v1beta1.TaskSpec{} gotSpec, err := tc.gcsResource.GetInputTaskModifier(&ts, "/workspace") if tc.wantErr && err == nil { t.Fatalf("Expected error to be %t but got %v:", tc.wantErr, err) @@ -254,7 +255,7 @@ func TestGetOutputTaskModifier(t *testing.T) { for _, tc := range []struct { name string gcsResource *storage.GCSResource - wantSteps []v1alpha1.Step + wantSteps []v1beta1.Step wantErr bool }{{ name: "valid upload to protected buckets with directory paths", @@ -262,14 +263,14 @@ func TestGetOutputTaskModifier(t *testing.T) { Name: "gcs-valid", Location: "gs://some-bucket", TypeDir: true, - Secrets: []v1alpha1.SecretParam{{ + Secrets: []resourcev1alpha1.SecretParam{{ SecretName: "secretName", FieldName: "GOOGLE_APPLICATION_CREDENTIALS", SecretKey: "key.json", }}, GsutilImage: "google/cloud-sdk", }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "upload-gcs-valid-9l9zj", Image: "google/cloud-sdk", Command: []string{"gsutil"}, @@ -285,7 +286,7 @@ func TestGetOutputTaskModifier(t *testing.T) { gcsResource: &storage.GCSResource{ Name: "gcs-valid", Location: "gs://some-bucket", - Secrets: []v1alpha1.SecretParam{{ + Secrets: []resourcev1alpha1.SecretParam{{ SecretName: "secretName", FieldName: "GOOGLE_APPLICATION_CREDENTIALS", SecretKey: "key.json", @@ -296,7 +297,7 @@ func TestGetOutputTaskModifier(t *testing.T) { }}, GsutilImage: "google/cloud-sdk", }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "upload-gcs-valid-mz4c7", Image: "google/cloud-sdk", Command: []string{"gsutil"}, @@ -317,7 +318,7 @@ func TestGetOutputTaskModifier(t *testing.T) { TypeDir: false, GsutilImage: "google/cloud-sdk", }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "upload-gcs-valid-mssqb", Image: "google/cloud-sdk", Command: []string{"gsutil"}, @@ -325,7 +326,7 @@ func TestGetOutputTaskModifier(t *testing.T) { }}}, }} { t.Run(tc.name, func(t *testing.T) { - ts := v1alpha1.TaskSpec{} + ts := v1beta1.TaskSpec{} got, err := tc.gcsResource.GetOutputTaskModifier(&ts, "/workspace/") if (err != nil) != tc.wantErr { t.Fatalf("Expected error to be %t but got %v:", tc.wantErr, err) diff --git a/pkg/apis/resource/v1alpha1/storage/storage.go b/pkg/apis/resource/v1alpha1/storage/storage.go index df96d6ddd7a..7a9149ada88 100644 --- a/pkg/apis/resource/v1alpha1/storage/storage.go +++ b/pkg/apis/resource/v1alpha1/storage/storage.go @@ -21,7 +21,7 @@ import ( "strings" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" @@ -38,14 +38,14 @@ const ( // It adds a function to the PipelineResourceInterface for retrieving secrets that are usually // needed for storage PipelineResources. type PipelineStorageResourceInterface interface { - v1alpha1.PipelineResourceInterface - GetSecretParams() []v1alpha1.SecretParam + v1beta1.PipelineResourceInterface + GetSecretParams() []resource.SecretParam } // NewResource returns an instance of the requested storage subtype, which can be used // to add input and output steps and volumes to an executing pod. func NewResource(images pipeline.Images, r *resource.PipelineResource) (PipelineStorageResourceInterface, error) { - if r.Spec.Type != v1alpha1.PipelineResourceTypeStorage { + if r.Spec.Type != v1beta1.PipelineResourceTypeStorage { return nil, fmt.Errorf("StoreResource: Cannot create a storage resource from a %s Pipeline Resource", r.Spec.Type) } @@ -64,7 +64,7 @@ func NewResource(images pipeline.Images, r *resource.PipelineResource) (Pipeline return nil, fmt.Errorf("StoreResource: Cannot create a storage resource without type %s in spec", r.Name) } -func getStorageVolumeSpec(s PipelineStorageResourceInterface, spec v1alpha1.TaskSpec) []corev1.Volume { +func getStorageVolumeSpec(s PipelineStorageResourceInterface, spec v1beta1.TaskSpec) []corev1.Volume { var storageVol []corev1.Volume mountedSecrets := map[string]string{} @@ -94,8 +94,8 @@ func getStorageVolumeSpec(s PipelineStorageResourceInterface, spec v1alpha1.Task } // of the step will include name. -func CreateDirStep(shellImage string, name, destinationPath string) v1alpha1.Step { - return v1alpha1.Step{Container: corev1.Container{ +func CreateDirStep(shellImage string, name, destinationPath string) v1beta1.Step { + return v1beta1.Step{Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("create-dir-%s", strings.ToLower(name))), Image: shellImage, Command: []string{"mkdir", "-p", destinationPath}, diff --git a/pkg/artifacts/artifact_storage_test.go b/pkg/artifacts/artifact_storage_test.go index 0bafe09b6f3..af62183e3f3 100644 --- a/pkg/artifacts/artifact_storage_test.go +++ b/pkg/artifacts/artifact_storage_test.go @@ -22,7 +22,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" "github.com/tektoncd/pipeline/pkg/system" corev1 "k8s.io/api/core/v1" @@ -46,7 +47,7 @@ var ( PRImage: "override-with-pr:latest", ImageDigestExporterImage: "override-with-imagedigest-exporter-image:latest", } - pipelinerun = &v1alpha1.PipelineRun{ + pipelinerun = &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "pipelineruntest", @@ -59,23 +60,23 @@ var ( return x.Cmp(y) == 0 }) - pipelineWithTasksWithFrom = v1alpha1.Pipeline{ - Spec: v1alpha1.PipelineSpec{ - Resources: []v1alpha1.PipelineDeclaredResource{{ + pipelineWithTasksWithFrom = v1beta1.Pipeline{ + Spec: v1beta1.PipelineSpec{ + Resources: []v1beta1.PipelineDeclaredResource{{ Name: "input1", Type: "git", }, { Name: "output", Type: "git", }}, - Tasks: []v1alpha1.PipelineTask{ + Tasks: []v1beta1.PipelineTask{ { Name: "task1", - TaskRef: &v1alpha1.TaskRef{ + TaskRef: &v1beta1.TaskRef{ Name: "task", }, - Resources: &v1alpha1.PipelineTaskResources{ - Outputs: []v1alpha1.PipelineTaskOutputResource{{ + Resources: &v1beta1.PipelineTaskResources{ + Outputs: []v1beta1.PipelineTaskOutputResource{{ Name: "foo", Resource: "output", }}, @@ -83,11 +84,11 @@ var ( }, { Name: "task2", - TaskRef: &v1alpha1.TaskRef{ + TaskRef: &v1beta1.TaskRef{ Name: "task", }, - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "foo", Resource: "output", From: []string{"task1"}, @@ -249,7 +250,7 @@ func TestInitializeArtifactStorageWithConfigMap(t *testing.T) { }, expectedArtifactStorage: &storage.ArtifactBucket{ Location: "gs://fake-bucket", - Secrets: []v1alpha1.SecretParam{{ + Secrets: []resourcev1alpha1.SecretParam{{ FieldName: "GOOGLE_APPLICATION_CREDENTIALS", SecretKey: "sakey", SecretName: "secret1", @@ -344,7 +345,7 @@ func TestInitializeArtifactStorageWithConfigMap(t *testing.T) { Location: "s3://fake-bucket", ShellImage: "busybox", GsutilImage: "google/cloud-sdk", - Secrets: []v1alpha1.SecretParam{{ + Secrets: []resourcev1alpha1.SecretParam{{ FieldName: "BOTO_CONFIG", SecretKey: "sakey", SecretName: "secret1", @@ -387,24 +388,24 @@ func TestInitializeArtifactStorageNoStorageNeeded(t *testing.T) { logger := logtesting.TestLogger(t) // This Pipeline has Tasks that use both inputs and outputs, but there is // no link between the inputs and outputs, so no storage is needed - pipeline := &v1alpha1.Pipeline{ + pipeline := &v1beta1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "pipelineruntest", }, - Spec: v1alpha1.PipelineSpec{ - Tasks: []v1alpha1.PipelineTask{ + Spec: v1beta1.PipelineSpec{ + Tasks: []v1beta1.PipelineTask{ { Name: "task1", - TaskRef: &v1alpha1.TaskRef{ + TaskRef: &v1beta1.TaskRef{ Name: "task", }, - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "input1", Resource: "resource", }}, - Outputs: []v1alpha1.PipelineTaskOutputResource{{ + Outputs: []v1beta1.PipelineTaskOutputResource{{ Name: "output", Resource: "resource", }}, @@ -412,15 +413,15 @@ func TestInitializeArtifactStorageNoStorageNeeded(t *testing.T) { }, { Name: "task2", - TaskRef: &v1alpha1.TaskRef{ + TaskRef: &v1beta1.TaskRef{ Name: "task", }, - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "input1", Resource: "resource", }}, - Outputs: []v1alpha1.PipelineTaskOutputResource{{ + Outputs: []v1beta1.PipelineTaskOutputResource{{ Name: "output", Resource: "resource", }}, @@ -429,13 +430,13 @@ func TestInitializeArtifactStorageNoStorageNeeded(t *testing.T) { }, }, } - pipelinerun := &v1alpha1.PipelineRun{ + pipelinerun := &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", Namespace: "namespace", }, - Spec: v1alpha1.PipelineRunSpec{ - PipelineRef: &v1alpha1.PipelineRef{ + Spec: v1beta1.PipelineRunSpec{ + PipelineRef: &v1beta1.PipelineRef{ Name: "pipeline", }, }, @@ -495,7 +496,7 @@ func TestInitializeArtifactStorageNoStorageNeeded(t *testing.T) { } func TestCleanupArtifactStorage(t *testing.T) { - pipelinerun := &v1alpha1.PipelineRun{ + pipelinerun := &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "pipelineruntest", @@ -559,7 +560,7 @@ func TestCleanupArtifactStorage(t *testing.T) { } func TestInitializeArtifactStorageWithoutConfigMap(t *testing.T) { - pipelinerun := &v1alpha1.PipelineRun{ + pipelinerun := &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelineruntest", Namespace: "foo", @@ -585,7 +586,7 @@ func TestInitializeArtifactStorageWithoutConfigMap(t *testing.T) { } func TestGetArtifactStorageWithConfigMap(t *testing.T) { - pipelinerun := &v1alpha1.PipelineRun{ + pipelinerun := &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", Name: "pipelineruntest", @@ -611,7 +612,7 @@ func TestGetArtifactStorageWithConfigMap(t *testing.T) { }, expectedArtifactStorage: &storage.ArtifactBucket{ Location: "gs://fake-bucket", - Secrets: []v1alpha1.SecretParam{{ + Secrets: []resourcev1alpha1.SecretParam{{ FieldName: "GOOGLE_APPLICATION_CREDENTIALS", SecretKey: "sakey", SecretName: "secret1", diff --git a/pkg/artifacts/artifacts_storage.go b/pkg/artifacts/artifacts_storage.go index de54acd4735..cde77b94153 100644 --- a/pkg/artifacts/artifacts_storage.go +++ b/pkg/artifacts/artifacts_storage.go @@ -22,7 +22,8 @@ import ( "strings" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" "github.com/tektoncd/pipeline/pkg/system" "go.uber.org/zap" @@ -85,23 +86,23 @@ func GetPVCConfigName() string { // ArtifactStorageInterface is an interface to define the steps to copy // an pipeline artifact to/from temporary storage type ArtifactStorageInterface interface { - GetCopyToStorageFromSteps(name, sourcePath, destinationPath string) []v1alpha1.Step - GetCopyFromStorageToSteps(name, sourcePath, destinationPath string) []v1alpha1.Step + GetCopyToStorageFromSteps(name, sourcePath, destinationPath string) []v1beta1.Step + GetCopyFromStorageToSteps(name, sourcePath, destinationPath string) []v1beta1.Step GetSecretsVolumes() []corev1.Volume GetType() string - StorageBasePath(pr *v1alpha1.PipelineRun) string + StorageBasePath(pr *v1beta1.PipelineRun) string } // ArtifactStorageNone is used when no storage is needed. type ArtifactStorageNone struct{} // GetCopyToStorageFromSteps returns no containers because none are needed. -func (a *ArtifactStorageNone) GetCopyToStorageFromSteps(name, sourcePath, destinationPath string) []v1alpha1.Step { +func (a *ArtifactStorageNone) GetCopyToStorageFromSteps(name, sourcePath, destinationPath string) []v1beta1.Step { return nil } // GetCopyFromStorageToSteps returns no containers because none are needed. -func (a *ArtifactStorageNone) GetCopyFromStorageToSteps(name, sourcePath, destinationPath string) []v1alpha1.Step { +func (a *ArtifactStorageNone) GetCopyFromStorageToSteps(name, sourcePath, destinationPath string) []v1beta1.Step { return nil } @@ -117,13 +118,13 @@ func (a *ArtifactStorageNone) GetType() string { // StorageBasePath returns an empty string because no storage is being used and so // there is no path that resources should be copied from / to. -func (a *ArtifactStorageNone) StorageBasePath(pr *v1alpha1.PipelineRun) string { +func (a *ArtifactStorageNone) StorageBasePath(pr *v1beta1.PipelineRun) string { return "" } // InitializeArtifactStorage will check if there is there is a // bucket configured, create a PVC or return nil if no storage is required. -func InitializeArtifactStorage(images pipeline.Images, pr *v1alpha1.PipelineRun, ps *v1alpha1.PipelineSpec, c kubernetes.Interface, logger *zap.SugaredLogger) (ArtifactStorageInterface, error) { +func InitializeArtifactStorage(images pipeline.Images, pr *v1beta1.PipelineRun, ps *v1beta1.PipelineSpec, c kubernetes.Interface, logger *zap.SugaredLogger) (ArtifactStorageInterface, error) { // Artifact storage is needed under the following condition: // Any Task in the pipeline contains an Output resource // AND that Output resource is one of the AllowedOutputResource types. @@ -132,7 +133,7 @@ func InitializeArtifactStorage(images pipeline.Images, pr *v1alpha1.PipelineRun, // Build an index of resources used in the pipeline that are an AllowedOutputResource possibleOutputs := map[string]struct{}{} for _, r := range ps.Resources { - if _, ok := v1alpha1.AllowedOutputResources[r.Type]; ok { + if _, ok := v1beta1.AllowedOutputResources[r.Type]; ok { possibleOutputs[r.Name] = struct{}{} } } @@ -169,7 +170,7 @@ func InitializeArtifactStorage(images pipeline.Images, pr *v1alpha1.PipelineRun, // CleanupArtifactStorage will delete the PipelineRun's artifact storage PVC if it exists. The PVC is created for using // an output workspace or artifacts from one Task to another Task. No other PVCs will be impacted by this cleanup. -func CleanupArtifactStorage(pr *v1alpha1.PipelineRun, c kubernetes.Interface, logger *zap.SugaredLogger) error { +func CleanupArtifactStorage(pr *v1beta1.PipelineRun, c kubernetes.Interface, logger *zap.SugaredLogger) error { configMap, err := c.CoreV1().ConfigMaps(system.GetNamespace()).Get(GetBucketConfigName(), metav1.GetOptions{}) shouldCreatePVC, err := ConfigMapNeedsPVC(configMap, err, logger) if err != nil { @@ -241,7 +242,7 @@ func NewArtifactBucketConfigFromConfigMap(images pipeline.Images) func(configMap } else { c.Location = location } - sp := v1alpha1.SecretParam{} + sp := resourcev1alpha1.SecretParam{} if secretName, ok := configMap.Data[BucketServiceAccountSecretName]; ok { if secretKey, ok := configMap.Data[BucketServiceAccountSecretKey]; ok { sp.FieldName = "GOOGLE_APPLICATION_CREDENTIALS" @@ -257,7 +258,7 @@ func NewArtifactBucketConfigFromConfigMap(images pipeline.Images) func(configMap } } -func createPVC(pr *v1alpha1.PipelineRun, c kubernetes.Interface) (*corev1.PersistentVolumeClaim, error) { +func createPVC(pr *v1beta1.PipelineRun, c kubernetes.Interface) (*corev1.PersistentVolumeClaim, error) { if _, err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Get(GetPVCName(pr), metav1.GetOptions{}); err != nil { if errors.IsNotFound(err) { @@ -297,7 +298,7 @@ func createPVC(pr *v1alpha1.PipelineRun, c kubernetes.Interface) (*corev1.Persis return nil, nil } -func deletePVC(pr *v1alpha1.PipelineRun, c kubernetes.Interface) error { +func deletePVC(pr *v1beta1.PipelineRun, c kubernetes.Interface) error { if _, err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Get(GetPVCName(pr), metav1.GetOptions{}); err != nil { if !errors.IsNotFound(err) { return fmt.Errorf("failed to get Persistent Volume %q due to error: %w", GetPVCName(pr), err) @@ -309,7 +310,7 @@ func deletePVC(pr *v1alpha1.PipelineRun, c kubernetes.Interface) error { } // GetPVCSpec returns the PVC to create for a given PipelineRun -func GetPVCSpec(pr *v1alpha1.PipelineRun, pvcSize resource.Quantity, storageClassName *string) *corev1.PersistentVolumeClaim { +func GetPVCSpec(pr *v1beta1.PipelineRun, pvcSize resource.Quantity, storageClassName *string) *corev1.PersistentVolumeClaim { return &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ Namespace: pr.Namespace, diff --git a/pkg/pod/entrypoint.go b/pkg/pod/entrypoint.go index aa0a98313be..47ce8d7b1e7 100644 --- a/pkg/pod/entrypoint.go +++ b/pkg/pod/entrypoint.go @@ -22,7 +22,7 @@ import ( "path/filepath" "strings" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -86,7 +86,7 @@ var ( // method, using entrypoint_lookup.go. // // TODO(#1605): Also use entrypoint injection to order sidecar start/stop. -func orderContainers(entrypointImage string, steps []corev1.Container, results []v1alpha1.TaskResult) (corev1.Container, []corev1.Container, error) { +func orderContainers(entrypointImage string, steps []corev1.Container, results []v1beta1.TaskResult) (corev1.Container, []corev1.Container, error) { initContainer := corev1.Container{ Name: "place-tools", Image: entrypointImage, @@ -142,14 +142,14 @@ func orderContainers(entrypointImage string, steps []corev1.Container, results [ return initContainer, steps, nil } -func resultArgument(steps []corev1.Container, results []v1alpha1.TaskResult) []string { +func resultArgument(steps []corev1.Container, results []v1beta1.TaskResult) []string { if len(results) == 0 { return nil } return []string{"-results", collectResultsName(results)} } -func collectResultsName(results []v1alpha1.TaskResult) string { +func collectResultsName(results []v1beta1.TaskResult) string { var resultNames []string for _, r := range results { resultNames = append(resultNames, r.Name) @@ -214,7 +214,7 @@ func StopSidecars(nopImage string, kubeclient kubernetes.Interface, pod corev1.P // IsSidecarStatusRunning determines if any SidecarStatus on a TaskRun // is still running. -func IsSidecarStatusRunning(tr *v1alpha1.TaskRun) bool { +func IsSidecarStatusRunning(tr *v1beta1.TaskRun) bool { for _, sidecar := range tr.Status.Sidecars { if sidecar.Terminated == nil { return true diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index e9d3fa4466f..f42b322cade 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -22,7 +22,7 @@ import ( "path/filepath" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/names" "github.com/tektoncd/pipeline/pkg/system" "github.com/tektoncd/pipeline/pkg/version" @@ -59,8 +59,8 @@ var ( ReleaseAnnotationValue = version.PipelineVersion groupVersionKind = schema.GroupVersionKind{ - Group: v1alpha1.SchemeGroupVersion.Group, - Version: v1alpha1.SchemeGroupVersion.Version, + Group: v1beta1.SchemeGroupVersion.Group, + Version: v1beta1.SchemeGroupVersion.Version, Kind: "TaskRun", } // These are injected into all of the source/step containers. @@ -88,7 +88,7 @@ var ( // MakePod converts TaskRun and TaskSpec objects to a Pod which implements the taskrun specified // by the supplied CRD. -func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha1.TaskSpec, kubeclient kubernetes.Interface, entrypointCache EntrypointCache, overrideHomeEnv bool) (*corev1.Pod, error) { +func MakePod(images pipeline.Images, taskRun *v1beta1.TaskRun, taskSpec v1beta1.TaskSpec, kubeclient kubernetes.Interface, entrypointCache EntrypointCache, overrideHomeEnv bool) (*corev1.Pod, error) { var initContainers []corev1.Container var volumes []corev1.Volume var volumeMounts []corev1.VolumeMount @@ -121,7 +121,7 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha // Merge step template with steps. // TODO(#1605): Move MergeSteps to pkg/pod - steps, err := v1alpha1.MergeStepsWithStepTemplate(taskSpec.StepTemplate, taskSpec.Steps) + steps, err := v1beta1.MergeStepsWithStepTemplate(taskSpec.StepTemplate, taskSpec.Steps) if err != nil { return nil, err } @@ -205,7 +205,7 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha } // By default, use an empty pod template and take the one defined in the task run spec if any - podTemplate := v1alpha1.PodTemplate{} + podTemplate := v1beta1.PodTemplate{} if taskRun.Spec.PodTemplate != nil { podTemplate = *taskRun.Spec.PodTemplate @@ -215,7 +215,7 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha volumes = append(volumes, taskSpec.Volumes...) volumes = append(volumes, podTemplate.Volumes...) - if err := v1alpha1.ValidateVolumes(volumes); err != nil { + if err := v1beta1.ValidateVolumes(volumes); err != nil { return nil, err } @@ -280,7 +280,7 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha } // MakeLabels constructs the labels we will propagate from TaskRuns to Pods. -func MakeLabels(s *v1alpha1.TaskRun) map[string]string { +func MakeLabels(s *v1beta1.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. diff --git a/pkg/pod/pod_test.go b/pkg/pod/pod_test.go index fca9b2dae5b..aea39879a1a 100644 --- a/pkg/pod/pod_test.go +++ b/pkg/pod/pod_test.go @@ -25,7 +25,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/system" "github.com/tektoncd/pipeline/test/names" @@ -74,19 +73,19 @@ func TestMakePod(t *testing.T) { for _, c := range []struct { desc string - trs v1alpha1.TaskRunSpec - ts v1alpha1.TaskSpec + trs v1beta1.TaskRunSpec + ts v1beta1.TaskSpec want *corev1.PodSpec wantAnnotations map[string]string }{{ desc: "simple", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}}, - }}, + }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{placeToolsInit}, @@ -116,14 +115,14 @@ func TestMakePod(t *testing.T) { }, }, { desc: "with service account", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}}, - }}, - trs: v1alpha1.TaskRunSpec{ + }, + trs: v1beta1.TaskRunSpec{ ServiceAccountName: "service-account", }, want: &corev1.PodSpec{ @@ -170,15 +169,15 @@ func TestMakePod(t *testing.T) { }, }, { desc: "with-pod-template", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}}, - }}, - trs: v1alpha1.TaskRunSpec{ - PodTemplate: &v1alpha1.PodTemplate{ + }, + trs: v1beta1.TaskRunSpec{ + PodTemplate: &v1beta1.PodTemplate{ SecurityContext: &corev1.PodSecurityContext{ Sysctls: []corev1.Sysctl{ {Name: "net.ipv4.tcp_syncookies", Value: "1"}, @@ -238,13 +237,13 @@ func TestMakePod(t *testing.T) { }, }, { desc: "very long step name", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "a-very-very-long-character-step-name-to-trigger-max-len----and-invalid-characters", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}}, - }}, + }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{placeToolsInit}, @@ -274,13 +273,13 @@ func TestMakePod(t *testing.T) { }, }, { desc: "step name ends with non alphanumeric", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "ends-with-invalid-%%__$$", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}}, - }}, + }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{placeToolsInit}, @@ -310,14 +309,14 @@ func TestMakePod(t *testing.T) { }, }, { desc: "workingDir in workspace", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "name", Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. WorkingDir: filepath.Join(pipeline.WorkspaceDir, "test"), }}}, - }}, + }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{ @@ -357,19 +356,19 @@ func TestMakePod(t *testing.T) { }, }, { desc: "sidecar container", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "primary-name", Image: "primary-image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}}, - Sidecars: []v1alpha1.Sidecar{{ + Sidecars: []v1beta1.Sidecar{{ Container: corev1.Container{ Name: "sc-name", Image: "sidecar-image", }, }}, - }}, + }, wantAnnotations: map[string]string{}, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, @@ -406,20 +405,20 @@ func TestMakePod(t *testing.T) { }, }, { desc: "sidecar container with script", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "primary-name", Image: "primary-image", Command: []string{"cmd"}, // avoid entrypoint lookup. }}}, - Sidecars: []v1alpha1.Sidecar{{ + Sidecars: []v1beta1.Sidecar{{ Container: corev1.Container{ Name: "sc-name", Image: "sidecar-image", }, Script: "#!/bin/sh\necho hello from sidecar", }}, - }}, + }, wantAnnotations: map[string]string{}, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, @@ -474,8 +473,8 @@ sidecar-script-heredoc-randomly-generated-mz4c7 }, }, { desc: "resource request", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Image: "image", Command: []string{"cmd"}, // avoid entrypoint lookup. Resources: corev1.ResourceRequirements{ @@ -494,7 +493,7 @@ sidecar-script-heredoc-randomly-generated-mz4c7 }, }, }}}, - }}, + }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{placeToolsInit}, @@ -556,12 +555,12 @@ sidecar-script-heredoc-randomly-generated-mz4c7 }, }, { desc: "step with script and stepTemplate", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + ts: v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ Env: []corev1.EnvVar{{Name: "FOO", Value: "bar"}}, Args: []string{"template", "args"}, }, - Steps: []v1alpha1.Step{{ + Steps: []v1beta1.Step{{ Container: corev1.Container{ Name: "one", Image: "image", @@ -582,7 +581,7 @@ print("Hello from Python")`, Command: []string{"regular", "command"}, }, }}, - }}, + }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{ @@ -685,21 +684,19 @@ script-heredoc-randomly-generated-78c5n }, }, { desc: "using another scheduler", - ts: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{ - { - Container: corev1.Container{ - Name: "schedule-me", - Image: "image", - Command: []string{"cmd"}, // avoid entrypoint lookup. - }, + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{ + { + Container: corev1.Container{ + Name: "schedule-me", + Image: "image", + Command: []string{"cmd"}, // avoid entrypoint lookup. }, }, }, }, - trs: v1alpha1.TaskRunSpec{ - PodTemplate: &v1alpha1.PodTemplate{ + trs: v1beta1.TaskRunSpec{ + PodTemplate: &v1beta1.PodTemplate{ SchedulerName: "there-scheduler", }, }, @@ -733,21 +730,19 @@ script-heredoc-randomly-generated-78c5n }, }, { desc: "using hostNetwork", - ts: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{ - { - Container: corev1.Container{ - Name: "use-my-hostNetwork", - Image: "image", - Command: []string{"cmd"}, // avoid entrypoint lookup. - }, + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{ + { + Container: corev1.Container{ + Name: "use-my-hostNetwork", + Image: "image", + Command: []string{"cmd"}, // avoid entrypoint lookup. }, }, }, }, - trs: v1alpha1.TaskRunSpec{ - PodTemplate: &v1alpha1.PodTemplate{ + trs: v1beta1.TaskRunSpec{ + PodTemplate: &v1beta1.PodTemplate{ HostNetwork: true, }, }, @@ -804,7 +799,7 @@ script-heredoc-randomly-generated-78c5n }, }, ) - tr := &v1alpha1.TaskRun{ + tr := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "taskrun-name", Annotations: map[string]string{ @@ -840,7 +835,7 @@ func TestMakeLabels(t *testing.T) { "foo": "bar", "hello": "world", } - got := MakeLabels(&v1alpha1.TaskRun{ + got := MakeLabels(&v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: taskRunName, Labels: map[string]string{ diff --git a/pkg/pod/script.go b/pkg/pod/script.go index 38b15c4b740..f77c68e0bac 100644 --- a/pkg/pod/script.go +++ b/pkg/pod/script.go @@ -21,7 +21,7 @@ import ( "path/filepath" "strings" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" ) @@ -50,7 +50,7 @@ var ( // It does this by prepending a container that writes specified Script bodies // to executable files in a shared volumeMount, then produces Containers that // simply run those executable files. -func convertScripts(shellImage string, steps []v1alpha1.Step, sidecars []v1alpha1.Sidecar) (*corev1.Container, []corev1.Container, []corev1.Container) { +func convertScripts(shellImage string, steps []v1beta1.Step, sidecars []v1beta1.Sidecar) (*corev1.Container, []corev1.Container, []corev1.Container) { placeScripts := false placeScriptsInit := corev1.Container{ Name: "place-scripts", @@ -74,7 +74,7 @@ func convertScripts(shellImage string, steps []v1alpha1.Step, sidecars []v1alpha // // 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 []v1alpha1.Step, initContainer *corev1.Container, placeScripts *bool, namePrefix string) []corev1.Container { +func convertListOfSteps(steps []v1beta1.Step, initContainer *corev1.Container, placeScripts *bool, namePrefix string) []corev1.Container { containers := []corev1.Container{} for i, s := range steps { if s.Script == "" { diff --git a/pkg/pod/status.go b/pkg/pod/status.go index 67e952b053d..208e9652df7 100644 --- a/pkg/pod/status.go +++ b/pkg/pod/status.go @@ -23,7 +23,7 @@ import ( "strings" "time" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/names" "github.com/tektoncd/pipeline/pkg/termination" "go.uber.org/zap" @@ -104,7 +104,7 @@ func SidecarsReady(podStatus corev1.PodStatus) bool { } // MakeTaskRunStatus returns a TaskRunStatus based on the Pod's status. -func MakeTaskRunStatus(logger *zap.SugaredLogger, tr v1alpha1.TaskRun, pod *corev1.Pod, taskSpec v1alpha1.TaskSpec) v1alpha1.TaskRunStatus { +func MakeTaskRunStatus(logger *zap.SugaredLogger, tr v1beta1.TaskRun, pod *corev1.Pod, taskSpec v1beta1.TaskSpec) v1beta1.TaskRunStatus { 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 @@ -117,8 +117,8 @@ func MakeTaskRunStatus(logger *zap.SugaredLogger, tr v1alpha1.TaskRun, pod *core } trs.PodName = pod.Name - trs.Steps = []v1alpha1.StepState{} - trs.Sidecars = []v1alpha1.SidecarState{} + trs.Steps = []v1beta1.StepState{} + trs.Sidecars = []v1beta1.SidecarState{} for _, s := range pod.Status.ContainerStatuses { if IsContainerStep(s.Name) { @@ -127,14 +127,14 @@ func MakeTaskRunStatus(logger *zap.SugaredLogger, tr v1alpha1.TaskRun, pod *core logger.Errorf("error setting the start time of step %q in taskrun %q: %w", s.Name, tr.Name, err) } } - trs.Steps = append(trs.Steps, v1alpha1.StepState{ + trs.Steps = append(trs.Steps, v1beta1.StepState{ ContainerState: *s.State.DeepCopy(), Name: trimStepPrefix(s.Name), ContainerName: s.Name, ImageID: s.ImageID, }) } else if isContainerSidecar(s.Name) { - trs.Sidecars = append(trs.Sidecars, v1alpha1.SidecarState{ + trs.Sidecars = append(trs.Sidecars, v1beta1.SidecarState{ ContainerState: *s.State.DeepCopy(), Name: TrimSidecarPrefix(s.Name), ContainerName: s.Name, @@ -188,7 +188,7 @@ func updateStatusStartTime(s *corev1.ContainerStatus) error { return nil } -func updateCompletedTaskRun(trs *v1alpha1.TaskRunStatus, pod *corev1.Pod) { +func updateCompletedTaskRun(trs *v1beta1.TaskRunStatus, pod *corev1.Pod) { if DidTaskRunFail(pod) { msg := getFailureMessage(pod) trs.SetCondition(&apis.Condition{ @@ -210,7 +210,7 @@ func updateCompletedTaskRun(trs *v1alpha1.TaskRunStatus, pod *corev1.Pod) { trs.CompletionTime = &metav1.Time{Time: time.Now()} } -func updateIncompleteTaskRun(trs *v1alpha1.TaskRunStatus, pod *corev1.Pod) { +func updateIncompleteTaskRun(trs *v1beta1.TaskRunStatus, pod *corev1.Pod) { switch pod.Status.Phase { case corev1.PodRunning: trs.SetCondition(&apis.Condition{ @@ -361,7 +361,7 @@ func getWaitingMessage(pod *corev1.Pod) string { // sortTaskRunStepOrder sorts the StepStates in the same order as the original // TaskSpec steps. -func sortTaskRunStepOrder(taskRunSteps []v1alpha1.StepState, taskSpecSteps []v1alpha1.Step) []v1alpha1.StepState { +func sortTaskRunStepOrder(taskRunSteps []v1beta1.StepState, taskSpecSteps []v1beta1.Step) []v1beta1.StepState { trt := &stepStateSorter{ taskRunSteps: taskRunSteps, } @@ -373,13 +373,13 @@ func sortTaskRunStepOrder(taskRunSteps []v1alpha1.StepState, taskSpecSteps []v1a // stepStateSorter implements a sorting mechanism to align the order of the steps in TaskRun // with the spec steps in Task. type stepStateSorter struct { - taskRunSteps []v1alpha1.StepState + taskRunSteps []v1beta1.StepState mapForSort map[string]int } // constructTaskStepsSorter constructs a map matching the names of // the steps to their indices for a task. -func (trt *stepStateSorter) constructTaskStepsSorter(taskSpecSteps []v1alpha1.Step) map[string]int { +func (trt *stepStateSorter) constructTaskStepsSorter(taskSpecSteps []v1beta1.Step) map[string]int { sorter := make(map[string]int) for index, step := range taskSpecSteps { stepName := step.Name diff --git a/pkg/pod/status_test.go b/pkg/pod/status_test.go index 333517f8f74..e0ee305293b 100644 --- a/pkg/pod/status_test.go +++ b/pkg/pod/status_test.go @@ -21,7 +21,6 @@ import ( "time" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/logging" corev1 "k8s.io/api/core/v1" @@ -42,19 +41,19 @@ func TestMakeTaskRunStatus(t *testing.T) { for _, c := range []struct { desc string podStatus corev1.PodStatus - taskSpec v1alpha1.TaskSpec - want v1alpha1.TaskRunStatus + taskSpec v1beta1.TaskSpec + want v1beta1.TaskRunStatus }{{ desc: "empty", podStatus: corev1.PodStatus{}, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { @@ -74,12 +73,12 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 123, @@ -87,7 +86,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "state-name", ContainerName: "step-state-name", }}, - Sidecars: []v1alpha1.SidecarState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { @@ -110,12 +109,12 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 123, @@ -124,7 +123,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-state-name", ImageID: "image-id", }}, - Sidecars: []v1alpha1.SidecarState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { @@ -141,7 +140,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ImageID: "image-id", }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -150,8 +149,8 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "All Steps have completed executing", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 0, @@ -160,7 +159,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-step-push", ImageID: "image-id", }}, - Sidecars: []v1alpha1.SidecarState{}, + Sidecars: []v1beta1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -176,19 +175,19 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, Name: "running-step", ContainerName: "step-running-step", }}, - Sidecars: []v1alpha1.SidecarState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { @@ -209,7 +208,7 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -218,8 +217,8 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "\"step-failure\" exited with code 123 (image: \"image-id\"); for logs run: kubectl -n foo logs pod -c step-failure\n", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 123, @@ -229,7 +228,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-failure", ImageID: "image-id", }}, - Sidecars: []v1alpha1.SidecarState{}, + Sidecars: []v1beta1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -240,7 +239,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Phase: corev1.PodFailed, Message: "boom", }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -249,9 +248,9 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "boom", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{}, + Sidecars: []v1beta1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -271,7 +270,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ImageID: "image-id", }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -280,8 +279,8 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "OOMKilled", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ Reason: "OOMKilled", @@ -291,7 +290,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-step-push", ImageID: "image-id", }}, - Sidecars: []v1alpha1.SidecarState{}, + Sidecars: []v1beta1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -299,7 +298,7 @@ func TestMakeTaskRunStatus(t *testing.T) { }, { desc: "failure-unspecified", podStatus: corev1.PodStatus{Phase: corev1.PodFailed}, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -308,9 +307,9 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "build failed for unspecified reasons.", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{}, + Sidecars: []v1beta1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -331,7 +330,7 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -340,8 +339,8 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: `build step "step-status-name" is pending with reason "i'm pending"`, }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Waiting: &corev1.ContainerStateWaiting{ Message: "i'm pending", @@ -350,7 +349,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "status-name", ContainerName: "step-status-name", }}, - Sidecars: []v1alpha1.SidecarState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { @@ -363,7 +362,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "the message", }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -372,9 +371,9 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: `pod status "the type":"Unknown"; message: "the message"`, }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { @@ -383,7 +382,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Phase: corev1.PodPending, Message: "pod status message", }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -392,15 +391,15 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "pod status message", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { desc: "pending-no-message", podStatus: corev1.PodStatus{Phase: corev1.PodPending}, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -409,9 +408,9 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "Pending", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { @@ -423,7 +422,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "0/1 nodes are available: 1 Insufficient cpu.", }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -432,9 +431,9 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "TaskRun Pod exceeded available resources", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { @@ -449,7 +448,7 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -458,9 +457,9 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "Pending", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{}, - Sidecars: []v1alpha1.SidecarState{}, + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{}, + Sidecars: []v1beta1.SidecarState{}, }, }, }, { @@ -481,19 +480,19 @@ func TestMakeTaskRunStatus(t *testing.T) { Ready: true, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, Name: "running-step", ContainerName: "step-running-step", }}, - Sidecars: []v1alpha1.SidecarState{{ + Sidecars: []v1beta1.SidecarState{{ ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, @@ -527,12 +526,12 @@ func TestMakeTaskRunStatus(t *testing.T) { Ready: true, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Waiting: &corev1.ContainerStateWaiting{ Reason: "PodInitializing", @@ -542,7 +541,7 @@ func TestMakeTaskRunStatus(t *testing.T) { Name: "waiting-step", ContainerName: "step-waiting-step", }}, - Sidecars: []v1alpha1.SidecarState{{ + Sidecars: []v1beta1.SidecarState{{ ContainerState: corev1.ContainerState{ Waiting: &corev1.ContainerStateWaiting{ Reason: "PodInitializing", @@ -577,19 +576,19 @@ func TestMakeTaskRunStatus(t *testing.T) { Ready: true, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{conditionRunning}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Running: &corev1.ContainerStateRunning{}, }, Name: "running-step", ContainerName: "step-running-step", }}, - Sidecars: []v1alpha1.SidecarState{{ + Sidecars: []v1beta1.SidecarState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, @@ -605,8 +604,8 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }, { desc: "non-json-termination-message-with-steps-afterwards-shouldnt-panic", - taskSpec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + taskSpec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "non-json", }}, {Container: corev1.Container{ Name: "after-non-json", @@ -615,7 +614,7 @@ func TestMakeTaskRunStatus(t *testing.T) { }}, {Container: corev1.Container{ Name: "foo", }}}, - }}, + }, podStatus: corev1.PodStatus{ Phase: corev1.PodFailed, ContainerStatuses: []corev1.ContainerStatus{{ @@ -647,7 +646,7 @@ func TestMakeTaskRunStatus(t *testing.T) { }, }}, }, - want: v1alpha1.TaskRunStatus{ + want: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -656,8 +655,8 @@ func TestMakeTaskRunStatus(t *testing.T) { Message: "\"step-non-json\" exited with code 1 (image: \"image\"); for logs run: kubectl -n foo logs pod -c step-non-json\n", }}, }, - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 1, @@ -686,7 +685,7 @@ func TestMakeTaskRunStatus(t *testing.T) { ContainerName: "step-foo", ImageID: "image", }}, - Sidecars: []v1alpha1.SidecarState{}, + Sidecars: []v1beta1.SidecarState{}, // We don't actually care about the time, just that it's not nil CompletionTime: &metav1.Time{Time: time.Now()}, }, @@ -703,13 +702,13 @@ func TestMakeTaskRunStatus(t *testing.T) { Status: c.podStatus, } startTime := time.Date(2010, 1, 1, 1, 1, 1, 1, time.UTC) - tr := v1alpha1.TaskRun{ + tr := v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "task-run", Namespace: "foo", }, - Status: v1alpha1.TaskRunStatus{ - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + Status: v1beta1.TaskRunStatus{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ StartTime: &metav1.Time{Time: startTime}, }, }, @@ -829,7 +828,7 @@ func TestSidecarsReady(t *testing.T) { } func TestSortTaskRunStepOrder(t *testing.T) { - steps := []v1alpha1.Step{{Container: corev1.Container{ + steps := []v1beta1.Step{{Container: corev1.Container{ Name: "hello", }}, {Container: corev1.Container{ Name: "exit", @@ -837,7 +836,7 @@ func TestSortTaskRunStepOrder(t *testing.T) { Name: "world", }}} - stepStates := []v1alpha1.StepState{{ + stepStates := []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ ExitCode: 0, diff --git a/pkg/reconciler/pipelinerun/cancel.go b/pkg/reconciler/pipelinerun/cancel.go index aebca6277d8..e097acc72bc 100644 --- a/pkg/reconciler/pipelinerun/cancel.go +++ b/pkg/reconciler/pipelinerun/cancel.go @@ -25,7 +25,7 @@ import ( "go.uber.org/zap" jsonpatch "gomodules.xyz/jsonpatch/v2" - "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" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -34,7 +34,7 @@ import ( ) // cancelPipelineRun marks the PipelineRun as cancelled and any resolved TaskRun(s) too. -func cancelPipelineRun(logger *zap.SugaredLogger, pr *v1alpha1.PipelineRun, clientSet clientset.Interface) error { +func cancelPipelineRun(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, clientSet clientset.Interface) error { pr.Status.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, @@ -57,7 +57,7 @@ func cancelPipelineRun(logger *zap.SugaredLogger, pr *v1alpha1.PipelineRun, clie for taskRunName := range pr.Status.TaskRuns { logger.Infof("cancelling TaskRun %s", taskRunName) - if _, err := clientSet.TektonV1alpha1().TaskRuns(pr.Namespace).Patch(taskRunName, types.JSONPatchType, b, ""); err != nil { + if _, err := clientSet.TektonV1beta1().TaskRuns(pr.Namespace).Patch(taskRunName, types.JSONPatchType, b, ""); err != nil { errs = append(errs, fmt.Errorf("Failed to patch TaskRun `%s` with cancellation: %s", taskRunName, err).Error()) continue } @@ -72,7 +72,7 @@ func getCancelPatch() ([]byte, error) { patches := []jsonpatch.JsonPatchOperation{{ Operation: "add", Path: "/spec/status", - Value: v1alpha1.TaskRunSpecStatusCancelled, + Value: v1beta1.TaskRunSpecStatusCancelled, }} patchBytes, err := json.Marshal(patches) if err != nil { diff --git a/pkg/reconciler/pipelinerun/cancel_test.go b/pkg/reconciler/pipelinerun/cancel_test.go index a3da9909eac..916e005e84f 100644 --- a/pkg/reconciler/pipelinerun/cancel_test.go +++ b/pkg/reconciler/pipelinerun/cancel_test.go @@ -20,10 +20,10 @@ import ( "context" "testing" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" - test "github.com/tektoncd/pipeline/test/v1alpha1" + "github.com/tektoncd/pipeline/test" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" logtesting "knative.dev/pkg/logging/testing" @@ -32,15 +32,16 @@ import ( func TestCancelPipelineRun(t *testing.T) { testCases := []struct { name string - pipelineRun *v1alpha1.PipelineRun - taskRuns []*v1alpha1.TaskRun + pipelineRun *v1beta1.PipelineRun + taskRuns []*v1beta1.TaskRun }{{ name: "no-resolved-taskrun", - pipelineRun: tb.PipelineRun("test-pipeline-run-cancelled", tb.PipelineRunNamespace("foo"), - tb.PipelineRunSpec("test-pipeline", - tb.PipelineRunCancelled, - ), - ), + pipelineRun: &v1beta1.PipelineRun{ + ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"}, + Spec: v1beta1.PipelineRunSpec{ + Status: v1beta1.PipelineRunSpecStatusCancelled, + }, + }, }, { name: "1-taskrun", pipelineRun: tb.PipelineRun("test-pipeline-run-cancelled", tb.PipelineRunNamespace("foo"), @@ -48,11 +49,11 @@ func TestCancelPipelineRun(t *testing.T) { tb.PipelineRunCancelled, ), tb.PipelineRunStatus( - tb.PipelineRunTaskRunsStatus("t1", &v1alpha1.PipelineRunTaskRunStatus{ + tb.PipelineRunTaskRunsStatus("t1", &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: "task-1", })), ), - taskRuns: []*v1alpha1.TaskRun{tb.TaskRun("t1", tb.TaskRunNamespace("foo"))}, + taskRuns: []*v1beta1.TaskRun{tb.TaskRun("t1", tb.TaskRunNamespace("foo"))}, }, { name: "multiple-taskruns", pipelineRun: tb.PipelineRun("test-pipeline-run-cancelled", tb.PipelineRunNamespace("foo"), @@ -61,17 +62,17 @@ func TestCancelPipelineRun(t *testing.T) { ), tb.PipelineRunStatus( tb.PipelineRunTaskRunsStatus( - "t1", &v1alpha1.PipelineRunTaskRunStatus{PipelineTaskName: "task-1"}), + "t1", &v1beta1.PipelineRunTaskRunStatus{PipelineTaskName: "task-1"}), tb.PipelineRunTaskRunsStatus( - "t2", &v1alpha1.PipelineRunTaskRunStatus{PipelineTaskName: "task-2"})), + "t2", &v1beta1.PipelineRunTaskRunStatus{PipelineTaskName: "task-2"})), ), - taskRuns: []*v1alpha1.TaskRun{tb.TaskRun("t1", tb.TaskRunNamespace("foo")), tb.TaskRun("t2", tb.TaskRunNamespace("foo"))}, + taskRuns: []*v1beta1.TaskRun{tb.TaskRun("t1", tb.TaskRunNamespace("foo")), tb.TaskRun("t2", tb.TaskRunNamespace("foo"))}, }} for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { d := test.Data{ - PipelineRuns: []*v1alpha1.PipelineRun{tc.pipelineRun}, + PipelineRuns: []*v1beta1.PipelineRun{tc.pipelineRun}, TaskRuns: tc.taskRuns, } ctx, _ := ttesting.SetupFakeContext(t) @@ -87,12 +88,12 @@ func TestCancelPipelineRun(t *testing.T) { if cond.IsTrue() { t.Errorf("Expected PipelineRun status to be complete and false, but was %v", cond) } - l, err := c.Pipeline.TektonV1alpha1().TaskRuns("foo").List(metav1.ListOptions{}) + l, err := c.Pipeline.TektonV1beta1().TaskRuns("foo").List(metav1.ListOptions{}) if err != nil { t.Fatal(err) } for _, tr := range l.Items { - if tr.Spec.Status != v1alpha1.TaskRunSpecStatusCancelled { + if tr.Spec.Status != v1beta1.TaskRunSpecStatusCancelled { t.Errorf("expected task %q to be marked as cancelled, was %q", tr.Name, tr.Spec.Status) } } diff --git a/pkg/reconciler/pipelinerun/controller.go b/pkg/reconciler/pipelinerun/controller.go index ffe48df5700..f3adaa52c1a 100644 --- a/pkg/reconciler/pipelinerun/controller.go +++ b/pkg/reconciler/pipelinerun/controller.go @@ -22,12 +22,12 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" pipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client" - clustertaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/clustertask" + clustertaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask" conditioninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/condition" - pipelineinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/pipeline" - pipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/pipelinerun" - taskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/task" - taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/taskrun" + pipelineinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/pipeline" + pipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/pipelinerun" + taskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/task" + taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun" resourceinformer "github.com/tektoncd/pipeline/pkg/client/resource/injection/informers/resource/v1alpha1/pipelineresource" "github.com/tektoncd/pipeline/pkg/reconciler" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/config" diff --git a/pkg/reconciler/pipelinerun/metrics.go b/pkg/reconciler/pipelinerun/metrics.go index 8fd93e658bf..776ef82762a 100644 --- a/pkg/reconciler/pipelinerun/metrics.go +++ b/pkg/reconciler/pipelinerun/metrics.go @@ -22,8 +22,8 @@ import ( "fmt" "time" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" @@ -120,7 +120,7 @@ func NewRecorder() (*Recorder, error) { // DurationAndCount logs the duration of PipelineRun execution and // count for number of PipelineRuns succeed or failed // returns an error if its failed to log the metrics -func (r *Recorder) DurationAndCount(pr *v1alpha1.PipelineRun) error { +func (r *Recorder) DurationAndCount(pr *v1beta1.PipelineRun) error { if !r.initialized { return fmt.Errorf("ignoring the metrics recording for %s , failed to initialize the metrics recorder", pr.Name) } diff --git a/pkg/reconciler/pipelinerun/metrics_test.go b/pkg/reconciler/pipelinerun/metrics_test.go index dc9846efc0c..22e34843e73 100644 --- a/pkg/reconciler/pipelinerun/metrics_test.go +++ b/pkg/reconciler/pipelinerun/metrics_test.go @@ -20,10 +20,10 @@ import ( "testing" "time" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - alpha1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1" - fakepipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/pipelinerun/fake" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + pipelineinformers "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1" + fakepipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/pipelinerun/fake" corev1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" "knative.dev/pkg/metrics/metricstest" @@ -36,7 +36,7 @@ import ( func TestUninitializedMetrics(t *testing.T) { metrics := Recorder{} - durationCountError := metrics.DurationAndCount(&v1alpha1.PipelineRun{}) + durationCountError := metrics.DurationAndCount(&v1beta1.PipelineRun{}) prCountError := metrics.RunningPipelineRuns(nil) assertErrNotNil(durationCountError, "DurationAndCount recording expected to return error but got nil", t) @@ -48,7 +48,7 @@ func TestRecordPipelineRunDurationCount(t *testing.T) { testData := []struct { name string - pipelineRun *v1alpha1.PipelineRun + pipelineRun *v1beta1.PipelineRun expectedTags map[string]string expectedCountTags map[string]string expectedDuration float64 @@ -135,7 +135,7 @@ func TestRecordRunningPipelineRunsCount(t *testing.T) { } -func addPipelineRun(informer alpha1.PipelineRunInformer, run, pipeline, ns string, status corev1.ConditionStatus, t *testing.T) { +func addPipelineRun(informer pipelineinformers.PipelineRunInformer, run, pipeline, ns string, status corev1.ConditionStatus, t *testing.T) { t.Helper() err := informer.Informer().GetIndexer().Add(tb.PipelineRun(run, tb.PipelineRunNamespace(ns), diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index b3492ddd291..0dbdadd72f1 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -31,7 +31,8 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/artifacts" - listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" + listersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" + listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" resourcelisters "github.com/tektoncd/pipeline/pkg/client/resource/listers/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/contexts" "github.com/tektoncd/pipeline/pkg/reconciler" @@ -103,7 +104,7 @@ type Reconciler struct { taskLister listers.TaskLister clusterTaskLister listers.ClusterTaskLister resourceLister resourcelisters.PipelineResourceLister - conditionLister listers.ConditionLister + conditionLister listersv1alpha1.ConditionLister tracker tracker.Interface configStore configStore timeoutHandler *reconciler.TimeoutSet @@ -238,13 +239,7 @@ func (c *Reconciler) Reconcile(ctx context.Context, key string) error { return merr.ErrorOrNil() } -func (c *Reconciler) updatePipelineResults(ctx context.Context, pr *v1alpha1.PipelineRun) { - if err := pr.ConvertTo(ctx, &v1beta1.PipelineRun{}); err != nil { - if ce, ok := err.(*v1beta1.CannotConvertError); ok { - pr.Status.MarkResourceNotConvertible(ce) - } - return - } +func (c *Reconciler) updatePipelineResults(ctx context.Context, pr *v1beta1.PipelineRun) { // TODO: Use factory func instead of hard-coding this once OCI images are supported. resolver := &resources.LocalPipelineRefResolver{ @@ -282,13 +277,13 @@ func (c *Reconciler) updatePipelineResults(ctx context.Context, pr *v1alpha1.Pip } pipelineState, err := resources.ResolvePipelineRun(ctx, *pr, - func(name string) (v1alpha1.TaskInterface, error) { + func(name string) (v1beta1.TaskInterface, error) { return c.taskLister.Tasks(pr.Namespace).Get(name) }, - func(name string) (*v1alpha1.TaskRun, error) { + func(name string) (*v1beta1.TaskRun, error) { return c.taskRunLister.TaskRuns(pr.Namespace).Get(name) }, - func(name string) (v1alpha1.TaskInterface, error) { + func(name string) (v1beta1.TaskInterface, error) { return c.clusterTaskLister.Get(name) }, func(name string) (*v1alpha1.Condition, error) { @@ -329,19 +324,11 @@ func (c *Reconciler) updatePipelineResults(ctx context.Context, pr *v1alpha1.Pip pr.Status.PipelineResults = getPipelineRunResults(pipelineSpec, resolvedResultRefs) } } -func (c *Reconciler) reconcile(ctx context.Context, pr *v1alpha1.PipelineRun) error { +func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun) error { // We may be reading a version of the object that was stored at an older version // and may not have had all of the assumed default specified. pr.SetDefaults(contexts.WithUpgradeViaDefaulting(ctx)) - if err := pr.ConvertTo(ctx, &v1beta1.PipelineRun{}); err != nil { - if ce, ok := err.(*v1beta1.CannotConvertError); ok { - pr.Status.MarkResourceNotConvertible(ce) - return nil - } - return err - } - // TODO: Use factory func instead of hard-coding this once OCI images are supported. resolver := &resources.LocalPipelineRefResolver{ Namespace: pr.Namespace, @@ -386,7 +373,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1alpha1.PipelineRun) er pr.ObjectMeta.Annotations[key] = value } - d, err := dag.Build(v1alpha1.PipelineTaskList(pipelineSpec.Tasks)) + d, err := dag.Build(v1beta1.PipelineTaskList(pipelineSpec.Tasks)) if err != nil { // This Run has failed, so we need to mark it as failed and stop reconciling it pr.Status.SetCondition(&apis.Condition{ @@ -467,13 +454,13 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1alpha1.PipelineRun) er pipelineState, err := resources.ResolvePipelineRun(ctx, *pr, - func(name string) (v1alpha1.TaskInterface, error) { + func(name string) (v1beta1.TaskInterface, error) { return c.taskLister.Tasks(pr.Namespace).Get(name) }, - func(name string) (*v1alpha1.TaskRun, error) { + func(name string) (*v1beta1.TaskRun, error) { return c.taskRunLister.TaskRuns(pr.Namespace).Get(name) }, - func(name string) (v1alpha1.TaskInterface, error) { + func(name string) (v1beta1.TaskInterface, error) { return c.clusterTaskLister.Get(name) }, func(name string) (*v1alpha1.Condition, error) { @@ -605,7 +592,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1alpha1.PipelineRun) er return nil } -func getPipelineRunResults(pipelineSpec *v1alpha1.PipelineSpec, resolvedResultRefs resources.ResolvedResultRefs) []v1beta1.PipelineRunResult { +func getPipelineRunResults(pipelineSpec *v1beta1.PipelineSpec, resolvedResultRefs resources.ResolvedResultRefs) []v1beta1.PipelineRunResult { var results []v1beta1.PipelineRunResult stringReplacements := map[string]string{} @@ -626,19 +613,19 @@ func getPipelineRunResults(pipelineSpec *v1alpha1.PipelineSpec, resolvedResultRe return results } -func getTaskRunsStatus(pr *v1alpha1.PipelineRun, state []*resources.ResolvedPipelineRunTask) map[string]*v1alpha1.PipelineRunTaskRunStatus { - status := make(map[string]*v1alpha1.PipelineRunTaskRunStatus) +func getTaskRunsStatus(pr *v1beta1.PipelineRun, state []*resources.ResolvedPipelineRunTask) map[string]*v1beta1.PipelineRunTaskRunStatus { + status := make(map[string]*v1beta1.PipelineRunTaskRunStatus) for _, rprt := range state { if rprt.TaskRun == nil && rprt.ResolvedConditionChecks == nil { continue } - var prtrs *v1alpha1.PipelineRunTaskRunStatus + var prtrs *v1beta1.PipelineRunTaskRunStatus if rprt.TaskRun != nil { prtrs = pr.Status.TaskRuns[rprt.TaskRun.Name] } if prtrs == nil { - prtrs = &v1alpha1.PipelineRunTaskRunStatus{ + prtrs = &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: rprt.PipelineTask.Name, } } @@ -648,9 +635,9 @@ func getTaskRunsStatus(pr *v1alpha1.PipelineRun, state []*resources.ResolvedPipe } if len(rprt.ResolvedConditionChecks) > 0 { - cStatus := make(map[string]*v1alpha1.PipelineRunConditionCheckStatus) + cStatus := make(map[string]*v1beta1.PipelineRunConditionCheckStatus) for _, c := range rprt.ResolvedConditionChecks { - cStatus[c.ConditionCheckName] = &v1alpha1.PipelineRunConditionCheckStatus{ + cStatus[c.ConditionCheckName] = &v1beta1.PipelineRunConditionCheckStatus{ ConditionName: c.ConditionRegisterName, } if c.ConditionCheck != nil { @@ -660,7 +647,7 @@ func getTaskRunsStatus(pr *v1alpha1.PipelineRun, state []*resources.ResolvedPipe prtrs.ConditionChecks = cStatus if rprt.ResolvedConditionChecks.IsDone() && !rprt.ResolvedConditionChecks.IsSuccess() { if prtrs.Status == nil { - prtrs.Status = &v1alpha1.TaskRunStatus{} + prtrs.Status = &v1beta1.TaskRunStatus{} } prtrs.Status.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, @@ -675,7 +662,7 @@ func getTaskRunsStatus(pr *v1alpha1.PipelineRun, state []*resources.ResolvedPipe return status } -func (c *Reconciler) updateTaskRunsStatusDirectly(pr *v1alpha1.PipelineRun) error { +func (c *Reconciler) updateTaskRunsStatusDirectly(pr *v1beta1.PipelineRun) error { for taskRunName := range pr.Status.TaskRuns { // TODO(dibyom): Add conditionCheck statuses here prtrs := pr.Status.TaskRuns[taskRunName] @@ -692,7 +679,7 @@ func (c *Reconciler) updateTaskRunsStatusDirectly(pr *v1alpha1.PipelineRun) erro return nil } -func (c *Reconciler) createTaskRun(rprt *resources.ResolvedPipelineRunTask, pr *v1alpha1.PipelineRun, storageBasePath string) (*v1alpha1.TaskRun, error) { +func (c *Reconciler) createTaskRun(rprt *resources.ResolvedPipelineRunTask, pr *v1beta1.PipelineRun, storageBasePath string) (*v1beta1.TaskRun, error) { tr, _ := c.taskRunLister.TaskRuns(pr.Namespace).Get(rprt.TaskRunName) if tr != nil { //is a retry @@ -702,10 +689,10 @@ func (c *Reconciler) createTaskRun(rprt *resources.ResolvedPipelineRunTask, pr * Type: apis.ConditionSucceeded, Status: corev1.ConditionUnknown, }) - return c.PipelineClientSet.TektonV1alpha1().TaskRuns(pr.Namespace).UpdateStatus(tr) + return c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).UpdateStatus(tr) } - tr = &v1alpha1.TaskRun{ + tr = &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: rprt.TaskRunName, Namespace: pr.Namespace, @@ -713,7 +700,7 @@ func (c *Reconciler) createTaskRun(rprt *resources.ResolvedPipelineRunTask, pr * Labels: getTaskrunLabels(pr, rprt.PipelineTask.Name), Annotations: getTaskrunAnnotations(pr), }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Params: rprt.PipelineTask.Params, ServiceAccountName: pr.GetServiceAccountName(rprt.PipelineTask.Name), Timeout: getTaskRunTimeout(pr, rprt), @@ -721,7 +708,7 @@ func (c *Reconciler) createTaskRun(rprt *resources.ResolvedPipelineRunTask, pr * }} if rprt.ResolvedTaskResources.TaskName != "" { - tr.Spec.TaskRef = &v1alpha1.TaskRef{ + tr.Spec.TaskRef = &v1beta1.TaskRef{ Name: rprt.ResolvedTaskResources.TaskName, Kind: rprt.ResolvedTaskResources.Kind, } @@ -729,7 +716,7 @@ func (c *Reconciler) createTaskRun(rprt *resources.ResolvedPipelineRunTask, pr * tr.Spec.TaskSpec = rprt.ResolvedTaskResources.TaskSpec } - pipelineRunWorkspaces := make(map[string]v1alpha1.WorkspaceBinding) + pipelineRunWorkspaces := make(map[string]v1beta1.WorkspaceBinding) for _, binding := range pr.Spec.Workspaces { pipelineRunWorkspaces[binding.Name] = binding } @@ -744,12 +731,12 @@ func (c *Reconciler) createTaskRun(rprt *resources.ResolvedPipelineRunTask, pr * resources.WrapSteps(&tr.Spec, rprt.PipelineTask, rprt.ResolvedTaskResources.Inputs, rprt.ResolvedTaskResources.Outputs, storageBasePath) c.Logger.Infof("Creating a new TaskRun object %s", rprt.TaskRunName) - return c.PipelineClientSet.TektonV1alpha1().TaskRuns(pr.Namespace).Create(tr) + return c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).Create(tr) } // 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 v1alpha1.WorkspaceBinding, taskWorkspaceName string, pipelineTaskSubPath string, owner metav1.OwnerReference) v1alpha1.WorkspaceBinding { +func taskWorkspaceByWorkspaceVolumeSource(wb v1beta1.WorkspaceBinding, taskWorkspaceName string, pipelineTaskSubPath string, owner metav1.OwnerReference) v1beta1.WorkspaceBinding { if wb.VolumeClaimTemplate == nil { binding := *wb.DeepCopy() binding.Name = taskWorkspaceName @@ -758,7 +745,7 @@ func taskWorkspaceByWorkspaceVolumeSource(wb v1alpha1.WorkspaceBinding, taskWork } // apply template - binding := v1alpha1.WorkspaceBinding{ + binding := v1beta1.WorkspaceBinding{ SubPath: combinedSubPath(wb.SubPath, pipelineTaskSubPath), PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: volumeclaim.GetPersistentVolumeClaimName(wb.VolumeClaimTemplate, wb, owner), @@ -779,19 +766,19 @@ func combinedSubPath(workspaceSubPath string, pipelineTaskSubPath string) string return filepath.Join(workspaceSubPath, pipelineTaskSubPath) } -func addRetryHistory(tr *v1alpha1.TaskRun) { +func addRetryHistory(tr *v1beta1.TaskRun) { newStatus := *tr.Status.DeepCopy() newStatus.RetriesStatus = nil tr.Status.RetriesStatus = append(tr.Status.RetriesStatus, newStatus) } -func clearStatus(tr *v1alpha1.TaskRun) { +func clearStatus(tr *v1beta1.TaskRun) { tr.Status.StartTime = nil tr.Status.CompletionTime = nil tr.Status.PodName = "" } -func getTaskrunAnnotations(pr *v1alpha1.PipelineRun) map[string]string { +func getTaskrunAnnotations(pr *v1beta1.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 { @@ -800,7 +787,7 @@ func getTaskrunAnnotations(pr *v1alpha1.PipelineRun) map[string]string { return annotations } -func getTaskrunLabels(pr *v1alpha1.PipelineRun, pipelineTaskName string) map[string]string { +func getTaskrunLabels(pr *v1beta1.PipelineRun, pipelineTaskName string) map[string]string { // Propagate labels from PipelineRun to TaskRun. labels := make(map[string]string, len(pr.ObjectMeta.Labels)+1) for key, val := range pr.ObjectMeta.Labels { @@ -813,7 +800,7 @@ func getTaskrunLabels(pr *v1alpha1.PipelineRun, pipelineTaskName string) map[str return labels } -func getTaskRunTimeout(pr *v1alpha1.PipelineRun, rprt *resources.ResolvedPipelineRunTask) *metav1.Duration { +func getTaskRunTimeout(pr *v1beta1.PipelineRun, rprt *resources.ResolvedPipelineRunTask) *metav1.Duration { var taskRunTimeout = &metav1.Duration{Duration: apisconfig.NoTimeoutDuration} var timeout time.Duration @@ -852,7 +839,7 @@ func getTaskRunTimeout(pr *v1alpha1.PipelineRun, rprt *resources.ResolvedPipelin return taskRunTimeout } -func (c *Reconciler) updateStatus(pr *v1alpha1.PipelineRun) (*v1alpha1.PipelineRun, error) { +func (c *Reconciler) updateStatus(pr *v1beta1.PipelineRun) (*v1beta1.PipelineRun, error) { newPr, err := c.pipelineRunLister.PipelineRuns(pr.Namespace).Get(pr.Name) if err != nil { return nil, fmt.Errorf("error getting PipelineRun %s when updating status: %w", pr.Name, err) @@ -865,12 +852,12 @@ func (c *Reconciler) updateStatus(pr *v1alpha1.PipelineRun) (*v1alpha1.PipelineR } if !reflect.DeepEqual(pr.Status, newPr.Status) { newPr.Status = pr.Status - return c.PipelineClientSet.TektonV1alpha1().PipelineRuns(pr.Namespace).UpdateStatus(newPr) + return c.PipelineClientSet.TektonV1beta1().PipelineRuns(pr.Namespace).UpdateStatus(newPr) } return newPr, nil } -func (c *Reconciler) updateLabelsAndAnnotations(pr *v1alpha1.PipelineRun) (*v1alpha1.PipelineRun, error) { +func (c *Reconciler) updateLabelsAndAnnotations(pr *v1beta1.PipelineRun) (*v1beta1.PipelineRun, error) { newPr, err := c.pipelineRunLister.PipelineRuns(pr.Namespace).Get(pr.Name) if err != nil { return nil, fmt.Errorf("error getting PipelineRun %s when updating labels/annotations: %w", pr.Name, err) @@ -878,12 +865,12 @@ func (c *Reconciler) updateLabelsAndAnnotations(pr *v1alpha1.PipelineRun) (*v1al if !reflect.DeepEqual(pr.ObjectMeta.Labels, newPr.ObjectMeta.Labels) || !reflect.DeepEqual(pr.ObjectMeta.Annotations, newPr.ObjectMeta.Annotations) { newPr.ObjectMeta.Labels = pr.ObjectMeta.Labels newPr.ObjectMeta.Annotations = pr.ObjectMeta.Annotations - return c.PipelineClientSet.TektonV1alpha1().PipelineRuns(pr.Namespace).Update(newPr) + return c.PipelineClientSet.TektonV1beta1().PipelineRuns(pr.Namespace).Update(newPr) } return newPr, nil } -func (c *Reconciler) makeConditionCheckContainer(rprt *resources.ResolvedPipelineRunTask, rcc *resources.ResolvedConditionCheck, pr *v1alpha1.PipelineRun) (*v1alpha1.ConditionCheck, error) { +func (c *Reconciler) makeConditionCheckContainer(rprt *resources.ResolvedPipelineRunTask, rcc *resources.ResolvedConditionCheck, pr *v1beta1.PipelineRun) (*v1beta1.ConditionCheck, error) { labels := getTaskrunLabels(pr, rprt.PipelineTask.Name) labels[pipeline.GroupName+pipeline.ConditionCheckKey] = rcc.ConditionCheckName labels[pipeline.GroupName+pipeline.ConditionNameKey] = rcc.Condition.Name @@ -897,7 +884,7 @@ func (c *Reconciler) makeConditionCheckContainer(rprt *resources.ResolvedPipelin return nil, fmt.Errorf("failed to get TaskSpec from Condition: %w", err) } - tr := &v1alpha1.TaskRun{ + tr := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: rcc.ConditionCheckName, Namespace: pr.Namespace, @@ -905,7 +892,7 @@ func (c *Reconciler) makeConditionCheckContainer(rprt *resources.ResolvedPipelin Labels: labels, Annotations: getTaskrunAnnotations(pr), // Propagate annotations from PipelineRun to TaskRun. }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ TaskSpec: taskSpec, ServiceAccountName: pr.GetServiceAccountName(rprt.PipelineTask.Name), Params: rcc.PipelineTaskCondition.Params, @@ -916,16 +903,15 @@ func (c *Reconciler) makeConditionCheckContainer(rprt *resources.ResolvedPipelin PodTemplate: pr.Spec.PodTemplate, }} - cctr, err := c.PipelineClientSet.TektonV1alpha1().TaskRuns(pr.Namespace).Create(tr) - cc := v1alpha1.ConditionCheck(*cctr) + cctr, err := c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).Create(tr) + cc := v1beta1.ConditionCheck(*cctr) return &cc, err } -func storePipelineSpec(ctx context.Context, pr *v1alpha1.PipelineRun, ps *v1alpha1.PipelineSpec) error { +func storePipelineSpec(ctx context.Context, pr *v1beta1.PipelineRun, ps *v1beta1.PipelineSpec) error { // Only store the PipelineSpec once, if it has never been set before. if pr.Status.PipelineSpec == nil { - pr.Status.PipelineSpec = &v1beta1.PipelineSpec{} - return ps.ConvertTo(ctx, pr.Status.PipelineSpec) + pr.Status.PipelineSpec = ps } return nil } diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 49a2468deb1..0d437928783 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -25,16 +25,18 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tbv1alpha1 "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources" taskrunresources "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" "github.com/tektoncd/pipeline/pkg/system" + test "github.com/tektoncd/pipeline/test" "github.com/tektoncd/pipeline/test/names" - test "github.com/tektoncd/pipeline/test/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ktesting "k8s.io/client-go/testing" @@ -59,7 +61,7 @@ var ( } ) -func getRunName(pr *v1alpha1.PipelineRun) string { +func getRunName(pr *v1beta1.PipelineRun) string { return strings.Join([]string{pr.Namespace, pr.Name}, "/") } @@ -78,24 +80,24 @@ func getPipelineRunController(t *testing.T, d test.Data) (test.Assets, func()) { } // conditionCheckFromTaskRun converts takes a pointer to a TaskRun and wraps it into a ConditionCheck -func conditionCheckFromTaskRun(tr *v1alpha1.TaskRun) *v1alpha1.ConditionCheck { - cc := v1alpha1.ConditionCheck(*tr) +func conditionCheckFromTaskRun(tr *v1beta1.TaskRun) *v1beta1.ConditionCheck { + cc := v1beta1.ConditionCheck(*tr) return &cc } func TestReconcile(t *testing.T) { names.TestingSeed() - prs := []*v1alpha1.PipelineRun{ + prs := []*v1beta1.PipelineRun{ tb.PipelineRun("test-pipeline-run-success", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa"), tb.PipelineRunResourceBinding("git-repo", tb.PipelineResourceBindingRef("some-repo")), tb.PipelineRunResourceBinding("best-image", tb.PipelineResourceBindingResourceSpec( - &v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeImage, - Params: []v1alpha1.ResourceParam{{ + &resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeImage, + Params: []v1beta1.ResourceParam{{ Name: "url", Value: "gcr.io/sven", }}, @@ -108,15 +110,15 @@ func TestReconcile(t *testing.T) { funParam := tb.PipelineTaskParam("foo", "somethingfun") moreFunParam := tb.PipelineTaskParam("bar", "$(params.bar)") templatedParam := tb.PipelineTaskParam("templatedparam", "$(inputs.workspace.$(params.rev-param))") - ps := []*v1alpha1.Pipeline{ + ps := []*v1beta1.Pipeline{ tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineDeclaredResource("git-repo", "git"), tb.PipelineDeclaredResource("best-image", "image"), - tb.PipelineParamSpec("pipeline-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("somethingdifferent")), - tb.PipelineParamSpec("rev-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("revision")), - tb.PipelineParamSpec("bar", v1alpha1.ParamTypeString), + tb.PipelineParamSpec("pipeline-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("somethingdifferent")), + tb.PipelineParamSpec("rev-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("revision")), + tb.PipelineParamSpec("bar", v1beta1.ParamTypeString), // unit-test-3 uses runAfter to indicate it should run last tb.PipelineTask("unit-test-3", "unit-test-task", funParam, moreFunParam, templatedParam, @@ -138,7 +140,7 @@ func TestReconcile(t *testing.T) { ), // unit-test-cluster-task can run right away because it has no dependencies tb.PipelineTask("unit-test-cluster-task", "unit-test-cluster-task", - tb.PipelineTaskRefKind(v1alpha1.ClusterTaskKind), + tb.PipelineTaskRefKind(v1beta1.ClusterTaskKind), funParam, moreFunParam, templatedParam, tb.PipelineTaskInputResource("workspace", "git-repo"), tb.PipelineTaskOutputResource("image-to-use", "best-image"), @@ -147,39 +149,35 @@ func TestReconcile(t *testing.T) { ), ), } - ts := []*v1alpha1.Task{ + ts := []*v1beta1.Task{ tb.Task("unit-test-task", tb.TaskSpec( - tb.TaskInputs( - tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit), - tb.InputsParamSpec("foo", v1alpha1.ParamTypeString), tb.InputsParamSpec("bar", v1alpha1.ParamTypeString), tb.InputsParamSpec("templatedparam", v1alpha1.ParamTypeString), - ), - tb.TaskOutputs( - tb.OutputsResource("image-to-use", v1alpha1.PipelineResourceTypeImage), - tb.OutputsResource("workspace", v1alpha1.PipelineResourceTypeGit), + tb.TaskParam("foo", v1beta1.ParamTypeString), tb.TaskParam("bar", v1beta1.ParamTypeString), tb.TaskParam("templatedparam", v1beta1.ParamTypeString), + tb.TaskResources( + tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit), + tb.TaskResourcesOutput("image-to-use", resourcev1alpha1.PipelineResourceTypeImage), + tb.TaskResourcesOutput("workspace", resourcev1alpha1.PipelineResourceTypeGit), ), ), tb.TaskNamespace("foo")), tb.Task("unit-test-followup-task", tb.TaskSpec( - tb.TaskInputs(tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit)), + tb.TaskResources(tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit)), ), tb.TaskNamespace("foo")), } - clusterTasks := []*v1alpha1.ClusterTask{ + clusterTasks := []*v1beta1.ClusterTask{ tb.ClusterTask("unit-test-cluster-task", tb.ClusterTaskSpec( - tb.TaskInputs( - tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit), - tb.InputsParamSpec("foo", v1alpha1.ParamTypeString), tb.InputsParamSpec("bar", v1alpha1.ParamTypeString), tb.InputsParamSpec("templatedparam", v1alpha1.ParamTypeString), - ), - tb.TaskOutputs( - tb.OutputsResource("image-to-use", v1alpha1.PipelineResourceTypeImage), - tb.OutputsResource("workspace", v1alpha1.PipelineResourceTypeGit), + tb.TaskParam("foo", v1beta1.ParamTypeString), tb.TaskParam("bar", v1beta1.ParamTypeString), tb.TaskParam("templatedparam", v1beta1.ParamTypeString), + tb.TaskResources( + tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit), + tb.TaskResourcesOutput("image-to-use", resourcev1alpha1.PipelineResourceTypeImage), + tb.TaskResourcesOutput("workspace", resourcev1alpha1.PipelineResourceTypeGit), ), )), tb.ClusterTask("unit-test-followup-task", tb.ClusterTaskSpec( - tb.TaskInputs(tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit)), + tb.TaskResources(tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit)), )), } - rs := []*v1alpha1.PipelineResource{ + rs := []*resourcev1alpha1.PipelineResource{ tb.PipelineResource("some-repo", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeGit, + resourcev1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("url", "https://github.com/kristoff/reindeer"), )), } @@ -213,7 +211,7 @@ func TestReconcile(t *testing.T) { t.Log("actions", clients.Pipeline.Actions()) // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-success", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-success", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } @@ -223,7 +221,7 @@ func TestReconcile(t *testing.T) { expectedTaskRun := tb.TaskRun("test-pipeline-run-success-unit-test-1-mz4c7", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-success", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"), @@ -239,9 +237,9 @@ func TestReconcile(t *testing.T) { tb.TaskRunResourcesInput("workspace", tb.TaskResourceBindingRef("some-repo")), tb.TaskRunResourcesOutput("image-to-use", tb.TaskResourceBindingResourceSpec( - &v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeImage, - Params: []v1alpha1.ResourceParam{{ + &resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeImage, + Params: []v1beta1.ResourceParam{{ Name: "url", Value: "gcr.io/sven", }}, @@ -257,7 +255,7 @@ func TestReconcile(t *testing.T) { ) // ignore IgnoreUnexported ignore both after and before steps fields - if d := cmp.Diff(expectedTaskRun, actual, cmpopts.SortSlices(func(x, y v1alpha1.TaskResourceBinding) bool { return x.Name < y.Name })); d != "" { + if d := cmp.Diff(expectedTaskRun, actual, cmpopts.SortSlices(func(x, y v1beta1.TaskResourceBinding) bool { return x.Name < y.Name })); d != "" { t.Errorf("expected to see TaskRun %v created. Diff (-want, +got): %s", expectedTaskRun, d) } // test taskrun is able to recreate correct pipeline-pvc-name @@ -291,21 +289,21 @@ func TestReconcile(t *testing.T) { func TestReconcile_PipelineSpecTaskSpec(t *testing.T) { names.TestingSeed() - prs := []*v1alpha1.PipelineRun{ + prs := []*v1beta1.PipelineRun{ tb.PipelineRun("test-pipeline-run-success", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline"), ), } - ps := []*v1alpha1.Pipeline{ + ps := []*v1beta1.Pipeline{ tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( - tb.PipelineTask("unit-test-task-spec", "", tb.PipelineTaskSpec(&v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + tb.PipelineTask("unit-test-task-spec", "", tb.PipelineTaskSpec(&v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "mystep", Image: "myimage"}}}, - }})), + })), ), ), } @@ -334,7 +332,7 @@ func TestReconcile_PipelineSpecTaskSpec(t *testing.T) { t.Log("actions", clients.Pipeline.Actions()) // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-success", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-success", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } @@ -344,7 +342,7 @@ func TestReconcile_PipelineSpecTaskSpec(t *testing.T) { expectedTaskRun := tb.TaskRun("test-pipeline-run-success-unit-test-task-spec-9l9zj", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-success", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"), @@ -354,7 +352,7 @@ func TestReconcile_PipelineSpecTaskSpec(t *testing.T) { ) // ignore IgnoreUnexported ignore both after and before steps fields - if d := cmp.Diff(expectedTaskRun, actual, cmpopts.SortSlices(func(x, y v1alpha1.TaskSpec) bool { return len(x.Steps) == len(y.Steps) })); d != "" { + if d := cmp.Diff(expectedTaskRun, actual, cmpopts.SortSlices(func(x, y v1beta1.TaskSpec) bool { return len(x.Steps) == len(y.Steps) })); d != "" { t.Errorf("expected to see TaskRun %v created. Diff (-want, +got): %s", expectedTaskRun, d) } @@ -373,35 +371,37 @@ func TestReconcile_PipelineSpecTaskSpec(t *testing.T) { } func TestReconcile_InvalidPipelineRuns(t *testing.T) { - ts := []*v1alpha1.Task{ + ts := []*v1beta1.Task{ tb.Task("a-task-that-exists", tb.TaskNamespace("foo")), tb.Task("a-task-that-needs-params", tb.TaskSpec( - tb.TaskInputs(tb.InputsParamSpec("some-param", v1alpha1.ParamTypeString))), tb.TaskNamespace("foo")), + tb.TaskParam("some-param", v1beta1.ParamTypeString), + ), tb.TaskNamespace("foo")), tb.Task("a-task-that-needs-array-params", tb.TaskSpec( - tb.TaskInputs(tb.InputsParamSpec("some-param", v1alpha1.ParamTypeArray))), tb.TaskNamespace("foo")), + tb.TaskParam("some-param", v1beta1.ParamTypeArray), + ), tb.TaskNamespace("foo")), tb.Task("a-task-that-needs-a-resource", tb.TaskSpec( - tb.TaskInputs(tb.InputsResource("workspace", "git")), + tb.TaskResources(tb.TaskResourcesInput("workspace", "git")), ), tb.TaskNamespace("foo")), } - ps := []*v1alpha1.Pipeline{ + ps := []*v1beta1.Pipeline{ tb.Pipeline("pipeline-missing-tasks", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("myspecialtask", "sometask"), )), tb.Pipeline("a-pipeline-without-params", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("some-task", "a-task-that-needs-params"))), tb.Pipeline("a-fine-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( - tb.PipelineDeclaredResource("a-resource", v1alpha1.PipelineResourceTypeGit), + tb.PipelineDeclaredResource("a-resource", resourcev1alpha1.PipelineResourceTypeGit), tb.PipelineTask("some-task", "a-task-that-exists", tb.PipelineTaskInputResource("needed-resource", "a-resource")))), tb.Pipeline("a-pipeline-that-should-be-caught-by-admission-control", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("some-task", "a-task-that-exists", tb.PipelineTaskInputResource("needed-resource", "a-resource")))), tb.Pipeline("a-pipeline-with-array-params", tb.PipelineNamespace("foo"), tb.PipelineSpec( - tb.PipelineParamSpec("some-param", v1alpha1.ParamTypeArray), + tb.PipelineParamSpec("some-param", v1beta1.ParamTypeArray), tb.PipelineTask("some-task", "a-task-that-needs-array-params"))), tb.Pipeline("a-pipeline-with-missing-conditions", tb.PipelineNamespace("foo"), tb.PipelineSpec(tb.PipelineTask("some-task", "a-task-that-exists", tb.PipelineTaskCondition("condition-does-not-exist")))), } - prs := []*v1alpha1.PipelineRun{ + prs := []*v1beta1.PipelineRun{ tb.PipelineRun("invalid-pipeline", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("pipeline-not-exist")), tb.PipelineRun("pipelinerun-missing-tasks", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("pipeline-missing-tasks")), tb.PipelineRun("pipeline-params-dont-exist", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("a-pipeline-without-params")), @@ -419,7 +419,7 @@ func TestReconcile_InvalidPipelineRuns(t *testing.T) { tb.PipelineTask("bad-t@$k", "b@d-t@$k"), ))), tb.PipelineRun("embedded-pipeline-mismatching-param-type", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("", tb.PipelineRunPipelineSpec( - tb.PipelineParamSpec("some-param", v1alpha1.ParamTypeArray), + tb.PipelineParamSpec("some-param", v1beta1.ParamTypeArray), tb.PipelineTask("some-task", "a-task-that-needs-array-params")), tb.PipelineRunParam("some-param", "stringval"), )), @@ -431,7 +431,7 @@ func TestReconcile_InvalidPipelineRuns(t *testing.T) { } tcs := []struct { name string - pipelineRun *v1alpha1.PipelineRun + pipelineRun *v1beta1.PipelineRun reason string hasNoDefaultLabels bool }{ @@ -567,12 +567,12 @@ func TestReconcile_InvalidPipelineRunNames(t *testing.T) { func TestUpdateTaskRunsState(t *testing.T) { pr := tb.PipelineRun("test-pipeline-run", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline")) - pipelineTask := v1alpha1.PipelineTask{ + pipelineTask := v1beta1.PipelineTask{ Name: "unit-test-1", - TaskRef: &v1alpha1.TaskRef{Name: "unit-test-task"}, + TaskRef: &v1beta1.TaskRef{Name: "unit-test-task"}, } task := tb.Task("unit-test-task", tb.TaskSpec( - tb.TaskInputs(tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit)), + tb.TaskResources(tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit)), ), tb.TaskNamespace("foo")) taskrun := tb.TaskRun("test-pipeline-run-success-unit-test-1", tb.TaskRunNamespace("foo"), @@ -584,12 +584,12 @@ func TestUpdateTaskRunsState(t *testing.T) { tb.StepState(tb.StateTerminated(0)), )) - expectedTaskRunsStatus := make(map[string]*v1alpha1.PipelineRunTaskRunStatus) - expectedTaskRunsStatus["test-pipeline-run-success-unit-test-1"] = &v1alpha1.PipelineRunTaskRunStatus{ + expectedTaskRunsStatus := make(map[string]*v1beta1.PipelineRunTaskRunStatus) + expectedTaskRunsStatus["test-pipeline-run-success-unit-test-1"] = &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: "unit-test-1", - Status: &v1alpha1.TaskRunStatus{ - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ - Steps: []v1alpha1.StepState{{ + Status: &v1beta1.TaskRunStatus{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + Steps: []v1beta1.StepState{{ ContainerState: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ExitCode: 0}, }, @@ -599,8 +599,8 @@ func TestUpdateTaskRunsState(t *testing.T) { }, }, } - expectedPipelineRunStatus := v1alpha1.PipelineRunStatus{ - PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + expectedPipelineRunStatus := v1beta1.PipelineRunStatus{ + PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ TaskRuns: expectedTaskRunsStatus, }, } @@ -626,12 +626,12 @@ func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { successConditionCheckName := "success-condition" failingConditionCheckName := "fail-condition" - successCondition := tb.Condition("cond-1", tb.ConditionNamespace("foo")) - failingCondition := tb.Condition("cond-2", tb.ConditionNamespace("foo")) + successCondition := tbv1alpha1.Condition("cond-1", tbv1alpha1.ConditionNamespace("foo")) + failingCondition := tbv1alpha1.Condition("cond-2", tbv1alpha1.ConditionNamespace("foo")) - pipelineTask := v1alpha1.PipelineTask{ - TaskRef: &v1alpha1.TaskRef{Name: "unit-test-task"}, - Conditions: []v1alpha1.PipelineTaskCondition{{ + pipelineTask := v1beta1.PipelineTask{ + TaskRef: &v1beta1.TaskRef{Name: "unit-test-task"}, + Conditions: []v1beta1.PipelineTaskCondition{{ ConditionRef: successCondition.Name, }, { ConditionRef: failingCondition.Name, @@ -670,10 +670,10 @@ func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { ConditionCheck: failingConditionCheck, } - successConditionCheckStatus := &v1alpha1.PipelineRunConditionCheckStatus{ + successConditionCheckStatus := &v1beta1.PipelineRunConditionCheckStatus{ ConditionName: successrcc.ConditionRegisterName, - Status: &v1alpha1.ConditionCheckStatus{ - ConditionCheckStatusFields: v1alpha1.ConditionCheckStatusFields{ + Status: &v1beta1.ConditionCheckStatus{ + ConditionCheckStatusFields: v1beta1.ConditionCheckStatusFields{ Check: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ExitCode: 0}, }, @@ -683,10 +683,10 @@ func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { }, }, } - failingConditionCheckStatus := &v1alpha1.PipelineRunConditionCheckStatus{ + failingConditionCheckStatus := &v1beta1.PipelineRunConditionCheckStatus{ ConditionName: failingrcc.ConditionRegisterName, - Status: &v1alpha1.ConditionCheckStatus{ - ConditionCheckStatusFields: v1alpha1.ConditionCheckStatusFields{ + Status: &v1beta1.ConditionCheckStatus{ + ConditionCheckStatusFields: v1beta1.ConditionCheckStatusFields{ Check: corev1.ContainerState{ Terminated: &corev1.ContainerStateTerminated{ExitCode: 127}, }, @@ -697,7 +697,7 @@ func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { }, } - failedTaskRunStatus := v1alpha1.TaskRunStatus{ + failedTaskRunStatus := v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -711,30 +711,30 @@ func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { tcs := []struct { name string rcc resources.TaskConditionCheckState - expectedStatus v1alpha1.PipelineRunTaskRunStatus + expectedStatus v1beta1.PipelineRunTaskRunStatus }{{ name: "success-condition-checks", rcc: resources.TaskConditionCheckState{&successrcc}, - expectedStatus: v1alpha1.PipelineRunTaskRunStatus{ - ConditionChecks: map[string]*v1alpha1.PipelineRunConditionCheckStatus{ + expectedStatus: v1beta1.PipelineRunTaskRunStatus{ + ConditionChecks: map[string]*v1beta1.PipelineRunConditionCheckStatus{ successrcc.ConditionCheck.Name: successConditionCheckStatus, }, }, }, { name: "failing-condition-checks", rcc: resources.TaskConditionCheckState{&failingrcc}, - expectedStatus: v1alpha1.PipelineRunTaskRunStatus{ + expectedStatus: v1beta1.PipelineRunTaskRunStatus{ Status: &failedTaskRunStatus, - ConditionChecks: map[string]*v1alpha1.PipelineRunConditionCheckStatus{ + ConditionChecks: map[string]*v1beta1.PipelineRunConditionCheckStatus{ failingrcc.ConditionCheck.Name: failingConditionCheckStatus, }, }, }, { name: "multiple-condition-checks", rcc: resources.TaskConditionCheckState{&successrcc, &failingrcc}, - expectedStatus: v1alpha1.PipelineRunTaskRunStatus{ + expectedStatus: v1beta1.PipelineRunTaskRunStatus{ Status: &failedTaskRunStatus, - ConditionChecks: map[string]*v1alpha1.PipelineRunConditionCheckStatus{ + ConditionChecks: map[string]*v1beta1.PipelineRunConditionCheckStatus{ successrcc.ConditionCheck.Name: successConditionCheckStatus, failingrcc.ConditionCheck.Name: failingConditionCheckStatus, }, @@ -752,7 +752,7 @@ func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { }} pr.Status.InitializeConditions() status := getTaskRunsStatus(pr, state) - expected := map[string]*v1alpha1.PipelineRunTaskRunStatus{ + expected := map[string]*v1beta1.PipelineRunTaskRunStatus{ taskrunName: &tc.expectedStatus, } if d := cmp.Diff(status, expected, ignoreLastTransitionTime); d != "" { @@ -764,7 +764,7 @@ func TestUpdateTaskRunStateWithConditionChecks(t *testing.T) { func TestReconcileOnCompletedPipelineRun(t *testing.T) { taskRunName := "test-pipeline-run-completed-hello-world" - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-completed", + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-completed", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa")), tb.PipelineRunStatus(tb.PipelineRunStatusCondition(apis.Condition{ @@ -773,16 +773,16 @@ func TestReconcileOnCompletedPipelineRun(t *testing.T) { Reason: resources.ReasonSucceeded, Message: "All Tasks have completed executing", }), - tb.PipelineRunTaskRunsStatus(taskRunName, &v1alpha1.PipelineRunTaskRunStatus{ + tb.PipelineRunTaskRunsStatus(taskRunName, &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: "hello-world-1", - Status: &v1alpha1.TaskRunStatus{}, + Status: &v1beta1.TaskRunStatus{}, }), ), )} - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world")))} - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} - trs := []*v1alpha1.TaskRun{ + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + trs := []*v1beta1.TaskRun{ tb.TaskRun(taskRunName, tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("kind", "name"), @@ -816,7 +816,7 @@ func TestReconcileOnCompletedPipelineRun(t *testing.T) { t.Fatalf("Expected client to have updated the TaskRun status for a completed PipelineRun, but it did not") } - actual := clients.Pipeline.Actions()[1].(ktesting.UpdateAction).GetObject().(*v1alpha1.PipelineRun) + actual := clients.Pipeline.Actions()[1].(ktesting.UpdateAction).GetObject().(*v1beta1.PipelineRun) if actual == nil { t.Errorf("Expected a PipelineRun to be updated, but it wasn't.") } @@ -832,7 +832,7 @@ func TestReconcileOnCompletedPipelineRun(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-completed", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-completed", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } @@ -842,10 +842,10 @@ func TestReconcileOnCompletedPipelineRun(t *testing.T) { t.Errorf("Expected PipelineRun status to be complete, but was %v", reconciledRun.Status.GetCondition(apis.ConditionSucceeded)) } - expectedTaskRunsStatus := make(map[string]*v1alpha1.PipelineRunTaskRunStatus) - expectedTaskRunsStatus[taskRunName] = &v1alpha1.PipelineRunTaskRunStatus{ + expectedTaskRunsStatus := make(map[string]*v1beta1.PipelineRunTaskRunStatus) + expectedTaskRunsStatus[taskRunName] = &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: "hello-world-1", - Status: &v1alpha1.TaskRunStatus{ + Status: &v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded}}, }, @@ -858,17 +858,17 @@ func TestReconcileOnCompletedPipelineRun(t *testing.T) { } func TestReconcileOnCancelledPipelineRun(t *testing.T) { - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-cancelled", + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-cancelled", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa"), tb.PipelineRunCancelled, ), )} - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world"), ))} - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} - trs := []*v1alpha1.TaskRun{ + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + trs := []*v1beta1.TaskRun{ tb.TaskRun("test-pipeline-run-cancelled-hello-world", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("kind", "name"), @@ -898,7 +898,7 @@ func TestReconcileOnCancelledPipelineRun(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-cancelled", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-cancelled", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } @@ -914,10 +914,10 @@ func TestReconcileOnCancelledPipelineRun(t *testing.T) { } func TestReconcileWithTimeout(t *testing.T) { - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world"), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-timeout", + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-timeout", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa"), @@ -926,7 +926,7 @@ func TestReconcileWithTimeout(t *testing.T) { tb.PipelineRunStatus( tb.PipelineRunStartTime(time.Now().AddDate(0, 0, -1))), )} - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} d := test.Data{ PipelineRuns: prs, @@ -945,7 +945,7 @@ func TestReconcileWithTimeout(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-with-timeout", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-with-timeout", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } @@ -960,7 +960,7 @@ func TestReconcileWithTimeout(t *testing.T) { } // Check that the expected TaskRun was created - actual := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1alpha1.TaskRun) + actual := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1beta1.TaskRun) if actual == nil { t.Fatalf("Expected a TaskRun to be created, but it wasn't.") } @@ -972,15 +972,15 @@ func TestReconcileWithTimeout(t *testing.T) { } func TestReconcileWithoutPVC(t *testing.T) { - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world"), tb.PipelineTask("hello-world-2", "hello-world"), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline")), } - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} d := test.Data{ PipelineRuns: prs, @@ -999,7 +999,7 @@ func TestReconcileWithoutPVC(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } @@ -1020,15 +1020,15 @@ func TestReconcileWithoutPVC(t *testing.T) { } func TestReconcileCancelledPipelineRun(t *testing.T) { - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world", tb.Retries(1)), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-timeout", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-timeout", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunCancelled, ), )} - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} d := test.Data{ PipelineRuns: prs, @@ -1047,7 +1047,7 @@ func TestReconcileCancelledPipelineRun(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-with-timeout", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-with-timeout", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } @@ -1071,17 +1071,17 @@ func TestReconcilePropagateLabels(t *testing.T) { names.TestingSeed() taskName := "hello-world-1" - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask(taskName, "hello-world"), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-labels", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-labels", tb.PipelineRunNamespace("foo"), tb.PipelineRunLabel("PipelineRunLabel", "PipelineRunValue"), tb.PipelineRunLabel("tekton.dev/pipeline", "WillNotBeUsed"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa"), ), )} - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} d := test.Data{ PipelineRuns: prs, @@ -1092,7 +1092,7 @@ func TestReconcilePropagateLabels(t *testing.T) { expected := tb.TaskRun("test-pipeline-run-with-labels-hello-world-1-9l9zj", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-with-labels", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"), @@ -1116,13 +1116,13 @@ func TestReconcilePropagateLabels(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - _, err = clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-with-labels", metav1.GetOptions{}) + _, err = clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-with-labels", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } // Check that the expected TaskRun was created - actual := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1alpha1.TaskRun) + actual := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1beta1.TaskRun) if actual == nil { t.Errorf("Expected a TaskRun to be created, but it wasn't.") } @@ -1135,17 +1135,17 @@ func TestReconcilePropagateLabels(t *testing.T) { func TestReconcileWithDifferentServiceAccounts(t *testing.T) { names.TestingSeed() - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-0", "hello-world-task"), tb.PipelineTask("hello-world-1", "hello-world-task"), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-different-service-accs", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-different-service-accs", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa-0"), tb.PipelineRunServiceAccountNameTask("hello-world-1", "test-sa-1"), ), )} - ts := []*v1alpha1.Task{ + ts := []*v1beta1.Task{ tb.Task("hello-world-task", tb.TaskNamespace("foo")), } @@ -1167,17 +1167,17 @@ func TestReconcileWithDifferentServiceAccounts(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - _, err = clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-different-service-accs", metav1.GetOptions{}) + _, err = clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-different-service-accs", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } taskRunNames := []string{"test-pipeline-run-different-service-accs-hello-world-0-9l9zj", "test-pipeline-run-different-service-accs-hello-world-1-mz4c7"} - expectedTaskRuns := []*v1alpha1.TaskRun{ + expectedTaskRuns := []*v1beta1.TaskRun{ tb.TaskRun(taskRunNames[0], tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-different-service-accs", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunSpec( @@ -1191,7 +1191,7 @@ func TestReconcileWithDifferentServiceAccounts(t *testing.T) { tb.TaskRun(taskRunNames[1], tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-different-service-accs", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunSpec( @@ -1205,7 +1205,7 @@ func TestReconcileWithDifferentServiceAccounts(t *testing.T) { } for i := range ps[0].Spec.Tasks { // Check that the expected TaskRun was created - actual, err := clients.Pipeline.TektonV1alpha1().TaskRuns("foo").Get(taskRunNames[i], metav1.GetOptions{}) + actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").Get(taskRunNames[i], metav1.GetOptions{}) if err != nil { t.Fatalf("Expected a TaskRun to be created, but it wasn't: %s", err) } @@ -1239,10 +1239,10 @@ func TestReconcileWithTimeoutAndRetry(t *testing.T) { for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline-retry", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline-retry", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world", tb.Retries(tc.retries)), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-retry-run-with-timeout", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-retry-run-with-timeout", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline-retry", tb.PipelineRunServiceAccountName("test-sa"), tb.PipelineRunTimeout(12*time.Hour), @@ -1251,10 +1251,10 @@ func TestReconcileWithTimeoutAndRetry(t *testing.T) { tb.PipelineRunStartTime(time.Now().AddDate(0, 0, -1))), )} - ts := []*v1alpha1.Task{ + ts := []*v1beta1.Task{ tb.Task("hello-world", tb.TaskNamespace("foo")), } - trs := []*v1alpha1.TaskRun{ + trs := []*v1beta1.TaskRun{ tb.TaskRun("hello-world-1", tb.TaskRunNamespace("foo"), tb.TaskRunStatus( @@ -1263,7 +1263,7 @@ func TestReconcileWithTimeoutAndRetry(t *testing.T) { Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, }), - tb.Retry(v1alpha1.TaskRunStatus{ + tb.Retry(v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -1274,11 +1274,11 @@ func TestReconcileWithTimeoutAndRetry(t *testing.T) { )), } - prtrs := &v1alpha1.PipelineRunTaskRunStatus{ + prtrs := &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: "hello-world-1", Status: &trs[0].Status, } - prs[0].Status.TaskRuns = make(map[string]*v1alpha1.PipelineRunTaskRunStatus) + prs[0].Status.TaskRuns = make(map[string]*v1beta1.PipelineRunTaskRunStatus) prs[0].Status.TaskRuns["hello-world-1"] = prtrs d := test.Data{ @@ -1299,7 +1299,7 @@ func TestReconcileWithTimeoutAndRetry(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-retry-run-with-timeout", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-retry-run-with-timeout", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } @@ -1319,16 +1319,16 @@ func TestReconcileWithTimeoutAndRetry(t *testing.T) { func TestReconcilePropagateAnnotations(t *testing.T) { names.TestingSeed() - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world"), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-annotations", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-annotations", tb.PipelineRunNamespace("foo"), tb.PipelineRunAnnotation("PipelineRunAnnotation", "PipelineRunValue"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa"), ), )} - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} d := test.Data{ PipelineRuns: prs, @@ -1347,20 +1347,20 @@ func TestReconcilePropagateAnnotations(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - _, err = clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-with-annotations", metav1.GetOptions{}) + _, err = clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-with-annotations", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } // Check that the expected TaskRun was created - actual := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1alpha1.TaskRun) + actual := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1beta1.TaskRun) if actual == nil { t.Errorf("Expected a TaskRun to be created, but it wasn't.") } expectedTaskRun := tb.TaskRun("test-pipeline-run-with-annotations-hello-world-1-9l9zj", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-with-annotations", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"), @@ -1385,7 +1385,7 @@ func TestGetTaskRunTimeout(t *testing.T) { tcs := []struct { name string - pr *v1alpha1.PipelineRun + pr *v1beta1.PipelineRun rprt *resources.ResolvedPipelineRunTask expected *metav1.Duration }{{ @@ -1395,7 +1395,7 @@ func TestGetTaskRunTimeout(t *testing.T) { tb.PipelineRunStatus(tb.PipelineRunStartTime(time.Now())), ), rprt: &resources.ResolvedPipelineRunTask{ - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Timeout: nil, }, }, @@ -1407,7 +1407,7 @@ func TestGetTaskRunTimeout(t *testing.T) { tb.PipelineRunStatus(tb.PipelineRunStartTime(time.Now())), ), rprt: &resources.ResolvedPipelineRunTask{ - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Timeout: nil, }, }, @@ -1419,7 +1419,7 @@ func TestGetTaskRunTimeout(t *testing.T) { tb.PipelineRunStatus(tb.PipelineRunStartTime(time.Now())), ), rprt: &resources.ResolvedPipelineRunTask{ - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Timeout: nil, }, }, @@ -1430,7 +1430,7 @@ func TestGetTaskRunTimeout(t *testing.T) { tb.PipelineRunSpec(p, tb.PipelineRunTimeout(1*time.Minute)), tb.PipelineRunStatus(tb.PipelineRunStartTime(time.Now().Add(-2*time.Minute)))), rprt: &resources.ResolvedPipelineRunTask{ - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Timeout: nil, }, }, @@ -1442,7 +1442,7 @@ func TestGetTaskRunTimeout(t *testing.T) { tb.PipelineRunStatus(tb.PipelineRunStartTime(time.Now())), ), rprt: &resources.ResolvedPipelineRunTask{ - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Timeout: &metav1.Duration{Duration: 2 * time.Minute}, }, }, @@ -1454,7 +1454,7 @@ func TestGetTaskRunTimeout(t *testing.T) { tb.PipelineRunStatus(tb.PipelineRunStartTime(time.Now())), ), rprt: &resources.ResolvedPipelineRunTask{ - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Timeout: &metav1.Duration{Duration: 2 * time.Minute}, }, }, @@ -1474,39 +1474,39 @@ func TestReconcileWithConditionChecks(t *testing.T) { names.TestingSeed() prName := "test-pipeline-run" conditions := []*v1alpha1.Condition{ - tb.Condition("cond-1", - tb.ConditionNamespace("foo"), - tb.ConditionLabels( + tbv1alpha1.Condition("cond-1", + tbv1alpha1.ConditionNamespace("foo"), + tbv1alpha1.ConditionLabels( map[string]string{ "label-1": "value-1", "label-2": "value-2", }), - tb.ConditionSpec( - tb.ConditionSpecCheck("", "foo", tb.Args("bar")), + tbv1alpha1.ConditionSpec( + tbv1alpha1.ConditionSpecCheck("", "foo", tb.Args("bar")), )), - tb.Condition("cond-2", - tb.ConditionNamespace("foo"), - tb.ConditionLabels( + tbv1alpha1.Condition("cond-2", + tbv1alpha1.ConditionNamespace("foo"), + tbv1alpha1.ConditionLabels( map[string]string{ "label-3": "value-3", "label-4": "value-4", }), - tb.ConditionSpec( - tb.ConditionSpecCheck("", "foo", tb.Args("bar")), + tbv1alpha1.ConditionSpec( + tbv1alpha1.ConditionSpecCheck("", "foo", tb.Args("bar")), )), } - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world", tb.PipelineTaskCondition("cond-1"), tb.PipelineTaskCondition("cond-2")), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun(prName, tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun(prName, tb.PipelineRunNamespace("foo"), tb.PipelineRunAnnotation("PipelineRunAnnotation", "PipelineRunValue"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa"), ), )} - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} d := test.Data{ PipelineRuns: prs, @@ -1526,7 +1526,7 @@ func TestReconcileWithConditionChecks(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - _, err = clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get(prName, metav1.GetOptions{}) + _, err = clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(prName, metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } @@ -1535,19 +1535,19 @@ func TestReconcileWithConditionChecks(t *testing.T) { "cond-1": ccNameBase + "-cond-1-0-mz4c7", "cond-2": ccNameBase + "-cond-2-1-mssqb", } - expectedConditionChecks := make([]*v1alpha1.TaskRun, len(conditions)) + expectedConditionChecks := make([]*v1beta1.TaskRun, len(conditions)) for index, condition := range conditions { expectedConditionChecks[index] = makeExpectedTr(condition.Name, ccNames[condition.Name], condition.Labels) } // Check that the expected TaskRun was created - condCheck0 := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1alpha1.TaskRun) - condCheck1 := clients.Pipeline.Actions()[2].(ktesting.CreateAction).GetObject().(*v1alpha1.TaskRun) + condCheck0 := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1beta1.TaskRun) + condCheck1 := clients.Pipeline.Actions()[2].(ktesting.CreateAction).GetObject().(*v1beta1.TaskRun) if condCheck0 == nil || condCheck1 == nil { t.Errorf("Expected two ConditionCheck TaskRuns to be created, but it wasn't.") } - actual := []*v1alpha1.TaskRun{condCheck0, condCheck1} + actual := []*v1beta1.TaskRun{condCheck0, condCheck1} if d := cmp.Diff(actual, expectedConditionChecks); d != "" { t.Errorf("expected to see 2 ConditionCheck TaskRuns created. Diff %s", d) } @@ -1556,25 +1556,25 @@ func TestReconcileWithConditionChecks(t *testing.T) { func TestReconcileWithFailingConditionChecks(t *testing.T) { names.TestingSeed() conditions := []*v1alpha1.Condition{ - tb.Condition("always-false", tb.ConditionNamespace("foo"), tb.ConditionSpec( - tb.ConditionSpecCheck("", "foo", tb.Args("bar")), + tbv1alpha1.Condition("always-false", tbv1alpha1.ConditionNamespace("foo"), tbv1alpha1.ConditionSpec( + tbv1alpha1.ConditionSpecCheck("", "foo", tb.Args("bar")), )), } pipelineRunName := "test-pipeline-run-with-conditions" - prccs := make(map[string]*v1alpha1.PipelineRunConditionCheckStatus) + prccs := make(map[string]*v1beta1.PipelineRunConditionCheckStatus) conditionCheckName := pipelineRunName + "task-2-always-false-xxxyyy" - prccs[conditionCheckName] = &v1alpha1.PipelineRunConditionCheckStatus{ + prccs[conditionCheckName] = &v1beta1.PipelineRunConditionCheckStatus{ ConditionName: "always-false-0", - Status: &v1alpha1.ConditionCheckStatus{}, + Status: &v1beta1.ConditionCheckStatus{}, } - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("task-1", "hello-world"), tb.PipelineTask("task-2", "hello-world", tb.PipelineTaskCondition("always-false")), tb.PipelineTask("task-3", "hello-world", tb.RunAfter("task-1")), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-conditions", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-with-conditions", tb.PipelineRunNamespace("foo"), tb.PipelineRunAnnotation("PipelineRunAnnotation", "PipelineRunValue"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa"), @@ -1584,18 +1584,18 @@ func TestReconcileWithFailingConditionChecks(t *testing.T) { Status: corev1.ConditionUnknown, Reason: resources.ReasonRunning, Message: "Not all Tasks in the Pipeline have finished executing", - }), tb.PipelineRunTaskRunsStatus(pipelineRunName+"task-1", &v1alpha1.PipelineRunTaskRunStatus{ + }), tb.PipelineRunTaskRunsStatus(pipelineRunName+"task-1", &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: "task-1", - Status: &v1alpha1.TaskRunStatus{}, - }), tb.PipelineRunTaskRunsStatus(pipelineRunName+"task-2", &v1alpha1.PipelineRunTaskRunStatus{ + Status: &v1beta1.TaskRunStatus{}, + }), tb.PipelineRunTaskRunsStatus(pipelineRunName+"task-2", &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: "task-2", - Status: &v1alpha1.TaskRunStatus{}, + Status: &v1beta1.TaskRunStatus{}, ConditionChecks: prccs, })), )} - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} - trs := []*v1alpha1.TaskRun{ + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + trs := []*v1beta1.TaskRun{ tb.TaskRun(pipelineRunName+"task-1", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("kind", "name"), @@ -1642,20 +1642,20 @@ func TestReconcileWithFailingConditionChecks(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - _, err = clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-with-conditions", metav1.GetOptions{}) + _, err = clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-with-conditions", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } // Check that the expected TaskRun was created - actual := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1alpha1.TaskRun) + actual := clients.Pipeline.Actions()[1].(ktesting.CreateAction).GetObject().(*v1beta1.TaskRun) if actual == nil { t.Errorf("Expected a ConditionCheck TaskRun to be created, but it wasn't.") } expectedTaskRun := tb.TaskRun("test-pipeline-run-with-conditions-task-3-9l9zj", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-with-conditions", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineLabelKey, "test-pipeline"), @@ -1673,11 +1673,11 @@ func TestReconcileWithFailingConditionChecks(t *testing.T) { } } -func makeExpectedTr(condName, ccName string, labels map[string]string) *v1alpha1.TaskRun { +func makeExpectedTr(condName, ccName string, labels map[string]string) *v1beta1.TaskRun { return tb.TaskRun(ccName, tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineLabelKey, "test-pipeline"), @@ -1690,7 +1690,6 @@ func makeExpectedTr(condName, ccName string, labels map[string]string) *v1alpha1 tb.TaskRunSpec( tb.TaskRunTaskSpec( tb.Step("foo", tb.StepName("condition-check-"+condName), tb.StepArgs("bar")), - tb.TaskInputs(), ), tb.TaskRunServiceAccountName("test-sa"), ), @@ -1720,16 +1719,16 @@ func TestReconcileWithVolumeClaimTemplateWorkspace(t *testing.T) { workspaceName := "ws1" claimName := "myclaim" pipelineRunName := "test-pipeline-run" - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world", tb.PipelineTaskWorkspaceBinding("taskWorkspaceName", workspaceName, "")), tb.PipelineTask("hello-world-2", "hello-world"), tb.PipelineWorkspaceDeclaration(workspaceName), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun(pipelineRunName, tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun(pipelineRunName, tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunWorkspaceBindingVolumeClaimTemplate(workspaceName, claimName, ""))), } - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} d := test.Data{ PipelineRuns: prs, @@ -1748,7 +1747,7 @@ func TestReconcileWithVolumeClaimTemplateWorkspace(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } @@ -1773,7 +1772,7 @@ func TestReconcileWithVolumeClaimTemplateWorkspace(t *testing.T) { t.Errorf("expected the created PVC to be named %s. It was named %s", expectedPVCName, pvcNames[0]) } - taskRuns, err := clients.Pipeline.TektonV1alpha1().TaskRuns("foo").List(metav1.ListOptions{}) + taskRuns, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error when listing TaskRuns: %v", err) } @@ -1803,7 +1802,7 @@ func TestReconcileWithVolumeClaimTemplateWorkspaceUsingSubPaths(t *testing.T) { subPath1 := "customdirectory" subPath2 := "otherdirecory" pipelineRunWsSubPath := "mypath" - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hello-world", tb.PipelineTaskWorkspaceBinding("taskWorkspaceName", workspaceName, subPath1)), tb.PipelineTask("hello-world-2", "hello-world", tb.PipelineTaskWorkspaceBinding("taskWorkspaceName", workspaceName, subPath2)), tb.PipelineTask("hello-world-3", "hello-world", tb.PipelineTaskWorkspaceBinding("taskWorkspaceName", workspaceName, "")), @@ -1812,12 +1811,12 @@ func TestReconcileWithVolumeClaimTemplateWorkspaceUsingSubPaths(t *testing.T) { tb.PipelineWorkspaceDeclaration(workspaceName, workspaceNameWithSubPath), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunWorkspaceBindingVolumeClaimTemplate(workspaceName, "myclaim", ""), tb.PipelineRunWorkspaceBindingVolumeClaimTemplate(workspaceNameWithSubPath, "myclaim", pipelineRunWsSubPath))), } - ts := []*v1alpha1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} + ts := []*v1beta1.Task{tb.Task("hello-world", tb.TaskNamespace("foo"))} d := test.Data{ PipelineRuns: prs, @@ -1836,12 +1835,12 @@ func TestReconcileWithVolumeClaimTemplateWorkspaceUsingSubPaths(t *testing.T) { } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err) } - taskRuns, err := clients.Pipeline.TektonV1alpha1().TaskRuns("foo").List(metav1.ListOptions{}) + taskRuns, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error when listing TaskRuns: %v", err) } @@ -1911,30 +1910,30 @@ func TestReconcileWithVolumeClaimTemplateWorkspaceUsingSubPaths(t *testing.T) { func TestReconcileWithTaskResults(t *testing.T) { names.TestingSeed() - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("a-task", "a-task"), tb.PipelineTask("b-task", "b-task", tb.PipelineTaskParam("bParam", "$(tasks.a-task.results.aResult)"), ), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-different-service-accs", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-different-service-accs", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa-0"), ), )} - ts := []*v1alpha1.Task{ + ts := []*v1beta1.Task{ tb.Task("a-task", tb.TaskNamespace("foo")), tb.Task("b-task", tb.TaskNamespace("foo"), tb.TaskSpec( - tb.TaskInputs(tb.InputsParamSpec("bParam", v1alpha1.ParamTypeString)), + tb.TaskParam("bParam", v1beta1.ParamTypeString), ), ), } - trs := []*v1alpha1.TaskRun{ + trs := []*v1beta1.TaskRun{ tb.TaskRun("test-pipeline-run-different-service-accs-a-task-9l9zj", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-different-service-accs", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"), @@ -1970,7 +1969,7 @@ func TestReconcileWithTaskResults(t *testing.T) { t.Errorf("Did not expect to see error when reconciling completed PipelineRun but saw %s", err) } // Check that the PipelineRun was reconciled correctly - _, err = clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-different-service-accs", metav1.GetOptions{}) + _, err = clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-different-service-accs", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } @@ -1978,7 +1977,7 @@ func TestReconcileWithTaskResults(t *testing.T) { expectedTaskRun := tb.TaskRun(expectedTaskRunName, tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-different-service-accs", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"), @@ -1991,7 +1990,7 @@ func TestReconcileWithTaskResults(t *testing.T) { ), ) // Check that the expected TaskRun was created - actual, err := clients.Pipeline.TektonV1alpha1().TaskRuns("foo").List(metav1.ListOptions{ + actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(metav1.ListOptions{ LabelSelector: "tekton.dev/pipelineTask=b-task,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs", Limit: 1, }) @@ -2010,10 +2009,10 @@ func TestReconcileWithTaskResults(t *testing.T) { func TestReconcileWithTaskResultsEmbeddedNoneStarted(t *testing.T) { names.TestingSeed() - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-different-service-accs", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-different-service-accs", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunPipelineSpec( - tb.PipelineParamSpec("foo", v1alpha1.ParamTypeString), + tb.PipelineParamSpec("foo", v1beta1.ParamTypeString), tb.PipelineTask("a-task", "a-task"), tb.PipelineTask("b-task", "b-task", tb.PipelineTaskParam("bParam", "$(params.foo)/baz@$(tasks.a-task.results.A_RESULT)"), @@ -2023,7 +2022,7 @@ func TestReconcileWithTaskResultsEmbeddedNoneStarted(t *testing.T) { tb.PipelineRunServiceAccountName("test-sa-0"), ), )} - ts := []*v1alpha1.Task{ + ts := []*v1beta1.Task{ tb.Task("a-task", tb.TaskNamespace("foo"), tb.TaskSpec( tb.TaskResults("A_RESULT", ""), @@ -2031,7 +2030,7 @@ func TestReconcileWithTaskResultsEmbeddedNoneStarted(t *testing.T) { ), tb.Task("b-task", tb.TaskNamespace("foo"), tb.TaskSpec( - tb.TaskInputs(tb.InputsParamSpec("bParam", v1alpha1.ParamTypeString)), + tb.TaskParam("bParam", v1beta1.ParamTypeString), ), ), } @@ -2048,7 +2047,7 @@ func TestReconcileWithTaskResultsEmbeddedNoneStarted(t *testing.T) { t.Errorf("Did not expect to see error when reconciling completed PipelineRun but saw %s", err) } // Check that the PipelineRun was reconciled correctly - reconciledRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-different-service-accs", metav1.GetOptions{}) + reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-different-service-accs", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } @@ -2062,7 +2061,7 @@ func TestReconcileWithTaskResultsEmbeddedNoneStarted(t *testing.T) { expectedTaskRun := tb.TaskRun(expectedTaskRunName, tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-different-service-accs", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline-run-different-service-accs"), @@ -2074,7 +2073,7 @@ func TestReconcileWithTaskResultsEmbeddedNoneStarted(t *testing.T) { ), ) // Check that the expected TaskRun was created (only) - actual, err := clients.Pipeline.TektonV1alpha1().TaskRuns("foo").List(metav1.ListOptions{}) + actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(metav1.ListOptions{}) if err != nil { t.Fatalf("Failure to list TaskRun's %s", err) } @@ -2089,33 +2088,33 @@ func TestReconcileWithTaskResultsEmbeddedNoneStarted(t *testing.T) { func TestReconcileWithPipelineResults(t *testing.T) { names.TestingSeed() - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineNamespace("foo"), tb.PipelineSpec( tb.PipelineTask("a-task", "a-task"), tb.PipelineTask("b-task", "b-task", tb.PipelineTaskParam("bParam", "$(tasks.a-task.results.aResult)"), ), tb.PipelineResult("result", "$(tasks.a-task.results.aResult)", "pipeline result"), ))} - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-different-service-accs", tb.PipelineRunNamespace("foo"), + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-different-service-accs", tb.PipelineRunNamespace("foo"), tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa-0"), ), tb.PipelineRunStatus( tb.PipelineRunResult("result", "aResultValue")), )} - ts := []*v1alpha1.Task{ + ts := []*v1beta1.Task{ tb.Task("a-task", tb.TaskNamespace("foo")), tb.Task("b-task", tb.TaskNamespace("foo"), tb.TaskSpec( - tb.TaskInputs(tb.InputsParamSpec("bParam", v1alpha1.ParamTypeString)), + tb.TaskParam("bParam", v1beta1.ParamTypeString), ), ), } - trs := []*v1alpha1.TaskRun{ + trs := []*v1beta1.TaskRun{ tb.TaskRun("test-pipeline-run-different-service-accs-a-task-9l9zj", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-different-service-accs", - tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"), + tb.OwnerReferenceAPIVersion("tekton.dev/v1beta1"), tb.Controller, tb.BlockOwnerDeletion, ), tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"), @@ -2151,7 +2150,7 @@ func TestReconcileWithPipelineResults(t *testing.T) { t.Errorf("Did not expect to see error when reconciling completed PipelineRun but saw %s", err) } // Check that the PipelineRun was reconciled correctly - pipelineRun, err := clients.Pipeline.TektonV1alpha1().PipelineRuns("foo").Get("test-pipeline-run-different-service-accs", metav1.GetOptions{}) + pipelineRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get("test-pipeline-run-different-service-accs", metav1.GetOptions{}) if err != nil { t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err) } @@ -2166,10 +2165,7 @@ func Test_storePipelineSpec(t *testing.T) { ps := tb.Pipeline("some-pipeline", tb.PipelineSpec(tb.PipelineDescription("foo-pipeline"))).Spec ps1 := tb.Pipeline("some-pipeline", tb.PipelineSpec(tb.PipelineDescription("bar-pipeline"))).Spec - want := &v1beta1.PipelineSpec{} - if err := ps.ConvertTo(ctx, want); err != nil { - t.Errorf("error converting to v1beta1: %v", err) - } + want := ps.DeepCopy() // The first time we set it, it should get copied. if err := storePipelineSpec(ctx, pr, &ps); err != nil { diff --git a/pkg/reconciler/pipelinerun/resources/apply.go b/pkg/reconciler/pipelinerun/resources/apply.go index 2c37a26c8fe..92c46d4cfbc 100644 --- a/pkg/reconciler/pipelinerun/resources/apply.go +++ b/pkg/reconciler/pipelinerun/resources/apply.go @@ -19,12 +19,11 @@ package resources import ( "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) // ApplyParameters applies the params from a PipelineRun.Params to a PipelineSpec. -func ApplyParameters(p *v1alpha1.PipelineSpec, pr *v1alpha1.PipelineRun) *v1alpha1.PipelineSpec { +func ApplyParameters(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) *v1beta1.PipelineSpec { // This assumes that the PipelineRun inputs have been validated against what the Pipeline requests. // stringReplacements is used for standard single-string stringReplacements, while arrayReplacements contains arrays @@ -35,7 +34,7 @@ func ApplyParameters(p *v1alpha1.PipelineSpec, pr *v1alpha1.PipelineRun) *v1alph // Set all the default stringReplacements for _, p := range p.Params { if p.Default != nil { - if p.Default.Type == v1alpha1.ParamTypeString { + if p.Default.Type == v1beta1.ParamTypeString { stringReplacements[fmt.Sprintf("params.%s", p.Name)] = p.Default.StringVal } else { arrayReplacements[fmt.Sprintf("params.%s", p.Name)] = p.Default.ArrayVal @@ -44,7 +43,7 @@ func ApplyParameters(p *v1alpha1.PipelineSpec, pr *v1alpha1.PipelineRun) *v1alph } // Set and overwrite params with the ones from the PipelineRun for _, p := range pr.Spec.Params { - if p.Value.Type == v1alpha1.ParamTypeString { + if p.Value.Type == v1beta1.ParamTypeString { stringReplacements[fmt.Sprintf("params.%s", p.Name)] = p.Value.StringVal } else { arrayReplacements[fmt.Sprintf("params.%s", p.Name)] = p.Value.ArrayVal @@ -79,7 +78,7 @@ func ApplyTaskResults(targets PipelineRunState, resolvedResultRefs ResolvedResul } // ApplyReplacements replaces placeholders for declared parameters with the specified replacements. -func ApplyReplacements(p *v1alpha1.PipelineSpec, replacements map[string]string, arrayReplacements map[string][]string) *v1alpha1.PipelineSpec { +func ApplyReplacements(p *v1beta1.PipelineSpec, replacements map[string]string, arrayReplacements map[string][]string) *v1beta1.PipelineSpec { p = p.DeepCopy() tasks := p.Tasks @@ -95,7 +94,7 @@ func ApplyReplacements(p *v1alpha1.PipelineSpec, replacements map[string]string, return p } -func replaceParamValues(params []v1alpha1.Param, stringReplacements map[string]string, arrayReplacements map[string][]string) []v1alpha1.Param { +func replaceParamValues(params []v1beta1.Param, stringReplacements map[string]string, arrayReplacements map[string][]string) []v1beta1.Param { for i := range params { params[i].Value.ApplyReplacements(stringReplacements, arrayReplacements) } diff --git a/pkg/reconciler/pipelinerun/resources/apply_test.go b/pkg/reconciler/pipelinerun/resources/apply_test.go index 608f8f07838..3f71215e13e 100644 --- a/pkg/reconciler/pipelinerun/resources/apply_test.go +++ b/pkg/reconciler/pipelinerun/resources/apply_test.go @@ -23,23 +23,24 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" ) func TestApplyParameters(t *testing.T) { tests := []struct { name string - original *v1alpha1.Pipeline - run *v1alpha1.PipelineRun - expected *v1alpha1.Pipeline + original *v1beta1.Pipeline + run *v1beta1.PipelineRun + expected *v1beta1.Pipeline }{{ name: "single parameter", original: tb.Pipeline("test-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("first-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("default-value")), - tb.PipelineParamSpec("second-param", v1alpha1.ParamTypeString), + tb.PipelineParamSpec("first-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("default-value")), + tb.PipelineParamSpec("second-param", v1beta1.ParamTypeString), tb.PipelineTask("first-task-1", "first-task", tb.PipelineTaskParam("first-task-first-param", "$(params.first-param)"), tb.PipelineTaskParam("first-task-second-param", "$(params.second-param)"), @@ -50,8 +51,8 @@ func TestApplyParameters(t *testing.T) { tb.PipelineRunParam("second-param", "second-value"))), expected: tb.Pipeline("test-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("first-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("default-value")), - tb.PipelineParamSpec("second-param", v1alpha1.ParamTypeString), + tb.PipelineParamSpec("first-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("default-value")), + tb.PipelineParamSpec("second-param", v1beta1.ParamTypeString), tb.PipelineTask("first-task-1", "first-task", tb.PipelineTaskParam("first-task-first-param", "default-value"), tb.PipelineTaskParam("first-task-second-param", "second-value"), @@ -61,8 +62,8 @@ func TestApplyParameters(t *testing.T) { name: "pipeline parameter nested inside task parameter", original: tb.Pipeline("test-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("first-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("default-value")), - tb.PipelineParamSpec("second-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("default-value")), + tb.PipelineParamSpec("first-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("default-value")), + tb.PipelineParamSpec("second-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("default-value")), tb.PipelineTask("first-task-1", "first-task", tb.PipelineTaskParam("first-task-first-param", "$(input.workspace.$(params.first-param))"), tb.PipelineTaskParam("first-task-second-param", "$(input.workspace.$(params.second-param))"), @@ -71,8 +72,8 @@ func TestApplyParameters(t *testing.T) { tb.PipelineRunSpec("test-pipeline")), expected: tb.Pipeline("test-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("first-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("default-value")), - tb.PipelineParamSpec("second-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("default-value")), + tb.PipelineParamSpec("first-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("default-value")), + tb.PipelineParamSpec("second-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("default-value")), tb.PipelineTask("first-task-1", "first-task", tb.PipelineTaskParam("first-task-first-param", "$(input.workspace.default-value)"), tb.PipelineTaskParam("first-task-second-param", "$(input.workspace.default-value)"), @@ -81,8 +82,8 @@ func TestApplyParameters(t *testing.T) { name: "parameters in task condition", original: tb.Pipeline("test-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("first-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("default-value")), - tb.PipelineParamSpec("second-param", v1alpha1.ParamTypeString), + tb.PipelineParamSpec("first-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("default-value")), + tb.PipelineParamSpec("second-param", v1beta1.ParamTypeString), tb.PipelineTask("first-task-1", "first-task", tb.PipelineTaskCondition("task-condition", tb.PipelineTaskConditionParam("cond-first-param", "$(params.first-param)"), @@ -94,8 +95,8 @@ func TestApplyParameters(t *testing.T) { tb.PipelineRunParam("second-param", "second-value"))), expected: tb.Pipeline("test-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("first-param", v1alpha1.ParamTypeString, tb.ParamSpecDefault("default-value")), - tb.PipelineParamSpec("second-param", v1alpha1.ParamTypeString), + tb.PipelineParamSpec("first-param", v1beta1.ParamTypeString, tb.ParamSpecDefault("default-value")), + tb.PipelineParamSpec("second-param", v1beta1.ParamTypeString), tb.PipelineTask("first-task-1", "first-task", tb.PipelineTaskCondition("task-condition", tb.PipelineTaskConditionParam("cond-first-param", "default-value"), @@ -106,10 +107,10 @@ func TestApplyParameters(t *testing.T) { name: "array parameter", original: tb.Pipeline("test-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("first-param", v1alpha1.ParamTypeArray, tb.ParamSpecDefault( + tb.PipelineParamSpec("first-param", v1beta1.ParamTypeArray, tb.ParamSpecDefault( "default", "array", "value")), - tb.PipelineParamSpec("second-param", v1alpha1.ParamTypeArray), - tb.PipelineParamSpec("fourth-param", v1alpha1.ParamTypeArray), + tb.PipelineParamSpec("second-param", v1beta1.ParamTypeArray), + tb.PipelineParamSpec("fourth-param", v1beta1.ParamTypeArray), tb.PipelineTask("first-task-1", "first-task", tb.PipelineTaskParam("first-task-first-param", "firstelement", "$(params.first-param)"), tb.PipelineTaskParam("first-task-second-param", "first", "$(params.second-param)"), @@ -122,10 +123,10 @@ func TestApplyParameters(t *testing.T) { tb.PipelineRunParam("fourth-param", "fourth-value", "array"))), expected: tb.Pipeline("test-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("first-param", v1alpha1.ParamTypeArray, tb.ParamSpecDefault( + tb.PipelineParamSpec("first-param", v1beta1.ParamTypeArray, tb.ParamSpecDefault( "default", "array", "value")), - tb.PipelineParamSpec("second-param", v1alpha1.ParamTypeArray), - tb.PipelineParamSpec("fourth-param", v1alpha1.ParamTypeArray), + tb.PipelineParamSpec("second-param", v1beta1.ParamTypeArray), + tb.PipelineParamSpec("fourth-param", v1beta1.ParamTypeArray), tb.PipelineTask("first-task-1", "first-task", tb.PipelineTaskParam("first-task-first-param", "firstelement", "default", "array", "value"), tb.PipelineTaskParam("first-task-second-param", "first", "second-value", "array"), @@ -171,9 +172,9 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, targets: PipelineRunState{ { - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "bTask", - TaskRef: &v1alpha1.TaskRef{Name: "bTask"}, + TaskRef: &v1beta1.TaskRef{Name: "bTask"}, Params: []v1beta1.Param{ { Name: "bParam", @@ -189,9 +190,9 @@ func TestApplyTaskResults_MinimalExpression(t *testing.T) { }, want: PipelineRunState{ { - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "bTask", - TaskRef: &v1alpha1.TaskRef{Name: "bTask"}, + TaskRef: &v1beta1.TaskRef{Name: "bTask"}, Params: []v1beta1.Param{ { Name: "bParam", @@ -244,9 +245,9 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }, targets: PipelineRunState{ { - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "bTask", - TaskRef: &v1alpha1.TaskRef{Name: "bTask"}, + TaskRef: &v1beta1.TaskRef{Name: "bTask"}, Params: []v1beta1.Param{ { Name: "bParam", @@ -262,9 +263,9 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) { }, want: PipelineRunState{ { - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "bTask", - TaskRef: &v1alpha1.TaskRef{Name: "bTask"}, + TaskRef: &v1beta1.TaskRef{Name: "bTask"}, Params: []v1beta1.Param{ { Name: "bParam", @@ -324,9 +325,9 @@ func TestApplyTaskResults_Conditions(t *testing.T) { Name: "always-true", }, Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{}, + Check: v1beta1.Step{}, }}, - ResolvedResources: map[string]*v1alpha1.PipelineResource{}, + ResolvedResources: map[string]*resourcev1alpha1.PipelineResource{}, PipelineTaskCondition: &v1beta1.PipelineTaskCondition{ Params: []v1beta1.Param{ { @@ -353,9 +354,9 @@ func TestApplyTaskResults_Conditions(t *testing.T) { Name: "always-true", }, Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{}, + Check: v1beta1.Step{}, }}, - ResolvedResources: map[string]*v1alpha1.PipelineResource{}, + ResolvedResources: map[string]*resourcev1alpha1.PipelineResource{}, PipelineTaskCondition: &v1beta1.PipelineTaskCondition{ Params: []v1beta1.Param{ { @@ -376,7 +377,7 @@ func TestApplyTaskResults_Conditions(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ApplyTaskResults(tt.args.targets, tt.args.resolvedResultRefs) - if d := cmp.Diff(tt.args.targets[0].ResolvedConditionChecks, tt.want[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { + if d := cmp.Diff(tt.args.targets[0].ResolvedConditionChecks, tt.want[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { t.Fatalf("ApplyTaskResults() -want, +got: %v", d) } }) diff --git a/pkg/reconciler/pipelinerun/resources/conditionresolution.go b/pkg/reconciler/pipelinerun/resources/conditionresolution.go index 96c0d2fc72a..421ece88b7f 100644 --- a/pkg/reconciler/pipelinerun/resources/conditionresolution.go +++ b/pkg/reconciler/pipelinerun/resources/conditionresolution.go @@ -42,13 +42,13 @@ type GetCondition func(string) (*v1alpha1.Condition, error) // has not been evaluated). type ResolvedConditionCheck struct { ConditionRegisterName string - PipelineTaskCondition *v1alpha1.PipelineTaskCondition + PipelineTaskCondition *v1beta1.PipelineTaskCondition ConditionCheckName string Condition *v1alpha1.Condition - ConditionCheck *v1alpha1.ConditionCheck + ConditionCheck *v1beta1.ConditionCheck // Resolved resources is a map of pipeline resources for this condition // keyed by the bound resource name (i.e. the name used in PipelineTaskCondition.Resources) - ResolvedResources map[string]*v1alpha1.PipelineResource + ResolvedResources map[string]*resourcev1alpha1.PipelineResource images pipeline.Images } @@ -94,23 +94,21 @@ func (state TaskConditionCheckState) IsSuccess() bool { } // ConditionToTaskSpec creates a TaskSpec from a given Condition -func (rcc *ResolvedConditionCheck) ConditionToTaskSpec() (*v1alpha1.TaskSpec, error) { +func (rcc *ResolvedConditionCheck) ConditionToTaskSpec() (*v1beta1.TaskSpec, error) { if rcc.Condition.Spec.Check.Name == "" { rcc.Condition.Spec.Check.Name = unnamedCheckNamePrefix + rcc.Condition.Name } - t := &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{rcc.Condition.Spec.Check}, - }, - } - - t.Inputs = &v1alpha1.Inputs{ + t := &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{rcc.Condition.Spec.Check}, Params: rcc.Condition.Spec.Params, } for _, r := range rcc.Condition.Spec.Resources { - t.Inputs.Resources = append(t.Inputs.Resources, v1alpha1.TaskResource{ + if t.Resources == nil { + t.Resources = &v1beta1.TaskResources{} + } + t.Resources.Inputs = append(t.Resources.Inputs, v1beta1.TaskResource{ ResourceDeclaration: r, }) } @@ -126,19 +124,19 @@ func (rcc *ResolvedConditionCheck) ConditionToTaskSpec() (*v1alpha1.TaskSpec, er } // convertParamTemplates replaces all instances of $(params.x) in the container to $(inputs.params.x) for each param name. -func convertParamTemplates(step *v1alpha1.Step, params []v1alpha1.ParamSpec) { +func convertParamTemplates(step *v1beta1.Step, params []v1beta1.ParamSpec) { replacements := make(map[string]string) for _, p := range params { replacements[fmt.Sprintf("params.%s", p.Name)] = fmt.Sprintf("$(inputs.params.%s)", p.Name) - v1alpha1.ApplyStepReplacements(step, replacements, map[string][]string{}) + v1beta1.ApplyStepReplacements(step, replacements, map[string][]string{}) } - v1alpha1.ApplyStepReplacements(step, replacements, map[string][]string{}) + v1beta1.ApplyStepReplacements(step, replacements, map[string][]string{}) } // ApplyResources applies the substitution from values in resources which are referenced // in spec as subitems of the replacementStr. -func ApplyResourceSubstitution(step *v1alpha1.Step, resolvedResources map[string]*resourcev1alpha1.PipelineResource, conditionResources []v1alpha1.ResourceDeclaration, images pipeline.Images) error { +func ApplyResourceSubstitution(step *v1beta1.Step, resolvedResources map[string]*resourcev1alpha1.PipelineResource, conditionResources []v1beta1.ResourceDeclaration, images pipeline.Images) error { replacements := make(map[string]string) for _, cr := range conditionResources { if rSpec, ok := resolvedResources[cr.Name]; ok { @@ -149,15 +147,15 @@ func ApplyResourceSubstitution(step *v1alpha1.Step, resolvedResources map[string for k, v := range r.Replacements() { replacements[fmt.Sprintf("resources.%s.%s", cr.Name, k)] = v } - replacements[fmt.Sprintf("resources.%s.path", cr.Name)] = v1alpha1.InputResourcePath(cr) + replacements[fmt.Sprintf("resources.%s.path", cr.Name)] = v1beta1.InputResourcePath(cr) } } - v1alpha1.ApplyStepReplacements(step, replacements, map[string][]string{}) + v1beta1.ApplyStepReplacements(step, replacements, map[string][]string{}) return nil } // NewConditionCheckStatus creates a ConditionCheckStatus from a ConditionCheck -func (rcc *ResolvedConditionCheck) NewConditionCheckStatus() *v1alpha1.ConditionCheckStatus { +func (rcc *ResolvedConditionCheck) NewConditionCheckStatus() *v1beta1.ConditionCheckStatus { var checkStep corev1.ContainerState trs := rcc.ConditionCheck.Status for _, s := range trs.Steps { @@ -167,9 +165,9 @@ func (rcc *ResolvedConditionCheck) NewConditionCheckStatus() *v1alpha1.Condition } } - return &v1alpha1.ConditionCheckStatus{ + return &v1beta1.ConditionCheckStatus{ Status: trs.Status, - ConditionCheckStatusFields: v1alpha1.ConditionCheckStatusFields{ + ConditionCheckStatusFields: v1beta1.ConditionCheckStatusFields{ PodName: trs.PodName, StartTime: trs.StartTime, CompletionTime: trs.CompletionTime, @@ -178,22 +176,22 @@ func (rcc *ResolvedConditionCheck) NewConditionCheckStatus() *v1alpha1.Condition } } -func (rcc *ResolvedConditionCheck) ToTaskResourceBindings() []v1alpha1.TaskResourceBinding { - var trb []v1alpha1.TaskResourceBinding +func (rcc *ResolvedConditionCheck) ToTaskResourceBindings() []v1beta1.TaskResourceBinding { + var trb []v1beta1.TaskResourceBinding for name, r := range rcc.ResolvedResources { - tr := v1alpha1.TaskResourceBinding{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + tr := v1beta1.TaskResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: name, }, } if r.SelfLink != "" { - tr.ResourceRef = &v1alpha1.PipelineResourceRef{ + tr.ResourceRef = &v1beta1.PipelineResourceRef{ Name: r.Name, APIVersion: r.APIVersion, } } else if r.Spec.Type != "" { - tr.ResourceSpec = &v1alpha1.PipelineResourceSpec{ + tr.ResourceSpec = &resourcev1alpha1.PipelineResourceSpec{ Type: r.Spec.Type, Params: r.Spec.Params, SecretParams: r.Spec.SecretParams, diff --git a/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go b/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go index 4fd79f2ffa2..709956ae794 100644 --- a/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go @@ -21,16 +21,18 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tbv1alpha1 "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) -var c = tb.Condition("conditionname") +var c = tbv1alpha1.Condition("conditionname") var notStartedState = TaskConditionCheckState{{ ConditionCheckName: "foo", @@ -40,7 +42,7 @@ var notStartedState = TaskConditionCheckState{{ var runningState = TaskConditionCheckState{{ ConditionCheckName: "foo", Condition: c, - ConditionCheck: &v1alpha1.ConditionCheck{ + ConditionCheck: &v1beta1.ConditionCheck{ ObjectMeta: metav1.ObjectMeta{ Name: "running-condition-check", }, @@ -50,12 +52,12 @@ var runningState = TaskConditionCheckState{{ var successState = TaskConditionCheckState{{ ConditionCheckName: "foo", Condition: c, - ConditionCheck: &v1alpha1.ConditionCheck{ + ConditionCheck: &v1beta1.ConditionCheck{ ObjectMeta: metav1.ObjectMeta{ Name: "successful-condition-check", }, - Spec: v1alpha1.TaskRunSpec{}, - Status: v1alpha1.TaskRunStatus{ + Spec: v1beta1.TaskRunSpec{}, + Status: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -69,12 +71,12 @@ var successState = TaskConditionCheckState{{ var failedState = TaskConditionCheckState{{ ConditionCheckName: "foo", Condition: c, - ConditionCheck: &v1alpha1.ConditionCheck{ + ConditionCheck: &v1beta1.ConditionCheck{ ObjectMeta: metav1.ObjectMeta{ Name: "failed-condition-check", }, - Spec: v1alpha1.TaskRunSpec{}, - Status: v1alpha1.TaskRunStatus{ + Spec: v1beta1.TaskRunSpec{}, + Status: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -188,86 +190,74 @@ func TestResolvedConditionCheck_ConditionToTaskSpec(t *testing.T) { tcs := []struct { name string cond *v1alpha1.Condition - resolvedResources map[string]*v1alpha1.PipelineResource - want v1alpha1.TaskSpec + resolvedResources map[string]*resourcev1alpha1.PipelineResource + want v1beta1.TaskSpec }{{ name: "user-provided-container-name", - cond: tb.Condition("name", tb.ConditionSpec( - tb.ConditionSpecCheck("foo", "ubuntu"), + cond: tbv1alpha1.Condition("name", tbv1alpha1.ConditionSpec( + tbv1alpha1.ConditionSpecCheck("foo", "ubuntu"), )), - want: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "foo", - Image: "ubuntu", - }}}, - }, - Inputs: &v1alpha1.Inputs{}, + want: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "foo", + Image: "ubuntu", + }}}, }, }, { name: "default-container-name", - cond: tb.Condition("bar", tb.ConditionSpec( - tb.ConditionSpecCheck("", "ubuntu"), + cond: tbv1alpha1.Condition("bar", tbv1alpha1.ConditionSpec( + tbv1alpha1.ConditionSpecCheck("", "ubuntu"), )), - want: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "condition-check-bar", - Image: "ubuntu", - }}}, - }, - Inputs: &v1alpha1.Inputs{}, + want: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "condition-check-bar", + Image: "ubuntu", + }}}, }, }, { name: "with-input-params", - cond: tb.Condition("bar", tb.ConditionSpec( - tb.ConditionSpecCheck("$(params.name)", "$(params.img)", + cond: tbv1alpha1.Condition("bar", tbv1alpha1.ConditionSpec( + tbv1alpha1.ConditionSpecCheck("$(params.name)", "$(params.img)", tb.WorkingDir("$(params.not.replaced)")), - tb.ConditionParamSpec("name", v1alpha1.ParamTypeString), - tb.ConditionParamSpec("img", v1alpha1.ParamTypeString), + tbv1alpha1.ConditionParamSpec("name", v1beta1.ParamTypeString), + tbv1alpha1.ConditionParamSpec("img", v1beta1.ParamTypeString), )), - want: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "$(inputs.params.name)", - Image: "$(inputs.params.img)", - WorkingDir: "$(params.not.replaced)", - }}}, - }, - Inputs: &v1alpha1.Inputs{ - Params: []v1alpha1.ParamSpec{{ - Name: "name", - Type: "string", - }, { - Name: "img", - Type: "string", - }}, - }, + want: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "$(inputs.params.name)", + Image: "$(inputs.params.img)", + WorkingDir: "$(params.not.replaced)", + }}}, + Params: []v1beta1.ParamSpec{{ + Name: "name", + Type: "string", + }, { + Name: "img", + Type: "string", + }}, }, }, { name: "with-resources", - cond: tb.Condition("bar", tb.ConditionSpec( - tb.ConditionSpecCheck("name", "ubuntu", + cond: tbv1alpha1.Condition("bar", tbv1alpha1.ConditionSpec( + tbv1alpha1.ConditionSpecCheck("name", "ubuntu", tb.Args("$(resources.git-resource.revision)")), - tb.ConditionResource("git-resource", v1alpha1.PipelineResourceTypeGit), + tbv1alpha1.ConditionResource("git-resource", resourcev1alpha1.PipelineResourceTypeGit), )), - resolvedResources: map[string]*v1alpha1.PipelineResource{ + resolvedResources: map[string]*resourcev1alpha1.PipelineResource{ "git-resource": tb.PipelineResource("git-resource", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeGit, + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("revision", "master"), )), }, - want: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "name", - Image: "ubuntu", - Args: []string{"master"}, - }}}, - }, - Inputs: &v1alpha1.Inputs{ - Resources: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + want: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "name", + Image: "ubuntu", + Args: []string{"master"}, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "git-resource", Type: "git", }}}, @@ -292,13 +282,13 @@ func TestResolvedConditionCheck_ConditionToTaskSpec(t *testing.T) { func TestResolvedConditionCheck_ToTaskResourceBindings(t *testing.T) { rcc := ResolvedConditionCheck{ - ResolvedResources: map[string]*v1alpha1.PipelineResource{ + ResolvedResources: map[string]*resourcev1alpha1.PipelineResource{ "git-resource": tb.PipelineResource("some-repo"), }, } - expected := []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + expected := []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "git-resource", }, }} diff --git a/pkg/reconciler/pipelinerun/resources/input_output_steps.go b/pkg/reconciler/pipelinerun/resources/input_output_steps.go index 0079f7b1b5d..7405e1983ab 100644 --- a/pkg/reconciler/pipelinerun/resources/input_output_steps.go +++ b/pkg/reconciler/pipelinerun/resources/input_output_steps.go @@ -19,17 +19,17 @@ package resources import ( "path/filepath" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" ) // GetOutputSteps will add the correct `path` to the output resources for pt -func GetOutputSteps(outputs map[string]*v1alpha1.PipelineResource, taskName, storageBasePath string) []v1alpha1.TaskResourceBinding { - var taskOutputResources []v1alpha1.TaskResourceBinding +func GetOutputSteps(outputs map[string]*resourcev1alpha1.PipelineResource, taskName, storageBasePath string) []v1beta1.TaskResourceBinding { + var taskOutputResources []v1beta1.TaskResourceBinding for name, outputResource := range outputs { - taskOutputResource := v1alpha1.TaskResourceBinding{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + taskOutputResource := v1beta1.TaskResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: name, }, Paths: []string{filepath.Join(storageBasePath, taskName, name)}, @@ -37,12 +37,12 @@ func GetOutputSteps(outputs map[string]*v1alpha1.PipelineResource, taskName, sto // SelfLink is being checked there to determine if this PipelineResource is an instance that // exists in the cluster (in which case Kubernetes will populate this field) or is specified by Spec if outputResource.SelfLink != "" { - taskOutputResource.ResourceRef = &v1alpha1.PipelineResourceRef{ + taskOutputResource.ResourceRef = &v1beta1.PipelineResourceRef{ Name: outputResource.Name, APIVersion: outputResource.APIVersion, } } else if outputResource.Spec.Type != "" { - taskOutputResource.ResourceSpec = &v1alpha1.PipelineResourceSpec{ + taskOutputResource.ResourceSpec = &resourcev1alpha1.PipelineResourceSpec{ Type: outputResource.Spec.Type, Params: outputResource.Spec.Params, SecretParams: outputResource.Spec.SecretParams, @@ -55,24 +55,24 @@ func GetOutputSteps(outputs map[string]*v1alpha1.PipelineResource, taskName, sto // GetInputSteps will add the correct `path` to the input resources for pt. If the resources are provided by // a previous task, the correct `path` will be used so that the resource provided by that task will be used. -func GetInputSteps(inputs map[string]*v1alpha1.PipelineResource, inputResources []v1alpha1.PipelineTaskInputResource, storageBasePath string) []v1alpha1.TaskResourceBinding { - var taskInputResources []v1alpha1.TaskResourceBinding +func GetInputSteps(inputs map[string]*resourcev1alpha1.PipelineResource, inputResources []v1beta1.PipelineTaskInputResource, storageBasePath string) []v1beta1.TaskResourceBinding { + var taskInputResources []v1beta1.TaskResourceBinding for name, inputResource := range inputs { - taskInputResource := v1alpha1.TaskResourceBinding{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + taskInputResource := v1beta1.TaskResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: name, }, } // SelfLink is being checked there to determine if this PipelineResource is an instance that // exists in the cluster (in which case Kubernetes will populate this field) or is specified by Spec if inputResource.SelfLink != "" { - taskInputResource.ResourceRef = &v1alpha1.PipelineResourceRef{ + taskInputResource.ResourceRef = &v1beta1.PipelineResourceRef{ Name: inputResource.Name, APIVersion: inputResource.APIVersion, } } else if inputResource.Spec.Type != "" { - taskInputResource.ResourceSpec = &v1alpha1.PipelineResourceSpec{ + taskInputResource.ResourceSpec = &resourcev1alpha1.PipelineResourceSpec{ Type: inputResource.Spec.Type, Params: inputResource.Spec.Params, SecretParams: inputResource.Spec.SecretParams, @@ -98,7 +98,7 @@ func GetInputSteps(inputs map[string]*v1alpha1.PipelineResource, inputResources } // WrapSteps will add the correct `paths` to all of the inputs and outputs for pt -func WrapSteps(tr *v1alpha1.TaskRunSpec, pt *v1alpha1.PipelineTask, inputs, outputs map[string]*v1alpha1.PipelineResource, storageBasePath string) { +func WrapSteps(tr *v1beta1.TaskRunSpec, pt *v1beta1.PipelineTask, inputs, outputs map[string]*resourcev1alpha1.PipelineResource, storageBasePath string) { if pt == nil { return } diff --git a/pkg/reconciler/pipelinerun/resources/input_output_steps_test.go b/pkg/reconciler/pipelinerun/resources/input_output_steps_test.go index 13d6eac458f..bb4609819c5 100644 --- a/pkg/reconciler/pipelinerun/resources/input_output_steps_test.go +++ b/pkg/reconciler/pipelinerun/resources/input_output_steps_test.go @@ -21,7 +21,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -29,22 +30,22 @@ import ( var pvcDir = "/pvc" func TestGetOutputSteps(t *testing.T) { - r1 := &v1alpha1.PipelineResource{ + r1 := &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "resource1", SelfLink: "/apis/tekton.dev/pipelineresources/resource1", }, } - r2 := &v1alpha1.PipelineResource{ + r2 := &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "resource2", SelfLink: "/apis/tekton.dev/pipelineresources/resource2", }, } - r3 := &v1alpha1.PipelineResource{ - Spec: v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, - Params: []v1alpha1.ResourceParam{{ + r3 := &resourcev1alpha1.PipelineResource{ + Spec: resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, + Params: []v1beta1.ResourceParam{{ Name: "url", Value: "https://github.com/tektoncd/pipeline.git", }}, @@ -53,45 +54,45 @@ func TestGetOutputSteps(t *testing.T) { } tcs := []struct { name string - outputs map[string]*v1alpha1.PipelineResource - expectedtaskOuputResources []v1alpha1.TaskResourceBinding + outputs map[string]*resourcev1alpha1.PipelineResource + expectedtaskOuputResources []v1beta1.TaskResourceBinding pipelineTaskName string }{{ name: "single output", - outputs: map[string]*v1alpha1.PipelineResource{"test-output": r1}, - expectedtaskOuputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + outputs: map[string]*resourcev1alpha1.PipelineResource{"test-output": r1}, + expectedtaskOuputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "test-output", - ResourceRef: &v1alpha1.PipelineResourceRef{Name: "resource1"}, + ResourceRef: &v1beta1.PipelineResourceRef{Name: "resource1"}, }, Paths: []string{"/pvc/test-taskname/test-output"}, }}, pipelineTaskName: "test-taskname", }, { name: "multiple-outputs", - outputs: map[string]*v1alpha1.PipelineResource{ + outputs: map[string]*resourcev1alpha1.PipelineResource{ "test-output": r1, "test-output-2": r2, }, - expectedtaskOuputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + expectedtaskOuputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "test-output", - ResourceRef: &v1alpha1.PipelineResourceRef{Name: "resource1"}, + ResourceRef: &v1beta1.PipelineResourceRef{Name: "resource1"}, }, Paths: []string{"/pvc/test-multiple-outputs/test-output"}, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "test-output-2", - ResourceRef: &v1alpha1.PipelineResourceRef{Name: "resource2"}, + ResourceRef: &v1beta1.PipelineResourceRef{Name: "resource2"}, }, Paths: []string{"/pvc/test-multiple-outputs/test-output-2"}, }}, pipelineTaskName: "test-multiple-outputs", }, { name: "single output with resource spec", - outputs: map[string]*v1alpha1.PipelineResource{"test-output": r3}, - expectedtaskOuputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + outputs: map[string]*resourcev1alpha1.PipelineResource{"test-output": r3}, + expectedtaskOuputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "test-output", ResourceSpec: &r3.Spec, }, @@ -100,18 +101,18 @@ func TestGetOutputSteps(t *testing.T) { pipelineTaskName: "test-taskname", }, { name: "multiple-outputs-with-resource-spec", - outputs: map[string]*v1alpha1.PipelineResource{ + outputs: map[string]*resourcev1alpha1.PipelineResource{ "test-output-1": r3, "test-output-2": r3, }, - expectedtaskOuputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + expectedtaskOuputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "test-output-1", ResourceSpec: &r3.Spec, }, Paths: []string{"/pvc/test-multiple-outputs-with-resource-spec/test-output-1"}, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "test-output-2", ResourceSpec: &r3.Spec, }, @@ -131,16 +132,16 @@ func TestGetOutputSteps(t *testing.T) { } func TestGetInputSteps(t *testing.T) { - r1 := &v1alpha1.PipelineResource{ + r1 := &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "resource1", SelfLink: "/apis/tekton.dev/pipelineresources/resource1", }, } - r2 := &v1alpha1.PipelineResource{ - Spec: v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, - Params: []v1alpha1.ResourceParam{{ + r2 := &resourcev1alpha1.PipelineResource{ + Spec: resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, + Params: []v1beta1.ResourceParam{{ Name: "url", Value: "https://github.com/tektoncd/pipeline.git", }}, @@ -149,76 +150,76 @@ func TestGetInputSteps(t *testing.T) { } tcs := []struct { name string - inputs map[string]*v1alpha1.PipelineResource - pipelineTask *v1alpha1.PipelineTask - expectedtaskInputResources []v1alpha1.TaskResourceBinding + inputs map[string]*resourcev1alpha1.PipelineResource + pipelineTask *v1beta1.PipelineTask + expectedtaskInputResources []v1beta1.TaskResourceBinding }{ { name: "task-with-a-constraint", - inputs: map[string]*v1alpha1.PipelineResource{"test-input": r1}, - pipelineTask: &v1alpha1.PipelineTask{ - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + inputs: map[string]*resourcev1alpha1.PipelineResource{"test-input": r1}, + pipelineTask: &v1beta1.PipelineTask{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "test-input", From: []string{"prev-task-1"}, }}, }, }, - expectedtaskInputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{Name: "resource1"}, + expectedtaskInputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{Name: "resource1"}, Name: "test-input", }, Paths: []string{"/pvc/prev-task-1/test-input"}, }}, }, { name: "task-with-no-input-constraint", - inputs: map[string]*v1alpha1.PipelineResource{"test-input": r1}, - expectedtaskInputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{Name: "resource1"}, + inputs: map[string]*resourcev1alpha1.PipelineResource{"test-input": r1}, + expectedtaskInputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{Name: "resource1"}, Name: "test-input", }, }}, - pipelineTask: &v1alpha1.PipelineTask{ + pipelineTask: &v1beta1.PipelineTask{ Name: "sample-test-task", - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "test-input", }}, }, }, }, { name: "task-with-multiple-constraints", - inputs: map[string]*v1alpha1.PipelineResource{"test-input": r1}, - pipelineTask: &v1alpha1.PipelineTask{ - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + inputs: map[string]*resourcev1alpha1.PipelineResource{"test-input": r1}, + pipelineTask: &v1beta1.PipelineTask{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "test-input", From: []string{"prev-task-1", "prev-task-2"}, }}, }, }, - expectedtaskInputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{Name: "resource1"}, + expectedtaskInputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{Name: "resource1"}, Name: "test-input", }, Paths: []string{"/pvc/prev-task-1/test-input", "/pvc/prev-task-2/test-input"}, }}, }, { name: "task-with-a-constraint-with-resource-spec", - inputs: map[string]*v1alpha1.PipelineResource{"test-input": r2}, - pipelineTask: &v1alpha1.PipelineTask{ - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + inputs: map[string]*resourcev1alpha1.PipelineResource{"test-input": r2}, + pipelineTask: &v1beta1.PipelineTask{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "test-input", From: []string{"prev-task-1"}, }}, }, }, - expectedtaskInputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + expectedtaskInputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ ResourceSpec: &r2.Spec, Name: "test-input", }, @@ -226,34 +227,34 @@ func TestGetInputSteps(t *testing.T) { }}, }, { name: "task-with-no-input-constraint-but-with-resource-spec", - inputs: map[string]*v1alpha1.PipelineResource{"test-input": r2}, - expectedtaskInputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + inputs: map[string]*resourcev1alpha1.PipelineResource{"test-input": r2}, + expectedtaskInputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ ResourceSpec: &r2.Spec, Name: "test-input", }, }}, - pipelineTask: &v1alpha1.PipelineTask{ + pipelineTask: &v1beta1.PipelineTask{ Name: "sample-test-task", - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "test-input", }}, }, }, }, { name: "task-with-multiple-constraints-with-resource-spec", - inputs: map[string]*v1alpha1.PipelineResource{"test-input": r2}, - pipelineTask: &v1alpha1.PipelineTask{ - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + inputs: map[string]*resourcev1alpha1.PipelineResource{"test-input": r2}, + pipelineTask: &v1beta1.PipelineTask{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "test-input", From: []string{"prev-task-1", "prev-task-2"}, }}, }, }, - expectedtaskInputResources: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + expectedtaskInputResources: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ ResourceSpec: &r2.Spec, Name: "test-input", }, @@ -274,70 +275,70 @@ func TestGetInputSteps(t *testing.T) { } func TestWrapSteps(t *testing.T) { - r1 := &v1alpha1.PipelineResource{ + r1 := &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "resource1", SelfLink: "/apis/tekton.dev/pipelineresources/resource1", }, } - r2 := &v1alpha1.PipelineResource{ - Spec: v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, - Params: []v1alpha1.ResourceParam{{ + r2 := &resourcev1alpha1.PipelineResource{ + Spec: resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, + Params: []v1beta1.ResourceParam{{ Name: "url", Value: "https://github.com/tektoncd/pipeline.git", }}, SecretParams: nil, }, } - inputs := map[string]*v1alpha1.PipelineResource{ + inputs := map[string]*resourcev1alpha1.PipelineResource{ "test-input": r1, "test-input-2": r1, "test-input-3": r2, } - outputs := map[string]*v1alpha1.PipelineResource{ + outputs := map[string]*resourcev1alpha1.PipelineResource{ "test-output": r1, "test-output-2": r2, } - pt := &v1alpha1.PipelineTask{ + pt := &v1beta1.PipelineTask{ Name: "test-task", - Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ + Resources: &v1beta1.PipelineTaskResources{ + Inputs: []v1beta1.PipelineTaskInputResource{{ Name: "test-input", From: []string{"prev-task"}, }}, }, } - taskRunSpec := &v1alpha1.TaskRunSpec{} + taskRunSpec := &v1beta1.TaskRunSpec{} resources.WrapSteps(taskRunSpec, pt, inputs, outputs, pvcDir) - expectedtaskInputResources := []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{Name: "resource1"}, + expectedtaskInputResources := []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{Name: "resource1"}, Name: "test-input", }, Paths: []string{"/pvc/prev-task/test-input"}, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{Name: "resource1"}, + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{Name: "resource1"}, Name: "test-input-2", }, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ ResourceSpec: &r2.Spec, Name: "test-input-3", }, }} - expectedtaskOuputResources := []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{Name: "resource1"}, + expectedtaskOuputResources := []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{Name: "resource1"}, Name: "test-output", }, Paths: []string{"/pvc/test-task/test-output"}, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ ResourceSpec: &r2.Spec, Name: "test-output-2", }, @@ -347,10 +348,10 @@ func TestWrapSteps(t *testing.T) { sort.SliceStable(expectedtaskInputResources, func(i, j int) bool { return expectedtaskInputResources[i].Name < expectedtaskInputResources[j].Name }) sort.SliceStable(expectedtaskOuputResources, func(i, j int) bool { return expectedtaskOuputResources[i].Name < expectedtaskOuputResources[j].Name }) - if d := cmp.Diff(taskRunSpec.Resources.Inputs, expectedtaskInputResources, cmpopts.SortSlices(func(x, y v1alpha1.TaskResourceBinding) bool { return x.Name < y.Name })); d != "" { + if d := cmp.Diff(taskRunSpec.Resources.Inputs, expectedtaskInputResources, cmpopts.SortSlices(func(x, y v1beta1.TaskResourceBinding) bool { return x.Name < y.Name })); d != "" { t.Errorf("error comparing input resources: %s", d) } - if d := cmp.Diff(taskRunSpec.Resources.Outputs, expectedtaskOuputResources, cmpopts.SortSlices(func(x, y v1alpha1.TaskResourceBinding) bool { return x.Name < y.Name })); d != "" { + if d := cmp.Diff(taskRunSpec.Resources.Outputs, expectedtaskOuputResources, cmpopts.SortSlices(func(x, y v1beta1.TaskResourceBinding) bool { return x.Name < y.Name })); d != "" { t.Errorf("error comparing output resources: %s", d) } } diff --git a/pkg/reconciler/pipelinerun/resources/pipelineref.go b/pkg/reconciler/pipelinerun/resources/pipelineref.go index 5b572b2743f..3ad299eb281 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelineref.go +++ b/pkg/reconciler/pipelinerun/resources/pipelineref.go @@ -19,7 +19,7 @@ package resources import ( "fmt" - "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" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -32,10 +32,10 @@ type LocalPipelineRefResolver struct { // GetPipeline will resolve a Pipeline from the local cluster using a versioned Tekton client. It will // return an error if it can't find an appropriate Pipeline for any reason. -func (l *LocalPipelineRefResolver) GetPipeline(name string) (v1alpha1.PipelineInterface, error) { +func (l *LocalPipelineRefResolver) GetPipeline(name string) (v1beta1.PipelineInterface, error) { // If we are going to resolve this reference locally, we need a namespace scope. if l.Namespace == "" { return nil, fmt.Errorf("Must specify namespace to resolve reference to pipeline %s", name) } - return l.Tektonclient.TektonV1alpha1().Pipelines(l.Namespace).Get(name, metav1.GetOptions{}) + return l.Tektonclient.TektonV1beta1().Pipelines(l.Namespace).Get(name, metav1.GetOptions{}) } diff --git a/pkg/reconciler/pipelinerun/resources/pipelineref_test.go b/pkg/reconciler/pipelinerun/resources/pipelineref_test.go index 097188259d7..322abe1c187 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelineref_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelineref_test.go @@ -20,7 +20,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/fake" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources" diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go index e1334a788a9..015e2cb4483 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go @@ -27,8 +27,8 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "knative.dev/pkg/apis" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/contexts" "github.com/tektoncd/pipeline/pkg/list" "github.com/tektoncd/pipeline/pkg/names" @@ -68,8 +68,8 @@ const ( // exists. TaskRun can be nil to represent there being no TaskRun. type ResolvedPipelineRunTask struct { TaskRunName string - TaskRun *v1alpha1.TaskRun - PipelineTask *v1alpha1.PipelineTask + TaskRun *v1beta1.TaskRun + PipelineTask *v1beta1.PipelineTask ResolvedTaskResources *resources.ResolvedTaskResources // ConditionChecks ~~TaskRuns but for evaling conditions ResolvedConditionChecks TaskConditionCheckState // Could also be a TaskRun or maybe just a Pod? @@ -126,7 +126,7 @@ func (t ResolvedPipelineRunTask) IsCancelled() bool { return false } - return c.IsFalse() && c.Reason == v1alpha1.TaskRunSpecStatusCancelled + return c.IsFalse() && c.Reason == v1beta1.TaskRunSpecStatusCancelled } // ToMap returns a map that maps pipeline task name to the resolved pipeline run task @@ -173,7 +173,7 @@ func (state PipelineRunState) GetNextTasks(candidateTasks map[string]struct{}) [ if _, ok := candidateTasks[t.PipelineTask.Name]; ok && t.TaskRun != nil { status := t.TaskRun.Status.GetCondition(apis.ConditionSucceeded) if status != nil && status.IsFalse() { - if !(t.TaskRun.IsCancelled() || status.Reason == v1alpha1.TaskRunSpecStatusCancelled || status.Reason == ReasonConditionCheckFailed) { + if !(t.TaskRun.IsCancelled() || status.Reason == v1beta1.TaskRunSpecStatusCancelled || status.Reason == ReasonConditionCheckFailed) { if len(t.TaskRun.Status.RetriesStatus) < t.PipelineTask.Retries { tasks = append(tasks, t) } @@ -200,13 +200,13 @@ func (state PipelineRunState) SuccessfulPipelineTaskNames() []string { } // GetTaskRun is a function that will retrieve the TaskRun name. -type GetTaskRun func(name string) (*v1alpha1.TaskRun, error) +type GetTaskRun func(name string) (*v1beta1.TaskRun, error) // GetResourcesFromBindings will retrieve all Resources bound in PipelineRun pr and return a map // from the declared name of the PipelineResource (which is how the PipelineResource will // be referred to in the PipelineRun) to the PipelineResource, obtained via getResource. -func GetResourcesFromBindings(pr *v1alpha1.PipelineRun, getResource resources.GetResource) (map[string]*v1alpha1.PipelineResource, error) { - rs := map[string]*v1alpha1.PipelineResource{} +func GetResourcesFromBindings(pr *v1beta1.PipelineRun, getResource resources.GetResource) (map[string]*resourcev1alpha1.PipelineResource, error) { + rs := map[string]*resourcev1alpha1.PipelineResource{} for _, resource := range pr.Spec.Resources { r, err := resources.GetResourceFromBinding(&resource, getResource) if err != nil { @@ -218,7 +218,7 @@ func GetResourcesFromBindings(pr *v1alpha1.PipelineRun, getResource resources.Ge } // ValidateResourceBindings validate that the PipelineResources declared in Pipeline p are bound in PipelineRun. -func ValidateResourceBindings(p *v1alpha1.PipelineSpec, pr *v1alpha1.PipelineRun) error { +func ValidateResourceBindings(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) error { required := make([]string, 0, len(p.Resources)) optional := make([]string, 0, len(p.Resources)) for _, resource := range p.Resources { @@ -248,8 +248,8 @@ func ValidateResourceBindings(p *v1alpha1.PipelineSpec, pr *v1alpha1.PipelineRun } // ValidateWorkspaceBindings validates that the Workspaces expected by a Pipeline are provided by a PipelineRun. -func ValidateWorkspaceBindings(p *v1alpha1.PipelineSpec, pr *v1alpha1.PipelineRun) error { - pipelineRunWorkspaces := make(map[string]v1alpha1.WorkspaceBinding) +func ValidateWorkspaceBindings(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) error { + pipelineRunWorkspaces := make(map[string]v1beta1.WorkspaceBinding) for _, binding := range pr.Spec.Workspaces { pipelineRunWorkspaces[binding.Name] = binding } @@ -287,13 +287,13 @@ func (e *ConditionNotFoundError) Error() string { // It will retrieve the Resources needed for the TaskRun using the mapping of providedResources. func ResolvePipelineRun( ctx context.Context, - pipelineRun v1alpha1.PipelineRun, + pipelineRun v1beta1.PipelineRun, getTask resources.GetTask, getTaskRun resources.GetTaskRun, getClusterTask resources.GetClusterTask, getCondition GetCondition, - tasks []v1alpha1.PipelineTask, - providedResources map[string]*v1alpha1.PipelineResource, + tasks []v1beta1.PipelineTask, + providedResources map[string]*resourcev1alpha1.PipelineResource, ) (PipelineRunState, error) { state := []*ResolvedPipelineRunTask{} @@ -307,15 +307,15 @@ func ResolvePipelineRun( // Find the Task that this PipelineTask is using var ( - t v1alpha1.TaskInterface + t v1beta1.TaskInterface err error - spec v1alpha1.TaskSpec + spec v1beta1.TaskSpec taskName string - kind v1alpha1.TaskKind + kind v1beta1.TaskKind ) if pt.TaskRef != nil { - if pt.TaskRef.Kind == v1alpha1.ClusterTaskKind { + if pt.TaskRef.Kind == v1beta1.ClusterTaskKind { t, err = getClusterTask(pt.TaskRef.Name) } else { t, err = getTask(pt.TaskRef.Name) @@ -333,9 +333,6 @@ func ResolvePipelineRun( spec = *pt.TaskSpec } spec.SetDefaults(contexts.WithUpgradeViaDefaulting(ctx)) - if err := spec.ConvertTo(ctx, &v1beta1.TaskSpec{}); err != nil { - return nil, err - } rtr, err := ResolvePipelineTaskResources(pt, &spec, taskName, kind, providedResources) if err != nil { return nil, fmt.Errorf("couldn't match referenced resources with declared resources: %w", err) @@ -369,7 +366,7 @@ func ResolvePipelineRun( } // getConditionCheckName should return a unique name for a `ConditionCheck` if one has not already been defined, and the existing one otherwise. -func getConditionCheckName(taskRunStatus map[string]*v1alpha1.PipelineRunTaskRunStatus, trName, conditionRegisterName string) string { +func getConditionCheckName(taskRunStatus map[string]*v1beta1.PipelineRunTaskRunStatus, trName, conditionRegisterName string) string { trStatus, ok := taskRunStatus[trName] if ok && trStatus.ConditionChecks != nil { for k, v := range trStatus.ConditionChecks { @@ -383,7 +380,7 @@ func getConditionCheckName(taskRunStatus map[string]*v1alpha1.PipelineRunTaskRun } // getTaskRunName should return a unique name for a `TaskRun` if one has not already been defined, and the existing one otherwise. -func getTaskRunName(taskRunsStatus map[string]*v1alpha1.PipelineRunTaskRunStatus, ptName, prName string) string { +func getTaskRunName(taskRunsStatus map[string]*v1beta1.PipelineRunTaskRunStatus, ptName, prName string) string { for k, v := range taskRunsStatus { if v.PipelineTaskName == ptName { return k @@ -395,7 +392,7 @@ func getTaskRunName(taskRunsStatus map[string]*v1alpha1.PipelineRunTaskRunStatus // GetPipelineConditionStatus will return the Condition that the PipelineRun prName should be // updated with, based on the status of the TaskRuns in state. -func GetPipelineConditionStatus(pr *v1alpha1.PipelineRun, state PipelineRunState, logger *zap.SugaredLogger, dag *dag.Graph) *apis.Condition { +func GetPipelineConditionStatus(pr *v1beta1.PipelineRun, state PipelineRunState, logger *zap.SugaredLogger, dag *dag.Graph) *apis.Condition { // We have 4 different states here: // 1. Timed out -> Failed // 2. Any one TaskRun has failed - >Failed. This should change with #1020 and #1023 @@ -503,7 +500,7 @@ func isSkipped(rprt *ResolvedPipelineRunTask, stateMap map[string]*ResolvedPipel return false } -func resolveConditionChecks(pt *v1alpha1.PipelineTask, taskRunStatus map[string]*v1alpha1.PipelineRunTaskRunStatus, taskRunName string, getTaskRun resources.GetTaskRun, getCondition GetCondition, providedResources map[string]*v1alpha1.PipelineResource) ([]*ResolvedConditionCheck, error) { +func resolveConditionChecks(pt *v1beta1.PipelineTask, taskRunStatus map[string]*v1beta1.PipelineRunTaskRunStatus, taskRunName string, getTaskRun resources.GetTaskRun, getCondition GetCondition, providedResources map[string]*resourcev1alpha1.PipelineResource) ([]*ResolvedConditionCheck, error) { rccs := []*ResolvedConditionCheck{} for i := range pt.Conditions { ptc := pt.Conditions[i] @@ -523,7 +520,7 @@ func resolveConditionChecks(pt *v1alpha1.PipelineTask, taskRunStatus map[string] return nil, fmt.Errorf("error retrieving ConditionCheck %s for taskRun name %s : %w", conditionCheckName, taskRunName, err) } } - conditionResources := map[string]*v1alpha1.PipelineResource{} + conditionResources := map[string]*resourcev1alpha1.PipelineResource{} for _, declared := range ptc.Resources { if r, ok := providedResources[declared.Resource]; ok { conditionResources[declared.Name] = r @@ -540,7 +537,7 @@ func resolveConditionChecks(pt *v1alpha1.PipelineTask, taskRunStatus map[string] ConditionRegisterName: crName, Condition: c, ConditionCheckName: conditionCheckName, - ConditionCheck: v1alpha1.NewConditionCheck(cctr), + ConditionCheck: v1beta1.NewConditionCheck(cctr), PipelineTaskCondition: &ptc, ResolvedResources: conditionResources, } @@ -552,13 +549,13 @@ func resolveConditionChecks(pt *v1alpha1.PipelineTask, taskRunStatus map[string] // ResolvePipelineTaskResources matches PipelineResources referenced by pt inputs and outputs with the // providedResources and returns an instance of ResolvedTaskResources. -func ResolvePipelineTaskResources(pt v1alpha1.PipelineTask, ts *v1alpha1.TaskSpec, taskName string, kind v1alpha1.TaskKind, providedResources map[string]*v1alpha1.PipelineResource) (*resources.ResolvedTaskResources, error) { +func ResolvePipelineTaskResources(pt v1beta1.PipelineTask, ts *v1beta1.TaskSpec, taskName string, kind v1beta1.TaskKind, providedResources map[string]*resourcev1alpha1.PipelineResource) (*resources.ResolvedTaskResources, error) { rtr := resources.ResolvedTaskResources{ TaskName: taskName, TaskSpec: ts, Kind: kind, - Inputs: map[string]*v1alpha1.PipelineResource{}, - Outputs: map[string]*v1alpha1.PipelineResource{}, + Inputs: map[string]*resourcev1alpha1.PipelineResource{}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{}, } if pt.Resources != nil { for _, taskInput := range pt.Resources.Inputs { diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go index c91f6f82d57..892f0c056cb 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go @@ -24,9 +24,11 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tbv1alpha1 "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "github.com/tektoncd/pipeline/test/names" @@ -38,87 +40,87 @@ import ( duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) -var pts = []v1alpha1.PipelineTask{{ +var pts = []v1beta1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, }, { Name: "mytask2", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, }, { Name: "mytask3", - TaskRef: &v1alpha1.TaskRef{Name: "clustertask"}, + TaskRef: &v1beta1.TaskRef{Name: "clustertask"}, }, { Name: "mytask4", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, Retries: 1, }, { Name: "mytask5", - TaskRef: &v1alpha1.TaskRef{Name: "cancelledTask"}, + TaskRef: &v1beta1.TaskRef{Name: "cancelledTask"}, Retries: 2, }, { Name: "mytask6", - TaskRef: &v1alpha1.TaskRef{Name: "taskWithConditions"}, - Conditions: []v1alpha1.PipelineTaskCondition{{ + TaskRef: &v1beta1.TaskRef{Name: "taskWithConditions"}, + Conditions: []v1beta1.PipelineTaskCondition{{ ConditionRef: "always-true", }}, }, { Name: "mytask7", - TaskRef: &v1alpha1.TaskRef{Name: "taskWithOneParent"}, + TaskRef: &v1beta1.TaskRef{Name: "taskWithOneParent"}, RunAfter: []string{"mytask6"}, }, { Name: "mytask8", - TaskRef: &v1alpha1.TaskRef{Name: "taskWithTwoParents"}, + TaskRef: &v1beta1.TaskRef{Name: "taskWithTwoParents"}, RunAfter: []string{"mytask1", "mytask6"}, }, { Name: "mytask9", - TaskRef: &v1alpha1.TaskRef{Name: "taskHasParentWithRunAfter"}, + TaskRef: &v1beta1.TaskRef{Name: "taskHasParentWithRunAfter"}, RunAfter: []string{"mytask8"}, }} -var p = &v1alpha1.Pipeline{ +var p = &v1beta1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "pipeline", }, - Spec: v1alpha1.PipelineSpec{ + Spec: v1beta1.PipelineSpec{ Tasks: pts, }, } -var task = &v1alpha1.Task{ +var task = &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + Spec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "step1", }}}, - }}, + }, } -var clustertask = &v1alpha1.ClusterTask{ +var clustertask = &v1beta1.ClusterTask{ ObjectMeta: metav1.ObjectMeta{ Name: "clustertask", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + Spec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "step1", }}}, - }}, + }, } -var trs = []v1alpha1.TaskRun{{ +var trs = []v1beta1.TaskRun{{ ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "pipelinerun-mytask1", }, - Spec: v1alpha1.TaskRunSpec{}, + Spec: v1beta1.TaskRunSpec{}, }, { ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "pipelinerun-mytask2", }, - Spec: v1alpha1.TaskRunSpec{}, + Spec: v1beta1.TaskRunSpec{}, }} var condition = v1alpha1.Condition{ @@ -126,49 +128,49 @@ var condition = v1alpha1.Condition{ Name: "always-true", }, Spec: v1alpha1.ConditionSpec{ - Check: v1alpha1.Step{}, + Check: v1beta1.Step{}, }, } -var conditionChecks = []v1alpha1.TaskRun{{ +var conditionChecks = []v1beta1.TaskRun{{ ObjectMeta: metav1.ObjectMeta{ Namespace: "namespace", Name: "always-true", }, - Spec: v1alpha1.TaskRunSpec{}, + Spec: v1beta1.TaskRunSpec{}, }} -func makeStarted(tr v1alpha1.TaskRun) *v1alpha1.TaskRun { +func makeStarted(tr v1beta1.TaskRun) *v1beta1.TaskRun { newTr := newTaskRun(tr) newTr.Status.Conditions[0].Status = corev1.ConditionUnknown return newTr } -func makeSucceeded(tr v1alpha1.TaskRun) *v1alpha1.TaskRun { +func makeSucceeded(tr v1beta1.TaskRun) *v1beta1.TaskRun { newTr := newTaskRun(tr) newTr.Status.Conditions[0].Status = corev1.ConditionTrue return newTr } -func makeFailed(tr v1alpha1.TaskRun) *v1alpha1.TaskRun { +func makeFailed(tr v1beta1.TaskRun) *v1beta1.TaskRun { newTr := newTaskRun(tr) newTr.Status.Conditions[0].Status = corev1.ConditionFalse return newTr } -func withCancelled(tr *v1alpha1.TaskRun) *v1alpha1.TaskRun { +func withCancelled(tr *v1beta1.TaskRun) *v1beta1.TaskRun { tr.Status.Conditions[0].Reason = "TaskRunCancelled" return tr } -func withCancelledBySpec(tr *v1alpha1.TaskRun) *v1alpha1.TaskRun { - tr.Spec.Status = v1alpha1.TaskRunSpecStatusCancelled +func withCancelledBySpec(tr *v1beta1.TaskRun) *v1beta1.TaskRun { + tr.Spec.Status = v1beta1.TaskRunSpecStatusCancelled return tr } -func makeRetried(tr v1alpha1.TaskRun) (newTr *v1alpha1.TaskRun) { +func makeRetried(tr v1beta1.TaskRun) (newTr *v1beta1.TaskRun) { newTr = newTaskRun(tr) - newTr.Status.RetriesStatus = []v1alpha1.TaskRunStatus{{ + newTr.Status.RetriesStatus = []v1beta1.TaskRunStatus{{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -178,8 +180,8 @@ func makeRetried(tr v1alpha1.TaskRun) (newTr *v1alpha1.TaskRun) { }} return } -func withRetries(tr *v1alpha1.TaskRun) *v1alpha1.TaskRun { - tr.Status.RetriesStatus = []v1alpha1.TaskRunStatus{{ +func withRetries(tr *v1beta1.TaskRun) *v1beta1.TaskRun { + tr.Status.RetriesStatus = []v1beta1.TaskRunStatus{{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -190,14 +192,14 @@ func withRetries(tr *v1alpha1.TaskRun) *v1alpha1.TaskRun { return tr } -func newTaskRun(tr v1alpha1.TaskRun) *v1alpha1.TaskRun { - return &v1alpha1.TaskRun{ +func newTaskRun(tr v1beta1.TaskRun) *v1beta1.TaskRun { + return &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Namespace: tr.Namespace, Name: tr.Name, }, Spec: tr.Spec, - Status: v1alpha1.TaskRunStatus{ + Status: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{Type: apis.ConditionSucceeded}}, }, @@ -284,13 +286,13 @@ var allFinishedState = PipelineRunState{{ var successTaskConditionCheckState = TaskConditionCheckState{{ ConditionCheckName: "myconditionCheck", Condition: &condition, - ConditionCheck: v1alpha1.NewConditionCheck(makeSucceeded(conditionChecks[0])), + ConditionCheck: v1beta1.NewConditionCheck(makeSucceeded(conditionChecks[0])), }} var failedTaskConditionCheckState = TaskConditionCheckState{{ ConditionCheckName: "myconditionCheck", Condition: &condition, - ConditionCheck: v1alpha1.NewConditionCheck(makeFailed(conditionChecks[0])), + ConditionCheck: v1beta1.NewConditionCheck(makeFailed(conditionChecks[0])), }} var conditionCheckSuccessNoTaskStartedState = PipelineRunState{{ @@ -313,7 +315,7 @@ var conditionCheckStartedState = PipelineRunState{{ ResolvedConditionChecks: TaskConditionCheckState{{ ConditionCheckName: "myconditionCheck", Condition: &condition, - ConditionCheck: v1alpha1.NewConditionCheck(makeStarted(conditionChecks[0])), + ConditionCheck: v1beta1.NewConditionCheck(makeStarted(conditionChecks[0])), }}, }} @@ -450,32 +452,29 @@ var taskCancelled = PipelineRunState{{ }, }} -var taskWithOptionalResourcesDeprecated = &v1alpha1.Task{ +var taskWithOptionalResourcesDeprecated = &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "step1", - }}}, - }, - Inputs: &v1alpha1.Inputs{ - Resources: []v1alpha1.TaskResource{{ResourceDeclaration: v1alpha1.ResourceDeclaration{ + Spec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "step1", + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "optional-input", Type: "git", Optional: true, - }}, {ResourceDeclaration: v1alpha1.ResourceDeclaration{ + }}, {ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "required-input", Type: "git", Optional: false, - }}}}, - Outputs: &v1alpha1.Outputs{ - Resources: []v1alpha1.TaskResource{{ResourceDeclaration: v1alpha1.ResourceDeclaration{ + }}}, + Outputs: []v1beta1.TaskResource{{ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "optional-output", Type: "git", Optional: true, - }}, {ResourceDeclaration: v1alpha1.ResourceDeclaration{ + }}, {ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "required-output", Type: "git", Optional: false, @@ -483,45 +482,43 @@ var taskWithOptionalResourcesDeprecated = &v1alpha1.Task{ }, }, } -var taskWithOptionalResources = &v1alpha1.Task{ +var taskWithOptionalResources = &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "step1", + Spec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "step1", + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "optional-input", + Type: "git", + Optional: true, + }}, {ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "required-input", + Type: "git", + Optional: false, + }}}, + Outputs: []v1beta1.TaskResource{{ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "optional-output", + Type: "git", + Optional: true, + }}, {ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "required-output", + Type: "git", + Optional: false, }}}, - Resources: &v1beta1.TaskResources{ - Inputs: []v1beta1.TaskResource{{ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "optional-input", - Type: "git", - Optional: true, - }}, {ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "required-input", - Type: "git", - Optional: false, - }}}, - Outputs: []v1beta1.TaskResource{{ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "optional-output", - Type: "git", - Optional: true, - }}, {ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "required-output", - Type: "git", - Optional: false, - }}}, - }, }, }, } func DagFromState(state PipelineRunState) (*dag.Graph, error) { - pts := []v1alpha1.PipelineTask{} + pts := []v1beta1.PipelineTask{} for _, rprt := range state { pts = append(pts, *rprt.PipelineTask) } - return dag.Build(v1alpha1.PipelineTaskList(pts)) + return dag.Build(v1beta1.PipelineTaskList(pts)) } func TestGetNextTasks(t *testing.T) { @@ -1099,9 +1096,9 @@ func TestGetResourcesFromBindings(t *testing.T) { pr := tb.PipelineRun("pipelinerun", tb.PipelineRunSpec("pipeline", tb.PipelineRunResourceBinding("git-resource", tb.PipelineResourceBindingRef("sweet-resource")), tb.PipelineRunResourceBinding("image-resource", tb.PipelineResourceBindingResourceSpec( - &v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeImage, - Params: []v1alpha1.ResourceParam{{ + &resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeImage, + Params: []v1beta1.ResourceParam{{ Name: "url", Value: "gcr.io/sven", }}, @@ -1109,7 +1106,7 @@ func TestGetResourcesFromBindings(t *testing.T) { ), )) r := tb.PipelineResource("sweet-resource") - getResource := func(name string) (*v1alpha1.PipelineResource, error) { + getResource := func(name string) (*resourcev1alpha1.PipelineResource, error) { if name != "sweet-resource" { return nil, fmt.Errorf("request for unexpected resource %s", name) } @@ -1130,7 +1127,7 @@ func TestGetResourcesFromBindings(t *testing.T) { r2, ok := m["image-resource"] if !ok { t.Errorf("Missing expected resource image-resource: %v", m) - } else if r2.Spec.Type != v1alpha1.PipelineResourceTypeImage || + } else if r2.Spec.Type != resourcev1alpha1.PipelineResourceTypeImage || len(r2.Spec.Params) != 1 || r2.Spec.Params[0].Name != "url" || r2.Spec.Params[0].Value != "gcr.io/sven" { @@ -1146,7 +1143,7 @@ func TestGetResourcesFromBindings_Missing(t *testing.T) { pr := tb.PipelineRun("pipelinerun", tb.PipelineRunSpec("pipeline", tb.PipelineRunResourceBinding("git-resource", tb.PipelineResourceBindingRef("sweet-resource")), )) - getResource := func(name string) (*v1alpha1.PipelineResource, error) { + getResource := func(name string) (*resourcev1alpha1.PipelineResource, error) { return nil, fmt.Errorf("request for unexpected resource %s", name) } _, err := GetResourcesFromBindings(pr, getResource) @@ -1159,7 +1156,7 @@ func TestGetResourcesFromBindings_ErrorGettingResource(t *testing.T) { pr := tb.PipelineRun("pipelinerun", tb.PipelineRunSpec("pipeline", tb.PipelineRunResourceBinding("git-resource", tb.PipelineResourceBindingRef("sweet-resource")), )) - getResource := func(name string) (*v1alpha1.PipelineResource, error) { + getResource := func(name string) (*resourcev1alpha1.PipelineResource, error) { return nil, fmt.Errorf("iT HAS ALL GONE WRONG") } _, err := GetResourcesFromBindings(pr, getResource) @@ -1183,32 +1180,32 @@ func TestResolvePipelineRun(t *testing.T) { tb.PipelineTaskOutputResource("output1", "git-resource"), ), tb.PipelineTask("mytask4", "", - tb.PipelineTaskSpec(&v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + tb.PipelineTaskSpec(&v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "step1", }}}, - }})), + })), )) - r := &v1alpha1.PipelineResource{ + r := &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "someresource", }, - Spec: v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, + Spec: resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, }, } - providedResources := map[string]*v1alpha1.PipelineResource{"git-resource": r} - pr := v1alpha1.PipelineRun{ + providedResources := map[string]*resourcev1alpha1.PipelineResource{"git-resource": r} + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, } // The Task "task" doesn't actually take any inputs or outputs, but validating // that is not done as part of Run resolution - getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { return nil, nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, nil } + getTask := func(name string) (v1beta1.TaskInterface, error) { return task, nil } + getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return nil, nil } getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } pipelineState, err := ResolvePipelineRun(context.Background(), pr, getTask, getTaskRun, getClusterTask, getCondition, p.Spec.Tasks, providedResources) @@ -1222,10 +1219,10 @@ func TestResolvePipelineRun(t *testing.T) { ResolvedTaskResources: &resources.ResolvedTaskResources{ TaskName: task.Name, TaskSpec: &task.Spec, - Inputs: map[string]*v1alpha1.PipelineResource{ + Inputs: map[string]*resourcev1alpha1.PipelineResource{ "input1": r, }, - Outputs: map[string]*v1alpha1.PipelineResource{}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{}, }, }, { PipelineTask: &p.Spec.Tasks[1], @@ -1234,8 +1231,8 @@ func TestResolvePipelineRun(t *testing.T) { ResolvedTaskResources: &resources.ResolvedTaskResources{ TaskName: task.Name, TaskSpec: &task.Spec, - Inputs: map[string]*v1alpha1.PipelineResource{}, - Outputs: map[string]*v1alpha1.PipelineResource{ + Inputs: map[string]*resourcev1alpha1.PipelineResource{}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{ "output1": r, }, }, @@ -1246,8 +1243,8 @@ func TestResolvePipelineRun(t *testing.T) { ResolvedTaskResources: &resources.ResolvedTaskResources{ TaskName: task.Name, TaskSpec: &task.Spec, - Inputs: map[string]*v1alpha1.PipelineResource{}, - Outputs: map[string]*v1alpha1.PipelineResource{ + Inputs: map[string]*resourcev1alpha1.PipelineResource{}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{ "output1": r, }, }, @@ -1258,34 +1255,34 @@ func TestResolvePipelineRun(t *testing.T) { ResolvedTaskResources: &resources.ResolvedTaskResources{ TaskName: "", TaskSpec: &task.Spec, - Inputs: map[string]*v1alpha1.PipelineResource{}, - Outputs: map[string]*v1alpha1.PipelineResource{}, + Inputs: map[string]*resourcev1alpha1.PipelineResource{}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{}, }, }} - if d := cmp.Diff(expectedState, pipelineState, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{})); d != "" { + if d := cmp.Diff(expectedState, pipelineState, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{})); d != "" { t.Errorf("Expected to get current pipeline state %v, but actual differed (-want, +got): %s", expectedState, d) } } func TestResolvePipelineRun_PipelineTaskHasNoResources(t *testing.T) { - pts := []v1alpha1.PipelineTask{{ + pts := []v1beta1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, }, { Name: "mytask2", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, }, { Name: "mytask3", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, }} - providedResources := map[string]*v1alpha1.PipelineResource{} + providedResources := map[string]*resourcev1alpha1.PipelineResource{} - getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { return &trs[0], nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return clustertask, nil } + getTask := func(name string) (v1beta1.TaskInterface, error) { return task, nil } + getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return &trs[0], nil } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return clustertask, nil } getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } - pr := v1alpha1.PipelineRun{ + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1300,39 +1297,39 @@ func TestResolvePipelineRun_PipelineTaskHasNoResources(t *testing.T) { expectedTaskResources := &resources.ResolvedTaskResources{ TaskName: task.Name, TaskSpec: &task.Spec, - Inputs: map[string]*v1alpha1.PipelineResource{}, - Outputs: map[string]*v1alpha1.PipelineResource{}, + Inputs: map[string]*resourcev1alpha1.PipelineResource{}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{}, } - if d := cmp.Diff(pipelineState[0].ResolvedTaskResources, expectedTaskResources, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{})); d != "" { + if d := cmp.Diff(pipelineState[0].ResolvedTaskResources, expectedTaskResources, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{})); d != "" { t.Fatalf("Expected resources where only Tasks were resolved but but actual differed: %s", d) } - if d := cmp.Diff(pipelineState[1].ResolvedTaskResources, expectedTaskResources, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{})); d != "" { + if d := cmp.Diff(pipelineState[1].ResolvedTaskResources, expectedTaskResources, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{})); d != "" { t.Fatalf("Expected resources where only Tasks were resolved but but actual differed: %s", d) } } func TestResolvePipelineRun_TaskDoesntExist(t *testing.T) { - pts := []v1alpha1.PipelineTask{{ + pts := []v1beta1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, }} - providedResources := map[string]*v1alpha1.PipelineResource{} + providedResources := map[string]*resourcev1alpha1.PipelineResource{} // Return an error when the Task is retrieved, as if it didn't exist - getTask := func(name string) (v1alpha1.TaskInterface, error) { - return nil, kerrors.NewNotFound(v1alpha1.Resource("task"), name) + getTask := func(name string) (v1beta1.TaskInterface, error) { + return nil, kerrors.NewNotFound(v1beta1.Resource("task"), name) } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { - return nil, kerrors.NewNotFound(v1alpha1.Resource("clustertask"), name) + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { + return nil, kerrors.NewNotFound(v1beta1.Resource("clustertask"), name) } - getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { - return nil, kerrors.NewNotFound(v1alpha1.Resource("taskrun"), name) + getTaskRun := func(name string) (*v1beta1.TaskRun, error) { + return nil, kerrors.NewNotFound(v1beta1.Resource("taskrun"), name) } getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } - pr := v1alpha1.PipelineRun{ + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1351,7 +1348,7 @@ func TestResolvePipelineRun_TaskDoesntExist(t *testing.T) { func TestResolvePipelineRun_ResourceBindingsDontExist(t *testing.T) { tests := []struct { name string - p *v1alpha1.Pipeline + p *v1beta1.Pipeline }{{ name: "input doesnt exist", p: tb.Pipeline("pipelines", tb.PipelineSpec( @@ -1367,18 +1364,18 @@ func TestResolvePipelineRun_ResourceBindingsDontExist(t *testing.T) { ), )), }} - providedResources := map[string]*v1alpha1.PipelineResource{} + providedResources := map[string]*resourcev1alpha1.PipelineResource{} - getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { return &trs[0], nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return clustertask, nil } + getTask := func(name string) (v1beta1.TaskInterface, error) { return task, nil } + getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return &trs[0], nil } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return clustertask, nil } getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - pr := v1alpha1.PipelineRun{ + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1401,27 +1398,27 @@ func TestResolvePipelineRun_withExistingTaskRuns(t *testing.T) { ), )) - r := &v1alpha1.PipelineResource{ + r := &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "someresource", }, - Spec: v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, + Spec: resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, }, } - providedResources := map[string]*v1alpha1.PipelineResource{"git-resource": r} - taskrunStatus := map[string]*v1alpha1.PipelineRunTaskRunStatus{} - taskrunStatus["pipelinerun-mytask-with-a-really-long-name-to-trigger-tru-9l9zj"] = &v1alpha1.PipelineRunTaskRunStatus{ + providedResources := map[string]*resourcev1alpha1.PipelineResource{"git-resource": r} + taskrunStatus := map[string]*v1beta1.PipelineRunTaskRunStatus{} + taskrunStatus["pipelinerun-mytask-with-a-really-long-name-to-trigger-tru-9l9zj"] = &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: "mytask-with-a-really-long-name-to-trigger-truncation", - Status: &v1alpha1.TaskRunStatus{}, + Status: &v1beta1.TaskRunStatus{}, } - pr := v1alpha1.PipelineRun{ + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, - Status: v1alpha1.PipelineRunStatus{ - PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + Status: v1beta1.PipelineRunStatus{ + PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ TaskRuns: taskrunStatus, }, }, @@ -1429,9 +1426,9 @@ func TestResolvePipelineRun_withExistingTaskRuns(t *testing.T) { // The Task "task" doesn't actually take any inputs or outputs, but validating // that is not done as part of Run resolution - getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, nil } - getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { return nil, nil } + getTask := func(name string) (v1beta1.TaskInterface, error) { return task, nil } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return nil, nil } + getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } pipelineState, err := ResolvePipelineRun(context.Background(), pr, getTask, getTaskRun, getClusterTask, getCondition, p.Spec.Tasks, providedResources) if err != nil { @@ -1444,14 +1441,14 @@ func TestResolvePipelineRun_withExistingTaskRuns(t *testing.T) { ResolvedTaskResources: &resources.ResolvedTaskResources{ TaskName: task.Name, TaskSpec: &task.Spec, - Inputs: map[string]*v1alpha1.PipelineResource{ + Inputs: map[string]*resourcev1alpha1.PipelineResource{ "input1": r, }, - Outputs: map[string]*v1alpha1.PipelineResource{}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{}, }, }} - if d := cmp.Diff(pipelineState, expectedState, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{})); d != "" { + if d := cmp.Diff(pipelineState, expectedState, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{})); d != "" { t.Fatalf("Expected to get current pipeline state %v, but actual differed: %s", expectedState, d) } } @@ -1466,24 +1463,24 @@ func TestResolvedPipelineRun_PipelineTaskHasOptionalResources(t *testing.T) { ), )) - r := &v1alpha1.PipelineResource{ + r := &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "someresource", }, - Spec: v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, + Spec: resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, }, } - providedResources := map[string]*v1alpha1.PipelineResource{"git-resource": r} - pr := v1alpha1.PipelineRun{ + providedResources := map[string]*resourcev1alpha1.PipelineResource{"git-resource": r} + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, } - getTask := func(name string) (v1alpha1.TaskInterface, error) { return taskWithOptionalResourcesDeprecated, nil } - getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { return nil, nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, nil } + getTask := func(name string) (v1beta1.TaskInterface, error) { return taskWithOptionalResourcesDeprecated, nil } + getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return nil, nil } getCondition := func(name string) (*v1alpha1.Condition, error) { return nil, nil } pipelineState, err := ResolvePipelineRun(context.Background(), pr, getTask, getTaskRun, getClusterTask, getCondition, p.Spec.Tasks, providedResources) @@ -1497,16 +1494,16 @@ func TestResolvedPipelineRun_PipelineTaskHasOptionalResources(t *testing.T) { ResolvedTaskResources: &resources.ResolvedTaskResources{ TaskName: taskWithOptionalResources.Name, TaskSpec: &taskWithOptionalResources.Spec, - Inputs: map[string]*v1alpha1.PipelineResource{ + Inputs: map[string]*resourcev1alpha1.PipelineResource{ "required-input": r, }, - Outputs: map[string]*v1alpha1.PipelineResource{ + Outputs: map[string]*resourcev1alpha1.PipelineResource{ "required-output": r, }, }, }} - if d := cmp.Diff(expectedState, pipelineState, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{})); d != "" { + if d := cmp.Diff(expectedState, pipelineState, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{})); d != "" { t.Errorf("Expected to get current pipeline state %v, but actual differed (-want, +got): %s", expectedState, d) } } @@ -1515,27 +1512,27 @@ func TestResolveConditionChecks(t *testing.T) { names.TestingSeed() ccName := "pipelinerun-mytask1-9l9zj-always-true-mz4c7" - cc := &v1alpha1.TaskRun{ + cc := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: ccName, }, } - ptc := v1alpha1.PipelineTaskCondition{ + ptc := v1beta1.PipelineTaskCondition{ ConditionRef: "always-true", } - pts := []v1alpha1.PipelineTask{{ + pts := []v1beta1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, - Conditions: []v1alpha1.PipelineTaskCondition{ptc}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, + Conditions: []v1beta1.PipelineTaskCondition{ptc}, }} - providedResources := map[string]*v1alpha1.PipelineResource{} + providedResources := map[string]*resourcev1alpha1.PipelineResource{} - getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } + getTask := func(name string) (v1beta1.TaskInterface, error) { return task, nil } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return nil, errors.New("should not get called") } getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } - pr := v1alpha1.PipelineRun{ + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1548,7 +1545,7 @@ func TestResolveConditionChecks(t *testing.T) { }{ { name: "conditionCheck exists", - getTaskRun: func(name string) (*v1alpha1.TaskRun, error) { + getTaskRun: func(name string) (*v1beta1.TaskRun, error) { switch name { case "pipelinerun-mytask1-9l9zj-always-true-0-mz4c7": return cc, nil @@ -1562,14 +1559,14 @@ func TestResolveConditionChecks(t *testing.T) { ConditionRegisterName: "always-true-0", ConditionCheckName: "pipelinerun-mytask1-9l9zj-always-true-0-mz4c7", Condition: &condition, - ConditionCheck: v1alpha1.NewConditionCheck(cc), + ConditionCheck: v1beta1.NewConditionCheck(cc), PipelineTaskCondition: &ptc, ResolvedResources: providedResources, }}, }, { name: "conditionCheck doesn't exist", - getTaskRun: func(name string) (*v1alpha1.TaskRun, error) { + getTaskRun: func(name string) (*v1beta1.TaskRun, error) { if name == "pipelinerun-mytask1-mssqb-always-true-0-78c5n" { return nil, nil } else if name == "pipelinerun-mytask1-mssqb" { @@ -1594,7 +1591,7 @@ func TestResolveConditionChecks(t *testing.T) { t.Fatalf("Did not expect error when resolving PipelineRun without Conditions: %v", err) } - if d := cmp.Diff(tc.expectedConditionCheck, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { + if d := cmp.Diff(tc.expectedConditionCheck, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { t.Fatalf("ConditionChecks did not resolve as expected for case %s (-want, +got) : %s", tc.name, d) } }) @@ -1606,39 +1603,39 @@ func TestResolveConditionChecks_MultipleConditions(t *testing.T) { ccName1 := "pipelinerun-mytask1-9l9zj-always-true-mz4c7" ccName2 := "pipelinerun-mytask1-9l9zj-always-true-mssqb" - cc1 := &v1alpha1.TaskRun{ + cc1 := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: ccName1, }, } - cc2 := &v1alpha1.TaskRun{ + cc2 := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: ccName2, }, } - ptc1 := v1alpha1.PipelineTaskCondition{ + ptc1 := v1beta1.PipelineTaskCondition{ ConditionRef: "always-true", - Params: []v1alpha1.Param{{Name: "path", Value: *tb.ArrayOrString("$(params.path)")}, {Name: "image", Value: *tb.ArrayOrString("$(params.image)")}}, + Params: []v1beta1.Param{{Name: "path", Value: *tb.ArrayOrString("$(params.path)")}, {Name: "image", Value: *tb.ArrayOrString("$(params.image)")}}, } - ptc2 := v1alpha1.PipelineTaskCondition{ + ptc2 := v1beta1.PipelineTaskCondition{ ConditionRef: "always-true", - Params: []v1alpha1.Param{{Name: "path", Value: *tb.ArrayOrString("$(params.path-test)")}, {Name: "image", Value: *tb.ArrayOrString("$(params.image-test)")}}, + Params: []v1beta1.Param{{Name: "path", Value: *tb.ArrayOrString("$(params.path-test)")}, {Name: "image", Value: *tb.ArrayOrString("$(params.image-test)")}}, } - pts := []v1alpha1.PipelineTask{{ + pts := []v1beta1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, - Conditions: []v1alpha1.PipelineTaskCondition{ptc1, ptc2}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, + Conditions: []v1beta1.PipelineTaskCondition{ptc1, ptc2}, }} - providedResources := map[string]*v1alpha1.PipelineResource{} + providedResources := map[string]*resourcev1alpha1.PipelineResource{} - getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } + getTask := func(name string) (v1beta1.TaskInterface, error) { return task, nil } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return nil, errors.New("should not get called") } getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } - pr := v1alpha1.PipelineRun{ + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1651,7 +1648,7 @@ func TestResolveConditionChecks_MultipleConditions(t *testing.T) { }{ { name: "conditionCheck exists", - getTaskRun: func(name string) (*v1alpha1.TaskRun, error) { + getTaskRun: func(name string) (*v1beta1.TaskRun, error) { switch name { case "pipelinerun-mytask1-9l9zj-always-true-0-mz4c7": return cc1, nil @@ -1666,14 +1663,14 @@ func TestResolveConditionChecks_MultipleConditions(t *testing.T) { ConditionRegisterName: "always-true-0", ConditionCheckName: "pipelinerun-mytask1-9l9zj-always-true-0-mz4c7", Condition: &condition, - ConditionCheck: v1alpha1.NewConditionCheck(cc1), + ConditionCheck: v1beta1.NewConditionCheck(cc1), PipelineTaskCondition: &ptc1, ResolvedResources: providedResources, }, { ConditionRegisterName: "always-true-1", ConditionCheckName: "pipelinerun-mytask1-9l9zj-always-true-1-mssqb", Condition: &condition, - ConditionCheck: v1alpha1.NewConditionCheck(cc2), + ConditionCheck: v1beta1.NewConditionCheck(cc2), PipelineTaskCondition: &ptc2, ResolvedResources: providedResources, }}, @@ -1687,7 +1684,7 @@ func TestResolveConditionChecks_MultipleConditions(t *testing.T) { t.Fatalf("Did not expect error when resolving PipelineRun without Conditions: %v", err) } - if d := cmp.Diff(tc.expectedConditionCheck, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { + if d := cmp.Diff(tc.expectedConditionCheck, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { t.Fatalf("ConditionChecks did not resolve as expected for case %s (-want, +got) : %s", tc.name, d) } }) @@ -1698,17 +1695,17 @@ func TestResolveConditionChecks_ConditionDoesNotExist(t *testing.T) { trName := "pipelinerun-mytask1-9l9zj" ccName := "pipelinerun-mytask1-9l9zj-does-not-exist-mz4c7" - pts := []v1alpha1.PipelineTask{{ + pts := []v1beta1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, - Conditions: []v1alpha1.PipelineTaskCondition{{ + TaskRef: &v1beta1.TaskRef{Name: "task"}, + Conditions: []v1beta1.PipelineTaskCondition{{ ConditionRef: "does-not-exist", }}, }} - providedResources := map[string]*v1alpha1.PipelineResource{} + providedResources := map[string]*resourcev1alpha1.PipelineResource{} - getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { + getTask := func(name string) (v1beta1.TaskInterface, error) { return task, nil } + getTaskRun := func(name string) (*v1beta1.TaskRun, error) { if name == ccName { return nil, fmt.Errorf("should not be called") } else if name == trName { @@ -1716,11 +1713,11 @@ func TestResolveConditionChecks_ConditionDoesNotExist(t *testing.T) { } return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return nil, errors.New("should not get called") } getCondition := func(name string) (*v1alpha1.Condition, error) { - return nil, kerrors.NewNotFound(v1alpha1.Resource("condition"), name) + return nil, kerrors.NewNotFound(v1beta1.Resource("condition"), name) } - pr := v1alpha1.PipelineRun{ + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1744,26 +1741,26 @@ func TestResolveConditionCheck_UseExistingConditionCheckName(t *testing.T) { trName := "pipelinerun-mytask1-9l9zj" ccName := "some-random-name" - cc := &v1alpha1.TaskRun{ + cc := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: ccName, }, - Spec: v1alpha1.TaskRunSpec{}, + Spec: v1beta1.TaskRunSpec{}, } - ptc := v1alpha1.PipelineTaskCondition{ + ptc := v1beta1.PipelineTaskCondition{ ConditionRef: "always-true", } - pts := []v1alpha1.PipelineTask{{ + pts := []v1beta1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, - Conditions: []v1alpha1.PipelineTaskCondition{ptc}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, + Conditions: []v1beta1.PipelineTaskCondition{ptc}, }} - providedResources := map[string]*v1alpha1.PipelineResource{} + providedResources := map[string]*resourcev1alpha1.PipelineResource{} - getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { + getTask := func(name string) (v1beta1.TaskInterface, error) { return task, nil } + getTaskRun := func(name string) (*v1beta1.TaskRun, error) { if name == ccName { return cc, nil } else if name == trName { @@ -1771,25 +1768,25 @@ func TestResolveConditionCheck_UseExistingConditionCheckName(t *testing.T) { } return nil, fmt.Errorf("getTaskRun called with unexpected name %s", name) } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return nil, errors.New("should not get called") } getCondition := func(name string) (*v1alpha1.Condition, error) { return &condition, nil } - ccStatus := make(map[string]*v1alpha1.PipelineRunConditionCheckStatus) - ccStatus[ccName] = &v1alpha1.PipelineRunConditionCheckStatus{ + ccStatus := make(map[string]*v1beta1.PipelineRunConditionCheckStatus) + ccStatus[ccName] = &v1beta1.PipelineRunConditionCheckStatus{ ConditionName: "always-true-0", } - trStatus := make(map[string]*v1alpha1.PipelineRunTaskRunStatus) - trStatus[trName] = &v1alpha1.PipelineRunTaskRunStatus{ + trStatus := make(map[string]*v1beta1.PipelineRunTaskRunStatus) + trStatus[trName] = &v1beta1.PipelineRunTaskRunStatus{ PipelineTaskName: "mytask-1", ConditionChecks: ccStatus, } - pr := v1alpha1.PipelineRun{ + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, - Status: v1alpha1.PipelineRunStatus{ + Status: v1beta1.PipelineRunStatus{ Status: duckv1beta1.Status{}, - PipelineRunStatusFields: v1alpha1.PipelineRunStatusFields{ + PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ TaskRuns: trStatus, }, }, @@ -1803,12 +1800,12 @@ func TestResolveConditionCheck_UseExistingConditionCheckName(t *testing.T) { ConditionRegisterName: "always-true-0", ConditionCheckName: ccName, Condition: &condition, - ConditionCheck: v1alpha1.NewConditionCheck(cc), + ConditionCheck: v1beta1.NewConditionCheck(cc), PipelineTaskCondition: &ptc, ResolvedResources: providedResources, }} - if d := cmp.Diff(expectedConditionChecks, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { + if d := cmp.Diff(expectedConditionChecks, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { t.Fatalf("ConditionChecks did not resolve as expected (-want, +got): %s", d) } } @@ -1816,30 +1813,30 @@ func TestResolveConditionCheck_UseExistingConditionCheckName(t *testing.T) { func TestResolvedConditionCheck_WithResources(t *testing.T) { names.TestingSeed() - condition := tb.Condition("always-true", tb.ConditionSpec( - tb.ConditionResource("workspace", v1alpha1.PipelineResourceTypeGit), + condition := tbv1alpha1.Condition("always-true", tbv1alpha1.ConditionSpec( + tbv1alpha1.ConditionResource("workspace", resourcev1alpha1.PipelineResourceTypeGit), )) gitResource := tb.PipelineResource("some-repo", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeGit)) + resourcev1alpha1.PipelineResourceTypeGit)) - ptc := v1alpha1.PipelineTaskCondition{ + ptc := v1beta1.PipelineTaskCondition{ ConditionRef: "always-true", - Resources: []v1alpha1.PipelineTaskInputResource{{ + Resources: []v1beta1.PipelineTaskInputResource{{ Name: "workspace", Resource: "blah", // The name used in the pipeline }}, } - pts := []v1alpha1.PipelineTask{{ + pts := []v1beta1.PipelineTask{{ Name: "mytask1", - TaskRef: &v1alpha1.TaskRef{Name: "task"}, - Conditions: []v1alpha1.PipelineTaskCondition{ptc}, + TaskRef: &v1beta1.TaskRef{Name: "task"}, + Conditions: []v1beta1.PipelineTaskCondition{ptc}, }} - getTask := func(name string) (v1alpha1.TaskInterface, error) { return task, nil } - getTaskRun := func(name string) (*v1alpha1.TaskRun, error) { return nil, nil } - getClusterTask := func(name string) (v1alpha1.TaskInterface, error) { return nil, errors.New("should not get called") } + getTask := func(name string) (v1beta1.TaskInterface, error) { return task, nil } + getTaskRun := func(name string) (*v1beta1.TaskRun, error) { return nil, nil } + getClusterTask := func(name string) (v1beta1.TaskInterface, error) { return nil, errors.New("should not get called") } // This err result is required to satisfy the type alias on this function, but it triggers // a false positive in the linter: https://github.com/mvdan/unparam/issues/40 @@ -1848,7 +1845,7 @@ func TestResolvedConditionCheck_WithResources(t *testing.T) { return condition, nil } - pr := v1alpha1.PipelineRun{ + pr := v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "pipelinerun", }, @@ -1856,16 +1853,16 @@ func TestResolvedConditionCheck_WithResources(t *testing.T) { tcs := []struct { name string - providedResources map[string]*v1alpha1.PipelineResource + providedResources map[string]*resourcev1alpha1.PipelineResource wantErr bool - expected map[string]*v1alpha1.PipelineResource + expected map[string]*resourcev1alpha1.PipelineResource }{{ name: "resource exists", - providedResources: map[string]*v1alpha1.PipelineResource{"blah": gitResource}, - expected: map[string]*v1alpha1.PipelineResource{"workspace": gitResource}, + providedResources: map[string]*resourcev1alpha1.PipelineResource{"blah": gitResource}, + expected: map[string]*resourcev1alpha1.PipelineResource{"workspace": gitResource}, }, { name: "resource does not exist", - providedResources: map[string]*v1alpha1.PipelineResource{}, + providedResources: map[string]*resourcev1alpha1.PipelineResource{}, wantErr: true, }} @@ -1888,7 +1885,7 @@ func TestResolvedConditionCheck_WithResources(t *testing.T) { PipelineTaskCondition: &ptc, ResolvedResources: tc.expected, }} - if d := cmp.Diff(expectedConditionChecks, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1alpha1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { + if d := cmp.Diff(expectedConditionChecks, pipelineState[0].ResolvedConditionChecks, cmpopts.IgnoreUnexported(v1beta1.TaskRunSpec{}, ResolvedConditionCheck{})); d != "" { t.Fatalf("ConditionChecks did not resolve as expected (-want, +got): %s", d) } } diff --git a/pkg/reconciler/pipelinerun/resources/pipelinespec.go b/pkg/reconciler/pipelinerun/resources/pipelinespec.go index fc591f1c04a..b6faa8e407a 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinespec.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinespec.go @@ -20,20 +20,19 @@ import ( "context" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // GetPipeline is a function used to retrieve Pipelines. -type GetPipeline func(string) (v1alpha1.PipelineInterface, error) +type GetPipeline func(string) (v1beta1.PipelineInterface, 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 *v1alpha1.PipelineRun, getPipeline GetPipeline) (*metav1.ObjectMeta, *v1alpha1.PipelineSpec, error) { +func GetPipelineData(ctx context.Context, pipelineRun *v1beta1.PipelineRun, getPipeline GetPipeline) (*metav1.ObjectMeta, *v1beta1.PipelineSpec, error) { pipelineMeta := metav1.ObjectMeta{} - pipelineSpec := v1alpha1.PipelineSpec{} + pipelineSpec := v1beta1.PipelineSpec{} switch { case pipelineRun.Spec.PipelineRef != nil && pipelineRun.Spec.PipelineRef.Name != "": // Get related pipeline for pipelinerun @@ -43,10 +42,6 @@ func GetPipelineData(ctx context.Context, pipelineRun *v1alpha1.PipelineRun, get } pipelineMeta = t.PipelineMetadata() pipelineSpec = t.PipelineSpec() - - if err := pipelineSpec.ConvertTo(ctx, &v1beta1.PipelineSpec{}); err != nil { - return nil, nil, err - } case pipelineRun.Spec.PipelineSpec != nil: pipelineMeta = pipelineRun.ObjectMeta pipelineSpec = *pipelineRun.Spec.PipelineSpec diff --git a/pkg/reconciler/pipelinerun/resources/pipelinespec_test.go b/pkg/reconciler/pipelinerun/resources/pipelinespec_test.go index 9f2655cf83a..10c1e672b65 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinespec_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinespec_test.go @@ -21,35 +21,35 @@ import ( "errors" "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestGetPipelineSpec_Ref(t *testing.T) { - pipeline := &v1alpha1.Pipeline{ + pipeline := &v1beta1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: "orchestrate", }, - Spec: v1alpha1.PipelineSpec{ - Tasks: []v1alpha1.PipelineTask{{ + Spec: v1beta1.PipelineSpec{ + Tasks: []v1beta1.PipelineTask{{ Name: "mytask", - TaskRef: &v1alpha1.TaskRef{ + TaskRef: &v1beta1.TaskRef{ Name: "mytask", }, }}, }, } - pr := &v1alpha1.PipelineRun{ + pr := &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, - Spec: v1alpha1.PipelineRunSpec{ - PipelineRef: &v1alpha1.PipelineRef{ + Spec: v1beta1.PipelineRunSpec{ + PipelineRef: &v1beta1.PipelineRef{ Name: "orchestrate", }, }, } - gt := func(n string) (v1alpha1.PipelineInterface, error) { return pipeline, nil } + gt := func(n string) (v1beta1.PipelineInterface, error) { return pipeline, nil } pipelineMeta, pipelineSpec, err := GetPipelineData(context.Background(), pr, gt) if err != nil { @@ -66,22 +66,22 @@ func TestGetPipelineSpec_Ref(t *testing.T) { } func TestGetPipelineSpec_Embedded(t *testing.T) { - pr := &v1alpha1.PipelineRun{ + pr := &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, - Spec: v1alpha1.PipelineRunSpec{ - PipelineSpec: &v1alpha1.PipelineSpec{ - Tasks: []v1alpha1.PipelineTask{{ + Spec: v1beta1.PipelineRunSpec{ + PipelineSpec: &v1beta1.PipelineSpec{ + Tasks: []v1beta1.PipelineTask{{ Name: "mytask", - TaskRef: &v1alpha1.TaskRef{ + TaskRef: &v1beta1.TaskRef{ Name: "mytask", }, }}, }, }, } - gt := func(n string) (v1alpha1.PipelineInterface, error) { return nil, errors.New("shouldn't be called") } + gt := func(n string) (v1beta1.PipelineInterface, error) { return nil, errors.New("shouldn't be called") } pipelineMeta, pipelineSpec, err := GetPipelineData(context.Background(), pr, gt) if err != nil { @@ -98,12 +98,12 @@ func TestGetPipelineSpec_Embedded(t *testing.T) { } func TestGetPipelineSpec_Invalid(t *testing.T) { - tr := &v1alpha1.PipelineRun{ + tr := &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, } - gt := func(n string) (v1alpha1.PipelineInterface, error) { return nil, errors.New("shouldn't be called") } + gt := func(n string) (v1beta1.PipelineInterface, error) { return nil, errors.New("shouldn't be called") } _, _, err := GetPipelineData(context.Background(), tr, gt) if err == nil { t.Fatalf("Expected error resolving spec with no embedded or referenced pipeline spec but didn't get error") @@ -111,17 +111,17 @@ func TestGetPipelineSpec_Invalid(t *testing.T) { } func TestGetPipelineSpec_Error(t *testing.T) { - tr := &v1alpha1.PipelineRun{ + tr := &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mypipelinerun", }, - Spec: v1alpha1.PipelineRunSpec{ - PipelineRef: &v1alpha1.PipelineRef{ + Spec: v1beta1.PipelineRunSpec{ + PipelineRef: &v1beta1.PipelineRef{ Name: "orchestrate", }, }, } - gt := func(n string) (v1alpha1.PipelineInterface, error) { return nil, errors.New("something went wrong") } + gt := func(n string) (v1beta1.PipelineInterface, error) { return nil, errors.New("something went wrong") } _, _, err := GetPipelineData(context.Background(), tr, gt) if err == nil { t.Fatalf("Expected error when unable to find referenced Pipeline but got none") diff --git a/pkg/reconciler/pipelinerun/resources/resultrefresolution.go b/pkg/reconciler/pipelinerun/resources/resultrefresolution.go index f0f42ebeb61..84e03660e1a 100644 --- a/pkg/reconciler/pipelinerun/resources/resultrefresolution.go +++ b/pkg/reconciler/pipelinerun/resources/resultrefresolution.go @@ -20,7 +20,6 @@ import ( "fmt" "sort" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) @@ -188,7 +187,7 @@ func resolveResultRef(pipelineState PipelineRunState, resultRef *v1beta1.ResultR }, nil } -func getReferencedTaskRun(pipelineState PipelineRunState, reference *v1beta1.ResultRef) (*v1alpha1.TaskRun, error) { +func getReferencedTaskRun(pipelineState PipelineRunState, reference *v1beta1.ResultRef) (*v1beta1.TaskRun, error) { referencedPipelineTask := pipelineState.ToMap()[reference.PipelineTask] if referencedPipelineTask == nil { @@ -200,7 +199,7 @@ func getReferencedTaskRun(pipelineState PipelineRunState, reference *v1beta1.Res return referencedPipelineTask.TaskRun, nil } -func findTaskResultForParam(taskRun *v1alpha1.TaskRun, reference *v1beta1.ResultRef) (*v1alpha1.TaskRunResult, error) { +func findTaskResultForParam(taskRun *v1beta1.TaskRun, reference *v1beta1.ResultRef) (*v1beta1.TaskRunResult, error) { results := taskRun.Status.TaskRunStatusFields.TaskRunResults for _, result := range results { if result.Name == reference.Result { diff --git a/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go b/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go index 410564ebe2a..22faf79db68 100644 --- a/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/resultrefresolution_test.go @@ -7,8 +7,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" corev1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" @@ -35,9 +34,9 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { { TaskRunName: "aTaskRun", TaskRun: tb.TaskRun("aTaskRun"), - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "aTask", - TaskRef: &v1alpha1.TaskRef{Name: "aTask"}, + TaskRef: &v1beta1.TaskRef{Name: "aTask"}, }, }, }, @@ -63,9 +62,9 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { TaskRun: tb.TaskRun("aTaskRun", tb.TaskRunStatus( tb.TaskRunResult("aResult", "aResultValue"), )), - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "aTask", - TaskRef: &v1alpha1.TaskRef{Name: "aTask"}, + TaskRef: &v1beta1.TaskRef{Name: "aTask"}, }, }, }, @@ -102,18 +101,18 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { TaskRun: tb.TaskRun("aTaskRun", tb.TaskRunStatus( tb.TaskRunResult("aResult", "aResultValue"), )), - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "aTask", - TaskRef: &v1alpha1.TaskRef{Name: "aTask"}, + TaskRef: &v1beta1.TaskRef{Name: "aTask"}, }, }, { TaskRunName: "bTaskRun", TaskRun: tb.TaskRun("bTaskRun", tb.TaskRunStatus( tb.TaskRunResult("bResult", "bResultValue"), )), - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "bTask", - TaskRef: &v1alpha1.TaskRef{Name: "bTask"}, + TaskRef: &v1beta1.TaskRef{Name: "bTask"}, }, }, }, @@ -160,9 +159,9 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { TaskRun: tb.TaskRun("aTaskRun", tb.TaskRunStatus( tb.TaskRunResult("aResult", "aResultValue"), )), - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "aTask", - TaskRef: &v1alpha1.TaskRef{Name: "aTask"}, + TaskRef: &v1beta1.TaskRef{Name: "aTask"}, }, }, }, @@ -197,9 +196,9 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { { TaskRunName: "aTaskRun", TaskRun: tb.TaskRun("aTaskRun"), - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "aTask", - TaskRef: &v1alpha1.TaskRef{Name: "aTask"}, + TaskRef: &v1beta1.TaskRef{Name: "aTask"}, }, }, }, @@ -236,9 +235,9 @@ func TestTaskParamResolver_ResolveResultRefs(t *testing.T) { fields: fields{ pipelineRunState: PipelineRunState{ { - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "aTask", - TaskRef: &v1alpha1.TaskRef{Name: "aTask"}, + TaskRef: &v1beta1.TaskRef{Name: "aTask"}, }, }, }, @@ -304,14 +303,14 @@ func TestResolveResultRefs(t *testing.T) { TaskRun: tb.TaskRun("aTaskRun", tb.TaskRunStatus( tb.TaskRunResult("aResult", "aResultValue"), )), - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "aTask", - TaskRef: &v1alpha1.TaskRef{Name: "aTask"}, + TaskRef: &v1beta1.TaskRef{Name: "aTask"}, }, }, { - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "bTask", - TaskRef: &v1alpha1.TaskRef{Name: "bTask"}, + TaskRef: &v1beta1.TaskRef{Name: "bTask"}, Params: []v1beta1.Param{ { Name: "bParam", @@ -394,9 +393,9 @@ func TestResolvePipelineResultRefs(t *testing.T) { TaskRun: tb.TaskRun("aTaskRun", tb.TaskRunStatus( tb.TaskRunResult("aResult", "aResultValue"), )), - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "aTask", - TaskRef: &v1alpha1.TaskRef{Name: "aTask"}, + TaskRef: &v1beta1.TaskRef{Name: "aTask"}, }, }, { TaskRunName: "bTaskRun", @@ -405,14 +404,14 @@ func TestResolvePipelineResultRefs(t *testing.T) { Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse})), ), - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "bTask", - TaskRef: &v1alpha1.TaskRef{Name: "bTask"}, + TaskRef: &v1beta1.TaskRef{Name: "bTask"}, }, }, { - PipelineTask: &v1alpha1.PipelineTask{ + PipelineTask: &v1beta1.PipelineTask{ Name: "cTask", - TaskRef: &v1alpha1.TaskRef{Name: "cTask"}, + TaskRef: &v1beta1.TaskRef{Name: "cTask"}, }, }, } diff --git a/pkg/reconciler/pipelinerun/resources/validate_params.go b/pkg/reconciler/pipelinerun/resources/validate_params.go index e0fc78c0018..80b4d61c0cf 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_params.go +++ b/pkg/reconciler/pipelinerun/resources/validate_params.go @@ -19,13 +19,13 @@ package resources import ( "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) // ValidateParamTypesMatching validate that parameters in PipelineRun override corresponding parameters in Pipeline of the same type. -func ValidateParamTypesMatching(p *v1alpha1.PipelineSpec, pr *v1alpha1.PipelineRun) error { +func ValidateParamTypesMatching(p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) error { // Build a map of parameter names/types declared in p. - paramTypes := make(map[string]v1alpha1.ParamType) + paramTypes := make(map[string]v1beta1.ParamType) for _, param := range p.Params { paramTypes[param.Name] = param.Type } diff --git a/pkg/reconciler/pipelinerun/resources/validate_params_test.go b/pkg/reconciler/pipelinerun/resources/validate_params_test.go index 7614e8c1860..c9a963cbbd2 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_params_test.go +++ b/pkg/reconciler/pipelinerun/resources/validate_params_test.go @@ -19,22 +19,22 @@ package resources import ( "testing" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) func TestValidateParamTypesMatching_Valid(t *testing.T) { tcs := []struct { name string - p *v1alpha1.Pipeline - pr *v1alpha1.PipelineRun + p *v1beta1.Pipeline + pr *v1beta1.PipelineRun errorExpected bool }{{ name: "proper param types", p: tb.Pipeline("a-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("correct-type-1", v1alpha1.ParamTypeString), - tb.PipelineParamSpec("mismatching-type", v1alpha1.ParamTypeString), - tb.PipelineParamSpec("correct-type-2", v1alpha1.ParamTypeArray))), + tb.PipelineParamSpec("correct-type-1", v1beta1.ParamTypeString), + tb.PipelineParamSpec("mismatching-type", v1beta1.ParamTypeString), + tb.PipelineParamSpec("correct-type-2", v1beta1.ParamTypeArray))), pr: tb.PipelineRun("a-pipelinerun", tb.PipelineRunSpec( "test-pipeline", tb.PipelineRunParam("correct-type-1", "somestring"), @@ -49,9 +49,9 @@ func TestValidateParamTypesMatching_Valid(t *testing.T) { }, { name: "string-array mismatch", p: tb.Pipeline("a-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("correct-type-1", v1alpha1.ParamTypeString), - tb.PipelineParamSpec("mismatching-type", v1alpha1.ParamTypeString), - tb.PipelineParamSpec("correct-type-2", v1alpha1.ParamTypeArray))), + tb.PipelineParamSpec("correct-type-1", v1beta1.ParamTypeString), + tb.PipelineParamSpec("mismatching-type", v1beta1.ParamTypeString), + tb.PipelineParamSpec("correct-type-2", v1beta1.ParamTypeArray))), pr: tb.PipelineRun("a-pipelinerun", tb.PipelineRunSpec("test-pipeline", tb.PipelineRunParam("correct-type-1", "somestring"), @@ -61,9 +61,9 @@ func TestValidateParamTypesMatching_Valid(t *testing.T) { }, { name: "array-string mismatch", p: tb.Pipeline("a-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("correct-type-1", v1alpha1.ParamTypeString), - tb.PipelineParamSpec("mismatching-type", v1alpha1.ParamTypeArray), - tb.PipelineParamSpec("correct-type-2", v1alpha1.ParamTypeArray))), + tb.PipelineParamSpec("correct-type-1", v1beta1.ParamTypeString), + tb.PipelineParamSpec("mismatching-type", v1beta1.ParamTypeArray), + tb.PipelineParamSpec("correct-type-2", v1beta1.ParamTypeArray))), pr: tb.PipelineRun("a-pipelinerun", tb.PipelineRunSpec("test-pipeline", tb.PipelineRunParam("correct-type-1", "somestring"), @@ -88,14 +88,14 @@ func TestValidateParamTypesMatching_Valid(t *testing.T) { func TestValidateParamTypesMatching_Invalid(t *testing.T) { tcs := []struct { name string - p *v1alpha1.Pipeline - pr *v1alpha1.PipelineRun + p *v1beta1.Pipeline + pr *v1beta1.PipelineRun }{{ name: "string-array mismatch", p: tb.Pipeline("a-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("correct-type-1", v1alpha1.ParamTypeString), - tb.PipelineParamSpec("mismatching-type", v1alpha1.ParamTypeString), - tb.PipelineParamSpec("correct-type-2", v1alpha1.ParamTypeArray))), + tb.PipelineParamSpec("correct-type-1", v1beta1.ParamTypeString), + tb.PipelineParamSpec("mismatching-type", v1beta1.ParamTypeString), + tb.PipelineParamSpec("correct-type-2", v1beta1.ParamTypeArray))), pr: tb.PipelineRun("a-pipelinerun", tb.PipelineRunSpec("test-pipeline", tb.PipelineRunParam("correct-type-1", "somestring"), @@ -104,9 +104,9 @@ func TestValidateParamTypesMatching_Invalid(t *testing.T) { }, { name: "array-string mismatch", p: tb.Pipeline("a-pipeline", tb.PipelineSpec( - tb.PipelineParamSpec("correct-type-1", v1alpha1.ParamTypeString), - tb.PipelineParamSpec("mismatching-type", v1alpha1.ParamTypeArray), - tb.PipelineParamSpec("correct-type-2", v1alpha1.ParamTypeArray))), + tb.PipelineParamSpec("correct-type-1", v1beta1.ParamTypeString), + tb.PipelineParamSpec("mismatching-type", v1beta1.ParamTypeArray), + tb.PipelineParamSpec("correct-type-2", v1beta1.ParamTypeArray))), pr: tb.PipelineRun("a-pipelinerun", tb.PipelineRunSpec("test-pipeline", tb.PipelineRunParam("correct-type-1", "somestring"), diff --git a/pkg/reconciler/reconciler_test.go b/pkg/reconciler/reconciler_test.go index cd7c8951511..8367d577852 100644 --- a/pkg/reconciler/reconciler_test.go +++ b/pkg/reconciler/reconciler_test.go @@ -22,12 +22,12 @@ import ( "strings" "testing" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" - test "github.com/tektoncd/pipeline/test/v1alpha1" + test "github.com/tektoncd/pipeline/test" "go.uber.org/zap" "go.uber.org/zap/zaptest/observer" corev1 "k8s.io/api/core/v1" @@ -38,7 +38,7 @@ import ( // Test case for providing recorder in the option func TestRecorderOptions(t *testing.T) { - prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-completed", + prs := []*v1beta1.PipelineRun{tb.PipelineRun("test-pipeline-run-completed", tb.PipelineRunSpec("test-pipeline", tb.PipelineRunServiceAccountName("test-sa")), tb.PipelineRunStatus(tb.PipelineRunStatusCondition(apis.Condition{ Type: apis.ConditionSucceeded, @@ -47,10 +47,10 @@ func TestRecorderOptions(t *testing.T) { Message: "All Tasks have completed executing", })), )} - ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineSpec( + ps := []*v1beta1.Pipeline{tb.Pipeline("test-pipeline", tb.PipelineSpec( tb.PipelineTask("hello-world-1", "hellow-world"), ))} - ts := []*v1alpha1.Task{tb.Task("hello-world")} + ts := []*v1beta1.Task{tb.Task("hello-world")} d := test.Data{ PipelineRuns: prs, Pipelines: ps, diff --git a/pkg/reconciler/taskrun/controller.go b/pkg/reconciler/taskrun/controller.go index 14dd9f1908a..1ef766049b9 100644 --- a/pkg/reconciler/taskrun/controller.go +++ b/pkg/reconciler/taskrun/controller.go @@ -21,11 +21,11 @@ import ( "time" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" pipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client" - clustertaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/clustertask" - taskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/task" - taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/taskrun" + clustertaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask" + taskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/task" + taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun" resourceinformer "github.com/tektoncd/pipeline/pkg/client/resource/injection/informers/resource/v1alpha1/pipelineresource" "github.com/tektoncd/pipeline/pkg/pod" "github.com/tektoncd/pipeline/pkg/reconciler" @@ -101,7 +101,7 @@ func NewController(images pipeline.Images) func(context.Context, configmap.Watch c.tracker = tracker.New(impl.EnqueueKey, controller.GetTrackerLease(ctx)) podInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ - FilterFunc: controller.FilterGroupKind(v1alpha1.Kind("TaskRun")), + FilterFunc: controller.FilterGroupKind(v1beta1.Kind("TaskRun")), Handler: controller.HandleAll(impl.EnqueueControllerOf), }) diff --git a/pkg/reconciler/taskrun/metrics.go b/pkg/reconciler/taskrun/metrics.go index 0ec5f3df626..681c686424b 100644 --- a/pkg/reconciler/taskrun/metrics.go +++ b/pkg/reconciler/taskrun/metrics.go @@ -22,8 +22,8 @@ import ( "time" "github.com/pkg/errors" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" @@ -163,7 +163,7 @@ func NewRecorder() (*Recorder, error) { // 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(tr *v1alpha1.TaskRun) error { +func (r *Recorder) DurationAndCount(tr *v1beta1.TaskRun) error { if !r.initialized { return fmt.Errorf("ignoring the metrics recording for %s , failed to initialize the metrics recorder", tr.Name) } @@ -252,7 +252,7 @@ func (r *Recorder) RunningTaskRuns(lister listers.TaskRunLister) error { // 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(pod *corev1.Pod, tr *v1alpha1.TaskRun) error { +func (r *Recorder) RecordPodLatency(pod *corev1.Pod, tr *v1beta1.TaskRun) error { if !r.initialized { return errors.New("ignoring the metrics recording for pod , failed to initialize the metrics recorder") } diff --git a/pkg/reconciler/taskrun/metrics_test.go b/pkg/reconciler/taskrun/metrics_test.go index 62703ae30ac..6bf6d9e8ed5 100644 --- a/pkg/reconciler/taskrun/metrics_test.go +++ b/pkg/reconciler/taskrun/metrics_test.go @@ -20,11 +20,11 @@ import ( "testing" "time" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - alpha1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1" - faketaskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/taskrun/fake" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + informersv1beta1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1" + faketaskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun/fake" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" @@ -35,7 +35,7 @@ import ( func TestUninitializedMetrics(t *testing.T) { metrics := Recorder{} - durationCountError := metrics.DurationAndCount(&v1alpha1.TaskRun{}) + durationCountError := metrics.DurationAndCount(&v1beta1.TaskRun{}) taskrunsCountError := metrics.RunningTaskRuns(nil) podLatencyError := metrics.RecordPodLatency(nil, nil) @@ -49,7 +49,7 @@ func TestRecordTaskrunDurationCount(t *testing.T) { for _, c := range []struct { name string - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun expectedTags map[string]string expectedCountTags map[string]string expectedDuration float64 @@ -127,7 +127,7 @@ func TestRecordPipelinerunTaskrunDurationCount(t *testing.T) { for _, c := range []struct { name string - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun expectedTags map[string]string expectedCountTags map[string]string expectedDuration float64 @@ -229,7 +229,7 @@ func TestRecordPodLatency(t *testing.T) { testData := []struct { name string pod *corev1.Pod - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun expectedTags map[string]string expectedValue float64 expectingError bool @@ -292,7 +292,7 @@ func TestRecordPodLatency(t *testing.T) { } -func addTaskruns(informer alpha1.TaskRunInformer, taskrun, task, ns string, status corev1.ConditionStatus, t *testing.T) { +func addTaskruns(informer informersv1beta1.TaskRunInformer, taskrun, task, ns string, status corev1.ConditionStatus, t *testing.T) { err := informer.Informer().GetIndexer().Add(tb.TaskRun(taskrun, tb.TaskRunNamespace(ns), tb.TaskRunSpec( diff --git a/pkg/reconciler/taskrun/resources/apply.go b/pkg/reconciler/taskrun/resources/apply.go index c2004106f61..42e9344293b 100644 --- a/pkg/reconciler/taskrun/resources/apply.go +++ b/pkg/reconciler/taskrun/resources/apply.go @@ -23,12 +23,12 @@ import ( "github.com/tektoncd/pipeline/pkg/workspace" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/substitution" ) // ApplyParameters applies the params from a TaskRun.Input.Parameters to a TaskSpec -func ApplyParameters(spec *v1alpha1.TaskSpec, tr *v1alpha1.TaskRun, defaults ...v1alpha1.ParamSpec) *v1alpha1.TaskSpec { +func ApplyParameters(spec *v1beta1.TaskSpec, tr *v1beta1.TaskRun, defaults ...v1beta1.ParamSpec) *v1beta1.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 @@ -39,26 +39,26 @@ func ApplyParameters(spec *v1alpha1.TaskSpec, tr *v1alpha1.TaskRun, defaults ... // Set all the default stringReplacements for _, p := range defaults { if p.Default != nil { - if p.Default.Type == v1alpha1.ParamTypeString { + if p.Default.Type == v1beta1.ParamTypeString { stringReplacements[fmt.Sprintf("params.%s", p.Name)] = p.Default.StringVal - // FIXME(vdemeester) Remove that with deprecating v1alpha1 + // FIXME(vdemeester) Remove that with deprecating v1beta1 stringReplacements[fmt.Sprintf("inputs.params.%s", p.Name)] = p.Default.StringVal } else { arrayReplacements[fmt.Sprintf("params.%s", p.Name)] = p.Default.ArrayVal - // FIXME(vdemeester) Remove that with deprecating v1alpha1 + // FIXME(vdemeester) Remove that with deprecating v1beta1 arrayReplacements[fmt.Sprintf("inputs.params.%s", p.Name)] = p.Default.ArrayVal } } } // Set and overwrite params with the ones from the TaskRun for _, p := range tr.Spec.Params { - if p.Value.Type == v1alpha1.ParamTypeString { + if p.Value.Type == v1beta1.ParamTypeString { stringReplacements[fmt.Sprintf("params.%s", p.Name)] = p.Value.StringVal - // FIXME(vdemeester) Remove that with deprecating v1alpha1 + // FIXME(vdemeester) Remove that with deprecating v1beta1 stringReplacements[fmt.Sprintf("inputs.params.%s", p.Name)] = p.Value.StringVal } else { arrayReplacements[fmt.Sprintf("params.%s", p.Name)] = p.Value.ArrayVal - // FIXME(vdemeester) Remove that with deprecating v1alpha1 + // FIXME(vdemeester) Remove that with deprecating v1beta1 arrayReplacements[fmt.Sprintf("inputs.params.%s", p.Name)] = p.Value.ArrayVal } } @@ -67,12 +67,12 @@ func ApplyParameters(spec *v1alpha1.TaskSpec, tr *v1alpha1.TaskRun, defaults ... // ApplyResources applies the substitution from values in resources which are referenced in spec as subitems // of the replacementStr. -func ApplyResources(spec *v1alpha1.TaskSpec, resolvedResources map[string]v1alpha1.PipelineResourceInterface, replacementStr string) *v1alpha1.TaskSpec { +func ApplyResources(spec *v1beta1.TaskSpec, resolvedResources map[string]v1beta1.PipelineResourceInterface, replacementStr string) *v1beta1.TaskSpec { replacements := map[string]string{} for name, r := range resolvedResources { for k, v := range r.Replacements() { replacements[fmt.Sprintf("resources.%s.%s.%s", replacementStr, name, k)] = v - // FIXME(vdemeester) Remove that with deprecating v1alpha1 + // FIXME(vdemeester) Remove that with deprecating v1beta1 replacements[fmt.Sprintf("%s.resources.%s.%s", replacementStr, name, k)] = v } } @@ -80,16 +80,16 @@ func ApplyResources(spec *v1alpha1.TaskSpec, resolvedResources map[string]v1alph // We always add replacements for 'path' if spec.Resources != nil && spec.Resources.Inputs != nil { for _, r := range spec.Resources.Inputs { - replacements[fmt.Sprintf("resources.inputs.%s.path", r.Name)] = v1alpha1.InputResourcePath(r.ResourceDeclaration) - // FIXME(vdemeester) Remove that with deprecating v1alpha1 - replacements[fmt.Sprintf("inputs.resources.%s.path", r.Name)] = v1alpha1.InputResourcePath(r.ResourceDeclaration) + replacements[fmt.Sprintf("resources.inputs.%s.path", r.Name)] = v1beta1.InputResourcePath(r.ResourceDeclaration) + // FIXME(vdemeester) Remove that with deprecating v1beta1 + replacements[fmt.Sprintf("inputs.resources.%s.path", r.Name)] = v1beta1.InputResourcePath(r.ResourceDeclaration) } } if spec.Resources != nil && spec.Resources.Outputs != nil { for _, r := range spec.Resources.Outputs { - replacements[fmt.Sprintf("resources.outputs.%s.path", r.Name)] = v1alpha1.OutputResourcePath(r.ResourceDeclaration) - // FIXME(vdemeester) Remove that with deprecating v1alpha1 - replacements[fmt.Sprintf("outputs.resources.%s.path", r.Name)] = v1alpha1.OutputResourcePath(r.ResourceDeclaration) + replacements[fmt.Sprintf("resources.outputs.%s.path", r.Name)] = v1beta1.OutputResourcePath(r.ResourceDeclaration) + // FIXME(vdemeester) Remove that with deprecating v1beta1 + replacements[fmt.Sprintf("outputs.resources.%s.path", r.Name)] = v1beta1.OutputResourcePath(r.ResourceDeclaration) } } @@ -99,7 +99,7 @@ func ApplyResources(spec *v1alpha1.TaskSpec, resolvedResources map[string]v1alph // ApplyWorkspaces applies the substitution from paths that the workspaces in w are mounted to, the // volumes that wb are realized with in the task spec ts and the PersistentVolumeClaim names for the // workspaces. -func ApplyWorkspaces(spec *v1alpha1.TaskSpec, w []v1alpha1.WorkspaceDeclaration, wb []v1alpha1.WorkspaceBinding) *v1alpha1.TaskSpec { +func ApplyWorkspaces(spec *v1beta1.TaskSpec, w []v1beta1.WorkspaceDeclaration, wb []v1beta1.WorkspaceBinding) *v1beta1.TaskSpec { stringReplacements := map[string]string{} for _, ww := range w { @@ -121,7 +121,7 @@ func ApplyWorkspaces(spec *v1alpha1.TaskSpec, w []v1alpha1.WorkspaceDeclaration, // ApplyTaskResults applies the substitution from values in results which are referenced in spec as subitems // of the replacementStr. -func ApplyTaskResults(spec *v1alpha1.TaskSpec) *v1alpha1.TaskSpec { +func ApplyTaskResults(spec *v1beta1.TaskSpec) *v1beta1.TaskSpec { stringReplacements := map[string]string{} for _, result := range spec.Results { @@ -132,7 +132,7 @@ func ApplyTaskResults(spec *v1alpha1.TaskSpec) *v1alpha1.TaskSpec { // ApplyCredentialsPath applies a substitution of the key $(credentials.path) with the path that the creds-init // helper will write its credentials to. -func ApplyCredentialsPath(spec *v1alpha1.TaskSpec, path string) *v1alpha1.TaskSpec { +func ApplyCredentialsPath(spec *v1beta1.TaskSpec, path string) *v1beta1.TaskSpec { stringReplacements := map[string]string{ "credentials.path": path, } @@ -140,18 +140,18 @@ func ApplyCredentialsPath(spec *v1alpha1.TaskSpec, path string) *v1alpha1.TaskSp } // ApplyReplacements replaces placeholders for declared parameters with the specified replacements. -func ApplyReplacements(spec *v1alpha1.TaskSpec, stringReplacements map[string]string, arrayReplacements map[string][]string) *v1alpha1.TaskSpec { +func ApplyReplacements(spec *v1beta1.TaskSpec, stringReplacements map[string]string, arrayReplacements map[string][]string) *v1beta1.TaskSpec { spec = spec.DeepCopy() // Apply variable expansion to steps fields. steps := spec.Steps for i := range steps { - v1alpha1.ApplyStepReplacements(&steps[i], stringReplacements, arrayReplacements) + v1beta1.ApplyStepReplacements(&steps[i], stringReplacements, arrayReplacements) } // Apply variable expansion to stepTemplate fields. if spec.StepTemplate != nil { - v1alpha1.ApplyStepReplacements(&v1alpha1.Step{Container: *spec.StepTemplate}, stringReplacements, arrayReplacements) + v1beta1.ApplyStepReplacements(&v1beta1.Step{Container: *spec.StepTemplate}, stringReplacements, arrayReplacements) } // Apply variable expansion to the build's volumes @@ -171,7 +171,7 @@ func ApplyReplacements(spec *v1alpha1.TaskSpec, stringReplacements map[string]st // Apply variable substitution to the sidecar definitions sidecars := spec.Sidecars for i := range sidecars { - v1alpha1.ApplyContainerReplacements(&sidecars[i].Container, stringReplacements, arrayReplacements) + v1beta1.ApplyContainerReplacements(&sidecars[i].Container, stringReplacements, arrayReplacements) } return spec diff --git a/pkg/reconciler/taskrun/resources/apply_test.go b/pkg/reconciler/taskrun/resources/apply_test.go index a460d4773e1..874cc8034e1 100644 --- a/pkg/reconciler/taskrun/resources/apply_test.go +++ b/pkg/reconciler/taskrun/resources/apply_test.go @@ -20,11 +20,11 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" @@ -45,161 +45,157 @@ var ( ImageDigestExporterImage: "override-with-imagedigest-exporter-image:latest", } - simpleTaskSpec = &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Sidecars: []v1alpha1.Sidecar{{ - Container: corev1.Container{ - Name: "foo", - Image: "$(inputs.params.myimage)", - Env: []corev1.EnvVar{{ - Name: "foo", - Value: "$(inputs.params.FOO)", - }}, - }, - }}, - StepTemplate: &corev1.Container{ - Env: []corev1.EnvVar{{ - Name: "template-var", - Value: "$(inputs.params.FOO)", - }}, - }, - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "foo", - Image: "$(inputs.params.myimage)", - }}, {Container: corev1.Container{ - Name: "baz", - Image: "bat", - WorkingDir: "$(inputs.resources.workspace.path)", - Args: []string{"$(inputs.resources.workspace.url)"}, - }}, {Container: corev1.Container{ - Name: "qux", - Image: "$(inputs.params.something)", - Args: []string{"$(outputs.resources.imageToUse.url)"}, - }}, {Container: corev1.Container{ + simpleTaskSpec = &v1beta1.TaskSpec{ + Sidecars: []v1beta1.Sidecar{{ + Container: corev1.Container{ Name: "foo", Image: "$(inputs.params.myimage)", - }}, {Container: corev1.Container{ - Name: "baz", - Image: "$(inputs.params.somethingelse)", - WorkingDir: "$(inputs.resources.workspace.path)", - Args: []string{"$(inputs.resources.workspace.url)"}, - }}, {Container: corev1.Container{ - Name: "qux", - Image: "quux", - Args: []string{"$(outputs.resources.imageToUse.url)"}, - }}, {Container: corev1.Container{ - Name: "foo", - Image: "busybox:$(inputs.params.FOO)", - VolumeMounts: []corev1.VolumeMount{{ - Name: "$(inputs.params.FOO)", - MountPath: "path/to/$(inputs.params.FOO)", - SubPath: "sub/$(inputs.params.FOO)/path", - }}, - }}, {Container: corev1.Container{ - Name: "foo", - Image: "busybox:$(inputs.params.FOO)", Env: []corev1.EnvVar{{ Name: "foo", - Value: "value-$(inputs.params.FOO)", - }, { - Name: "bar", - ValueFrom: &corev1.EnvVarSource{ - ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{Name: "config-$(inputs.params.FOO)"}, - Key: "config-key-$(inputs.params.FOO)", - }, - }, - }, { - Name: "baz", - ValueFrom: &corev1.EnvVarSource{ - SecretKeyRef: &corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{Name: "secret-$(inputs.params.FOO)"}, - Key: "secret-key-$(inputs.params.FOO)", - }, - }, + Value: "$(inputs.params.FOO)", }}, - EnvFrom: []corev1.EnvFromSource{{ - Prefix: "prefix-0-$(inputs.params.FOO)", - ConfigMapRef: &corev1.ConfigMapEnvSource{ + }, + }}, + StepTemplate: &corev1.Container{ + Env: []corev1.EnvVar{{ + Name: "template-var", + Value: "$(inputs.params.FOO)", + }}, + }, + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "foo", + Image: "$(inputs.params.myimage)", + }}, {Container: corev1.Container{ + Name: "baz", + Image: "bat", + WorkingDir: "$(inputs.resources.workspace.path)", + Args: []string{"$(inputs.resources.workspace.url)"}, + }}, {Container: corev1.Container{ + Name: "qux", + Image: "$(inputs.params.something)", + Args: []string{"$(outputs.resources.imageToUse.url)"}, + }}, {Container: corev1.Container{ + Name: "foo", + Image: "$(inputs.params.myimage)", + }}, {Container: corev1.Container{ + Name: "baz", + Image: "$(inputs.params.somethingelse)", + WorkingDir: "$(inputs.resources.workspace.path)", + Args: []string{"$(inputs.resources.workspace.url)"}, + }}, {Container: corev1.Container{ + Name: "qux", + Image: "quux", + Args: []string{"$(outputs.resources.imageToUse.url)"}, + }}, {Container: corev1.Container{ + Name: "foo", + Image: "busybox:$(inputs.params.FOO)", + VolumeMounts: []corev1.VolumeMount{{ + Name: "$(inputs.params.FOO)", + MountPath: "path/to/$(inputs.params.FOO)", + SubPath: "sub/$(inputs.params.FOO)/path", + }}, + }}, {Container: corev1.Container{ + Name: "foo", + Image: "busybox:$(inputs.params.FOO)", + Env: []corev1.EnvVar{{ + Name: "foo", + Value: "value-$(inputs.params.FOO)", + }, { + Name: "bar", + ValueFrom: &corev1.EnvVarSource{ + ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ LocalObjectReference: corev1.LocalObjectReference{Name: "config-$(inputs.params.FOO)"}, - }, - }, { - Prefix: "prefix-1-$(inputs.params.FOO)", - SecretRef: &corev1.SecretEnvSource{ - LocalObjectReference: corev1.LocalObjectReference{Name: "secret-$(inputs.params.FOO)"}, - }, - }}, - }}, {Container: corev1.Container{ - Name: "outputs-resources-path-ab", - Image: "$(outputs.resources.imageToUse-ab.path)", - }}, {Container: corev1.Container{ - Name: "outputs-resources-path-re", - Image: "$(outputs.resources.imageToUse-re.path)", - }}}, - Volumes: []corev1.Volume{{ - Name: "$(inputs.params.FOO)", - VolumeSource: corev1.VolumeSource{ - ConfigMap: &corev1.ConfigMapVolumeSource{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "$(inputs.params.FOO)", - }, + Key: "config-key-$(inputs.params.FOO)", }, }, }, { - Name: "some-secret", - VolumeSource: corev1.VolumeSource{ - Secret: &corev1.SecretVolumeSource{ - SecretName: "$(inputs.params.FOO)", + Name: "baz", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{Name: "secret-$(inputs.params.FOO)"}, + Key: "secret-key-$(inputs.params.FOO)", }, }, + }}, + EnvFrom: []corev1.EnvFromSource{{ + Prefix: "prefix-0-$(inputs.params.FOO)", + ConfigMapRef: &corev1.ConfigMapEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{Name: "config-$(inputs.params.FOO)"}, + }, }, { - Name: "some-pvc", - VolumeSource: corev1.VolumeSource{ - PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ - ClaimName: "$(inputs.params.FOO)", - }, + Prefix: "prefix-1-$(inputs.params.FOO)", + SecretRef: &corev1.SecretEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{Name: "secret-$(inputs.params.FOO)"}, }, }}, - Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "workspace", - }, - }}, - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "imageToUse-ab", - TargetPath: "/foo/builtImage", - }, - }, { - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "imageToUse-re", - TargetPath: "foo/builtImage", + }}, {Container: corev1.Container{ + Name: "outputs-resources-path-ab", + Image: "$(outputs.resources.imageToUse-ab.path)", + }}, {Container: corev1.Container{ + Name: "outputs-resources-path-re", + Image: "$(outputs.resources.imageToUse-re.path)", + }}}, + Volumes: []corev1.Volume{{ + Name: "$(inputs.params.FOO)", + VolumeSource: corev1.VolumeSource{ + ConfigMap: &corev1.ConfigMapVolumeSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "$(inputs.params.FOO)", }, - }}, + }, + }, + }, { + Name: "some-secret", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: "$(inputs.params.FOO)", + }, + }, + }, { + Name: "some-pvc", + VolumeSource: corev1.VolumeSource{ + PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ + ClaimName: "$(inputs.params.FOO)", + }, }, + }}, + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "workspace", + }, + }}, + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "imageToUse-ab", + TargetPath: "/foo/builtImage", + }, + }, { + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "imageToUse-re", + TargetPath: "foo/builtImage", + }, + }}, }, } - gcsTaskSpec = &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "foobar", - Image: "someImage", - Args: []string{"$(outputs.resources.bucket.path)"}, - }}}, - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "bucket", - }, - }}, - }, + gcsTaskSpec = &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "foobar", + Image: "someImage", + Args: []string{"$(outputs.resources.bucket.path)"}, + }}}, + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "bucket", + }, + }}, }, } - arrayParamTaskSpec = &v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + arrayParamTaskSpec = &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "simple-image", Image: "some-image", }}, {Container: corev1.Container{ @@ -208,10 +204,10 @@ var ( Command: []string{"echo"}, Args: []string{"first", "second", "$(inputs.params.array-param)", "last"}, }}}, - }} + } - arrayAndStringParamTaskSpec = &v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + arrayAndStringParamTaskSpec = &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "simple-image", Image: "some-image", }}, {Container: corev1.Container{ @@ -220,10 +216,10 @@ var ( Command: []string{"echo"}, Args: []string{"$(inputs.params.normal-param)", "second", "$(inputs.params.array-param)", "last"}, }}}, - }} + } - multipleArrayParamsTaskSpec = &v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + multipleArrayParamsTaskSpec = &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "simple-image", Image: "some-image", }}, {Container: corev1.Container{ @@ -232,10 +228,10 @@ var ( Command: []string{"cmd", "$(inputs.params.another-array-param)"}, Args: []string{"first", "second", "$(inputs.params.array-param)", "last"}, }}}, - }} + } - multipleArrayAndStringsParamsTaskSpec = &v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + multipleArrayAndStringsParamsTaskSpec = &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "simple-image", Image: "image-$(inputs.params.string-param2)", }}, {Container: corev1.Container{ @@ -244,41 +240,41 @@ var ( Command: []string{"cmd", "$(inputs.params.array-param1)"}, Args: []string{"$(inputs.params.array-param2)", "second", "$(inputs.params.array-param1)", "$(inputs.params.string-param1)", "last"}, }}}, - }} + } - arrayTaskRun0Elements = &v1alpha1.TaskRun{ - Spec: v1alpha1.TaskRunSpec{ - Params: []v1alpha1.Param{{ + arrayTaskRun0Elements = &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + Params: []v1beta1.Param{{ Name: "array-param", - Value: v1alpha1.ArrayOrString{ - Type: v1alpha1.ParamTypeArray, + Value: v1beta1.ArrayOrString{ + Type: v1beta1.ParamTypeArray, ArrayVal: []string{}, }}, }, }, } - arrayTaskRun1Elements = &v1alpha1.TaskRun{ - Spec: v1alpha1.TaskRunSpec{ - Params: []v1alpha1.Param{{ + arrayTaskRun1Elements = &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + Params: []v1beta1.Param{{ Name: "array-param", Value: *tb.ArrayOrString("foo"), }}, }, } - arrayTaskRun3Elements = &v1alpha1.TaskRun{ - Spec: v1alpha1.TaskRunSpec{ - Params: []v1alpha1.Param{{ + arrayTaskRun3Elements = &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + Params: []v1beta1.Param{{ Name: "array-param", Value: *tb.ArrayOrString("foo", "bar", "third"), }}, }, } - arrayTaskRunMultipleArrays = &v1alpha1.TaskRun{ - Spec: v1alpha1.TaskRunSpec{ - Params: []v1alpha1.Param{{ + arrayTaskRunMultipleArrays = &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + Params: []v1beta1.Param{{ Name: "array-param", Value: *tb.ArrayOrString("foo", "bar", "third"), }, { @@ -288,9 +284,9 @@ var ( }, } - arrayTaskRunWith1StringParam = &v1alpha1.TaskRun{ - Spec: v1alpha1.TaskRunSpec{ - Params: []v1alpha1.Param{{ + arrayTaskRunWith1StringParam = &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + Params: []v1beta1.Param{{ Name: "array-param", Value: *tb.ArrayOrString("middlefirst", "middlesecond"), }, { @@ -300,9 +296,9 @@ var ( }, } - arrayTaskRunMultipleArraysAndStrings = &v1alpha1.TaskRun{ - Spec: v1alpha1.TaskRunSpec{ - Params: []v1alpha1.Param{{ + arrayTaskRunMultipleArraysAndStrings = &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + Params: []v1beta1.Param{{ Name: "array-param1", Value: *tb.ArrayOrString("1-param1", "2-param1", "3-param1", "4-param1"), }, { @@ -318,48 +314,48 @@ var ( }, } - inputs = map[string]v1alpha1.PipelineResourceInterface{ + inputs = map[string]v1beta1.PipelineResourceInterface{ "workspace": gitResource, } - outputs = map[string]v1alpha1.PipelineResourceInterface{ + outputs = map[string]v1beta1.PipelineResourceInterface{ "imageToUse": imageResource, "bucket": gcsResource, } - gitResource, _ = resource.FromType(&v1alpha1.PipelineResource{ + gitResource, _ = resource.FromType(&resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "git-resource", }, - Spec: v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, - Params: []v1alpha1.ResourceParam{{ + Spec: resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, + Params: []v1beta1.ResourceParam{{ Name: "URL", Value: "https://git-repo", }}, }, }, images) - imageResource, _ = resource.FromType(&v1alpha1.PipelineResource{ + imageResource, _ = resource.FromType(&resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "image-resource", }, - Spec: v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeImage, - Params: []v1alpha1.ResourceParam{{ + Spec: resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeImage, + Params: []v1beta1.ResourceParam{{ Name: "URL", Value: "gcr.io/hans/sandwiches", }}, }, }, images) - gcsResource, _ = resource.FromType(&v1alpha1.PipelineResource{ + gcsResource, _ = resource.FromType(&resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "gcs-resource", }, - Spec: v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeStorage, - Params: []v1alpha1.ResourceParam{{ + Spec: resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeStorage, + Params: []v1beta1.ResourceParam{{ Name: "type", Value: "gcs", }, { @@ -370,7 +366,7 @@ var ( }, images) ) -func applyMutation(ts *v1alpha1.TaskSpec, f func(*v1alpha1.TaskSpec)) *v1alpha1.TaskSpec { +func applyMutation(ts *v1beta1.TaskSpec, f func(*v1beta1.TaskSpec)) *v1beta1.TaskSpec { ts = ts.DeepCopy() f(ts) return ts @@ -378,21 +374,21 @@ func applyMutation(ts *v1alpha1.TaskSpec, f func(*v1alpha1.TaskSpec)) *v1alpha1. func TestApplyArrayParameters(t *testing.T) { type args struct { - ts *v1alpha1.TaskSpec - tr *v1alpha1.TaskRun - dp []v1alpha1.ParamSpec + ts *v1beta1.TaskSpec + tr *v1beta1.TaskRun + dp []v1beta1.ParamSpec } tests := []struct { name string args args - want *v1alpha1.TaskSpec + want *v1beta1.TaskSpec }{{ name: "array parameter with 0 elements", args: args{ ts: arrayParamTaskSpec, tr: arrayTaskRun0Elements, }, - want: applyMutation(arrayParamTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(arrayParamTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[1].Args = []string{"first", "second", "last"} }), }, { @@ -401,7 +397,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: arrayParamTaskSpec, tr: arrayTaskRun1Elements, }, - want: applyMutation(arrayParamTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(arrayParamTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[1].Args = []string{"first", "second", "foo", "last"} }), }, { @@ -410,7 +406,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: arrayParamTaskSpec, tr: arrayTaskRun3Elements, }, - want: applyMutation(arrayParamTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(arrayParamTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[1].Args = []string{"first", "second", "foo", "bar", "third", "last"} }), }, { @@ -419,7 +415,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: multipleArrayParamsTaskSpec, tr: arrayTaskRunMultipleArrays, }, - want: applyMutation(multipleArrayParamsTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(multipleArrayParamsTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[1].Command = []string{"cmd", "part1", "part2"} spec.Steps[1].Args = []string{"first", "second", "foo", "bar", "third", "last"} }), @@ -429,7 +425,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: arrayAndStringParamTaskSpec, tr: arrayTaskRunWith1StringParam, }, - want: applyMutation(arrayAndStringParamTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(arrayAndStringParamTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[1].Args = []string{"foo", "second", "middlefirst", "middlesecond", "last"} }), }, { @@ -438,7 +434,7 @@ func TestApplyArrayParameters(t *testing.T) { ts: multipleArrayAndStringsParamsTaskSpec, tr: arrayTaskRunMultipleArraysAndStrings, }, - want: applyMutation(multipleArrayAndStringsParamsTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(multipleArrayAndStringsParamsTaskSpec, func(spec *v1beta1.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"} @@ -447,15 +443,15 @@ func TestApplyArrayParameters(t *testing.T) { name: "default array parameter", args: args{ ts: arrayParamTaskSpec, - tr: &v1alpha1.TaskRun{}, - dp: []v1alpha1.ParamSpec{ + tr: &v1beta1.TaskRun{}, + dp: []v1beta1.ParamSpec{ { Name: "array-param", Default: tb.ArrayOrString("defaulted", "value!"), }, }, }, - want: applyMutation(arrayParamTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(arrayParamTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[1].Args = []string{"first", "second", "defaulted", "value!", "last"} }), }} @@ -470,9 +466,9 @@ func TestApplyArrayParameters(t *testing.T) { } func TestApplyParameters(t *testing.T) { - tr := &v1alpha1.TaskRun{ - Spec: v1alpha1.TaskRunSpec{ - Params: []v1alpha1.Param{{ + tr := &v1beta1.TaskRun{ + Spec: v1beta1.TaskRunSpec{ + Params: []v1beta1.Param{{ Name: "myimage", Value: *tb.ArrayOrString("bar"), }, { @@ -481,14 +477,14 @@ func TestApplyParameters(t *testing.T) { }}, }, } - dp := []v1alpha1.ParamSpec{{ + dp := []v1beta1.ParamSpec{{ Name: "something", Default: tb.ArrayOrString("mydefault"), }, { Name: "somethingelse", Default: tb.ArrayOrString(""), }} - want := applyMutation(simpleTaskSpec, func(spec *v1alpha1.TaskSpec) { + want := applyMutation(simpleTaskSpec, func(spec *v1beta1.TaskSpec) { spec.StepTemplate.Env[0].Value = "world" spec.Steps[0].Image = "bar" @@ -530,22 +526,22 @@ func TestApplyParameters(t *testing.T) { func TestApplyResources(t *testing.T) { type args struct { - ts *v1alpha1.TaskSpec - r map[string]v1alpha1.PipelineResourceInterface + ts *v1beta1.TaskSpec + r map[string]v1beta1.PipelineResourceInterface rStr string } tests := []struct { name string args args - want *v1alpha1.TaskSpec + want *v1beta1.TaskSpec }{{ name: "no replacements specified", args: args{ ts: simpleTaskSpec, - r: make(map[string]v1alpha1.PipelineResourceInterface), + r: make(map[string]v1beta1.PipelineResourceInterface), rStr: "inputs", }, - want: applyMutation(simpleTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(simpleTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[1].WorkingDir = "/workspace/workspace" spec.Steps[4].WorkingDir = "/workspace/workspace" spec.Steps[8].Image = "/foo/builtImage" @@ -558,7 +554,7 @@ func TestApplyResources(t *testing.T) { r: inputs, rStr: "inputs", }, - want: applyMutation(simpleTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(simpleTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[1].WorkingDir = "/workspace/workspace" spec.Steps[1].Args = []string{"https://git-repo"} spec.Steps[4].WorkingDir = "/workspace/workspace" @@ -573,7 +569,7 @@ func TestApplyResources(t *testing.T) { r: outputs, rStr: "outputs", }, - want: applyMutation(simpleTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(simpleTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[1].WorkingDir = "/workspace/workspace" spec.Steps[2].Args = []string{"gcr.io/hans/sandwiches"} spec.Steps[4].WorkingDir = "/workspace/workspace" @@ -588,7 +584,7 @@ func TestApplyResources(t *testing.T) { r: outputs, rStr: "outputs", }, - want: applyMutation(gcsTaskSpec, func(spec *v1alpha1.TaskSpec) { + want: applyMutation(gcsTaskSpec, func(spec *v1beta1.TaskSpec) { spec.Steps[0].Args = []string{"/workspace/output/bucket"} }), }} @@ -604,7 +600,7 @@ func TestApplyResources(t *testing.T) { func TestApplyWorkspaces(t *testing.T) { names.TestingSeed() - ts := &v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + ts := &v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ Env: []corev1.EnvVar{{ Name: "template-var", @@ -617,7 +613,7 @@ func TestApplyWorkspaces(t *testing.T) { Value: "$(workspaces.otherws.claim)", }}, }, - Steps: []v1alpha1.Step{{Container: corev1.Container{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "$(workspaces.myws.volume)", Image: "$(workspaces.otherws.volume)", WorkingDir: "$(workspaces.otherws.volume)", @@ -674,8 +670,8 @@ func TestApplyWorkspaces(t *testing.T) { }, }, }}, - }} - want := applyMutation(ts, func(spec *v1alpha1.TaskSpec) { + } + want := applyMutation(ts, func(spec *v1beta1.TaskSpec) { spec.StepTemplate.Env[0].Value = "ws-9l9zj" spec.StepTemplate.Env[1].Value = "foo" spec.StepTemplate.Env[2].Value = "" @@ -700,13 +696,13 @@ func TestApplyWorkspaces(t *testing.T) { spec.Volumes[1].VolumeSource.Secret.SecretName = "ws-9l9zj" spec.Volumes[2].VolumeSource.PersistentVolumeClaim.ClaimName = "ws-9l9zj" }) - w := []v1alpha1.WorkspaceDeclaration{{ + w := []v1beta1.WorkspaceDeclaration{{ Name: "myws", }, { Name: "otherws", MountPath: "/foo", }} - wb := []v1alpha1.WorkspaceBinding{{ + wb := []v1beta1.WorkspaceBinding{{ Name: "myws", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "foo", @@ -723,15 +719,15 @@ func TestApplyWorkspaces(t *testing.T) { func TestTaskResults(t *testing.T) { names.TestingSeed() - ts := &v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Results: []v1alpha1.TaskResult{{ + ts := &v1beta1.TaskSpec{ + Results: []v1beta1.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: []v1alpha1.Step{{ + Steps: []v1beta1.Step{{ Container: corev1.Container{ Name: "print-date-unix-timestamp", Image: "bash:latest", @@ -745,8 +741,8 @@ func TestTaskResults(t *testing.T) { }, Script: "#!/usr/bin/env bash\ndate | tee $(results.current-date-human-readable.path)", }}, - }} - want := applyMutation(ts, func(spec *v1alpha1.TaskSpec) { + } + want := applyMutation(ts, func(spec *v1beta1.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" @@ -760,41 +756,41 @@ func TestTaskResults(t *testing.T) { func TestApplyCredentialsPath(t *testing.T) { for _, tc := range []struct { description string - spec v1alpha1.TaskSpec + spec v1beta1.TaskSpec path string - want v1alpha1.TaskSpec + want v1beta1.TaskSpec }{{ description: "replacement in spec container", - spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{ + spec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{ Container: corev1.Container{ Command: []string{"cp"}, Args: []string{"-R", "$(credentials.path)/", "$HOME"}, }, }}, - }}, + }, path: "/tekton/creds", - want: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{ + want: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{ Container: corev1.Container{ Command: []string{"cp"}, Args: []string{"-R", "/tekton/creds/", "$HOME"}, }, }}, - }}, + }, }, { description: "replacement in spec Script", - spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{ + spec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{ Script: `cp -R "$(credentials.path)/" $HOME`, }}, - }}, + }, path: "/tekton/home", - want: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{ + want: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{ Script: `cp -R "/tekton/home/" $HOME`, }}, - }}, + }, }} { t.Run(tc.description, func(t *testing.T) { got := resources.ApplyCredentialsPath(&tc.spec, tc.path) diff --git a/pkg/reconciler/taskrun/resources/cloudevent/cloud_event_controller.go b/pkg/reconciler/taskrun/resources/cloudevent/cloud_event_controller.go index 694a3ebe2fc..2bb69dd20fc 100644 --- a/pkg/reconciler/taskrun/resources/cloudevent/cloud_event_controller.go +++ b/pkg/reconciler/taskrun/resources/cloudevent/cloud_event_controller.go @@ -22,7 +22,7 @@ import ( cloudevents "github.com/cloudevents/sdk-go/v2" "github.com/hashicorp/go-multierror" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/cloudevent" "go.uber.org/zap" @@ -31,7 +31,7 @@ import ( // InitializeCloudEvents initializes the CloudEvents part of the // TaskRunStatus from a slice of PipelineResources -func InitializeCloudEvents(tr *v1alpha1.TaskRun, prs []*v1alpha1.PipelineResource) { +func InitializeCloudEvents(tr *v1beta1.TaskRun, prs []*resource.PipelineResource) { // If there are no cloud event resources, this check will run on every reconcile if len(tr.Status.CloudEvents) == 0 { var targets []string @@ -47,15 +47,15 @@ func InitializeCloudEvents(tr *v1alpha1.TaskRun, prs []*v1alpha1.PipelineResourc } } -func cloudEventDeliveryFromTargets(targets []string) []v1alpha1.CloudEventDelivery { +func cloudEventDeliveryFromTargets(targets []string) []v1beta1.CloudEventDelivery { if len(targets) > 0 { - initialState := v1alpha1.CloudEventDeliveryState{ - Condition: v1alpha1.CloudEventConditionUnknown, + initialState := v1beta1.CloudEventDeliveryState{ + Condition: v1beta1.CloudEventConditionUnknown, RetryCount: 0, } - events := make([]v1alpha1.CloudEventDelivery, len(targets)) + events := make([]v1beta1.CloudEventDelivery, len(targets)) for idx, target := range targets { - events[idx] = v1alpha1.CloudEventDelivery{ + events[idx] = v1beta1.CloudEventDelivery{ Target: target, Status: initialState, } @@ -67,7 +67,7 @@ func cloudEventDeliveryFromTargets(targets []string) []v1alpha1.CloudEventDelive // SendCloudEvents is used by the TaskRun controller to send cloud events once // the TaskRun is complete. `tr` is used to obtain the list of targets -func SendCloudEvents(tr *v1alpha1.TaskRun, ceclient CEClient, logger *zap.SugaredLogger) error { +func SendCloudEvents(tr *v1beta1.TaskRun, ceclient CEClient, logger *zap.SugaredLogger) error { logger = logger.With(zap.String("taskrun", tr.Name)) // Make the event we would like to send: @@ -84,7 +84,7 @@ func SendCloudEvents(tr *v1alpha1.TaskRun, ceclient CEClient, logger *zap.Sugare eventStatus := &(tr.Status.CloudEvents[idx].Status) // Skip events that have already been sent (successfully or unsuccessfully) // Ensure we try to send all events once (possibly through different reconcile calls) - if eventStatus.Condition != v1alpha1.CloudEventConditionUnknown || eventStatus.RetryCount > 0 { + if eventStatus.Condition != v1beta1.CloudEventConditionUnknown || eventStatus.RetryCount > 0 { continue } @@ -96,11 +96,11 @@ func SendCloudEvents(tr *v1alpha1.TaskRun, ceclient CEClient, logger *zap.Sugare eventStatus.RetryCount++ if !cloudevents.IsACK(result) { merr = multierror.Append(merr, result) - eventStatus.Condition = v1alpha1.CloudEventConditionFailed + eventStatus.Condition = v1beta1.CloudEventConditionFailed eventStatus.Error = merr.Error() } else { logger.Infow("Event sent.", zap.String("target", cloudEventDelivery.Target)) - eventStatus.Condition = v1alpha1.CloudEventConditionSent + eventStatus.Condition = v1beta1.CloudEventConditionSent } } if merr != nil && merr.Len() > 0 { diff --git a/pkg/reconciler/taskrun/resources/cloudevent/cloud_event_controller_test.go b/pkg/reconciler/taskrun/resources/cloudevent/cloud_event_controller_test.go index 4b1afd1c6aa..0573effd9ba 100644 --- a/pkg/reconciler/taskrun/resources/cloudevent/cloud_event_controller_test.go +++ b/pkg/reconciler/taskrun/resources/cloudevent/cloud_event_controller_test.go @@ -20,8 +20,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/logging" ) @@ -29,7 +30,7 @@ func TestCloudEventDeliveryFromTargets(t *testing.T) { tests := []struct { name string targets []string - wantCloudEvents []v1alpha1.CloudEventDelivery + wantCloudEvents []v1beta1.CloudEventDelivery }{{ name: "testWithNilTarget", targets: nil, @@ -41,11 +42,11 @@ func TestCloudEventDeliveryFromTargets(t *testing.T) { }, { name: "testWithTwoTargets", targets: []string{"target1", "target2"}, - wantCloudEvents: []v1alpha1.CloudEventDelivery{ + wantCloudEvents: []v1beta1.CloudEventDelivery{ { Target: "target1", - Status: v1alpha1.CloudEventDeliveryState{ - Condition: v1alpha1.CloudEventConditionUnknown, + Status: v1beta1.CloudEventDeliveryState{ + Condition: v1beta1.CloudEventConditionUnknown, SentAt: nil, Error: "", RetryCount: 0, @@ -53,8 +54,8 @@ func TestCloudEventDeliveryFromTargets(t *testing.T) { }, { Target: "target2", - Status: v1alpha1.CloudEventDeliveryState{ - Condition: v1alpha1.CloudEventConditionUnknown, + Status: v1beta1.CloudEventDeliveryState{ + Condition: v1beta1.CloudEventConditionUnknown, SentAt: nil, Error: "", RetryCount: 0, @@ -75,8 +76,8 @@ func TestCloudEventDeliveryFromTargets(t *testing.T) { func TestSendCloudEvents(t *testing.T) { tests := []struct { name string - taskRun *v1alpha1.TaskRun - wantTaskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun + wantTaskRun *v1beta1.TaskRun }{{ name: "testWithMultipleMixedCloudEvents", taskRun: tb.TaskRun("test-taskrun-multiple-cloudeventdelivery", @@ -86,12 +87,12 @@ func TestSendCloudEvents(t *testing.T) { tb.TaskRunTaskRef("fakeTaskName"), ), tb.TaskRunStatus( - tb.TaskRunCloudEvent("http//notattemptedunknown", "", 0, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent("http//notattemptedfailed", "somehow", 0, v1alpha1.CloudEventConditionFailed), - tb.TaskRunCloudEvent("http//notattemptedsucceeded", "", 0, v1alpha1.CloudEventConditionSent), - tb.TaskRunCloudEvent("http//attemptedunknown", "", 1, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent("http//attemptedfailed", "iknewit", 1, v1alpha1.CloudEventConditionFailed), - tb.TaskRunCloudEvent("http//attemptedsucceeded", "", 1, v1alpha1.CloudEventConditionSent), + tb.TaskRunCloudEvent("http//notattemptedunknown", "", 0, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent("http//notattemptedfailed", "somehow", 0, v1beta1.CloudEventConditionFailed), + tb.TaskRunCloudEvent("http//notattemptedsucceeded", "", 0, v1beta1.CloudEventConditionSent), + tb.TaskRunCloudEvent("http//attemptedunknown", "", 1, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent("http//attemptedfailed", "iknewit", 1, v1beta1.CloudEventConditionFailed), + tb.TaskRunCloudEvent("http//attemptedsucceeded", "", 1, v1beta1.CloudEventConditionSent), ), ), wantTaskRun: tb.TaskRun("test-taskrun-multiple-cloudeventdelivery", @@ -100,12 +101,12 @@ func TestSendCloudEvents(t *testing.T) { tb.TaskRunTaskRef("fakeTaskName"), ), tb.TaskRunStatus( - tb.TaskRunCloudEvent("http//notattemptedunknown", "", 1, v1alpha1.CloudEventConditionSent), - tb.TaskRunCloudEvent("http//notattemptedfailed", "somehow", 0, v1alpha1.CloudEventConditionFailed), - tb.TaskRunCloudEvent("http//notattemptedsucceeded", "", 0, v1alpha1.CloudEventConditionSent), - tb.TaskRunCloudEvent("http//attemptedunknown", "", 1, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent("http//attemptedfailed", "iknewit", 1, v1alpha1.CloudEventConditionFailed), - tb.TaskRunCloudEvent("http//attemptedsucceeded", "", 1, v1alpha1.CloudEventConditionSent), + tb.TaskRunCloudEvent("http//notattemptedunknown", "", 1, v1beta1.CloudEventConditionSent), + tb.TaskRunCloudEvent("http//notattemptedfailed", "somehow", 0, v1beta1.CloudEventConditionFailed), + tb.TaskRunCloudEvent("http//notattemptedsucceeded", "", 0, v1beta1.CloudEventConditionSent), + tb.TaskRunCloudEvent("http//attemptedunknown", "", 1, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent("http//attemptedfailed", "iknewit", 1, v1beta1.CloudEventConditionFailed), + tb.TaskRunCloudEvent("http//attemptedsucceeded", "", 1, v1beta1.CloudEventConditionSent), ), ), }} @@ -130,8 +131,8 @@ func TestSendCloudEvents(t *testing.T) { func TestSendCloudEventsErrors(t *testing.T) { tests := []struct { name string - taskRun *v1alpha1.TaskRun - wantTaskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun + wantTaskRun *v1beta1.TaskRun }{{ name: "testWithMultipleMixedCloudEvents", taskRun: tb.TaskRun("test-taskrun-multiple-cloudeventdelivery", @@ -141,8 +142,8 @@ func TestSendCloudEventsErrors(t *testing.T) { tb.TaskRunTaskRef("fakeTaskName"), ), tb.TaskRunStatus( - tb.TaskRunCloudEvent("http//sink1", "", 0, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent("http//sink2", "", 0, v1alpha1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent("http//sink1", "", 0, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent("http//sink2", "", 0, v1beta1.CloudEventConditionUnknown), ), ), wantTaskRun: tb.TaskRun("test-taskrun-multiple-cloudeventdelivery", @@ -152,8 +153,8 @@ func TestSendCloudEventsErrors(t *testing.T) { ), tb.TaskRunStatus( // Error message is not checked in the Diff below - tb.TaskRunCloudEvent("http//sink1", "", 1, v1alpha1.CloudEventConditionFailed), - tb.TaskRunCloudEvent("http//sink2", "", 1, v1alpha1.CloudEventConditionFailed), + tb.TaskRunCloudEvent("http//sink1", "", 1, v1beta1.CloudEventConditionFailed), + tb.TaskRunCloudEvent("http//sink2", "", 1, v1beta1.CloudEventConditionFailed), ), ), }} @@ -178,33 +179,33 @@ func TestSendCloudEventsErrors(t *testing.T) { func TestInitializeCloudEvents(t *testing.T) { tests := []struct { name string - taskRun *v1alpha1.TaskRun - pipelineResources []*v1alpha1.PipelineResource - wantTaskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun + pipelineResources []*resourcev1alpha1.PipelineResource + wantTaskRun *v1beta1.TaskRun }{{ name: "testWithMultipleMixedResources", taskRun: tb.TaskRun("test-taskrun-multiple-mixed-resources", tb.TaskRunNamespace("foo"), tb.TaskRunSelfLink("/task/1234"), tb.TaskRunSpec( tb.TaskRunTaskRef("fakeTaskName"), - tb.TaskRunOutputs( - tb.TaskRunOutputsResource("ce1", tb.TaskResourceBindingRef("ce1")), - tb.TaskRunOutputsResource("git", tb.TaskResourceBindingRef("git")), - tb.TaskRunOutputsResource("ce2", tb.TaskResourceBindingRef("ce2")), + tb.TaskRunResources( + tb.TaskRunResourcesOutput("ce1", tb.TaskResourceBindingRef("ce1")), + tb.TaskRunResourcesOutput("git", tb.TaskResourceBindingRef("git")), + tb.TaskRunResourcesOutput("ce2", tb.TaskResourceBindingRef("ce2")), ), ), ), - pipelineResources: []*v1alpha1.PipelineResource{ + pipelineResources: []*resourcev1alpha1.PipelineResource{ tb.PipelineResource("ce1", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeCloudEvent, + resourcev1alpha1.PipelineResourceTypeCloudEvent, tb.PipelineResourceSpecParam("TargetURI", "http://foosink"), )), tb.PipelineResource("ce2", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeCloudEvent, + resourcev1alpha1.PipelineResourceTypeCloudEvent, tb.PipelineResourceSpecParam("TargetURI", "http://barsink"), )), tb.PipelineResource("git", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeGit, + resourcev1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("URL", "http://git.fake"), tb.PipelineResourceSpecParam("Revision", "abcd"), )), @@ -215,8 +216,8 @@ func TestInitializeCloudEvents(t *testing.T) { tb.TaskRunTaskRef("fakeTaskName"), ), tb.TaskRunStatus( - tb.TaskRunCloudEvent("http://barsink", "", 0, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent("http://foosink", "", 0, v1alpha1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent("http://barsink", "", 0, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent("http://foosink", "", 0, v1beta1.CloudEventConditionUnknown), ), ), }, { @@ -225,14 +226,14 @@ func TestInitializeCloudEvents(t *testing.T) { tb.TaskRunNamespace("foo"), tb.TaskRunSelfLink("/task/1234"), tb.TaskRunSpec( tb.TaskRunTaskRef("fakeTaskName"), - tb.TaskRunOutputs( - tb.TaskRunOutputsResource("git", tb.TaskResourceBindingRef("git")), + tb.TaskRunResources( + tb.TaskRunResourcesOutput("git", tb.TaskResourceBindingRef("git")), ), ), ), - pipelineResources: []*v1alpha1.PipelineResource{ + pipelineResources: []*resourcev1alpha1.PipelineResource{ tb.PipelineResource("git", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeGit, + resourcev1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("URL", "http://git.fake"), tb.PipelineResourceSpecParam("Revision", "abcd"), )), diff --git a/pkg/reconciler/taskrun/resources/cloudevent/cloudevent.go b/pkg/reconciler/taskrun/resources/cloudevent/cloudevent.go index fab0a8b122a..25ed3aa734f 100644 --- a/pkg/reconciler/taskrun/resources/cloudevent/cloudevent.go +++ b/pkg/reconciler/taskrun/resources/cloudevent/cloudevent.go @@ -28,7 +28,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "knative.dev/pkg/apis" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) // TektonEventType holds the types of cloud events sent by Tekton @@ -54,11 +54,11 @@ type CEClient cloudevents.Client // a Tekton cloud event. It only includes a TaskRun for now. Using a type opens // the possibility for the future to add more data to the payload type TektonCloudEventData struct { - TaskRun *v1alpha1.TaskRun `json:"taskRun"` + TaskRun *v1beta1.TaskRun `json:"taskRun"` } // NewTektonCloudEventData returns a new instance of NewTektonCloudEventData -func NewTektonCloudEventData(taskRun *v1alpha1.TaskRun) TektonCloudEventData { +func NewTektonCloudEventData(taskRun *v1beta1.TaskRun) TektonCloudEventData { return TektonCloudEventData{ TaskRun: taskRun, } @@ -66,7 +66,7 @@ func NewTektonCloudEventData(taskRun *v1alpha1.TaskRun) TektonCloudEventData { // EventForTaskRun will create a new event based on a TaskRun, // or return an error if not possible. -func EventForTaskRun(taskRun *v1alpha1.TaskRun) (*cloudevents.Event, error) { +func EventForTaskRun(taskRun *v1beta1.TaskRun) (*cloudevents.Event, error) { // Check if the TaskRun is defined if taskRun == nil { return nil, errors.New("Cannot send an event for an empty TaskRun") @@ -98,15 +98,15 @@ func EventForTaskRun(taskRun *v1alpha1.TaskRun) (*cloudevents.Event, error) { // and compare a list of CloudEventDelivery func GetCloudEventDeliveryCompareOptions() []cmp.Option { // Setup cmp options - cloudDeliveryStateCompare := func(x, y v1alpha1.CloudEventDeliveryState) bool { + cloudDeliveryStateCompare := func(x, y v1beta1.CloudEventDeliveryState) bool { return cmp.Equal(x.Condition, y.Condition) && cmp.Equal(x.RetryCount, y.RetryCount) } - less := func(x, y v1alpha1.CloudEventDelivery) bool { + less := func(x, y v1beta1.CloudEventDelivery) bool { return strings.Compare(x.Target, y.Target) < 0 || (strings.Compare(x.Target, y.Target) == 0 && x.Status.SentAt.Before(y.Status.SentAt)) } return []cmp.Option{ cmpopts.SortSlices(less), - cmp.Comparer(func(x, y v1alpha1.CloudEventDelivery) bool { + cmp.Comparer(func(x, y v1beta1.CloudEventDelivery) bool { return (strings.Compare(x.Target, y.Target) == 0) && cloudDeliveryStateCompare(x.Status, y.Status) }), } diff --git a/pkg/reconciler/taskrun/resources/cloudevent/cloudevent_test.go b/pkg/reconciler/taskrun/resources/cloudevent/cloudevent_test.go index 17d122bd469..b4811f4d710 100644 --- a/pkg/reconciler/taskrun/resources/cloudevent/cloudevent_test.go +++ b/pkg/reconciler/taskrun/resources/cloudevent/cloudevent_test.go @@ -20,7 +20,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -33,15 +33,15 @@ const ( taskRunName = "faketaskrunname" ) -func getTaskRunByCondition(status corev1.ConditionStatus) *v1alpha1.TaskRun { - return &v1alpha1.TaskRun{ +func getTaskRunByCondition(status corev1.ConditionStatus) *v1beta1.TaskRun { + return &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: taskRunName, Namespace: "marshmallow", SelfLink: defaultEventSourceURI, }, - Spec: v1alpha1.TaskRunSpec{}, - Status: v1alpha1.TaskRunStatus{ + Spec: v1beta1.TaskRunSpec{}, + Status: v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{ Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, @@ -55,7 +55,7 @@ func getTaskRunByCondition(status corev1.ConditionStatus) *v1alpha1.TaskRun { func TestEventForTaskRun(t *testing.T) { for _, c := range []struct { desc string - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun wantEventType TektonEventType }{{ desc: "send a cloud event with unknown status taskrun", diff --git a/pkg/reconciler/taskrun/resources/image_exporter.go b/pkg/reconciler/taskrun/resources/image_exporter.go index acb4be6884c..c2c3a3a1b9e 100644 --- a/pkg/reconciler/taskrun/resources/image_exporter.go +++ b/pkg/reconciler/taskrun/resources/image_exporter.go @@ -21,7 +21,7 @@ import ( "fmt" "path/filepath" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/image" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" @@ -32,8 +32,8 @@ const imageDigestExporterContainerName = "image-digest-exporter" // AddOutputImageDigestExporter add a step to check the index.json for all output images func AddOutputImageDigestExporter( imageDigestExporterImage string, - tr *v1alpha1.TaskRun, - taskSpec *v1alpha1.TaskSpec, + tr *v1beta1.TaskRun, + taskSpec *v1beta1.TaskSpec, gr GetResource, ) error { @@ -49,7 +49,7 @@ func AddOutputImageDigestExporter( if err != nil { return fmt.Errorf("failed to get output pipeline Resource for taskRun %q resource %v; error: %w while adding output image digest exporter", tr.Name, boundResource, err) } - if resource.Spec.Type == v1alpha1.PipelineResourceTypeImage { + if resource.Spec.Type == v1beta1.PipelineResourceTypeImage { imageResource, err := image.NewResource(resource) if err != nil { return fmt.Errorf("invalid Image Resource for taskRun %q resource %v; error: %w", tr.Name, boundResource, err) @@ -74,7 +74,7 @@ func AddOutputImageDigestExporter( fmt.Println(output) if len(output) > 0 { - augmentedSteps := []v1alpha1.Step{} + augmentedSteps := []v1beta1.Step{} imagesJSON, err := json.Marshal(output) if err != nil { return fmt.Errorf("failed to format image resource data for output image exporter: %w", err) @@ -90,8 +90,8 @@ func AddOutputImageDigestExporter( return nil } -func imageDigestExporterStep(imageDigestExporterImage string, imagesJSON []byte) v1alpha1.Step { - return v1alpha1.Step{Container: corev1.Container{ +func imageDigestExporterStep(imageDigestExporterImage string, imagesJSON []byte) v1beta1.Step { + return v1beta1.Step{Container: corev1.Container{ Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(imageDigestExporterContainerName), Image: imageDigestExporterImage, Command: []string{"/ko-app/imagedigestexporter"}, diff --git a/pkg/reconciler/taskrun/resources/image_exporter_test.go b/pkg/reconciler/taskrun/resources/image_exporter_test.go index 5ea20c61593..a5bf0825cc4 100644 --- a/pkg/reconciler/taskrun/resources/image_exporter_test.go +++ b/pkg/reconciler/taskrun/resources/image_exporter_test.go @@ -20,8 +20,8 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/test/names" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -30,57 +30,55 @@ import ( func TestAddOutputImageDigestExporter(t *testing.T) { for _, c := range []struct { desc string - task *v1alpha1.Task - taskRun *v1alpha1.TaskRun - wantSteps []v1alpha1.Step + task *v1beta1.Task + taskRun *v1beta1.TaskRun + wantSteps []v1beta1.Step }{{ desc: "image resource declared as both input and output", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "step1", - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-image", - Type: "image", - }, - }}, - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-image", - Type: "image", - }, - }}, - }, + Spec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "step1", + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-image", + Type: "image", + }, + }}, + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-image", + Type: "image", + }, + }}, }, }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-image", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image-1", }, }, }}, - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-image", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image-1", }, }, @@ -88,7 +86,7 @@ func TestAddOutputImageDigestExporter(t *testing.T) { }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "step1", }}, {Container: corev1.Container{ Name: "image-digest-exporter-9l9zj", @@ -98,54 +96,52 @@ func TestAddOutputImageDigestExporter(t *testing.T) { }}}, }, { desc: "image resource in task with multiple steps", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "step1", - }}, {Container: corev1.Container{ - Name: "step2", - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-image", - Type: "image", - }, - }}, - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-image", - Type: "image", - }, - }}, - }, + Spec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "step1", + }}, {Container: corev1.Container{ + Name: "step2", + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-image", + Type: "image", + }, + }}, + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-image", + Type: "image", + }, + }}, }, }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-image", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image-1", }, }, }}, - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-image", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image-1", }, }, @@ -153,7 +149,7 @@ func TestAddOutputImageDigestExporter(t *testing.T) { }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "step1", }}, {Container: corev1.Container{ Name: "step2", @@ -166,15 +162,15 @@ func TestAddOutputImageDigestExporter(t *testing.T) { }} { t.Run(c.desc, func(t *testing.T) { names.TestingSeed() - gr := func(n string) (*v1alpha1.PipelineResource, error) { - return &v1alpha1.PipelineResource{ + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { + return &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "source-image-1", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "image", - Params: []v1alpha1.ResourceParam{{ + Params: []v1beta1.ResourceParam{{ Name: "url", Value: "gcr.io/some-image-1", }, { diff --git a/pkg/reconciler/taskrun/resources/input_resource_test.go b/pkg/reconciler/taskrun/resources/input_resource_test.go index 36cbb8697b9..a3a1a400959 100644 --- a/pkg/reconciler/taskrun/resources/input_resource_test.go +++ b/pkg/reconciler/taskrun/resources/input_resource_test.go @@ -21,9 +21,9 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/artifacts" "github.com/tektoncd/pipeline/pkg/logging" "github.com/tektoncd/pipeline/test/names" @@ -46,58 +46,58 @@ var ( PRImage: "override-with-pr:latest", ImageDigestExporterImage: "override-with-imagedigest-exporter-image:latest", } - inputResourceInterfaces map[string]v1alpha1.PipelineResourceInterface + inputResourceInterfaces map[string]v1beta1.PipelineResourceInterface logger *zap.SugaredLogger - gitInputs = []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + gitInputs = []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "gitspace", Type: "git", }}} - multipleGitInputs = []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + multipleGitInputs = []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "gitspace", Type: "git", }}, { - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "git-duplicate-space", Type: "git", }}, } - gcsInputs = []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + gcsInputs = []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "workspace", Type: "gcs", TargetPath: "gcs-dir", }}} - multipleGcsInputs = []v1alpha1.TaskResource{ + multipleGcsInputs = []v1beta1.TaskResource{ { - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "workspace", Type: "gcs", TargetPath: "gcs-dir", }, }, { - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "workspace2", Type: "gcs", TargetPath: "gcs-dir", }, }, } - clusterInputs = []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + clusterInputs = []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "target-cluster", Type: "cluster", }}} - optionalGitInputs = []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + optionalGitInputs = []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "gitspace", Type: "git", Optional: false, }}, { - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "git-optional-space", Type: "git", Optional: true, @@ -108,14 +108,14 @@ var ( func setUp() { logger, _ = logging.NewLogger("", "") - rs := []*v1alpha1.PipelineResource{{ + rs := []*resourcev1alpha1.PipelineResource{{ ObjectMeta: metav1.ObjectMeta{ Name: "the-git", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "git", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Url", Value: "https://github.com/grafeas/kritis", }}, @@ -125,9 +125,9 @@ func setUp() { Name: "the-git-with-branch", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "git", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Url", Value: "https://github.com/grafeas/kritis", }, { @@ -140,9 +140,9 @@ func setUp() { Name: "the-git-with-sslVerify-false", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "git", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Url", Value: "https://github.com/grafeas/kritis", }, { @@ -158,16 +158,16 @@ func setUp() { Name: "cluster2", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "cluster", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Name", Value: "cluster2", }, { Name: "Url", Value: "http://10.10.10.10", }}, - SecretParams: []v1alpha1.SecretParam{{ + SecretParams: []resourcev1alpha1.SecretParam{{ FieldName: "cadata", SecretKey: "cadatakey", SecretName: "secret1", @@ -178,9 +178,9 @@ func setUp() { Name: "cluster3", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "cluster", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "name", Value: "cluster3", }, { @@ -208,9 +208,9 @@ func setUp() { Name: "storage1", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "storage", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Location", Value: "gs://fake-bucket/rules.zip", }, { @@ -223,9 +223,9 @@ func setUp() { Name: "storage2", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "storage", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Location", Value: "gs://fake-bucket/other.zip", }, { @@ -238,9 +238,9 @@ func setUp() { Name: "storage-gcs-keys", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "storage", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Location", Value: "gs://fake-bucket/rules.zip", }, { @@ -250,7 +250,7 @@ func setUp() { Name: "Dir", Value: "true", }}, - SecretParams: []v1alpha1.SecretParam{{ + SecretParams: []resourcev1alpha1.SecretParam{{ SecretKey: "key.json", SecretName: "secret-name", FieldName: "GOOGLE_APPLICATION_CREDENTIALS", @@ -265,9 +265,9 @@ func setUp() { Name: "storage-gcs-invalid", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "storage", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Location", Value: "gs://fake-bucket/rules", }, { @@ -276,7 +276,7 @@ func setUp() { }}, }, }} - inputResourceInterfaces = make(map[string]v1alpha1.PipelineResourceInterface) + inputResourceInterfaces = make(map[string]v1beta1.PipelineResourceInterface) for _, r := range rs { ri, _ := resource.FromType(r, images) inputResourceInterfaces[r.Name] = ri @@ -284,64 +284,64 @@ func setUp() { } func TestAddInputResourceToTask(t *testing.T) { - task := &v1alpha1.Task{ + task := &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: gitInputs, }, - }}, + }, } - taskWithMultipleGitSources := &v1alpha1.Task{ + taskWithMultipleGitSources := &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: multipleGitInputs, }, - }}, + }, } - taskWithTargetPath := &v1alpha1.Task{ + taskWithTargetPath := &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task-with-targetpath", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: gcsInputs, }, - }}, + }, } - taskWithOptionalGitSources := &v1alpha1.Task{ + taskWithOptionalGitSources := &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-with-optional-source", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: optionalGitInputs, }, - }}, + }, } - taskRun := &v1alpha1.TaskRun{ + taskRun := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "simpleTask", }, Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git", }, Name: "gitspace", @@ -353,46 +353,44 @@ func TestAddInputResourceToTask(t *testing.T) { for _, c := range []struct { desc string - task *v1alpha1.Task - taskRun *v1alpha1.TaskRun + task *v1beta1.Task + taskRun *v1beta1.TaskRun wantErr bool - want *v1alpha1.TaskSpec + want *v1beta1.TaskSpec }{{ desc: "simple with default revision", task: task, taskRun: taskRun, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "git-source-the-git-9l9zj", - Image: "override-with-git:latest", - Command: []string{"/ko-app/git-init"}, - Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "master", "-path", "/workspace/gitspace"}, - WorkingDir: "/workspace", - Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git"}}, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: gitInputs, - }, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "git-source-the-git-9l9zj", + Image: "override-with-git:latest", + Command: []string{"/ko-app/git-init"}, + Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "master", "-path", "/workspace/gitspace"}, + WorkingDir: "/workspace", + Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git"}}, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: gitInputs, }, }, }, { desc: "simple with branch", task: task, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "simpleTask", }, Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git-with-branch", }, Name: "gitspace", @@ -402,44 +400,42 @@ func TestAddInputResourceToTask(t *testing.T) { }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "git-source-the-git-with-branch-9l9zj", - Image: "override-with-git:latest", - Command: []string{"/ko-app/git-init"}, - Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace"}, - WorkingDir: "/workspace", - Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: gitInputs, - }, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "git-source-the-git-with-branch-9l9zj", + Image: "override-with-git:latest", + Command: []string{"/ko-app/git-init"}, + Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace"}, + WorkingDir: "/workspace", + Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: gitInputs, }, }, }, { desc: "reuse git input resource and verify order", task: taskWithMultipleGitSources, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "simpleTask", }, Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git-with-branch", }, Name: "gitspace", }, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git-with-branch", }, Name: "git-duplicate-space", @@ -449,44 +445,42 @@ func TestAddInputResourceToTask(t *testing.T) { }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "git-source-the-git-with-branch-mz4c7", - Image: "override-with-git:latest", - Command: []string{"/ko-app/git-init"}, - Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace"}, - WorkingDir: "/workspace", - Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, - }}, {Container: corev1.Container{ - Name: "git-source-the-git-with-branch-9l9zj", - Image: "override-with-git:latest", - Command: []string{"/ko-app/git-init"}, - Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/git-duplicate-space"}, - WorkingDir: "/workspace", - Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: multipleGitInputs, - }, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "git-source-the-git-with-branch-mz4c7", + Image: "override-with-git:latest", + Command: []string{"/ko-app/git-init"}, + Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace"}, + WorkingDir: "/workspace", + Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, + }}, {Container: corev1.Container{ + Name: "git-source-the-git-with-branch-9l9zj", + Image: "override-with-git:latest", + Command: []string{"/ko-app/git-init"}, + Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/git-duplicate-space"}, + WorkingDir: "/workspace", + Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: multipleGitInputs, }, }, }, { desc: "set revision to default value 1", task: task, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "simpleTask", }, Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git", }, Name: "gitspace", @@ -496,37 +490,35 @@ func TestAddInputResourceToTask(t *testing.T) { }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "git-source-the-git-9l9zj", - Image: "override-with-git:latest", - Command: []string{"/ko-app/git-init"}, - Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "master", "-path", "/workspace/gitspace"}, - WorkingDir: "/workspace", - Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git"}}, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: gitInputs, - }, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "git-source-the-git-9l9zj", + Image: "override-with-git:latest", + Command: []string{"/ko-app/git-init"}, + Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "master", "-path", "/workspace/gitspace"}, + WorkingDir: "/workspace", + Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git"}}, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: gitInputs, }, }, }, { desc: "set revision to provdided branch", task: task, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "simpleTask", }, Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git-with-branch", }, Name: "gitspace", @@ -536,25 +528,23 @@ func TestAddInputResourceToTask(t *testing.T) { }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "git-source-the-git-with-branch-9l9zj", - Image: "override-with-git:latest", - Command: []string{"/ko-app/git-init"}, - Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace"}, - WorkingDir: "/workspace", - Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: gitInputs, - }, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "git-source-the-git-with-branch-9l9zj", + Image: "override-with-git:latest", + Command: []string{"/ko-app/git-init"}, + Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace"}, + WorkingDir: "/workspace", + Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: gitInputs, }, }, }, { desc: "git resource as input from previous task", task: task, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-from-git", Namespace: "marshmallow", @@ -563,11 +553,11 @@ func TestAddInputResourceToTask(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git", }, Name: "gitspace", @@ -578,45 +568,43 @@ func TestAddInputResourceToTask(t *testing.T) { }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "create-dir-gitspace-mz4c7", - Image: "busybox", - Command: []string{"mkdir", "-p", "/workspace/gitspace"}, - }}, {Container: corev1.Container{ - Name: "source-copy-gitspace-9l9zj", - Image: "busybox", - Command: []string{"cp", "-r", "prev-task-path/.", "/workspace/gitspace"}, - VolumeMounts: []corev1.VolumeMount{{MountPath: "/pvc", Name: "pipelinerun-pvc"}}, - }}}, - Volumes: []corev1.Volume{{ - Name: "pipelinerun-pvc", - VolumeSource: corev1.VolumeSource{ - PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ClaimName: "pipelinerun-pvc"}, - }, - }}, - Resources: &v1beta1.TaskResources{ - Inputs: gitInputs, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "create-dir-gitspace-mz4c7", + Image: "busybox", + Command: []string{"mkdir", "-p", "/workspace/gitspace"}, + }}, {Container: corev1.Container{ + Name: "source-copy-gitspace-9l9zj", + Image: "busybox", + Command: []string{"cp", "-r", "prev-task-path/.", "/workspace/gitspace"}, + VolumeMounts: []corev1.VolumeMount{{MountPath: "/pvc", Name: "pipelinerun-pvc"}}, + }}}, + Volumes: []corev1.Volume{{ + Name: "pipelinerun-pvc", + VolumeSource: corev1.VolumeSource{ + PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ClaimName: "pipelinerun-pvc"}, }, + }}, + Resources: &v1beta1.TaskResources{ + Inputs: gitInputs, }, }, }, { desc: "simple with sslVerify false", task: task, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "simpleTask", }, Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git-with-sslVerify-false", }, Name: "gitspace", @@ -626,34 +614,32 @@ func TestAddInputResourceToTask(t *testing.T) { }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "git-source-the-git-with-sslVerify-false-9l9zj", - Image: "override-with-git:latest", - Command: []string{"/ko-app/git-init"}, - Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace", "-sslVerify=false"}, - WorkingDir: "/workspace", - Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-sslVerify-false"}}, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: gitInputs, - }, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "git-source-the-git-with-sslVerify-false-9l9zj", + Image: "override-with-git:latest", + Command: []string{"/ko-app/git-init"}, + Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace", "-sslVerify=false"}, + WorkingDir: "/workspace", + Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-sslVerify-false"}}, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: gitInputs, }, }, }, { desc: "storage resource as input with target path", task: taskWithTargetPath, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-from-gcs", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "storage1", }, Name: "workspace", @@ -663,34 +649,32 @@ func TestAddInputResourceToTask(t *testing.T) { }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "create-dir-storage1-9l9zj", - Image: "busybox", - Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, - }}, { - Script: `#!/usr/bin/env bash + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "create-dir-storage1-9l9zj", + Image: "busybox", + Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, + }}, { + Script: `#!/usr/bin/env bash if [[ "${GOOGLE_APPLICATION_CREDENTIALS}" != "" ]]; then echo GOOGLE_APPLICATION_CREDENTIALS is set, activating Service Account... gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} fi gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir `, - Container: corev1.Container{ - Name: "fetch-storage1-mz4c7", - Image: "google/cloud-sdk", - }, - }}, - Resources: &v1beta1.TaskResources{ - Inputs: gcsInputs, + Container: corev1.Container{ + Name: "fetch-storage1-mz4c7", + Image: "google/cloud-sdk", }, + }}, + Resources: &v1beta1.TaskResources{ + Inputs: gcsInputs, }, }, }, { desc: "storage resource as input from previous task", task: taskWithTargetPath, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-from-gcs", Namespace: "marshmallow", @@ -699,11 +683,11 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "storage1", }, Name: "workspace", @@ -714,42 +698,40 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "create-dir-workspace-mz4c7", - Image: "busybox", - Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, - }}, {Container: corev1.Container{ - Name: "source-copy-workspace-9l9zj", - Image: "busybox", - Command: []string{"cp", "-r", "prev-task-path/.", "/workspace/gcs-dir"}, - VolumeMounts: []corev1.VolumeMount{{MountPath: "/pvc", Name: "pipelinerun-pvc"}}, - }}}, - Volumes: []corev1.Volume{{ - Name: "pipelinerun-pvc", - VolumeSource: corev1.VolumeSource{ - PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ClaimName: "pipelinerun-pvc"}, - }, - }}, - Resources: &v1beta1.TaskResources{ - Inputs: gcsInputs, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "create-dir-workspace-mz4c7", + Image: "busybox", + Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, + }}, {Container: corev1.Container{ + Name: "source-copy-workspace-9l9zj", + Image: "busybox", + Command: []string{"cp", "-r", "prev-task-path/.", "/workspace/gcs-dir"}, + VolumeMounts: []corev1.VolumeMount{{MountPath: "/pvc", Name: "pipelinerun-pvc"}}, + }}}, + Volumes: []corev1.Volume{{ + Name: "pipelinerun-pvc", + VolumeSource: corev1.VolumeSource{ + PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ClaimName: "pipelinerun-pvc"}, }, + }}, + Resources: &v1beta1.TaskResources{ + Inputs: gcsInputs, }, }, }, { desc: "invalid gcs resource type name", task: task, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-from-invalid-gcs", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "storage-gcs-invalid", }, Name: "workspace", @@ -762,16 +744,16 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir }, { desc: "invalid gcs resource type name", task: task, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-from-invalid-gcs", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "storage-gcs-invalid", }, Name: "workspace", @@ -783,50 +765,50 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir wantErr: true, }, { desc: "invalid resource name", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "workspace-invalid", Type: "git", }}}, }, - }}, + }, }, taskRun: taskRun, wantErr: true, }, { desc: "cluster resource with plain text", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: clusterInputs, }, - }}, + }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "build-from-repo", }, Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "target-cluster", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "cluster3", }, }, @@ -835,48 +817,46 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "kubeconfig-9l9zj", - Image: "override-with-kubeconfig-writer:latest", - Command: []string{"/ko-app/kubeconfigwriter"}, - Args: []string{ - "-clusterConfig", `{"name":"cluster3","type":"cluster","url":"http://10.10.10.10","revision":"","username":"","password":"","namespace":"namespace1","token":"","Insecure":false,"cadata":"bXktY2EtY2VydAo=","clientKeyData":"Y2xpZW50LWtleS1kYXRh","clientCertificateData":"Y2xpZW50LWNlcnRpZmljYXRlLWRhdGE=","secrets":null}`, - }, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: clusterInputs, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "kubeconfig-9l9zj", + Image: "override-with-kubeconfig-writer:latest", + Command: []string{"/ko-app/kubeconfigwriter"}, + Args: []string{ + "-clusterConfig", `{"name":"cluster3","type":"cluster","url":"http://10.10.10.10","revision":"","username":"","password":"","namespace":"namespace1","token":"","Insecure":false,"cadata":"bXktY2EtY2VydAo=","clientKeyData":"Y2xpZW50LWtleS1kYXRh","clientCertificateData":"Y2xpZW50LWNlcnRpZmljYXRlLWRhdGE=","secrets":null}`, }, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: clusterInputs, }, }, }, { desc: "cluster resource with secrets", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: clusterInputs, }, - }}, + }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "build-from-repo", }, Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "target-cluster", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "cluster2", }, }, @@ -885,48 +865,46 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "kubeconfig-9l9zj", - Image: "override-with-kubeconfig-writer:latest", - Command: []string{"/ko-app/kubeconfigwriter"}, - Args: []string{ - "-clusterConfig", `{"name":"cluster2","type":"cluster","url":"http://10.10.10.10","revision":"","username":"","password":"","namespace":"","token":"","Insecure":false,"cadata":null,"clientKeyData":null,"clientCertificateData":null,"secrets":[{"fieldName":"cadata","secretKey":"cadatakey","secretName":"secret1"}]}`, - }, - Env: []corev1.EnvVar{{ - ValueFrom: &corev1.EnvVarSource{ - SecretKeyRef: &corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: "secret1", - }, - Key: "cadatakey", + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "kubeconfig-9l9zj", + Image: "override-with-kubeconfig-writer:latest", + Command: []string{"/ko-app/kubeconfigwriter"}, + Args: []string{ + "-clusterConfig", `{"name":"cluster2","type":"cluster","url":"http://10.10.10.10","revision":"","username":"","password":"","namespace":"","token":"","Insecure":false,"cadata":null,"clientKeyData":null,"clientCertificateData":null,"secrets":[{"fieldName":"cadata","secretKey":"cadatakey","secretName":"secret1"}]}`, + }, + Env: []corev1.EnvVar{{ + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "secret1", }, + Key: "cadatakey", }, - Name: "CADATA", - }}, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: clusterInputs, - }, + }, + Name: "CADATA", + }}, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: clusterInputs, }, }, }, { desc: "optional git input resource", task: taskWithOptionalGitSources, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo-with-optional-git", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "simpleTask", }, Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git-with-branch", }, Name: "gitspace", @@ -936,19 +914,17 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "git-source-the-git-with-branch-9l9zj", - Image: "override-with-git:latest", - Command: []string{"/ko-app/git-init"}, - Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace"}, - WorkingDir: "/workspace", - Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: optionalGitInputs, - }, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "git-source-the-git-with-branch-9l9zj", + Image: "override-with-git:latest", + Command: []string{"/ko-app/git-init"}, + Args: []string{"-url", "https://github.com/grafeas/kritis", "-revision", "branch", "-path", "/workspace/gitspace"}, + WorkingDir: "/workspace", + Env: []corev1.EnvVar{{Name: "TEKTON_RESOURCE_NAME", Value: "the-git-with-branch"}}, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: optionalGitInputs, }, }, }} { @@ -970,14 +946,14 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-dir } func TestStorageInputResource(t *testing.T) { - gcsStorageInputs := []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + gcsStorageInputs := []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "gcs-input-resource", Type: "storage", }}, } - optionalStorageInputs := []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + optionalStorageInputs := []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "gcs-input-resource", Type: "storage", Optional: true, @@ -986,32 +962,32 @@ func TestStorageInputResource(t *testing.T) { for _, c := range []struct { desc string - task *v1alpha1.Task - taskRun *v1alpha1.TaskRun + task *v1beta1.Task + taskRun *v1beta1.TaskRun wantErr bool - want *v1alpha1.TaskSpec + want *v1beta1.TaskSpec }{{ desc: "inputs with no resource spec and resource ref", - task: &v1alpha1.Task{ - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + task: &v1beta1.Task{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ Name: "gcs-input-resource", Type: "storage", }}}, }, - }}, + }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-storage-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "gcs-input-resource", }, }}, @@ -1021,26 +997,26 @@ func TestStorageInputResource(t *testing.T) { wantErr: true, }, { desc: "inputs with resource spec and no resource ref", - task: &v1alpha1.Task{ - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + task: &v1beta1.Task{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: gcsStorageInputs, }, - }}, + }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-storage-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "gcs-input-resource", - ResourceSpec: &v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeStorage, - Params: []v1alpha1.ResourceParam{{ + ResourceSpec: &resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeStorage, + Params: []resourcev1alpha1.ResourceParam{{ Name: "Location", Value: "gs://fake-bucket/rules.zip", }, { @@ -1054,70 +1030,68 @@ func TestStorageInputResource(t *testing.T) { }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "create-dir-gcs-input-resource-9l9zj", - Image: "busybox", - Command: []string{"mkdir", "-p", "/workspace/gcs-input-resource"}, - }}, { - Script: `#!/usr/bin/env bash + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "create-dir-gcs-input-resource-9l9zj", + Image: "busybox", + Command: []string{"mkdir", "-p", "/workspace/gcs-input-resource"}, + }}, { + Script: `#!/usr/bin/env bash if [[ "${GOOGLE_APPLICATION_CREDENTIALS}" != "" ]]; then echo GOOGLE_APPLICATION_CREDENTIALS is set, activating Service Account... gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} fi gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-input-resource `, - Container: corev1.Container{ - Name: "fetch-gcs-input-resource-mz4c7", - Image: "google/cloud-sdk", - }, - }}, - Resources: &v1beta1.TaskResources{ - Inputs: gcsStorageInputs, + Container: corev1.Container{ + Name: "fetch-gcs-input-resource-mz4c7", + Image: "google/cloud-sdk", }, + }}, + Resources: &v1beta1.TaskResources{ + Inputs: gcsStorageInputs, }, }, }, { desc: "no inputs", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "get-storage", Namespace: "marshmallow", }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-storage-run", Namespace: "marshmallow", }, }, wantErr: false, - want: &v1alpha1.TaskSpec{}, + want: &v1beta1.TaskSpec{}, }, { desc: "storage resource as input", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "get-storage", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: gcsStorageInputs, }, - }}, + }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-storage-run", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "gcs-input-resource", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "storage-gcs-keys", }, }, @@ -1126,58 +1100,56 @@ gsutil cp gs://fake-bucket/rules.zip /workspace/gcs-input-resource }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "create-dir-storage-gcs-keys-9l9zj", - Image: "busybox", - Command: []string{"mkdir", "-p", "/workspace/gcs-input-resource"}, - }}, { - Script: `#!/usr/bin/env bash + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "create-dir-storage-gcs-keys-9l9zj", + Image: "busybox", + Command: []string{"mkdir", "-p", "/workspace/gcs-input-resource"}, + }}, { + Script: `#!/usr/bin/env bash if [[ "${GOOGLE_APPLICATION_CREDENTIALS}" != "" ]]; then echo GOOGLE_APPLICATION_CREDENTIALS is set, activating Service Account... gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} fi gsutil rsync -d -r gs://fake-bucket/rules.zip /workspace/gcs-input-resource `, - Container: corev1.Container{ - Name: "fetch-storage-gcs-keys-mz4c7", - Image: "google/cloud-sdk", - VolumeMounts: []corev1.VolumeMount{ - {Name: "volume-storage-gcs-keys-secret-name", MountPath: "/var/secret/secret-name"}, - }, - Env: []corev1.EnvVar{ - {Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/secret-name/key.json"}, - }, + Container: corev1.Container{ + Name: "fetch-storage-gcs-keys-mz4c7", + Image: "google/cloud-sdk", + VolumeMounts: []corev1.VolumeMount{ + {Name: "volume-storage-gcs-keys-secret-name", MountPath: "/var/secret/secret-name"}, + }, + Env: []corev1.EnvVar{ + {Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/secret-name/key.json"}, }, - }}, - Resources: &v1beta1.TaskResources{ - Inputs: gcsStorageInputs, }, - Volumes: []corev1.Volume{{ - Name: "volume-storage-gcs-keys-secret-name", - VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{SecretName: "secret-name"}}, - }, { - Name: "volume-storage-gcs-keys-secret-name2", - VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{SecretName: "secret-name2"}}, - }}, + }}, + Resources: &v1beta1.TaskResources{ + Inputs: gcsStorageInputs, }, + Volumes: []corev1.Volume{{ + Name: "volume-storage-gcs-keys-secret-name", + VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{SecretName: "secret-name"}}, + }, { + Name: "volume-storage-gcs-keys-secret-name2", + VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{SecretName: "secret-name2"}}, + }}, }, }, { desc: "optional inputs with no resource spec and no resource ref", - task: &v1alpha1.Task{ - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + task: &v1beta1.Task{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: optionalStorageInputs, }, - }}, + }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-storage-run-with-optional-inputs", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Params: nil, Resources: &v1beta1.TaskRunResources{ Inputs: nil, @@ -1185,12 +1157,10 @@ gsutil rsync -d -r gs://fake-bucket/rules.zip /workspace/gcs-input-resource }, }, wantErr: false, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: nil, - Resources: &v1beta1.TaskResources{ - Inputs: optionalStorageInputs, - }, + want: &v1beta1.TaskSpec{ + Steps: nil, + Resources: &v1beta1.TaskResources{ + Inputs: optionalStorageInputs, }, }, }} { @@ -1210,38 +1180,38 @@ gsutil rsync -d -r gs://fake-bucket/rules.zip /workspace/gcs-input-resource } func TestAddStepsToTaskWithBucketFromConfigMap(t *testing.T) { - task := &v1alpha1.Task{ + task := &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "build-from-repo", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: gitInputs, }, - }}, + }, } - taskWithTargetPath := &v1alpha1.Task{ + taskWithTargetPath := &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task-with-targetpath", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: gcsInputs, }, - }}, + }, } - taskWithMultipleGcsInputs := &v1alpha1.Task{ + taskWithMultipleGcsInputs := &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task-with-multiple-gcs-inputs", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + Spec: v1beta1.TaskSpec{ Resources: &v1beta1.TaskResources{ Inputs: multipleGcsInputs, }, - }}, + }, } gcsVolumes := []corev1.Volume{ @@ -1264,13 +1234,13 @@ func TestAddStepsToTaskWithBucketFromConfigMap(t *testing.T) { for _, c := range []struct { desc string - task *v1alpha1.Task - taskRun *v1alpha1.TaskRun - want *v1alpha1.TaskSpec + task *v1beta1.Task + taskRun *v1beta1.TaskRun + want *v1beta1.TaskSpec }{{ desc: "git resource as input from previous task - copy to bucket", task: task, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-from-git", Namespace: "marshmallow", @@ -1279,11 +1249,11 @@ func TestAddStepsToTaskWithBucketFromConfigMap(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "the-git", }, Name: "gitspace", @@ -1293,30 +1263,28 @@ func TestAddStepsToTaskWithBucketFromConfigMap(t *testing.T) { }, }, }, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "artifact-dest-mkdir-gitspace-9l9zj", - Image: "busybox", - Command: []string{"mkdir", "-p", "/workspace/gitspace"}, - }}, {Container: corev1.Container{ - Name: "artifact-copy-from-gitspace-mz4c7", - Image: "google/cloud-sdk", - Command: []string{"gsutil"}, - Args: []string{"cp", "-P", "-r", "gs://fake-bucket/prev-task-path/*", "/workspace/gitspace"}, - Env: gcsEnv, - VolumeMounts: gcsVolumeMounts, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: gitInputs, - }, - Volumes: gcsVolumes, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "artifact-dest-mkdir-gitspace-9l9zj", + Image: "busybox", + Command: []string{"mkdir", "-p", "/workspace/gitspace"}, + }}, {Container: corev1.Container{ + Name: "artifact-copy-from-gitspace-mz4c7", + Image: "google/cloud-sdk", + Command: []string{"gsutil"}, + Args: []string{"cp", "-P", "-r", "gs://fake-bucket/prev-task-path/*", "/workspace/gitspace"}, + Env: gcsEnv, + VolumeMounts: gcsVolumeMounts, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: gitInputs, }, + Volumes: gcsVolumes, }, }, { desc: "storage resource as input from previous task - copy from bucket", task: taskWithTargetPath, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-from-gcs", Namespace: "marshmallow", @@ -1325,11 +1293,11 @@ func TestAddStepsToTaskWithBucketFromConfigMap(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "storage1", }, Name: "workspace", @@ -1339,30 +1307,28 @@ func TestAddStepsToTaskWithBucketFromConfigMap(t *testing.T) { }, }, }, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "artifact-dest-mkdir-workspace-mssqb", - Image: "busybox", - Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, - }}, {Container: corev1.Container{ - Name: "artifact-copy-from-workspace-78c5n", - Image: "google/cloud-sdk", - Command: []string{"gsutil"}, - Args: []string{"cp", "-P", "-r", "gs://fake-bucket/prev-task-path/*", "/workspace/gcs-dir"}, - Env: gcsEnv, - VolumeMounts: gcsVolumeMounts, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: gcsInputs, - }, - Volumes: gcsVolumes, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "artifact-dest-mkdir-workspace-mssqb", + Image: "busybox", + Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, + }}, {Container: corev1.Container{ + Name: "artifact-copy-from-workspace-78c5n", + Image: "google/cloud-sdk", + Command: []string{"gsutil"}, + Args: []string{"cp", "-P", "-r", "gs://fake-bucket/prev-task-path/*", "/workspace/gcs-dir"}, + Env: gcsEnv, + VolumeMounts: gcsVolumeMounts, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: gcsInputs, }, + Volumes: gcsVolumes, }, }, { desc: "storage resource with multiple inputs from previous task - copy from bucket", task: taskWithMultipleGcsInputs, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "get-from-gcs", Namespace: "marshmallow", @@ -1371,19 +1337,19 @@ func TestAddStepsToTaskWithBucketFromConfigMap(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "storage1", }, Name: "workspace", }, Paths: []string{"prev-task-path"}, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "storage2", }, Name: "workspace2", @@ -1393,36 +1359,34 @@ func TestAddStepsToTaskWithBucketFromConfigMap(t *testing.T) { }, }, }, - want: &v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Name: "artifact-dest-mkdir-workspace-vr6ds", - Image: "busybox", - Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, - }}, {Container: corev1.Container{ - Name: "artifact-copy-from-workspace-l22wn", - Image: "google/cloud-sdk", - Command: []string{"gsutil"}, - Args: []string{"cp", "-P", "-r", "gs://fake-bucket/prev-task-path/*", "/workspace/gcs-dir"}, - Env: gcsEnv, - VolumeMounts: gcsVolumeMounts, - }}, {Container: corev1.Container{ - Name: "artifact-dest-mkdir-workspace2-6nl7g", - Image: "busybox", - Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, - }}, {Container: corev1.Container{ - Name: "artifact-copy-from-workspace2-j2tds", - Image: "google/cloud-sdk", - Command: []string{"gsutil"}, - Args: []string{"cp", "-P", "-r", "gs://fake-bucket/prev-task-path2/*", "/workspace/gcs-dir"}, - Env: gcsEnv, - VolumeMounts: gcsVolumeMounts, - }}}, - Resources: &v1beta1.TaskResources{ - Inputs: multipleGcsInputs, - }, - Volumes: gcsVolumes, + want: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + Name: "artifact-dest-mkdir-workspace-vr6ds", + Image: "busybox", + Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, + }}, {Container: corev1.Container{ + Name: "artifact-copy-from-workspace-l22wn", + Image: "google/cloud-sdk", + Command: []string{"gsutil"}, + Args: []string{"cp", "-P", "-r", "gs://fake-bucket/prev-task-path/*", "/workspace/gcs-dir"}, + Env: gcsEnv, + VolumeMounts: gcsVolumeMounts, + }}, {Container: corev1.Container{ + Name: "artifact-dest-mkdir-workspace2-6nl7g", + Image: "busybox", + Command: []string{"mkdir", "-p", "/workspace/gcs-dir"}, + }}, {Container: corev1.Container{ + Name: "artifact-copy-from-workspace2-j2tds", + Image: "google/cloud-sdk", + Command: []string{"gsutil"}, + Args: []string{"cp", "-P", "-r", "gs://fake-bucket/prev-task-path2/*", "/workspace/gcs-dir"}, + Env: gcsEnv, + VolumeMounts: gcsVolumeMounts, + }}}, + Resources: &v1beta1.TaskResources{ + Inputs: multipleGcsInputs, }, + Volumes: gcsVolumes, }, }} { t.Run(c.desc, func(t *testing.T) { @@ -1451,19 +1415,19 @@ func TestAddStepsToTaskWithBucketFromConfigMap(t *testing.T) { } } -func mockResolveTaskResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.PipelineResourceInterface { - resolved := make(map[string]v1alpha1.PipelineResourceInterface) +func mockResolveTaskResources(taskRun *v1beta1.TaskRun) map[string]v1beta1.PipelineResourceInterface { + resolved := make(map[string]v1beta1.PipelineResourceInterface) if taskRun.Spec.Resources == nil { return resolved } for _, r := range taskRun.Spec.Resources.Inputs { - var i v1alpha1.PipelineResourceInterface + var i v1beta1.PipelineResourceInterface switch { case r.ResourceRef != nil && r.ResourceRef.Name != "": i = inputResourceInterfaces[r.ResourceRef.Name] resolved[r.Name] = i case r.ResourceSpec != nil: - i, _ = resource.FromType(&v1alpha1.PipelineResource{ + i, _ = resource.FromType(&resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: r.Name, }, diff --git a/pkg/reconciler/taskrun/resources/input_resources.go b/pkg/reconciler/taskrun/resources/input_resources.go index 2c5b05aabb0..083f5f28f4a 100644 --- a/pkg/reconciler/taskrun/resources/input_resources.go +++ b/pkg/reconciler/taskrun/resources/input_resources.go @@ -21,7 +21,7 @@ import ( "path/filepath" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" "github.com/tektoncd/pipeline/pkg/artifacts" "go.uber.org/zap" @@ -29,7 +29,7 @@ import ( "k8s.io/client-go/kubernetes" ) -func getBoundResource(resourceName string, boundResources []v1alpha1.TaskResourceBinding) (*v1alpha1.TaskResourceBinding, error) { +func getBoundResource(resourceName string, boundResources []v1beta1.TaskResourceBinding) (*v1beta1.TaskResourceBinding, error) { for _, br := range boundResources { if br.Name == resourceName { return &br, nil @@ -48,11 +48,11 @@ func AddInputResource( kubeclient kubernetes.Interface, images pipeline.Images, taskName string, - taskSpec *v1alpha1.TaskSpec, - taskRun *v1alpha1.TaskRun, - inputResources map[string]v1alpha1.PipelineResourceInterface, + taskSpec *v1beta1.TaskSpec, + taskRun *v1beta1.TaskRun, + inputResources map[string]v1beta1.PipelineResourceInterface, logger *zap.SugaredLogger, -) (*v1alpha1.TaskSpec, error) { +) (*v1beta1.TaskSpec, error) { if taskSpec == nil || taskSpec.Resources == nil || taskSpec.Resources.Inputs == nil { return taskSpec, nil } @@ -93,11 +93,11 @@ func AddInputResource( if !ok || resource == nil { return nil, fmt.Errorf("failed to Get Pipeline Resource for task %s with boundResource %v", taskName, boundResource) } - var copyStepsFromPrevTasks []v1alpha1.Step + var copyStepsFromPrevTasks []v1beta1.Step dPath := destinationPath(input.Name, input.TargetPath) // if taskrun is fetching resource from previous task then execute copy step instead of fetching new copy // to the desired destination directory, as long as the resource exports output to be copied - if v1alpha1.AllowedOutputResources[resource.GetType()] && taskRun.HasPipelineRunOwnerReference() { + if v1beta1.AllowedOutputResources[resource.GetType()] && taskRun.HasPipelineRunOwnerReference() { for _, path := range boundResource.Paths { cpSteps := as.GetCopyFromStorageToSteps(boundResource.Name, path, dPath) if as.GetType() == pipeline.ArtifactStoragePVCType { @@ -124,7 +124,7 @@ func AddInputResource( if err != nil { return nil, err } - if err := v1alpha1.ApplyTaskModifier(taskSpec, modifier); err != nil { + if err := v1beta1.ApplyTaskModifier(taskSpec, modifier); err != nil { return nil, fmt.Errorf("unabled to apply Resource %s: %w", boundResource.Name, err) } } diff --git a/pkg/reconciler/taskrun/resources/output_resource.go b/pkg/reconciler/taskrun/resources/output_resource.go index 82b4557786a..3fcc5dc748a 100644 --- a/pkg/reconciler/taskrun/resources/output_resource.go +++ b/pkg/reconciler/taskrun/resources/output_resource.go @@ -21,7 +21,7 @@ import ( "path/filepath" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/storage" "github.com/tektoncd/pipeline/pkg/artifacts" "go.uber.org/zap" @@ -48,11 +48,11 @@ func AddOutputResources( kubeclient kubernetes.Interface, images pipeline.Images, taskName string, - taskSpec *v1alpha1.TaskSpec, - taskRun *v1alpha1.TaskRun, - outputResources map[string]v1alpha1.PipelineResourceInterface, + taskSpec *v1beta1.TaskSpec, + taskRun *v1beta1.TaskRun, + outputResources map[string]v1beta1.PipelineResourceInterface, logger *zap.SugaredLogger, -) (*v1alpha1.TaskSpec, error) { +) (*v1beta1.TaskSpec, error) { if taskSpec == nil || taskSpec.Resources == nil || taskSpec.Resources.Outputs == nil { return taskSpec, nil } @@ -94,11 +94,11 @@ func AddOutputResources( } // Add containers to mkdir each output directory. This should run before the build steps themselves. - mkdirSteps := []v1alpha1.Step{storage.CreateDirStep(images.ShellImage, boundResource.Name, sourcePath)} + mkdirSteps := []v1beta1.Step{storage.CreateDirStep(images.ShellImage, boundResource.Name, sourcePath)} taskSpec.Steps = append(mkdirSteps, taskSpec.Steps...) - if v1alpha1.AllowedOutputResources[resource.GetType()] && taskRun.HasPipelineRunOwnerReference() { - var newSteps []v1alpha1.Step + if v1beta1.AllowedOutputResources[resource.GetType()] && taskRun.HasPipelineRunOwnerReference() { + var newSteps []v1beta1.Step for _, dPath := range boundResource.Paths { newSteps = append(newSteps, as.GetCopyToStorageFromSteps(resource.GetName(), sourcePath, dPath)...) needsPvc = true @@ -112,7 +112,7 @@ func AddOutputResources( if err != nil { return nil, err } - if err := v1alpha1.ApplyTaskModifier(taskSpec, modifier); err != nil { + if err := v1beta1.ApplyTaskModifier(taskSpec, modifier); err != nil { return nil, fmt.Errorf("Unabled to apply Resource %s: %w", boundResource.Name, err) } } diff --git a/pkg/reconciler/taskrun/resources/output_resource_test.go b/pkg/reconciler/taskrun/resources/output_resource_test.go index 9bc00820f49..79cd801782d 100644 --- a/pkg/reconciler/taskrun/resources/output_resource_test.go +++ b/pkg/reconciler/taskrun/resources/output_resource_test.go @@ -20,9 +20,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/artifacts" "github.com/tektoncd/pipeline/pkg/logging" "github.com/tektoncd/pipeline/test/names" @@ -32,20 +32,20 @@ import ( ) var ( - outputTestResources map[string]v1alpha1.PipelineResourceInterface + outputTestResources map[string]v1beta1.PipelineResourceInterface ) func outputTestResourceSetup() { logger, _ = logging.NewLogger("", "") - rs := []*v1alpha1.PipelineResource{{ + rs := []*resourcev1alpha1.PipelineResource{{ ObjectMeta: metav1.ObjectMeta{ Name: "source-git", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "git", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Url", Value: "https://github.com/grafeas/kritis", }, { @@ -58,7 +58,7 @@ func outputTestResourceSetup() { Name: "invalid-source-storage", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "storage", }, }, { @@ -66,9 +66,9 @@ func outputTestResourceSetup() { Name: "source-gcs", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "storage", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Location", Value: "gs://some-bucket", }, { @@ -78,7 +78,7 @@ func outputTestResourceSetup() { Name: "dir", Value: "true", }}, - SecretParams: []v1alpha1.SecretParam{{ + SecretParams: []resourcev1alpha1.SecretParam{{ SecretKey: "key.json", SecretName: "sname", FieldName: "GOOGLE_APPLICATION_CREDENTIALS", @@ -89,9 +89,9 @@ func outputTestResourceSetup() { Name: "source-gcs-bucket", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "storage", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Location", Value: "gs://some-bucket", }, { @@ -107,9 +107,9 @@ func outputTestResourceSetup() { Name: "source-gcs-bucket-2", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "storage", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Location", Value: "gs://some-bucket-2", }, { @@ -125,9 +125,9 @@ func outputTestResourceSetup() { Name: "source-gcs-bucket-3", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "storage", - Params: []v1alpha1.ResourceParam{{ + Params: []resourcev1alpha1.ResourceParam{{ Name: "Location", Value: "gs://some-bucket-3", }, { @@ -143,12 +143,12 @@ func outputTestResourceSetup() { Name: "source-image", Namespace: "marshmallow", }, - Spec: v1alpha1.PipelineResourceSpec{ + Spec: resourcev1alpha1.PipelineResourceSpec{ Type: "image", }, }} - outputTestResources = make(map[string]v1alpha1.PipelineResourceInterface) + outputTestResources = make(map[string]v1beta1.PipelineResourceInterface) for _, r := range rs { ri, _ := resource.FromType(r, images) outputTestResources[r.Name] = ri @@ -160,14 +160,14 @@ func TestValidOutputResources(t *testing.T) { for _, c := range []struct { name string desc string - task *v1alpha1.Task - taskRun *v1alpha1.TaskRun - wantSteps []v1alpha1.Step + task *v1beta1.Task + taskRun *v1beta1.TaskRun + wantSteps []v1beta1.Step wantVolumes []corev1.Volume }{{ name: "git resource in input and output", desc: "git resource declared as both input and output with pipelinerun owner reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", @@ -176,20 +176,20 @@ func TestValidOutputResources(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-git", }, }, }}, - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-git", }, }, @@ -198,29 +198,27 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - }}}, - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + }}}, + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace"}, @@ -255,7 +253,7 @@ func TestValidOutputResources(t *testing.T) { }, { name: "git resource in output only", desc: "git resource declared as output with pipelinerun owner reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", @@ -264,12 +262,12 @@ func TestValidOutputResources(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-git", }, }, @@ -278,24 +276,22 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace"}, @@ -330,7 +326,7 @@ func TestValidOutputResources(t *testing.T) { }, { name: "image resource in output with pipelinerun with owner", desc: "image resource declared as output with pipelinerun owner reference should not generate any steps", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", @@ -339,12 +335,12 @@ func TestValidOutputResources(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image", }, }, @@ -353,24 +349,22 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "image", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "image", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace"}, @@ -379,17 +373,17 @@ func TestValidOutputResources(t *testing.T) { }, { name: "git resource in output", desc: "git resource declared in output without pipelinerun owner reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-git", }, }, @@ -397,24 +391,22 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace"}, @@ -422,7 +414,7 @@ func TestValidOutputResources(t *testing.T) { }, { name: "storage resource as both input and output", desc: "storage resource defined in both input and output with parents pipelinerun reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", @@ -431,20 +423,20 @@ func TestValidOutputResources(t *testing.T) { Name: "pipelinerun-parent", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs", }, }, }}, - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs", }, }, @@ -453,30 +445,28 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - TargetPath: "faraway-disk", - }}}, - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + TargetPath: "faraway-disk", + }}}, + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{ + wantSteps: []v1beta1.Step{ {Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", @@ -528,7 +518,7 @@ func TestValidOutputResources(t *testing.T) { }, { name: "storage resource as output", desc: "storage resource defined only in output with pipeline ownder reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-only-output-step", Namespace: "marshmallow", @@ -537,12 +527,12 @@ func TestValidOutputResources(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs", }, }, @@ -551,24 +541,22 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{ + wantSteps: []v1beta1.Step{ {Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", @@ -617,17 +605,17 @@ func TestValidOutputResources(t *testing.T) { }, { name: "storage resource as output with no owner", desc: "storage resource defined only in output without pipelinerun reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-only-output-step", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs", }, }, @@ -636,24 +624,22 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{ + wantSteps: []v1beta1.Step{ {Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", @@ -681,17 +667,17 @@ func TestValidOutputResources(t *testing.T) { }, { name: "storage resource as output with matching build volumes", desc: "storage resource defined only in output without pipelinerun reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-only-output-step", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs", }, }, @@ -699,24 +685,22 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{ + wantSteps: []v1beta1.Step{ {Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", @@ -744,7 +728,7 @@ func TestValidOutputResources(t *testing.T) { }, { name: "image resource as output", desc: "image resource defined only in output", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-only-output-step", Namespace: "marshmallow", @@ -753,12 +737,12 @@ func TestValidOutputResources(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image", }, }, @@ -766,24 +750,22 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "image", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "image", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace"}, @@ -791,7 +773,7 @@ func TestValidOutputResources(t *testing.T) { }, { name: "Resource with TargetPath as output", desc: "Resource with TargetPath defined only in output", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-only-output-step", Namespace: "marshmallow", @@ -800,12 +782,12 @@ func TestValidOutputResources(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image", }, }, @@ -813,42 +795,40 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "image", - TargetPath: "/workspace", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "image", + TargetPath: "/workspace", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace"}, }}}, }, { desc: "image output resource with no steps", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image", }, }, @@ -856,48 +836,46 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "image", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "image", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace"}, }}}, }, { desc: "multiple image output resource with no steps", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image", }, }, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace-1", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-image", }, }, @@ -905,28 +883,26 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "image", - }}, { - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace-1", - Type: "image", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "image", + }}, { + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace-1", + Type: "image", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-1-mz4c7", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace-1"}, @@ -961,13 +937,13 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { for _, c := range []struct { name string desc string - task *v1alpha1.Task - taskRun *v1alpha1.TaskRun - wantSteps []v1alpha1.Step + task *v1beta1.Task + taskRun *v1beta1.TaskRun + wantSteps []v1beta1.Step }{{ name: "git resource in input and output with bucket storage", desc: "git resource declared as both input and output with pipelinerun owner reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", @@ -976,20 +952,20 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-git", }, }, }}, - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-git", }, }, @@ -998,29 +974,27 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - }}}, - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + }}}, + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace"}, @@ -1033,7 +1007,7 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { }, { name: "git resource in output only with bucket storage", desc: "git resource declared as output with pipelinerun owner reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", @@ -1042,12 +1016,12 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-git", }, }, @@ -1056,24 +1030,22 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace"}, @@ -1086,17 +1058,17 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { }, { name: "git resource in output", desc: "git resource declared in output without pipelinerun owner reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-git", }, }, @@ -1104,24 +1076,22 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{{Container: corev1.Container{ + wantSteps: []v1beta1.Step{{Container: corev1.Container{ Name: "create-dir-source-workspace-9l9zj", Image: "busybox", Command: []string{"mkdir", "-p", "/workspace/output/source-workspace"}, @@ -1157,19 +1127,19 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { func TestInvalidOutputResources(t *testing.T) { for _, c := range []struct { desc string - task *v1alpha1.Task - taskRun *v1alpha1.TaskRun + task *v1beta1.Task + taskRun *v1beta1.TaskRun wantErr bool }{{ desc: "no outputs defined", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{}, + Spec: v1beta1.TaskSpec{}, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-only-output-step", Namespace: "marshmallow", @@ -1182,24 +1152,22 @@ func TestInvalidOutputResources(t *testing.T) { wantErr: false, }, { desc: "no outputs defined in task but defined in taskrun", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + }}}, }, }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-only-output-step", Namespace: "marshmallow", @@ -1208,12 +1176,12 @@ func TestInvalidOutputResources(t *testing.T) { Name: "pipelinerun", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs", }, }, @@ -1225,24 +1193,22 @@ func TestInvalidOutputResources(t *testing.T) { wantErr: false, }, { desc: "no outputs defined in taskrun but defined in task", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + }}}, }, }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-only-output-step", Namespace: "foo", @@ -1255,17 +1221,17 @@ func TestInvalidOutputResources(t *testing.T) { wantErr: true, }, { desc: "invalid storage resource", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "invalid-source-storage", }, }, @@ -1273,44 +1239,40 @@ func TestInvalidOutputResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + }}}, }, }, }, wantErr: true, }, { desc: "optional outputs declared", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - Optional: true, - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + Optional: true, + }}}, }, }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-optional-output", Namespace: "marshmallow", @@ -1323,24 +1285,22 @@ func TestInvalidOutputResources(t *testing.T) { wantErr: false, }, { desc: "required outputs declared", - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "git", - Optional: false, - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "git", + Optional: false, + }}}, }, }, }, - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-required-output", Namespace: "marshmallow", @@ -1363,18 +1323,18 @@ func TestInvalidOutputResources(t *testing.T) { } } -func resolveInputResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.PipelineResourceInterface { - resolved := make(map[string]v1alpha1.PipelineResourceInterface) +func resolveInputResources(taskRun *v1beta1.TaskRun) map[string]v1beta1.PipelineResourceInterface { + resolved := make(map[string]v1beta1.PipelineResourceInterface) if taskRun.Spec.Resources == nil { return resolved } for _, r := range taskRun.Spec.Resources.Inputs { - var i v1alpha1.PipelineResourceInterface + var i v1beta1.PipelineResourceInterface if name := r.ResourceRef.Name; name != "" { i = outputTestResources[name] resolved[r.Name] = i } else if r.ResourceSpec != nil { - i, _ = resource.FromType(&v1alpha1.PipelineResource{ + i, _ = resource.FromType(&resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: r.Name, }, @@ -1386,18 +1346,18 @@ func resolveInputResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.Pipeli return resolved } -func resolveOutputResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.PipelineResourceInterface { - resolved := make(map[string]v1alpha1.PipelineResourceInterface) +func resolveOutputResources(taskRun *v1beta1.TaskRun) map[string]v1beta1.PipelineResourceInterface { + resolved := make(map[string]v1beta1.PipelineResourceInterface) if taskRun.Spec.Resources == nil { return resolved } for _, r := range taskRun.Spec.Resources.Outputs { - var i v1alpha1.PipelineResourceInterface + var i v1beta1.PipelineResourceInterface if name := r.ResourceRef.Name; name != "" { i = outputTestResources[name] resolved[r.Name] = i } else if r.ResourceSpec != nil { - i, _ = resource.FromType(&v1alpha1.PipelineResource{ + i, _ = resource.FromType(&resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: r.Name, }, @@ -1415,14 +1375,14 @@ func TestInputOutputBucketResources(t *testing.T) { for _, c := range []struct { name string desc string - task *v1alpha1.Task - taskRun *v1alpha1.TaskRun - wantSteps []v1alpha1.Step + task *v1beta1.Task + taskRun *v1beta1.TaskRun + wantSteps []v1beta1.Step wantVolumes []corev1.Volume }{{ name: "storage resource as both input and output", desc: "storage resource defined in both input and output with parents pipelinerun reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", @@ -1431,21 +1391,21 @@ func TestInputOutputBucketResources(t *testing.T) { Name: "pipelinerun-parent", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs-bucket", }, }, Paths: []string{"pipeline-task-path"}, }}, - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs-bucket", }, }, @@ -1453,30 +1413,28 @@ func TestInputOutputBucketResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - TargetPath: "faraway-disk", - }}}, - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + TargetPath: "faraway-disk", + }}}, + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{ + wantSteps: []v1beta1.Step{ {Container: corev1.Container{ Name: "create-dir-source-workspace-mssqb", Image: "busybox", @@ -1525,7 +1483,7 @@ func TestInputOutputBucketResources(t *testing.T) { }, { name: "two storage resource inputs and one output", desc: "two storage resources defined in input and one in output with parents pipelinerun reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", @@ -1534,29 +1492,29 @@ func TestInputOutputBucketResources(t *testing.T) { Name: "pipelinerun-parent", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Inputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Inputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs-bucket", }, }, Paths: []string{"pipeline-task-path"}, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace-2", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs-bucket-2", }, }, Paths: []string{"pipeline-task-path-2"}, }}, - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace-3", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs-bucket-3", }, }, @@ -1564,35 +1522,33 @@ func TestInputOutputBucketResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Inputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - TargetPath: "faraway-disk", - }}, { - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace-2", - Type: "storage", - TargetPath: "faraway-disk-2", - }}}, - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace-3", - Type: "storage", - }}}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Inputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + TargetPath: "faraway-disk", + }}, { + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace-2", + Type: "storage", + TargetPath: "faraway-disk-2", + }}}, + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace-3", + Type: "storage", + }}}, }, }, }, - wantSteps: []v1alpha1.Step{ + wantSteps: []v1beta1.Step{ {Container: corev1.Container{ Name: "create-dir-source-workspace-3-6nl7g", Image: "busybox", @@ -1658,7 +1614,7 @@ func TestInputOutputBucketResources(t *testing.T) { }, { name: "two storage resource outputs", desc: "two storage resources defined in output with parents pipelinerun reference", - taskRun: &v1alpha1.TaskRun{ + taskRun: &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "test-taskrun-run-output-steps", Namespace: "marshmallow", @@ -1667,19 +1623,19 @@ func TestInputOutputBucketResources(t *testing.T) { Name: "pipelinerun-parent", }}, }, - Spec: v1alpha1.TaskRunSpec{ + Spec: v1beta1.TaskRunSpec{ Resources: &v1beta1.TaskRunResources{ - Outputs: []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + Outputs: []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs-bucket", }, }, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "source-workspace-2", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "source-gcs-bucket-2", }, }, @@ -1687,29 +1643,27 @@ func TestInputOutputBucketResources(t *testing.T) { }, }, }, - task: &v1alpha1.Task{ + task: &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "task1", Namespace: "marshmallow", }, - Spec: v1alpha1.TaskSpec{ - TaskSpec: v1beta1.TaskSpec{ - Resources: &v1beta1.TaskResources{ - Outputs: []v1alpha1.TaskResource{{ - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace", - Type: "storage", - }}, { - ResourceDeclaration: v1alpha1.ResourceDeclaration{ - Name: "source-workspace-2", - Type: "storage", - }}, - }, + Spec: v1beta1.TaskSpec{ + Resources: &v1beta1.TaskResources{ + Outputs: []v1beta1.TaskResource{{ + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace", + Type: "storage", + }}, { + ResourceDeclaration: v1beta1.ResourceDeclaration{ + Name: "source-workspace-2", + Type: "storage", + }}, }, }, }, }, - wantSteps: []v1alpha1.Step{ + wantSteps: []v1beta1.Step{ {Container: corev1.Container{ Name: "create-dir-source-workspace-2-mssqb", Image: "busybox", diff --git a/pkg/reconciler/taskrun/resources/taskref.go b/pkg/reconciler/taskrun/resources/taskref.go index bc5ab51f19f..8d259eae0be 100644 --- a/pkg/reconciler/taskrun/resources/taskref.go +++ b/pkg/reconciler/taskrun/resources/taskref.go @@ -19,7 +19,7 @@ package resources import ( "fmt" - "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" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -27,15 +27,15 @@ import ( // LocalTaskRefResolver uses the current cluster to resolve a task reference. type LocalTaskRefResolver struct { Namespace string - Kind v1alpha1.TaskKind + Kind v1beta1.TaskKind Tektonclient clientset.Interface } // GetTask will resolve either a Task or ClusterTask from the local cluster using a versioned Tekton client. It will // return an error if it can't find an appropriate Task for any reason. -func (l *LocalTaskRefResolver) GetTask(name string) (v1alpha1.TaskInterface, error) { - if l.Kind == v1alpha1.ClusterTaskKind { - task, err := l.Tektonclient.TektonV1alpha1().ClusterTasks().Get(name, metav1.GetOptions{}) +func (l *LocalTaskRefResolver) GetTask(name string) (v1beta1.TaskInterface, error) { + if l.Kind == v1beta1.ClusterTaskKind { + task, err := l.Tektonclient.TektonV1beta1().ClusterTasks().Get(name, metav1.GetOptions{}) if err != nil { return nil, err } @@ -46,5 +46,5 @@ func (l *LocalTaskRefResolver) GetTask(name string) (v1alpha1.TaskInterface, err if l.Namespace == "" { return nil, fmt.Errorf("Must specify namespace to resolve reference to task %s", name) } - return l.Tektonclient.TektonV1alpha1().Tasks(l.Namespace).Get(name, metav1.GetOptions{}) + return l.Tektonclient.TektonV1beta1().Tasks(l.Namespace).Get(name, metav1.GetOptions{}) } diff --git a/pkg/reconciler/taskrun/resources/taskref_test.go b/pkg/reconciler/taskrun/resources/taskref_test.go index 07468d38d79..bf184311673 100644 --- a/pkg/reconciler/taskrun/resources/taskref_test.go +++ b/pkg/reconciler/taskrun/resources/taskref_test.go @@ -22,7 +22,7 @@ import ( "github.com/google/go-cmp/cmp" "k8s.io/apimachinery/pkg/runtime" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/fake" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" diff --git a/pkg/reconciler/taskrun/resources/taskresourceresolution.go b/pkg/reconciler/taskrun/resources/taskresourceresolution.go index b501b0b5ac8..359691617b2 100644 --- a/pkg/reconciler/taskrun/resources/taskresourceresolution.go +++ b/pkg/reconciler/taskrun/resources/taskresourceresolution.go @@ -20,8 +20,8 @@ import ( "errors" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -29,29 +29,29 @@ import ( // the TaskRun: the TaskRun, it's Task and the PipelineResources it needs. type ResolvedTaskResources struct { TaskName string - Kind v1alpha1.TaskKind - TaskSpec *v1alpha1.TaskSpec + Kind v1beta1.TaskKind + TaskSpec *v1beta1.TaskSpec // Inputs is a map from the name of the input required by the Task // to the actual Resource to use for it - Inputs map[string]*v1alpha1.PipelineResource + Inputs map[string]*resourcev1alpha1.PipelineResource // Outputs is a map from the name of the output required by the Task // to the actual Resource to use for it - Outputs map[string]*v1alpha1.PipelineResource + Outputs map[string]*resourcev1alpha1.PipelineResource } // GetResource is a function used to retrieve PipelineResources. -type GetResource func(string) (*v1alpha1.PipelineResource, error) +type GetResource func(string) (*resourcev1alpha1.PipelineResource, error) // ResolveTaskResources looks up PipelineResources referenced by inputs and outputs and returns // a structure that unites the resolved references and the Task Spec. If referenced PipelineResources // can't be found, an error is returned. -func ResolveTaskResources(ts *v1alpha1.TaskSpec, taskName string, kind v1alpha1.TaskKind, inputs []v1beta1.TaskResourceBinding, outputs []v1beta1.TaskResourceBinding, gr GetResource) (*ResolvedTaskResources, error) { +func ResolveTaskResources(ts *v1beta1.TaskSpec, taskName string, kind v1beta1.TaskKind, inputs []v1beta1.TaskResourceBinding, outputs []v1beta1.TaskResourceBinding, gr GetResource) (*ResolvedTaskResources, error) { rtr := ResolvedTaskResources{ TaskName: taskName, TaskSpec: ts, Kind: kind, - Inputs: map[string]*v1alpha1.PipelineResource{}, - Outputs: map[string]*v1alpha1.PipelineResource{}, + Inputs: map[string]*resourcev1alpha1.PipelineResource{}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{}, } for _, r := range inputs { @@ -77,7 +77,7 @@ func ResolveTaskResources(ts *v1alpha1.TaskSpec, taskName string, kind v1alpha1. // GetResourceFromBinding will return an instance of a PipelineResource to use for r, either by getting it with getter or by // instantiating it from the embedded spec. -func GetResourceFromBinding(r *v1alpha1.PipelineResourceBinding, getter GetResource) (*v1alpha1.PipelineResource, error) { +func GetResourceFromBinding(r *v1beta1.PipelineResourceBinding, getter GetResource) (*resourcev1alpha1.PipelineResource, error) { if (r.ResourceRef != nil && r.ResourceRef.Name != "") && r.ResourceSpec != nil { return nil, errors.New("Both ResourseRef and ResourceSpec are defined. Expected only one") } @@ -85,7 +85,7 @@ func GetResourceFromBinding(r *v1alpha1.PipelineResourceBinding, getter GetResou return getter(r.ResourceRef.Name) } if r.ResourceSpec != nil { - return &v1alpha1.PipelineResource{ + return &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: r.Name, }, diff --git a/pkg/reconciler/taskrun/resources/taskresourceresolution_test.go b/pkg/reconciler/taskrun/resources/taskresourceresolution_test.go index 77c494471bf..3c9ff44dace 100644 --- a/pkg/reconciler/taskrun/resources/taskresourceresolution_test.go +++ b/pkg/reconciler/taskrun/resources/taskresourceresolution_test.go @@ -21,68 +21,68 @@ import ( "fmt" "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestResolveTaskRun(t *testing.T) { - inputs := []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + inputs := []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "repoToBuildFrom", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "git-repo", }, }, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "clusterToUse", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "k8s-cluster", }, }, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "clusterspecToUse", - ResourceSpec: &v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeCluster, + ResourceSpec: &resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeCluster, }, }, }} - outputs := []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + outputs := []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "imageToBuild", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "image", }, }, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "gitRepoToUpdate", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "another-git-repo", }, }, }, { - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "gitspecToUse", - ResourceSpec: &v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, + ResourceSpec: &resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, }, }, }} taskName := "orchestrate" - kind := v1alpha1.NamespacedTaskKind - taskSpec := v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + kind := v1beta1.NamespacedTaskKind + taskSpec := v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "step1", - }}}, - }} + }}, + }} - resources := []*v1alpha1.PipelineResource{{ + resources := []*resourcev1alpha1.PipelineResource{{ ObjectMeta: metav1.ObjectMeta{ Name: "git-repo", }, @@ -100,7 +100,7 @@ func TestResolveTaskRun(t *testing.T) { }, }} resourceIndex := 0 - gr := func(n string) (*v1alpha1.PipelineResource, error) { + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { r := resources[resourceIndex] resourceIndex++ return r, nil @@ -134,7 +134,7 @@ func TestResolveTaskRun(t *testing.T) { r, ok = rtr.Inputs["clusterspecToUse"] if !ok { t.Errorf("Expected value present in map for `clusterspecToUse' but it was missing") - } else if r.Spec.Type != v1alpha1.PipelineResourceTypeCluster { + } else if r.Spec.Type != resourcev1alpha1.PipelineResourceTypeCluster { t.Errorf("Expected to use resource to be of type `cluster` for `clusterspecToUse` but got %s", r.Spec.Type) } } else { @@ -157,7 +157,7 @@ func TestResolveTaskRun(t *testing.T) { r, ok = rtr.Outputs["gitspecToUse"] if !ok { t.Errorf("Expected value present in map for `gitspecToUse' but it was missing") - } else if r.Spec.Type != v1alpha1.PipelineResourceTypeGit { + } else if r.Spec.Type != resourcev1alpha1.PipelineResourceTypeGit { t.Errorf("Expected to use resource type `git` for but got %s", r.Spec.Type) } } else { @@ -166,47 +166,49 @@ func TestResolveTaskRun(t *testing.T) { } func TestResolveTaskRun_missingOutput(t *testing.T) { - outputs := []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + outputs := []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "repoToUpdate", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "another-git-repo", }, }}} - gr := func(n string) (*v1alpha1.PipelineResource, error) { return nil, errors.New("nope") } - _, err := ResolveTaskResources(&v1alpha1.TaskSpec{}, "orchestrate", v1alpha1.NamespacedTaskKind, []v1alpha1.TaskResourceBinding{}, outputs, gr) + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { return nil, errors.New("nope") } + _, err := ResolveTaskResources(&v1beta1.TaskSpec{}, "orchestrate", v1beta1.NamespacedTaskKind, []v1beta1.TaskResourceBinding{}, outputs, gr) if err == nil { t.Fatalf("Expected to get error because output resource couldn't be resolved") } } func TestResolveTaskRun_missingInput(t *testing.T) { - inputs := []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + inputs := []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "repoToBuildFrom", - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "git-repo", }, }}} - gr := func(n string) (*v1alpha1.PipelineResource, error) { return nil, errors.New("nope") } + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { return nil, errors.New("nope") } - _, err := ResolveTaskResources(&v1alpha1.TaskSpec{}, "orchestrate", v1alpha1.NamespacedTaskKind, inputs, []v1alpha1.TaskResourceBinding{}, gr) + _, err := ResolveTaskResources(&v1beta1.TaskSpec{}, "orchestrate", v1beta1.NamespacedTaskKind, inputs, []v1beta1.TaskResourceBinding{}, gr) if err == nil { t.Fatalf("Expected to get error because output resource couldn't be resolved") } } func TestResolveTaskRun_noResources(t *testing.T) { - taskSpec := v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + taskSpec := v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "step1", - }}}, - }} + }}, + }} - gr := func(n string) (*v1alpha1.PipelineResource, error) { return &v1alpha1.PipelineResource{}, nil } + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { + return &resourcev1alpha1.PipelineResource{}, nil + } - rtr, err := ResolveTaskResources(&taskSpec, "orchestrate", v1alpha1.NamespacedTaskKind, []v1alpha1.TaskResourceBinding{}, []v1alpha1.TaskResourceBinding{}, gr) + rtr, err := ResolveTaskResources(&taskSpec, "orchestrate", v1beta1.NamespacedTaskKind, []v1beta1.TaskResourceBinding{}, []v1beta1.TaskResourceBinding{}, gr) if err != nil { t.Fatalf("Did not expect error trying to resolve TaskRun: %s", err) } @@ -227,52 +229,56 @@ func TestResolveTaskRun_noResources(t *testing.T) { } func TestResolveTaskRun_InvalidBothSpecified(t *testing.T) { - inputs := []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + inputs := []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "repoToBuildFrom", // Can't specify both ResourceRef and ResourceSpec - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "git-repo", }, - ResourceSpec: &v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, + ResourceSpec: &resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, }, }, }} - gr := func(n string) (*v1alpha1.PipelineResource, error) { return &v1alpha1.PipelineResource{}, nil } + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { + return &resourcev1alpha1.PipelineResource{}, nil + } - _, err := ResolveTaskResources(&v1alpha1.TaskSpec{}, "orchestrate", v1alpha1.NamespacedTaskKind, inputs, []v1alpha1.TaskResourceBinding{}, gr) + _, err := ResolveTaskResources(&v1beta1.TaskSpec{}, "orchestrate", v1beta1.NamespacedTaskKind, inputs, []v1beta1.TaskResourceBinding{}, gr) if err == nil { t.Fatalf("Expected to get error because both ref and spec were used") } } func TestResolveTaskRun_InvalidNeitherSpecified(t *testing.T) { - inputs := []v1alpha1.TaskResourceBinding{{ - PipelineResourceBinding: v1alpha1.PipelineResourceBinding{ + inputs := []v1beta1.TaskResourceBinding{{ + PipelineResourceBinding: v1beta1.PipelineResourceBinding{ Name: "repoToBuildFrom", }, }} - gr := func(n string) (*v1alpha1.PipelineResource, error) { return &v1alpha1.PipelineResource{}, nil } + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { + return &resourcev1alpha1.PipelineResource{}, nil + } - _, err := ResolveTaskResources(&v1alpha1.TaskSpec{}, "orchestrate", v1alpha1.NamespacedTaskKind, inputs, []v1alpha1.TaskResourceBinding{}, gr) + _, err := ResolveTaskResources(&v1beta1.TaskSpec{}, "orchestrate", v1beta1.NamespacedTaskKind, inputs, []v1beta1.TaskResourceBinding{}, gr) if err == nil { t.Fatalf("Expected to get error because neither spec or ref were used") } } func TestGetResourceFromBinding_Ref(t *testing.T) { - r := &v1alpha1.PipelineResource{ + r := &resourcev1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: "git-repo", }, } - binding := &v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + binding := &v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "foo-resource", }, } - gr := func(n string) (*v1alpha1.PipelineResource, error) { + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { return r, nil } @@ -286,16 +292,16 @@ func TestGetResourceFromBinding_Ref(t *testing.T) { } func TestGetResourceFromBinding_Spec(t *testing.T) { - binding := &v1alpha1.PipelineResourceBinding{ - ResourceSpec: &v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, - Params: []v1alpha1.ResourceParam{{ + binding := &v1beta1.PipelineResourceBinding{ + ResourceSpec: &resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, + Params: []v1beta1.ResourceParam{{ Name: "url", Value: "github.com/mycoolorg/mycoolrepo", }}, }, } - gr := func(n string) (*v1alpha1.PipelineResource, error) { + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { return nil, fmt.Errorf("shouldnt be called! but was for %s", n) } @@ -303,7 +309,7 @@ func TestGetResourceFromBinding_Spec(t *testing.T) { if err != nil { t.Fatalf("Did not expect error trying to get resource from binding: %s", err) } - if rr.Spec.Type != v1alpha1.PipelineResourceTypeGit { + if rr.Spec.Type != resourcev1alpha1.PipelineResourceTypeGit { t.Errorf("Got %s instead of expected resource type", rr.Spec.Type) } if len(rr.Spec.Params) != 1 || rr.Spec.Params[0].Name != "url" || rr.Spec.Params[0].Value != "github.com/mycoolorg/mycoolrepo" { @@ -312,8 +318,8 @@ func TestGetResourceFromBinding_Spec(t *testing.T) { } func TestGetResourceFromBinding_NoNameOrSpec(t *testing.T) { - binding := &v1alpha1.PipelineResourceBinding{} - gr := func(n string) (*v1alpha1.PipelineResource, error) { + binding := &v1beta1.PipelineResourceBinding{} + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { return nil, nil } @@ -324,19 +330,19 @@ func TestGetResourceFromBinding_NoNameOrSpec(t *testing.T) { } func TestGetResourceFromBinding_NameAndSpec(t *testing.T) { - binding := &v1alpha1.PipelineResourceBinding{ - ResourceSpec: &v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, - Params: []v1alpha1.ResourceParam{{ + binding := &v1beta1.PipelineResourceBinding{ + ResourceSpec: &resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, + Params: []v1beta1.ResourceParam{{ Name: "url", Value: "github.com/mycoolorg/mycoolrepo", }}, }, - ResourceRef: &v1alpha1.PipelineResourceRef{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "foo-resource", }, } - gr := func(n string) (*v1alpha1.PipelineResource, error) { + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { return nil, nil } @@ -347,12 +353,12 @@ func TestGetResourceFromBinding_NameAndSpec(t *testing.T) { } func TestGetResourceFromBinding_ErrorGettingResource(t *testing.T) { - binding := &v1alpha1.PipelineResourceBinding{ - ResourceRef: &v1alpha1.PipelineResourceRef{ + binding := &v1beta1.PipelineResourceBinding{ + ResourceRef: &v1beta1.PipelineResourceRef{ Name: "foo-resource", }, } - gr := func(n string) (*v1alpha1.PipelineResource, error) { + gr := func(n string) (*resourcev1alpha1.PipelineResource, error) { return nil, fmt.Errorf("it has all gone wrong") } _, err := GetResourceFromBinding(binding, gr) diff --git a/pkg/reconciler/taskrun/resources/taskspec.go b/pkg/reconciler/taskrun/resources/taskspec.go index 155cdd4ac00..2f27002d2c4 100644 --- a/pkg/reconciler/taskrun/resources/taskspec.go +++ b/pkg/reconciler/taskrun/resources/taskspec.go @@ -20,25 +20,24 @@ import ( "context" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/contexts" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // GetTask is a function used to retrieve Tasks. -type GetTask func(string) (v1alpha1.TaskInterface, error) -type GetTaskRun func(string) (*v1alpha1.TaskRun, error) +type GetTask func(string) (v1beta1.TaskInterface, error) +type GetTaskRun func(string) (*v1beta1.TaskRun, error) // GetClusterTask is a function that will retrieve the Task from name and namespace. -type GetClusterTask func(name string) (v1alpha1.TaskInterface, error) +type GetClusterTask func(name string) (v1beta1.TaskInterface, 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 *v1alpha1.TaskRun, getTask GetTask) (*metav1.ObjectMeta, *v1alpha1.TaskSpec, error) { +func GetTaskData(ctx context.Context, taskRun *v1beta1.TaskRun, getTask GetTask) (*metav1.ObjectMeta, *v1beta1.TaskSpec, error) { taskMeta := metav1.ObjectMeta{} - taskSpec := v1alpha1.TaskSpec{} + taskSpec := v1beta1.TaskSpec{} switch { case taskRun.Spec.TaskRef != nil && taskRun.Spec.TaskRef.Name != "": // Get related task for taskrun @@ -49,10 +48,6 @@ func GetTaskData(ctx context.Context, taskRun *v1alpha1.TaskRun, getTask GetTask taskMeta = t.TaskMetadata() taskSpec = t.TaskSpec() taskSpec.SetDefaults(contexts.WithUpgradeViaDefaulting(ctx)) - - if err := taskSpec.ConvertTo(ctx, &v1beta1.TaskSpec{}); err != nil { - return nil, nil, err - } case taskRun.Spec.TaskSpec != nil: taskMeta = taskRun.ObjectMeta taskSpec = *taskRun.Spec.TaskSpec diff --git a/pkg/reconciler/taskrun/resources/taskspec_test.go b/pkg/reconciler/taskrun/resources/taskspec_test.go index 5b71476fce3..2a1d6ab179b 100644 --- a/pkg/reconciler/taskrun/resources/taskspec_test.go +++ b/pkg/reconciler/taskrun/resources/taskspec_test.go @@ -21,34 +21,33 @@ import ( "errors" "testing" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestGetTaskSpec_Ref(t *testing.T) { - task := &v1alpha1.Task{ + task := &v1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "orchestrate", }, - Spec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + Spec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "step1", }}}, - }}, + }, } - tr := &v1alpha1.TaskRun{ + tr := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "orchestrate", }, }, } - gt := func(n string) (v1alpha1.TaskInterface, error) { return task, nil } + gt := func(n string) (v1beta1.TaskInterface, error) { return task, nil } taskMeta, taskSpec, err := GetTaskData(context.Background(), tr, gt) if err != nil { @@ -65,19 +64,19 @@ func TestGetTaskSpec_Ref(t *testing.T) { } func TestGetTaskSpec_Embedded(t *testing.T) { - tr := &v1alpha1.TaskRun{ + tr := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, - Spec: v1alpha1.TaskRunSpec{ - TaskSpec: &v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ + Spec: v1beta1.TaskRunSpec{ + TaskSpec: &v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ Name: "step1", }}}, - }}, + }, }, } - gt := func(n string) (v1alpha1.TaskInterface, error) { return nil, errors.New("shouldn't be called") } + gt := func(n string) (v1beta1.TaskInterface, error) { return nil, errors.New("shouldn't be called") } taskMeta, taskSpec, err := GetTaskData(context.Background(), tr, gt) if err != nil { @@ -94,12 +93,12 @@ func TestGetTaskSpec_Embedded(t *testing.T) { } func TestGetTaskSpec_Invalid(t *testing.T) { - tr := &v1alpha1.TaskRun{ + tr := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, } - gt := func(n string) (v1alpha1.TaskInterface, error) { return nil, errors.New("shouldn't be called") } + gt := func(n string) (v1beta1.TaskInterface, error) { return nil, errors.New("shouldn't be called") } _, _, err := GetTaskData(context.Background(), tr, gt) if err == nil { t.Fatalf("Expected error resolving spec with no embedded or referenced task spec but didn't get error") @@ -107,17 +106,17 @@ func TestGetTaskSpec_Invalid(t *testing.T) { } func TestGetTaskSpec_Error(t *testing.T) { - tr := &v1alpha1.TaskRun{ + tr := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ Name: "mytaskrun", }, - Spec: v1alpha1.TaskRunSpec{ - TaskRef: &v1alpha1.TaskRef{ + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ Name: "orchestrate", }, }, } - gt := func(n string) (v1alpha1.TaskInterface, error) { return nil, errors.New("something went wrong") } + gt := func(n string) (v1beta1.TaskInterface, error) { return nil, errors.New("something went wrong") } _, _, err := GetTaskData(context.Background(), tr, gt) if err == nil { t.Fatalf("Expected error when unable to find referenced Task but got none") diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index f51c4cb2078..0175b0aa4cd 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -26,10 +26,10 @@ import ( "github.com/hashicorp/go-multierror" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource" - listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" + listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" resourcelisters "github.com/tektoncd/pipeline/pkg/client/resource/listers/resource/v1alpha1" "github.com/tektoncd/pipeline/pkg/contexts" podconvert "github.com/tektoncd/pipeline/pkg/pod" @@ -216,14 +216,14 @@ func (c *Reconciler) Reconcile(ctx context.Context, key string) error { return multierror.Append(err, c.updateStatusLabelsAndAnnotations(tr, original)).ErrorOrNil() } -func (c *Reconciler) getTaskResolver(tr *v1alpha1.TaskRun) (*resources.LocalTaskRefResolver, v1alpha1.TaskKind) { +func (c *Reconciler) getTaskResolver(tr *v1beta1.TaskRun) (*resources.LocalTaskRefResolver, v1beta1.TaskKind) { resolver := &resources.LocalTaskRefResolver{ Namespace: tr.Namespace, Tektonclient: c.PipelineClientSet, } - kind := v1alpha1.NamespacedTaskKind - if tr.Spec.TaskRef != nil && tr.Spec.TaskRef.Kind == v1alpha1.ClusterTaskKind { - kind = v1alpha1.ClusterTaskKind + kind := v1beta1.NamespacedTaskKind + if tr.Spec.TaskRef != nil && tr.Spec.TaskRef.Kind == v1beta1.ClusterTaskKind { + kind = v1beta1.ClusterTaskKind } resolver.Kind = kind return resolver, kind @@ -239,19 +239,11 @@ func (c *Reconciler) getTaskResolver(tr *v1alpha1.TaskRun) (*resources.LocalTask // `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 *v1alpha1.TaskRun) (*v1alpha1.TaskSpec, *resources.ResolvedTaskResources, error) { +func (c *Reconciler) prepare(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1.TaskSpec, *resources.ResolvedTaskResources, error) { // We may be reading a version of the object that was stored at an older version // and may not have had all of the assumed default specified. tr.SetDefaults(contexts.WithUpgradeViaDefaulting(ctx)) - if err := tr.ConvertTo(ctx, &v1beta1.TaskRun{}); err != nil { - if ce, ok := err.(*v1beta1.CannotConvertError); ok { - tr.Status.MarkResourceNotConvertible(ce) - return nil, nil, nil - } - return nil, nil, err - } - resolver, kind := c.getTaskResolver(tr) taskMeta, taskSpec, err := resources.GetTaskData(ctx, tr, resolver.GetTask) if err != nil { @@ -320,7 +312,7 @@ func (c *Reconciler) prepare(ctx context.Context, tr *v1alpha1.TaskRun) (*v1alph // FIXME(afrittoli) This resource specific logic will have to be replaced // once we have a custom PipelineResource framework in place. c.Logger.Infof("Cloud Events: %s", tr.Status.CloudEvents) - prs := make([]*v1alpha1.PipelineResource, 0, len(rtr.Outputs)) + prs := make([]*resourcev1alpha1.PipelineResource, 0, len(rtr.Outputs)) for _, pr := range rtr.Outputs { prs = append(prs, pr) } @@ -334,8 +326,8 @@ func (c *Reconciler) prepare(ctx context.Context, tr *v1alpha1.TaskRun) (*v1alph // 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 *v1alpha1.TaskRun, - taskSpec *v1alpha1.TaskSpec, rtr *resources.ResolvedTaskResources) error { +func (c *Reconciler) reconcile(ctx context.Context, tr *v1beta1.TaskRun, + taskSpec *v1beta1.TaskSpec, rtr *resources.ResolvedTaskResources) error { // Get the TaskRun's Pod if it should have one. Otherwise, create the Pod. var pod *corev1.Pod var err error @@ -417,7 +409,7 @@ func (c *Reconciler) reconcile(ctx context.Context, tr *v1alpha1.TaskRun, // Push changes (if any) to the TaskRun status, labels and annotations to // TaskRun definition in ectd -func (c *Reconciler) updateStatusLabelsAndAnnotations(tr, original *v1alpha1.TaskRun) error { +func (c *Reconciler) updateStatusLabelsAndAnnotations(tr, original *v1beta1.TaskRun) error { var updated bool if !equality.Semantic.DeepEqual(original.Status, tr.Status) { @@ -456,19 +448,19 @@ func (c *Reconciler) updateStatusLabelsAndAnnotations(tr, original *v1alpha1.Tas return nil } -func (c *Reconciler) updateStatus(taskrun *v1alpha1.TaskRun) (*v1alpha1.TaskRun, error) { +func (c *Reconciler) updateStatus(taskrun *v1beta1.TaskRun) (*v1beta1.TaskRun, error) { newtaskrun, err := c.taskRunLister.TaskRuns(taskrun.Namespace).Get(taskrun.Name) if err != nil { return nil, fmt.Errorf("error getting TaskRun %s when updating status: %w", taskrun.Name, err) } if !reflect.DeepEqual(taskrun.Status, newtaskrun.Status) { newtaskrun.Status = taskrun.Status - return c.PipelineClientSet.TektonV1alpha1().TaskRuns(taskrun.Namespace).UpdateStatus(newtaskrun) + return c.PipelineClientSet.TektonV1beta1().TaskRuns(taskrun.Namespace).UpdateStatus(newtaskrun) } return newtaskrun, nil } -func (c *Reconciler) updateLabelsAndAnnotations(tr *v1alpha1.TaskRun) (*v1alpha1.TaskRun, error) { +func (c *Reconciler) updateLabelsAndAnnotations(tr *v1beta1.TaskRun) (*v1beta1.TaskRun, error) { newTr, err := c.taskRunLister.TaskRuns(tr.Namespace).Get(tr.Name) if err != nil { return nil, fmt.Errorf("error getting TaskRun %s when updating labels/annotations: %w", tr.Name, err) @@ -476,12 +468,12 @@ func (c *Reconciler) updateLabelsAndAnnotations(tr *v1alpha1.TaskRun) (*v1alpha1 if !reflect.DeepEqual(tr.ObjectMeta.Labels, newTr.ObjectMeta.Labels) || !reflect.DeepEqual(tr.ObjectMeta.Annotations, newTr.ObjectMeta.Annotations) { newTr.ObjectMeta.Labels = tr.ObjectMeta.Labels newTr.ObjectMeta.Annotations = tr.ObjectMeta.Annotations - return c.PipelineClientSet.TektonV1alpha1().TaskRuns(tr.Namespace).Update(newTr) + return c.PipelineClientSet.TektonV1beta1().TaskRuns(tr.Namespace).Update(newTr) } return newTr, nil } -func (c *Reconciler) handlePodCreationError(tr *v1alpha1.TaskRun, err error) { +func (c *Reconciler) handlePodCreationError(tr *v1beta1.TaskRun, err error) { var msg string if isExceededResourceQuotaError(err) { backoff, currentlyBackingOff := c.timeoutHandler.GetBackoff(tr) @@ -514,7 +506,7 @@ func (c *Reconciler) handlePodCreationError(tr *v1alpha1.TaskRun, err error) { // 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(tr *v1alpha1.TaskRun, reason, message string) error { +func (c *Reconciler) failTaskRun(tr *v1beta1.TaskRun, reason, message string) error { c.Logger.Warn("stopping task run %q because of %q", tr.Name, reason) tr.Status.MarkResourceFailed(reason, errors.New(message)) @@ -541,7 +533,7 @@ func (c *Reconciler) failTaskRun(tr *v1alpha1.TaskRun, reason, message string) e // 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(tr *v1alpha1.TaskRun, rtr *resources.ResolvedTaskResources) (*corev1.Pod, error) { +func (c *Reconciler) createPod(tr *v1beta1.TaskRun, rtr *resources.ResolvedTaskResources) (*corev1.Pod, error) { ts := rtr.TaskSpec.DeepCopy() inputResources, err := resourceImplBinding(rtr.Inputs, c.Images) if err != nil { @@ -573,7 +565,7 @@ func (c *Reconciler) createPod(tr *v1alpha1.TaskRun, rtr *resources.ResolvedTask return nil, err } - var defaults []v1alpha1.ParamSpec + var defaults []v1beta1.ParamSpec if len(ts.Params) > 0 { defaults = append(defaults, ts.Params...) } @@ -612,7 +604,7 @@ func (c *Reconciler) createPod(tr *v1alpha1.TaskRun, rtr *resources.ResolvedTask type DeletePod func(podName string, options *metav1.DeleteOptions) error -func updateTaskRunResourceResult(taskRun *v1alpha1.TaskRun, podStatus corev1.PodStatus) error { +func updateTaskRunResourceResult(taskRun *v1beta1.TaskRun, podStatus corev1.PodStatus) error { if taskRun.IsSuccessful() { for idx, cs := range podStatus.ContainerStatuses { if cs.State.Terminated != nil { @@ -630,18 +622,18 @@ func updateTaskRunResourceResult(taskRun *v1alpha1.TaskRun, podStatus corev1.Pod return nil } -func getResults(results []v1alpha1.PipelineResourceResult) ([]v1alpha1.TaskRunResult, []v1alpha1.PipelineResourceResult) { - var taskResults []v1alpha1.TaskRunResult - var pipelineResourceResults []v1alpha1.PipelineResourceResult +func getResults(results []v1beta1.PipelineResourceResult) ([]v1beta1.TaskRunResult, []v1beta1.PipelineResourceResult) { + var taskResults []v1beta1.TaskRunResult + var pipelineResourceResults []v1beta1.PipelineResourceResult for _, r := range results { switch r.ResultType { - case v1alpha1.TaskRunResultType: - taskRunResult := v1alpha1.TaskRunResult{ + case v1beta1.TaskRunResultType: + taskRunResult := v1beta1.TaskRunResult{ Name: r.Key, Value: r.Value, } taskResults = append(taskResults, taskRunResult) - case v1alpha1.PipelineResourceResultType: + case v1beta1.PipelineResourceResultType: fallthrough default: pipelineResourceResults = append(pipelineResourceResults, r) @@ -655,8 +647,8 @@ func isExceededResourceQuotaError(err error) bool { } // resourceImplBinding maps pipeline resource names to the actual resource type implementations -func resourceImplBinding(resources map[string]*v1alpha1.PipelineResource, images pipeline.Images) (map[string]v1alpha1.PipelineResourceInterface, error) { - p := make(map[string]v1alpha1.PipelineResourceInterface) +func resourceImplBinding(resources map[string]*resourcev1alpha1.PipelineResource, images pipeline.Images) (map[string]v1beta1.PipelineResourceInterface, error) { + p := make(map[string]v1beta1.PipelineResourceInterface) for rName, r := range resources { i, err := resource.FromType(r, images) if err != nil { @@ -668,7 +660,7 @@ func resourceImplBinding(resources map[string]*v1alpha1.PipelineResource, images } // getLabelSelector get label of centain taskrun -func getLabelSelector(tr *v1alpha1.TaskRun) string { +func getLabelSelector(tr *v1beta1.TaskRun) string { labels := []string{} labelsMap := podconvert.MakeLabels(tr) for key, value := range labelsMap { @@ -679,8 +671,8 @@ func getLabelSelector(tr *v1alpha1.TaskRun) string { // updateStoppedSidecarStatus updates SidecarStatus for sidecars that were // terminated by nop image -func updateStoppedSidecarStatus(pod *corev1.Pod, tr *v1alpha1.TaskRun, c *Reconciler) error { - tr.Status.Sidecars = []v1alpha1.SidecarState{} +func updateStoppedSidecarStatus(pod *corev1.Pod, tr *v1beta1.TaskRun, c *Reconciler) error { + tr.Status.Sidecars = []v1beta1.SidecarState{} for _, s := range pod.Status.ContainerStatuses { if !podconvert.IsContainerStep(s.Name) { var sidecarState corev1.ContainerState @@ -702,7 +694,7 @@ func updateStoppedSidecarStatus(pod *corev1.Pod, tr *v1alpha1.TaskRun, c *Reconc sidecarState = s.State } - tr.Status.Sidecars = append(tr.Status.Sidecars, v1alpha1.SidecarState{ + tr.Status.Sidecars = append(tr.Status.Sidecars, v1beta1.SidecarState{ ContainerState: *sidecarState.DeepCopy(), Name: podconvert.TrimSidecarPrefix(s.Name), ContainerName: s.Name, @@ -715,8 +707,8 @@ func updateStoppedSidecarStatus(pod *corev1.Pod, tr *v1alpha1.TaskRun, c *Reconc } // apply VolumeClaimTemplates and return WorkspaceBindings were templates is translated to PersistentVolumeClaims -func applyVolumeClaimTemplates(workspaceBindings []v1alpha1.WorkspaceBinding, owner metav1.OwnerReference) []v1alpha1.WorkspaceBinding { - taskRunWorkspaceBindings := make([]v1alpha1.WorkspaceBinding, 0) +func applyVolumeClaimTemplates(workspaceBindings []v1beta1.WorkspaceBinding, owner metav1.OwnerReference) []v1beta1.WorkspaceBinding { + taskRunWorkspaceBindings := make([]v1beta1.WorkspaceBinding, 0) for _, wb := range workspaceBindings { if wb.VolumeClaimTemplate == nil { taskRunWorkspaceBindings = append(taskRunWorkspaceBindings, wb) @@ -724,7 +716,7 @@ func applyVolumeClaimTemplates(workspaceBindings []v1alpha1.WorkspaceBinding, ow } // apply template - b := v1alpha1.WorkspaceBinding{ + b := v1beta1.WorkspaceBinding{ Name: wb.Name, SubPath: wb.SubPath, PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ @@ -736,11 +728,10 @@ func applyVolumeClaimTemplates(workspaceBindings []v1alpha1.WorkspaceBinding, ow return taskRunWorkspaceBindings } -func storeTaskSpec(ctx context.Context, tr *v1alpha1.TaskRun, ts *v1alpha1.TaskSpec) error { +func storeTaskSpec(ctx context.Context, tr *v1beta1.TaskRun, ts *v1beta1.TaskSpec) error { // Only store the TaskSpec once, if it has never been set before. if tr.Status.TaskSpec == nil { - tr.Status.TaskSpec = &v1beta1.TaskSpec{} - return ts.ConvertTo(ctx, tr.Status.TaskSpec) + tr.Status.TaskSpec = ts } return nil } diff --git a/pkg/reconciler/taskrun/taskrun_test.go b/pkg/reconciler/taskrun/taskrun_test.go index a5533fda5bd..7d4845bd477 100644 --- a/pkg/reconciler/taskrun/taskrun_test.go +++ b/pkg/reconciler/taskrun/taskrun_test.go @@ -26,21 +26,19 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" podconvert "github.com/tektoncd/pipeline/pkg/pod" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources/cloudevent" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" "github.com/tektoncd/pipeline/pkg/system" + test "github.com/tektoncd/pipeline/test" "github.com/tektoncd/pipeline/test/names" - test "github.com/tektoncd/pipeline/test/v1alpha1" corev1 "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" "k8s.io/apimachinery/pkg/runtime" @@ -60,7 +58,7 @@ const ( clusterTaskNameLabelKey = pipeline.GroupName + pipeline.ClusterTaskLabelKey taskRunNameLabelKey = pipeline.GroupName + pipeline.TaskRunLabelKey workspaceDir = "/workspace" - currentAPIVersion = "tekton.dev/v1alpha1" + currentAPIVersion = "tekton.dev/v1beta1" ) var ( @@ -113,23 +111,24 @@ var ( ), tb.TaskNamespace("foo")) outputTask = tb.Task("test-output-task", tb.TaskSpec( - simpleStep, tb.TaskInputs( - tb.InputsResource(gitResource.Name, v1alpha1.PipelineResourceTypeGit), - tb.InputsResource(anotherGitResource.Name, v1alpha1.PipelineResourceTypeGit), + simpleStep, tb.TaskResources( + tb.TaskResourcesInput(gitResource.Name, resourcev1alpha1.PipelineResourceTypeGit), + tb.TaskResourcesInput(anotherGitResource.Name, resourcev1alpha1.PipelineResourceTypeGit), ), - tb.TaskOutputs(tb.OutputsResource(gitResource.Name, v1alpha1.PipelineResourceTypeGit)), + tb.TaskResources(tb.TaskResourcesOutput(gitResource.Name, resourcev1alpha1.PipelineResourceTypeGit)), )) saTask = tb.Task("test-with-sa", tb.TaskSpec(tb.Step("foo", tb.StepName("sa-step"), tb.StepCommand("/mycmd"))), tb.TaskNamespace("foo")) templatedTask = tb.Task("test-task-with-substitution", tb.TaskSpec( - tb.TaskInputs( - tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit), - tb.InputsParamSpec("myarg", v1alpha1.ParamTypeString), tb.InputsParamSpec("myarghasdefault", v1alpha1.ParamTypeString, tb.ParamSpecDefault("dont see me")), - tb.InputsParamSpec("myarghasdefault2", v1alpha1.ParamTypeString, tb.ParamSpecDefault("thedefault")), - tb.InputsParamSpec("configmapname", v1alpha1.ParamTypeString), + tb.TaskParam("myarg", v1beta1.ParamTypeString), + tb.TaskParam("myarghasdefault", v1beta1.ParamTypeString, tb.ParamSpecDefault("dont see me")), + tb.TaskParam("myarghasdefault2", v1beta1.ParamTypeString, tb.ParamSpecDefault("thedefault")), + tb.TaskParam("configmapname", v1beta1.ParamTypeString), + tb.TaskResources( + tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit), + tb.TaskResourcesOutput("myimage", resourcev1alpha1.PipelineResourceTypeImage), ), - tb.TaskOutputs(tb.OutputsResource("myimage", v1alpha1.PipelineResourceTypeImage)), tb.Step("myimage", tb.StepName("mycontainer"), tb.StepCommand("/mycmd"), tb.StepArgs( "--my-arg=$(inputs.params.myarg)", "--my-arg-with-default=$(inputs.params.myarghasdefault)", @@ -149,26 +148,26 @@ var ( ), tb.TaskNamespace("foo")) twoOutputsTask = tb.Task("test-two-output-task", tb.TaskSpec( - simpleStep, tb.TaskOutputs( - tb.OutputsResource(cloudEventResource.Name, v1alpha1.PipelineResourceTypeCloudEvent), - tb.OutputsResource(anotherCloudEventResource.Name, v1alpha1.PipelineResourceTypeCloudEvent), + simpleStep, tb.TaskResources( + tb.TaskResourcesOutput(cloudEventResource.Name, resourcev1alpha1.PipelineResourceTypeCloudEvent), + tb.TaskResourcesOutput(anotherCloudEventResource.Name, resourcev1alpha1.PipelineResourceTypeCloudEvent), ), ), tb.TaskNamespace("foo")) gitResource = tb.PipelineResource("git-resource", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("URL", "https://foo.git"), + resourcev1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("URL", "https://foo.git"), )) anotherGitResource = tb.PipelineResource("another-git-resource", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("URL", "https://foobar.git"), + resourcev1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("URL", "https://foobar.git"), )) imageResource = tb.PipelineResource("image-resource", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeImage, tb.PipelineResourceSpecParam("URL", "gcr.io/kristoff/sven"), + resourcev1alpha1.PipelineResourceTypeImage, tb.PipelineResourceSpecParam("URL", "gcr.io/kristoff/sven"), )) cloudEventResource = tb.PipelineResource("cloud-event-resource", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeCloudEvent, tb.PipelineResourceSpecParam("TargetURI", cloudEventTarget1), + resourcev1alpha1.PipelineResourceTypeCloudEvent, tb.PipelineResourceSpecParam("TargetURI", cloudEventTarget1), )) anotherCloudEventResource = tb.PipelineResource("another-cloud-event-resource", tb.PipelineResourceNamespace("foo"), tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeCloudEvent, tb.PipelineResourceSpecParam("TargetURI", cloudEventTarget2), + resourcev1alpha1.PipelineResourceTypeCloudEvent, tb.PipelineResourceSpecParam("TargetURI", cloudEventTarget2), )) toolsVolume = corev1.Volume{ @@ -250,7 +249,7 @@ var ( } ) -func getRunName(tr *v1alpha1.TaskRun) string { +func getRunName(tr *v1beta1.TaskRun) string { return strings.Join([]string{tr.Namespace, tr.Name}, "/") } @@ -311,10 +310,10 @@ func TestReconcile_ExplicitDefaultSA(t *testing.T) { tb.TaskRunTaskRef(saTask.Name, tb.TaskRefAPIVersion("a1")), tb.TaskRunServiceAccountName("test-sa"), )) - taskruns := []*v1alpha1.TaskRun{taskRunSuccess, taskRunWithSaSuccess} + taskruns := []*v1beta1.TaskRun{taskRunSuccess, taskRunWithSaSuccess} d := test.Data{ TaskRuns: taskruns, - Tasks: []*v1alpha1.Task{simpleTask, saTask}, + Tasks: []*v1beta1.Task{simpleTask, saTask}, } defaultSAName := "pipelines" @@ -328,7 +327,7 @@ func TestReconcile_ExplicitDefaultSA(t *testing.T) { for _, tc := range []struct { name string - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun wantPod *corev1.Pod }{{ name: "success", @@ -443,7 +442,7 @@ func TestReconcile_ExplicitDefaultSA(t *testing.T) { t.Errorf("Invalid resource key: %v", err) } - tr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(namespace).Get(name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(namespace).Get(name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -487,31 +486,29 @@ func TestReconcile(t *testing.T) { )) taskRunSubstitution := tb.TaskRun("test-taskrun-substitution", tb.TaskRunNamespace("foo"), tb.TaskRunSpec( tb.TaskRunTaskRef(templatedTask.Name, tb.TaskRefAPIVersion("a1")), - tb.TaskRunInputs( - tb.TaskRunInputsParam("myarg", "foo"), - tb.TaskRunInputsParam("myarghasdefault", "bar"), - tb.TaskRunInputsParam("configmapname", "configbar"), - tb.TaskRunInputsResource("workspace", tb.TaskResourceBindingRef(gitResource.Name)), + tb.TaskRunParam("myarg", "foo"), + tb.TaskRunParam("myarghasdefault", "bar"), + tb.TaskRunParam("configmapname", "configbar"), + tb.TaskRunResources( + tb.TaskRunResourcesInput("workspace", tb.TaskResourceBindingRef(gitResource.Name)), + tb.TaskRunResourcesOutput("myimage", tb.TaskResourceBindingRef("image-resource")), ), - tb.TaskRunOutputs(tb.TaskRunOutputsResource("myimage", tb.TaskResourceBindingRef("image-resource"))), )) taskRunInputOutput := tb.TaskRun("test-taskrun-input-output", tb.TaskRunNamespace("foo"), tb.TaskRunOwnerReference("PipelineRun", "test"), tb.TaskRunSpec( tb.TaskRunTaskRef(outputTask.Name), - tb.TaskRunInputs( - tb.TaskRunInputsResource(gitResource.Name, + tb.TaskRunResources( + tb.TaskRunResourcesInput(gitResource.Name, tb.TaskResourceBindingRef(gitResource.Name), tb.TaskResourceBindingPaths("source-folder"), ), - tb.TaskRunInputsResource(anotherGitResource.Name, + tb.TaskRunResourcesInput(anotherGitResource.Name, tb.TaskResourceBindingRef(anotherGitResource.Name), tb.TaskResourceBindingPaths("source-folder"), ), - ), - tb.TaskRunOutputs( - tb.TaskRunOutputsResource(gitResource.Name, + tb.TaskRunResourcesOutput(gitResource.Name, tb.TaskResourceBindingRef(gitResource.Name), tb.TaskResourceBindingPaths("output-folder"), ), @@ -519,14 +516,14 @@ func TestReconcile(t *testing.T) { ), ) taskRunWithTaskSpec := tb.TaskRun("test-taskrun-with-taskspec", tb.TaskRunNamespace("foo"), tb.TaskRunSpec( - tb.TaskRunInputs( - tb.TaskRunInputsParam("myarg", "foo"), - tb.TaskRunInputsResource("workspace", tb.TaskResourceBindingRef(gitResource.Name)), + tb.TaskRunParam("myarg", "foo"), + tb.TaskRunResources( + tb.TaskRunResourcesInput("workspace", tb.TaskResourceBindingRef(gitResource.Name)), ), tb.TaskRunTaskSpec( - tb.TaskInputs( - tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit), - tb.InputsParamSpec("myarg", v1alpha1.ParamTypeString, tb.ParamSpecDefault("mydefault")), + tb.TaskParam("myarg", v1beta1.ParamTypeString, tb.ParamSpecDefault("mydefault")), + tb.TaskResources( + tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit), ), tb.Step("myimage", tb.StepName("mycontainer"), tb.StepCommand("/mycmd"), tb.StepArgs("--my-arg=$(inputs.params.myarg)"), @@ -535,10 +532,10 @@ func TestReconcile(t *testing.T) { )) taskRunWithResourceSpecAndTaskSpec := tb.TaskRun("test-taskrun-with-resource-spec", tb.TaskRunNamespace("foo"), tb.TaskRunSpec( - tb.TaskRunInputs( - tb.TaskRunInputsResource("workspace", tb.TaskResourceBindingResourceSpec(&v1alpha1.PipelineResourceSpec{ - Type: v1alpha1.PipelineResourceTypeGit, - Params: []v1alpha1.ResourceParam{{ + tb.TaskRunResources( + tb.TaskRunResourcesInput("workspace", tb.TaskResourceBindingResourceSpec(&resourcev1alpha1.PipelineResourceSpec{ + Type: resourcev1alpha1.PipelineResourceTypeGit, + Params: []v1beta1.ResourceParam{{ Name: "URL", Value: "github.com/foo/bar.git", }, { @@ -548,15 +545,15 @@ func TestReconcile(t *testing.T) { })), ), tb.TaskRunTaskSpec( - tb.TaskInputs( - tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit)), + tb.TaskResources( + tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit)), tb.Step("ubuntu", tb.StepName("mystep"), tb.StepCommand("/mycmd")), ), )) taskRunWithClusterTask := tb.TaskRun("test-taskrun-with-cluster-task", tb.TaskRunNamespace("foo"), - tb.TaskRunSpec(tb.TaskRunTaskRef(clustertask.Name, tb.TaskRefKind(v1alpha1.ClusterTaskKind))), + tb.TaskRunSpec(tb.TaskRunTaskRef(clustertask.Name, tb.TaskRefKind(v1beta1.ClusterTaskKind))), ) taskRunWithLabels := tb.TaskRun("test-taskrun-with-labels", @@ -588,7 +585,7 @@ func TestReconcile(t *testing.T) { ), )) - taskruns := []*v1alpha1.TaskRun{ + taskruns := []*v1beta1.TaskRun{ taskRunSuccess, taskRunWithSaSuccess, taskRunSubstitution, taskRunInputOutput, taskRunWithTaskSpec, taskRunWithClusterTask, taskRunWithResourceSpecAndTaskSpec, @@ -598,13 +595,13 @@ func TestReconcile(t *testing.T) { d := test.Data{ TaskRuns: taskruns, - Tasks: []*v1alpha1.Task{simpleTask, saTask, templatedTask, outputTask}, - ClusterTasks: []*v1alpha1.ClusterTask{clustertask}, - PipelineResources: []*v1alpha1.PipelineResource{gitResource, anotherGitResource, imageResource}, + Tasks: []*v1beta1.Task{simpleTask, saTask, templatedTask, outputTask}, + ClusterTasks: []*v1beta1.ClusterTask{clustertask}, + PipelineResources: []*resourcev1alpha1.PipelineResource{gitResource, anotherGitResource, imageResource}, } for _, tc := range []struct { name string - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun wantPod *corev1.Pod wantEvents []string }{{ @@ -1064,7 +1061,7 @@ func TestReconcile(t *testing.T) { t.Errorf("Invalid resource key: %v", err) } - tr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(namespace).Get(name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(namespace).Get(name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -1110,8 +1107,8 @@ func TestReconcile_SetsStartTime(t *testing.T) { tb.TaskRunTaskRef(simpleTask.Name), )) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRun}, - Tasks: []*v1alpha1.Task{simpleTask}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -1137,8 +1134,8 @@ func TestReconcile_SortTaskRunStatusSteps(t *testing.T) { // spec steps of the Task any more. After Reconcile is called, we should see the order of status // steps in TaksRun has been converted to the same one as in spec steps of the Task. d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRun}, - Tasks: []*v1alpha1.Task{taskMultipleSteps}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{taskMultipleSteps}, Pods: []*corev1.Pod{{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", @@ -1186,7 +1183,7 @@ func TestReconcile_SortTaskRunStatusSteps(t *testing.T) { verifyTaskRunStatusStep(t, taskRun) } -func verifyTaskRunStatusStep(t *testing.T, taskRun *v1alpha1.TaskRun) { +func verifyTaskRunStatusStep(t *testing.T, taskRun *v1beta1.TaskRun) { actualStepOrder := []string{} for _, state := range taskRun.Status.Steps { actualStepOrder = append(actualStepOrder, state.Name) @@ -1212,8 +1209,8 @@ func TestReconcile_DoesntChangeStartTime(t *testing.T) { ), ) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRun}, - Tasks: []*v1alpha1.Task{simpleTask}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{simpleTask}, Pods: []*corev1.Pod{{ ObjectMeta: metav1.ObjectMeta{ Namespace: "foo", @@ -1236,10 +1233,10 @@ func TestReconcile_DoesntChangeStartTime(t *testing.T) { func TestReconcileInvalidTaskRuns(t *testing.T) { noTaskRun := tb.TaskRun("notaskrun", tb.TaskRunNamespace("foo"), tb.TaskRunSpec(tb.TaskRunTaskRef("notask"))) withWrongRef := tb.TaskRun("taskrun-with-wrong-ref", tb.TaskRunNamespace("foo"), tb.TaskRunSpec( - tb.TaskRunTaskRef("taskrun-with-wrong-ref", tb.TaskRefKind(v1alpha1.ClusterTaskKind)), + tb.TaskRunTaskRef("taskrun-with-wrong-ref", tb.TaskRefKind(v1beta1.ClusterTaskKind)), )) - taskRuns := []*v1alpha1.TaskRun{noTaskRun, withWrongRef} - tasks := []*v1alpha1.Task{simpleTask} + taskRuns := []*v1beta1.TaskRun{noTaskRun, withWrongRef} + tasks := []*v1beta1.Task{simpleTask} d := test.Data{ TaskRuns: taskRuns, @@ -1248,7 +1245,7 @@ func TestReconcileInvalidTaskRuns(t *testing.T) { testcases := []struct { name string - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun reason string wantEvents []string }{{ @@ -1317,8 +1314,8 @@ func TestReconcilePodFetchError(t *testing.T) { tb.TaskRunStatus(tb.PodName("will-not-be-found")), ) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRun}, - Tasks: []*v1alpha1.Task{simpleTask}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) @@ -1335,7 +1332,7 @@ func TestReconcilePodFetchError(t *testing.T) { } } -func makePod(taskRun *v1alpha1.TaskRun, task *v1alpha1.Task) (*corev1.Pod, error) { +func makePod(taskRun *v1beta1.TaskRun, task *v1beta1.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 @@ -1365,14 +1362,14 @@ func TestReconcilePodUpdateStatus(t *testing.T) { if err != nil { t.Fatalf("MakePod: %v", err) } - taskRun.Status = v1alpha1.TaskRunStatus{ - TaskRunStatusFields: v1alpha1.TaskRunStatusFields{ + taskRun.Status = v1beta1.TaskRunStatus{ + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ PodName: pod.Name, }, } d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRun}, - Tasks: []*v1alpha1.Task{simpleTask}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{simpleTask}, Pods: []*corev1.Pod{pod}, } @@ -1386,7 +1383,7 @@ func TestReconcilePodUpdateStatus(t *testing.T) { if err := reconciler.Reconcile(context.Background(), getRunName(taskRun)); err != nil { t.Fatalf("Unexpected error when Reconcile() : %v", err) } - newTr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(taskRun.Namespace).Get(taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(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) } @@ -1410,7 +1407,7 @@ func TestReconcilePodUpdateStatus(t *testing.T) { t.Fatalf("Unexpected error when Reconcile(): %v", err) } - newTr, err = clients.Pipeline.TektonV1alpha1().TaskRuns(taskRun.Namespace).Get(taskRun.Name, metav1.GetOptions{}) + newTr, err = clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(taskRun.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Unexpected error fetching taskrun: %v", err) } @@ -1445,10 +1442,10 @@ func TestReconcileOnCompletedTaskRun(t *testing.T) { tb.TaskRunTaskRef(simpleTask.Name), ), tb.TaskRunStatus(tb.StatusCondition(*taskSt))) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{ + TaskRuns: []*v1beta1.TaskRun{ taskRun, }, - Tasks: []*v1alpha1.Task{simpleTask}, + Tasks: []*v1beta1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) @@ -1459,7 +1456,7 @@ func TestReconcileOnCompletedTaskRun(t *testing.T) { if err := c.Reconciler.Reconcile(context.Background(), getRunName(taskRun)); err != nil { t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err) } - newTr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(taskRun.Namespace).Get(taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(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) } @@ -1479,8 +1476,8 @@ func TestReconcileOnCancelledTaskRun(t *testing.T) { Status: corev1.ConditionUnknown, }))) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRun}, - Tasks: []*v1alpha1.Task{simpleTask}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) @@ -1493,7 +1490,7 @@ func TestReconcileOnCancelledTaskRun(t *testing.T) { if err := reconciler.Reconcile(context.Background(), getRunName(taskRun)); err != nil { t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err) } - newTr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(taskRun.Namespace).Get(taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(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) } @@ -1520,7 +1517,7 @@ func TestReconcileOnCancelledTaskRun(t *testing.T) { func TestReconcileTimeouts(t *testing.T) { type testCase struct { - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun expectedStatus *apis.Condition wantEvents []string } @@ -1592,8 +1589,8 @@ func TestReconcileTimeouts(t *testing.T) { for _, tc := range testcases { d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{tc.taskRun}, - Tasks: []*v1alpha1.Task{simpleTask}, + TaskRuns: []*v1beta1.TaskRun{tc.taskRun}, + Tasks: []*v1beta1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -1605,7 +1602,7 @@ func TestReconcileTimeouts(t *testing.T) { if err := c.Reconciler.Reconcile(context.Background(), getRunName(tc.taskRun)); err != nil { t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err) } - newTr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(tc.taskRun.Namespace).Get(tc.taskRun.Name, metav1.GetOptions{}) + newTr, err := clients.Pipeline.TektonV1beta1().TaskRuns(tc.taskRun.Namespace).Get(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) } @@ -1631,8 +1628,8 @@ func TestHandlePodCreationError(t *testing.T) { }), )) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRun}, - Tasks: []*v1alpha1.Task{simpleTask}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{simpleTask}, } testAssets, cancel := getTaskRunController(t, d) defer cancel() @@ -1692,9 +1689,9 @@ func TestReconcileCloudEvents(t *testing.T) { tb.TaskRunNamespace("foo"), tb.TaskRunSpec( tb.TaskRunTaskRef(twoOutputsTask.Name), - tb.TaskRunOutputs( - tb.TaskRunOutputsResource(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), - tb.TaskRunOutputsResource(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), + tb.TaskRunResources( + tb.TaskRunResourcesOutput(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), + tb.TaskRunResourcesOutput(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), ), ), ) @@ -1702,14 +1699,14 @@ func TestReconcileCloudEvents(t *testing.T) { tb.TaskRunNamespace("foo"), tb.TaskRunSpec( tb.TaskRunTaskRef(twoOutputsTask.Name), - tb.TaskRunOutputs( - tb.TaskRunOutputsResource(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), - tb.TaskRunOutputsResource(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), + tb.TaskRunResources( + tb.TaskRunResourcesOutput(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), + tb.TaskRunResourcesOutput(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), ), ), tb.TaskRunStatus( - tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1alpha1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1beta1.CloudEventConditionUnknown), ), ) taskRunWithCESucceded := tb.TaskRun("test-taskrun-ce-succeeded", @@ -1717,9 +1714,9 @@ func TestReconcileCloudEvents(t *testing.T) { tb.TaskRunSelfLink("/task/1234"), tb.TaskRunSpec( tb.TaskRunTaskRef(twoOutputsTask.Name), - tb.TaskRunOutputs( - tb.TaskRunOutputsResource(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), - tb.TaskRunOutputsResource(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), + tb.TaskRunResources( + tb.TaskRunResourcesOutput(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), + tb.TaskRunResourcesOutput(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), ), ), tb.TaskRunStatus( @@ -1727,8 +1724,8 @@ func TestReconcileCloudEvents(t *testing.T) { Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, }), - tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1alpha1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1beta1.CloudEventConditionUnknown), ), ) taskRunWithCEFailed := tb.TaskRun("test-taskrun-ce-failed", @@ -1736,9 +1733,9 @@ func TestReconcileCloudEvents(t *testing.T) { tb.TaskRunSelfLink("/task/1234"), tb.TaskRunSpec( tb.TaskRunTaskRef(twoOutputsTask.Name), - tb.TaskRunOutputs( - tb.TaskRunOutputsResource(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), - tb.TaskRunOutputsResource(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), + tb.TaskRunResources( + tb.TaskRunResourcesOutput(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), + tb.TaskRunResourcesOutput(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), ), ), tb.TaskRunStatus( @@ -1746,8 +1743,8 @@ func TestReconcileCloudEvents(t *testing.T) { Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, }), - tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1alpha1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1beta1.CloudEventConditionUnknown), ), ) taskRunWithCESuccededOneAttempt := tb.TaskRun("test-taskrun-ce-succeeded-one-attempt", @@ -1755,9 +1752,9 @@ func TestReconcileCloudEvents(t *testing.T) { tb.TaskRunSelfLink("/task/1234"), tb.TaskRunSpec( tb.TaskRunTaskRef(twoOutputsTask.Name), - tb.TaskRunOutputs( - tb.TaskRunOutputsResource(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), - tb.TaskRunOutputsResource(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), + tb.TaskRunResources( + tb.TaskRunResourcesOutput(cloudEventResource.Name, tb.TaskResourceBindingRef(cloudEventResource.Name)), + tb.TaskRunResourcesOutput(anotherCloudEventResource.Name, tb.TaskResourceBindingRef(anotherCloudEventResource.Name)), ), ), tb.TaskRunStatus( @@ -1765,11 +1762,11 @@ func TestReconcileCloudEvents(t *testing.T) { Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, }), - tb.TaskRunCloudEvent(cloudEventTarget1, "", 1, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent(cloudEventTarget2, "fakemessage", 0, v1alpha1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget1, "", 1, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget2, "fakemessage", 0, v1beta1.CloudEventConditionUnknown), ), ) - taskruns := []*v1alpha1.TaskRun{ + taskruns := []*v1beta1.TaskRun{ taskRunWithNoCEResources, taskRunWithTwoCEResourcesNoInit, taskRunWithTwoCEResourcesInit, taskRunWithCESucceded, taskRunWithCEFailed, taskRunWithCESuccededOneAttempt, @@ -1777,14 +1774,14 @@ func TestReconcileCloudEvents(t *testing.T) { d := test.Data{ TaskRuns: taskruns, - Tasks: []*v1alpha1.Task{simpleTask, twoOutputsTask}, - ClusterTasks: []*v1alpha1.ClusterTask{}, - PipelineResources: []*v1alpha1.PipelineResource{cloudEventResource, anotherCloudEventResource}, + Tasks: []*v1beta1.Task{simpleTask, twoOutputsTask}, + ClusterTasks: []*v1beta1.ClusterTask{}, + PipelineResources: []*resourcev1alpha1.PipelineResource{cloudEventResource, anotherCloudEventResource}, } for _, tc := range []struct { name string - taskRun *v1alpha1.TaskRun - wantCloudEvents []v1alpha1.CloudEventDelivery + taskRun *v1beta1.TaskRun + wantCloudEvents []v1beta1.CloudEventDelivery }{{ name: "no-ce-resources", taskRun: taskRunWithNoCEResources, @@ -1793,36 +1790,36 @@ func TestReconcileCloudEvents(t *testing.T) { name: "ce-resources-no-init", taskRun: taskRunWithTwoCEResourcesNoInit, wantCloudEvents: tb.TaskRun("want", tb.TaskRunStatus( - tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1alpha1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1beta1.CloudEventConditionUnknown), )).Status.CloudEvents, }, { name: "ce-resources-init", taskRun: taskRunWithTwoCEResourcesInit, wantCloudEvents: tb.TaskRun("want2", tb.TaskRunStatus( - tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1alpha1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget1, "", 0, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget2, "", 0, v1beta1.CloudEventConditionUnknown), )).Status.CloudEvents, }, { name: "ce-resources-init-task-successful", taskRun: taskRunWithCESucceded, wantCloudEvents: tb.TaskRun("want3", tb.TaskRunStatus( - tb.TaskRunCloudEvent(cloudEventTarget1, "", 1, v1alpha1.CloudEventConditionSent), - tb.TaskRunCloudEvent(cloudEventTarget2, "", 1, v1alpha1.CloudEventConditionSent), + tb.TaskRunCloudEvent(cloudEventTarget1, "", 1, v1beta1.CloudEventConditionSent), + tb.TaskRunCloudEvent(cloudEventTarget2, "", 1, v1beta1.CloudEventConditionSent), )).Status.CloudEvents, }, { name: "ce-resources-init-task-failed", taskRun: taskRunWithCEFailed, wantCloudEvents: tb.TaskRun("want4", tb.TaskRunStatus( - tb.TaskRunCloudEvent(cloudEventTarget1, "", 1, v1alpha1.CloudEventConditionSent), - tb.TaskRunCloudEvent(cloudEventTarget2, "", 1, v1alpha1.CloudEventConditionSent), + tb.TaskRunCloudEvent(cloudEventTarget1, "", 1, v1beta1.CloudEventConditionSent), + tb.TaskRunCloudEvent(cloudEventTarget2, "", 1, v1beta1.CloudEventConditionSent), )).Status.CloudEvents, }, { name: "ce-resources-init-task-successful-one-attempt", taskRun: taskRunWithCESuccededOneAttempt, wantCloudEvents: tb.TaskRun("want5", tb.TaskRunStatus( - tb.TaskRunCloudEvent(cloudEventTarget1, "", 1, v1alpha1.CloudEventConditionUnknown), - tb.TaskRunCloudEvent(cloudEventTarget2, "fakemessage", 1, v1alpha1.CloudEventConditionSent), + tb.TaskRunCloudEvent(cloudEventTarget1, "", 1, v1beta1.CloudEventConditionUnknown), + tb.TaskRunCloudEvent(cloudEventTarget2, "fakemessage", 1, v1beta1.CloudEventConditionSent), )).Status.CloudEvents, }} { t.Run(tc.name, func(t *testing.T) { @@ -1853,7 +1850,7 @@ func TestReconcileCloudEvents(t *testing.T) { t.Errorf("Invalid resource key: %v", err) } - tr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(namespace).Get(name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(namespace).Get(name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated taskrun: %v", err) } @@ -1870,8 +1867,8 @@ func TestUpdateTaskRunResourceResult(t *testing.T) { for _, c := range []struct { desc string podStatus corev1.PodStatus - taskRunStatus *v1alpha1.TaskRunStatus - want []v1alpha1.PipelineResourceResult + taskRunStatus *v1beta1.TaskRunStatus + want []resourcev1alpha1.PipelineResourceResult }{{ desc: "image resource updated", podStatus: corev1.PodStatus{ @@ -1883,15 +1880,15 @@ func TestUpdateTaskRunResourceResult(t *testing.T) { }, }}, }, - want: []v1alpha1.PipelineResourceResult{{ + want: []resourcev1alpha1.PipelineResourceResult{{ Key: "digest", Value: "sha256:1234", - ResourceRef: v1alpha1.PipelineResourceRef{Name: "source-image"}, + ResourceRef: resourcev1alpha1.PipelineResourceRef{Name: "source-image"}, }}, }} { t.Run(c.desc, func(t *testing.T) { names.TestingSeed() - tr := &v1alpha1.TaskRun{} + tr := &v1beta1.TaskRun{} tr.Status.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, @@ -1910,9 +1907,9 @@ func TestUpdateTaskRunResult(t *testing.T) { for _, c := range []struct { desc string podStatus corev1.PodStatus - taskRunStatus *v1alpha1.TaskRunStatus - wantResults []v1alpha1.TaskRunResult - want []v1alpha1.PipelineResourceResult + taskRunStatus *v1beta1.TaskRunStatus + wantResults []v1beta1.TaskRunResult + want []resourcev1alpha1.PipelineResourceResult }{{ desc: "test result with pipeline result", podStatus: corev1.PodStatus{ @@ -1924,20 +1921,20 @@ func TestUpdateTaskRunResult(t *testing.T) { }, }}, }, - wantResults: []v1alpha1.TaskRunResult{{ + wantResults: []v1beta1.TaskRunResult{{ Name: "resultName", Value: "resultValue", }}, - want: []v1alpha1.PipelineResourceResult{{ + want: []resourcev1alpha1.PipelineResourceResult{{ Key: "digest", Value: "sha256:1234", - ResourceRef: v1alpha1.PipelineResourceRef{Name: "source-image"}, + ResourceRef: resourcev1alpha1.PipelineResourceRef{Name: "source-image"}, ResultType: "PipelineResourceResult", }}, }} { t.Run(c.desc, func(t *testing.T) { names.TestingSeed() - tr := &v1alpha1.TaskRun{} + tr := &v1beta1.TaskRun{} tr.Status.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, @@ -1959,9 +1956,9 @@ func TestUpdateTaskRunResult2(t *testing.T) { for _, c := range []struct { desc string podStatus corev1.PodStatus - taskRunStatus *v1alpha1.TaskRunStatus - wantResults []v1alpha1.TaskRunResult - want []v1alpha1.PipelineResourceResult + taskRunStatus *v1beta1.TaskRunStatus + wantResults []v1beta1.TaskRunResult + want []resourcev1alpha1.PipelineResourceResult }{{ desc: "test result with pipeline result - no result type", podStatus: corev1.PodStatus{ @@ -1973,19 +1970,19 @@ func TestUpdateTaskRunResult2(t *testing.T) { }, }}, }, - wantResults: []v1alpha1.TaskRunResult{{ + wantResults: []v1beta1.TaskRunResult{{ Name: "resultName", Value: "resultValue", }}, - want: []v1alpha1.PipelineResourceResult{{ + want: []resourcev1alpha1.PipelineResourceResult{{ Key: "digest", Value: "sha256:1234", - ResourceRef: v1alpha1.PipelineResourceRef{Name: "source-image"}, + ResourceRef: resourcev1alpha1.PipelineResourceRef{Name: "source-image"}, }}, }} { t.Run(c.desc, func(t *testing.T) { names.TestingSeed() - tr := &v1alpha1.TaskRun{} + tr := &v1beta1.TaskRun{} tr.Status.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, @@ -2007,8 +2004,8 @@ func TestUpdateTaskRunResultTwoResults(t *testing.T) { for _, c := range []struct { desc string podStatus corev1.PodStatus - taskRunStatus *v1alpha1.TaskRunStatus - want []v1alpha1.TaskRunResult + taskRunStatus *v1beta1.TaskRunStatus + want []v1beta1.TaskRunResult }{{ desc: "two test results", podStatus: corev1.PodStatus{ @@ -2020,7 +2017,7 @@ func TestUpdateTaskRunResultTwoResults(t *testing.T) { }, }}, }, - want: []v1alpha1.TaskRunResult{{ + want: []v1beta1.TaskRunResult{{ Name: "resultNameOne", Value: "resultValueOne", }, { @@ -2030,7 +2027,7 @@ func TestUpdateTaskRunResultTwoResults(t *testing.T) { }} { t.Run(c.desc, func(t *testing.T) { names.TestingSeed() - tr := &v1alpha1.TaskRun{} + tr := &v1beta1.TaskRun{} tr.Status.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, @@ -2049,9 +2046,9 @@ func TestUpdateTaskRunResultWhenTaskFailed(t *testing.T) { for _, c := range []struct { desc string podStatus corev1.PodStatus - taskRunStatus *v1alpha1.TaskRunStatus - wantResults []v1alpha1.TaskRunResult - want []v1alpha1.PipelineResourceResult + taskRunStatus *v1beta1.TaskRunStatus + wantResults []v1beta1.TaskRunResult + want []resourcev1alpha1.PipelineResourceResult }{{ desc: "update task results when task fails", podStatus: corev1.PodStatus{ @@ -2063,7 +2060,7 @@ func TestUpdateTaskRunResultWhenTaskFailed(t *testing.T) { }, }}, }, - taskRunStatus: &v1alpha1.TaskRunStatus{ + taskRunStatus: &v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, @@ -2088,8 +2085,8 @@ func TestUpdateTaskRunResourceResult_Errors(t *testing.T) { for _, c := range []struct { desc string podStatus corev1.PodStatus - taskRunStatus *v1alpha1.TaskRunStatus - want []v1alpha1.PipelineResourceResult + taskRunStatus *v1beta1.TaskRunStatus + want []resourcev1alpha1.PipelineResourceResult }{{ desc: "image resource exporter with malformed json output", podStatus: corev1.PodStatus{ @@ -2101,7 +2098,7 @@ func TestUpdateTaskRunResourceResult_Errors(t *testing.T) { }, }}, }, - taskRunStatus: &v1alpha1.TaskRunStatus{ + taskRunStatus: &v1beta1.TaskRunStatus{ Status: duckv1beta1.Status{Conditions: []apis.Condition{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, @@ -2111,7 +2108,7 @@ func TestUpdateTaskRunResourceResult_Errors(t *testing.T) { }} { t.Run(c.desc, func(t *testing.T) { names.TestingSeed() - if err := updateTaskRunResourceResult(&v1alpha1.TaskRun{Status: *c.taskRunStatus}, c.podStatus); err == nil { + if err := updateTaskRunResourceResult(&v1beta1.TaskRun{Status: *c.taskRunStatus}, c.podStatus); err == nil { t.Error("Expected error, got nil") } if d := cmp.Diff(c.want, c.taskRunStatus.ResourcesResult); d != "" { @@ -2138,8 +2135,8 @@ func TestReconcile_Single_SidecarState(t *testing.T) { ) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRun}, - Tasks: []*v1alpha1.Task{taskSidecar}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{taskSidecar}, } testAssets, cancel := getTaskRunController(t, d) @@ -2150,12 +2147,12 @@ func TestReconcile_Single_SidecarState(t *testing.T) { t.Errorf("expected no error reconciling valid TaskRun but got %v", err) } - getTaskRun, err := clients.Pipeline.TektonV1alpha1().TaskRuns(taskRun.Namespace).Get(taskRun.Name, metav1.GetOptions{}) + getTaskRun, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(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 := v1alpha1.SidecarState{ + expected := v1beta1.SidecarState{ Name: "sidecar", ImageID: "image-id", ContainerName: "sidecar-sidecar", @@ -2195,8 +2192,8 @@ func TestReconcile_Multiple_SidecarStates(t *testing.T) { ) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRun}, - Tasks: []*v1alpha1.Task{taskMultipleSidecars}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{taskMultipleSidecars}, } testAssets, cancel := getTaskRunController(t, d) @@ -2207,12 +2204,12 @@ func TestReconcile_Multiple_SidecarStates(t *testing.T) { t.Errorf("expected no error reconciling valid TaskRun but got %v", err) } - getTaskRun, err := clients.Pipeline.TektonV1alpha1().TaskRuns(taskRun.Namespace).Get(taskRun.Name, metav1.GetOptions{}) + getTaskRun, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(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 := []v1alpha1.SidecarState{ + expected := []v1beta1.SidecarState{ { Name: "sidecar1", ImageID: "image-id", @@ -2249,8 +2246,8 @@ func TestReconcileWorkspaceMissing(t *testing.T) { tb.TaskRunTaskRef(taskWithWorkspace.Name, tb.TaskRefAPIVersion("a1")), )) d := test.Data{ - Tasks: []*v1alpha1.Task{taskWithWorkspace}, - TaskRuns: []*v1alpha1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{taskWithWorkspace}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, ClusterTasks: nil, PipelineResources: nil, } @@ -2263,7 +2260,7 @@ func TestReconcileWorkspaceMissing(t *testing.T) { t.Errorf("expected no error reconciling valid TaskRun but got %v", err) } - tr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(taskRun.Namespace).Get(taskRun.Name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(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) } @@ -2288,17 +2285,17 @@ func TestReconcileTaskResourceResolutionAndValidation(t *testing.T) { }{{ desc: "Fail ResolveTaskResources", d: test.Data{ - Tasks: []*v1alpha1.Task{ + Tasks: []*v1beta1.Task{ tb.Task("test-task-missing-resource", tb.TaskSpec( - tb.TaskInputs(tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit)), + tb.TaskResources(tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit)), ), tb.TaskNamespace("foo")), }, - TaskRuns: []*v1alpha1.TaskRun{ + TaskRuns: []*v1beta1.TaskRun{ tb.TaskRun("test-taskrun-missing-resource", tb.TaskRunNamespace("foo"), tb.TaskRunSpec( tb.TaskRunTaskRef("test-task-missing-resource", tb.TaskRefAPIVersion("a1")), - tb.TaskRunInputs( - tb.TaskRunInputsResource("workspace", tb.TaskResourceBindingRef("git")), + tb.TaskRunResources( + tb.TaskRunResourcesInput("workspace", tb.TaskResourceBindingRef("git")), ), )), }, @@ -2313,13 +2310,13 @@ func TestReconcileTaskResourceResolutionAndValidation(t *testing.T) { }, { desc: "Fail ValidateResolvedTaskResources", d: test.Data{ - Tasks: []*v1alpha1.Task{ + Tasks: []*v1beta1.Task{ tb.Task("test-task-missing-resource", tb.TaskSpec( - tb.TaskInputs(tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit)), + tb.TaskResources(tb.TaskResourcesInput("workspace", resourcev1alpha1.PipelineResourceTypeGit)), ), tb.TaskNamespace("foo")), }, - TaskRuns: []*v1alpha1.TaskRun{ + TaskRuns: []*v1beta1.TaskRun{ tb.TaskRun("test-taskrun-missing-resource", tb.TaskRunNamespace("foo"), tb.TaskRunSpec( tb.TaskRunTaskRef("test-task-missing-resource", tb.TaskRefAPIVersion("a1")), )), @@ -2345,7 +2342,7 @@ func TestReconcileTaskResourceResolutionAndValidation(t *testing.T) { t.Errorf("expected no error reconciling valid TaskRun but got %v", err) } - tr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(tt.d.TaskRuns[0].Namespace).Get(tt.d.TaskRuns[0].Name, metav1.GetOptions{}) + tr, err := clients.Pipeline.TektonV1beta1().TaskRuns(tt.d.TaskRuns[0].Namespace).Get(tt.d.TaskRuns[0].Name, metav1.GetOptions{}) if err != nil { t.Fatalf("Expected TaskRun %s to exist but instead got error when getting it: %v", tt.d.TaskRuns[0].Name, err) } @@ -2383,8 +2380,8 @@ func TestReconcileWorkspaceWithVolumeClaimTemplate(t *testing.T) { }), )) d := test.Data{ - Tasks: []*v1alpha1.Task{taskWithWorkspace}, - TaskRuns: []*v1alpha1.TaskRun{taskRun}, + Tasks: []*v1beta1.Task{taskWithWorkspace}, + TaskRuns: []*v1beta1.TaskRun{taskRun}, ClusterTasks: nil, PipelineResources: nil, } @@ -2397,7 +2394,7 @@ func TestReconcileWorkspaceWithVolumeClaimTemplate(t *testing.T) { t.Errorf("expected no error reconciling valid TaskRun but got %v", err) } - ttt, err := clients.Pipeline.TektonV1alpha1().TaskRuns(taskRun.Namespace).Get(taskRun.Name, metav1.GetOptions{}) + ttt, err := clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(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) } @@ -2418,7 +2415,7 @@ func TestReconcileWorkspaceWithVolumeClaimTemplate(t *testing.T) { func TestFailTaskRun(t *testing.T) { testCases := []struct { name string - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun pod *corev1.Pod reason string message string @@ -2466,7 +2463,7 @@ func TestFailTaskRun(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{tc.taskRun}, + TaskRuns: []*v1beta1.TaskRun{tc.taskRun}, } if tc.pod != nil { d.Pods = []*corev1.Pod{tc.pod} @@ -2496,11 +2493,8 @@ func Test_storeTaskSpec(t *testing.T) { tr := tb.TaskRun("foo", tb.TaskRunSpec(tb.TaskRunTaskRef("foo-task"))) ts := tb.Task("some-task", tb.TaskSpec(tb.TaskDescription("foo-task"))).Spec - ts1 := tb.Task("some-task", tb.TaskSpec(tb.TaskDescription("bar-task"))).Spec - want := &v1beta1.TaskSpec{} - if err := ts.ConvertTo(ctx, want); err != nil { - t.Errorf("error converting to v1beta1: %v", err) - } + ts1 := tb.Task("some-task", tb.TaskSpec(tb.TaskDescription("foo-task"))).Spec + want := ts.DeepCopy() // The first time we set it, it should get copied. if err := storeTaskSpec(ctx, tr, &ts); err != nil { diff --git a/pkg/reconciler/taskrun/validate_resources_test.go b/pkg/reconciler/taskrun/validate_resources_test.go index 2ade9115644..75eb02e549e 100644 --- a/pkg/reconciler/taskrun/validate_resources_test.go +++ b/pkg/reconciler/taskrun/validate_resources_test.go @@ -19,49 +19,57 @@ package taskrun_test import ( "testing" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" + resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" ) func TestValidateResolvedTaskResources_ValidResources(t *testing.T) { - rtr := tb.ResolvedTaskResources( - tb.ResolvedTaskResourcesTaskSpec( - tb.Step("myimage", tb.StepCommand("mycmd")), - tb.TaskResources( - tb.TaskResourcesInput("resource-to-build", v1alpha1.PipelineResourceTypeGit), - tb.TaskResourcesInput("optional-resource-to-build", v1alpha1.PipelineResourceTypeGit, tb.ResourceOptional(true)), - tb.TaskResourcesOutput("resource-to-provide", v1alpha1.PipelineResourceTypeImage), - tb.TaskResourcesOutput("optional-resource-to-provide", v1alpha1.PipelineResourceTypeImage, tb.ResourceOptional(true)), - ), - ), - tb.ResolvedTaskResourcesInputs("resource-to-build", tb.PipelineResource("example-resource", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeGit, - tb.PipelineResourceSpecParam("foo", "bar"), - ))), - tb.ResolvedTaskResourcesInputs("optional-resource-to-build", tb.PipelineResource("example-resource", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeGit, - tb.PipelineResourceSpecParam("foo", "bar"), - ))), - tb.ResolvedTaskResourcesOutputs("resource-to-provide", tb.PipelineResource("example-image", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeImage)), + task := tb.Task("foo", tb.TaskSpec( + tb.Step("myimage", tb.StepCommand("mycmd")), + tb.TaskResources( + tb.TaskResourcesInput("resource-to-build", resourcev1alpha1.PipelineResourceTypeGit), + tb.TaskResourcesInput("optional-resource-to-build", resourcev1alpha1.PipelineResourceTypeGit, tb.ResourceOptional(true)), + tb.TaskResourcesOutput("resource-to-provide", resourcev1alpha1.PipelineResourceTypeImage), + tb.TaskResourcesOutput("optional-resource-to-provide", resourcev1alpha1.PipelineResourceTypeImage, tb.ResourceOptional(true)), ), - tb.ResolvedTaskResourcesOutputs("optional-resource-to-provide", tb.PipelineResource("example-image", - tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeImage)), - )) - if err := taskrun.ValidateResolvedTaskResources([]v1alpha1.Param{}, rtr); err != nil { + )) + rtr := &resources.ResolvedTaskResources{ + TaskSpec: &task.Spec, + Inputs: map[string]*resourcev1alpha1.PipelineResource{ + "resource-to-build": tb.PipelineResource("example-resource", + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeGit, + tb.PipelineResourceSpecParam("foo", "bar"), + )), + "optional-resource-to-build": tb.PipelineResource("example-resource", + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeGit, + tb.PipelineResourceSpecParam("foo", "bar"), + )), + }, + Outputs: map[string]*resourcev1alpha1.PipelineResource{ + "resource-to-provide": tb.PipelineResource("example-image", + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeImage)), + "optional-resource-to-provide": tb.PipelineResource("example-image", + tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeImage)), + }, + } + if err := taskrun.ValidateResolvedTaskResources([]v1beta1.Param{}, rtr); err != nil { t.Fatalf("Did not expect to see error when validating valid resolved TaskRun but saw %v", err) } } func TestValidateResolvedTaskResources_ValidParams(t *testing.T) { - rtr := tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( + task := tb.Task("foo", tb.TaskSpec( tb.Step("myimage", tb.StepCommand("mycmd")), - tb.TaskParam("foo", v1alpha1.ParamTypeString), - tb.TaskParam("bar", v1alpha1.ParamTypeString), + tb.TaskParam("foo", v1beta1.ParamTypeString), + tb.TaskParam("bar", v1beta1.ParamTypeString), )) - p := []v1alpha1.Param{{ + rtr := &resources.ResolvedTaskResources{ + TaskSpec: &task.Spec, + } + p := []v1beta1.Param{{ Name: "foo", Value: *tb.ArrayOrString("somethinggood"), }, { @@ -74,27 +82,29 @@ func TestValidateResolvedTaskResources_ValidParams(t *testing.T) { } func TestValidateResolvedTaskResources_InvalidParams(t *testing.T) { + task := tb.Task("foo", tb.TaskSpec( + tb.Step("myimage", tb.StepCommand("mycmd")), + tb.TaskParam("foo", v1beta1.ParamTypeString), + )) tcs := []struct { name string rtr *resources.ResolvedTaskResources - params []v1alpha1.Param + params []v1beta1.Param }{{ name: "missing-params", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.Step("myimage", tb.StepCommand("mycmd")), - tb.TaskInputs(tb.InputsParamSpec("foo", v1alpha1.ParamTypeString)), - )), - params: []v1alpha1.Param{{ + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &task.Spec, + }, + params: []v1beta1.Param{{ Name: "foobar", Value: *tb.ArrayOrString("somethingfun"), }}, }, { name: "missing-params", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.Step("myimage", tb.StepCommand("mycmd")), - tb.TaskInputs(tb.InputsParamSpec("foo", v1alpha1.ParamTypeString)), - )), - params: []v1alpha1.Param{{ + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &task.Spec, + }, + params: []v1beta1.Param{{ Name: "foo", Value: *tb.ArrayOrString("i am a real param"), }, { @@ -113,104 +123,129 @@ func TestValidateResolvedTaskResources_InvalidParams(t *testing.T) { func TestValidateResolvedTaskResources_InvalidResources(t *testing.T) { r := tb.PipelineResource("git-test-resource", tb.PipelineResourceSpec( - v1alpha1.PipelineResourceTypeGit, + resourcev1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("foo", "bar"), )) + testinput := tb.Task("foo", tb.TaskSpec( + tb.TaskResources(tb.TaskResourcesInput("testinput", resourcev1alpha1.PipelineResourceTypeGit)), + // tb.TaskResources(tb.TaskResourcesInput()), + )) + testimageinput := tb.Task("foo", tb.TaskSpec( + tb.TaskResources(tb.TaskResourcesInput("testimageinput", resourcev1alpha1.PipelineResourceTypeImage)), + )) + testrequiredgitinput := tb.Task("foo", tb.TaskSpec( + tb.TaskResources(tb.TaskResourcesInput("requiredgitinput", resourcev1alpha1.PipelineResourceTypeGit, + tb.ResourceOptional(false))), + )) + testoutput := tb.Task("foo", tb.TaskSpec( + tb.TaskResources(tb.TaskResourcesOutput("testoutput", resourcev1alpha1.PipelineResourceTypeGit)), + )) + testimageoutput := tb.Task("foo", tb.TaskSpec( + tb.TaskResources(tb.TaskResourcesOutput("testimageoutput", resourcev1alpha1.PipelineResourceTypeImage)), + )) + testrequiredgitoutput := tb.Task("foo", tb.TaskSpec( + tb.TaskResources(tb.TaskResourcesOutput( + "requiredgitoutput", resourcev1alpha1.PipelineResourceTypeGit, + tb.ResourceOptional(false)), + ), + )) + testrequiredinputandoutput := tb.Task("foo", tb.TaskSpec( + tb.TaskResources( + tb.TaskResourcesInput("requiredimageinput", resourcev1alpha1.PipelineResourceTypeImage, + tb.ResourceOptional(false)), + tb.TaskResourcesOutput("requiredimageoutput", resourcev1alpha1.PipelineResourceTypeImage, + tb.ResourceOptional(false)), + ), + )) tcs := []struct { name string rtr *resources.ResolvedTaskResources }{{ name: "bad-inputkey", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesInput("testinput", v1alpha1.PipelineResourceTypeGit)), - // tb.TaskResources(tb.TaskResourcesInput()), - ), tb.ResolvedTaskResourcesInputs("wrong-resource-name", r)), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testinput.Spec, + Inputs: map[string]*resourcev1alpha1.PipelineResource{"wrong-resource-name": r}, + }, }, { name: "bad-outputkey", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesOutput("testoutput", v1alpha1.PipelineResourceTypeGit)), - ), tb.ResolvedTaskResourcesOutputs("wrong-resource-name", r)), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testoutput.Spec, + Outputs: map[string]*resourcev1alpha1.PipelineResource{"wrong-resource-name": r}, + }, }, { name: "input-resource-mismatch", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesInput("testimageinput", v1alpha1.PipelineResourceTypeImage)), - ), tb.ResolvedTaskResourcesInputs("testimageinput", r)), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testimageinput.Spec, + Inputs: map[string]*resourcev1alpha1.PipelineResource{"testimageinput": r}, + }, }, { name: "input-resource-missing", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesInput("testimageinput", v1alpha1.PipelineResourceTypeImage)), - )), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testimageinput.Spec, + }, }, { name: "output-resource-mismatch", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesOutput("testimageoutput", v1alpha1.PipelineResourceTypeImage)), - ), tb.ResolvedTaskResourcesOutputs("testimageoutput", r)), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testimageoutput.Spec, + Outputs: map[string]*resourcev1alpha1.PipelineResource{"testimageoutput": r}, + }, }, { name: "output-resource-missing", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesOutput("testimageoutput", v1alpha1.PipelineResourceTypeImage)), - )), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testimageoutput.Spec, + }, }, { name: "extra-input-resource", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesInput("testoutput", v1alpha1.PipelineResourceTypeGit))), - tb.ResolvedTaskResourcesInputs("testoutput", r), - tb.ResolvedTaskResourcesInputs("someextrainput", r), - ), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testinput.Spec, + Inputs: map[string]*resourcev1alpha1.PipelineResource{ + "testinput": r, + "someextrainput": r, + }, + }, }, { name: "extra-output-resource", - rtr: tb.ResolvedTaskResources( - tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesOutput("testoutput", v1alpha1.PipelineResourceTypeGit)), - ), - tb.ResolvedTaskResourcesOutputs("testoutput", r), - tb.ResolvedTaskResourcesOutputs("someextraoutput", r), - ), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testoutput.Spec, + Outputs: map[string]*resourcev1alpha1.PipelineResource{ + "testoutput": r, + "someextraoutput": r, + }, + }, }, { name: "extra-input-resource-none-required", - rtr: tb.ResolvedTaskResources( - tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesOutput("testoutput", v1alpha1.PipelineResourceTypeGit)), - ), - tb.ResolvedTaskResourcesOutputs("testoutput", r), - tb.ResolvedTaskResourcesInputs("someextrainput", r), - ), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testoutput.Spec, + Inputs: map[string]*resourcev1alpha1.PipelineResource{"someextrainput": r}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{"testoutput": r}, + }, }, { name: "extra-output-resource-none-required", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesInput("testinput", v1alpha1.PipelineResourceTypeGit))), - tb.ResolvedTaskResourcesInputs("testinput", r), - tb.ResolvedTaskResourcesOutputs("someextraoutput", r), - ), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testinput.Spec, + Inputs: map[string]*resourcev1alpha1.PipelineResource{"testinput": r}, + Outputs: map[string]*resourcev1alpha1.PipelineResource{"someextraoutput": r}, + }, }, { name: "required-input-resource-missing", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesInput("requiredgitinput", v1alpha1.PipelineResourceTypeGit, - tb.ResourceOptional(false)))), - ), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testrequiredgitinput.Spec, + }, }, { name: "required-output-resource-missing", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources(tb.TaskResourcesOutput( - "requiredgitoutput", v1alpha1.PipelineResourceTypeGit, - tb.ResourceOptional(false)), - )), - ), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testrequiredgitoutput.Spec, + }, }, { name: "required-input-and-output-resource-missing", - rtr: tb.ResolvedTaskResources(tb.ResolvedTaskResourcesTaskSpec( - tb.TaskResources( - tb.TaskResourcesInput("requiredimageinput", v1alpha1.PipelineResourceTypeImage, - tb.ResourceOptional(false)), - tb.TaskResourcesOutput("requiredimageoutput", v1alpha1.PipelineResourceTypeImage, - tb.ResourceOptional(false)), - ), - )), + rtr: &resources.ResolvedTaskResources{ + TaskSpec: &testrequiredinputandoutput.Spec, + }, }} for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { - if err := taskrun.ValidateResolvedTaskResources([]v1alpha1.Param{}, tc.rtr); err == nil { + if err := taskrun.ValidateResolvedTaskResources([]v1beta1.Param{}, tc.rtr); err == nil { t.Errorf("Expected to see error when validating invalid resolved TaskRun but saw none") } }) diff --git a/pkg/reconciler/timeout_handler.go b/pkg/reconciler/timeout_handler.go index f8712efcacb..d186e5d688f 100644 --- a/pkg/reconciler/timeout_handler.go +++ b/pkg/reconciler/timeout_handler.go @@ -24,7 +24,7 @@ import ( "time" "github.com/tektoncd/pipeline/pkg/apis/config" - "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" "go.uber.org/zap" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -135,7 +135,7 @@ func (t *TimeoutSet) getOrCreateFinishedChan(runObj StatusKey) chan bool { // describing the time at which the next attempt should be performed. // Additionally a boolean is returned indicating whether a backoff for the // TaskRun is already in progress. -func (t *TimeoutSet) GetBackoff(tr *v1alpha1.TaskRun) (Backoff, bool) { +func (t *TimeoutSet) GetBackoff(tr *v1beta1.TaskRun) (Backoff, bool) { t.backoffsMut.Lock() defer t.backoffsMut.Unlock() b := t.backoffs[tr.GetRunKey()] @@ -168,7 +168,7 @@ func backoffDuration(count uint, jf jitterFunc) time.Duration { // checkPipelineRunTimeouts function creates goroutines to wait for pipelinerun to // finish/timeout in a given namespace func (t *TimeoutSet) checkPipelineRunTimeouts(namespace string, pipelineclientset clientset.Interface) { - pipelineRuns, err := pipelineclientset.TektonV1alpha1().PipelineRuns(namespace).List(metav1.ListOptions{}) + pipelineRuns, err := pipelineclientset.TektonV1beta1().PipelineRuns(namespace).List(metav1.ListOptions{}) if err != nil { t.logger.Errorf("Can't get pipelinerun list in namespace %s: %s", namespace, err) return @@ -201,7 +201,7 @@ func (t *TimeoutSet) CheckTimeouts(kubeclientset kubernetes.Interface, pipelinec // checkTaskRunTimeouts function creates goroutines to wait for pipelinerun to // finish/timeout in a given namespace func (t *TimeoutSet) checkTaskRunTimeouts(namespace string, pipelineclientset clientset.Interface) { - taskruns, err := pipelineclientset.TektonV1alpha1().TaskRuns(namespace).List(metav1.ListOptions{}) + taskruns, err := pipelineclientset.TektonV1beta1().TaskRuns(namespace).List(metav1.ListOptions{}) if err != nil { t.logger.Errorf("Can't get taskrun list in namespace %s: %s", namespace, err) return @@ -220,7 +220,7 @@ func (t *TimeoutSet) checkTaskRunTimeouts(namespace string, pipelineclientset cl // WaitTaskRun function creates a blocking function for taskrun to wait for // 1. Stop signal, 2. TaskRun to complete or 3. Taskrun to time out, which is // determined by checking if the tr's timeout has occurred since the startTime -func (t *TimeoutSet) WaitTaskRun(tr *v1alpha1.TaskRun, startTime *metav1.Time) { +func (t *TimeoutSet) WaitTaskRun(tr *v1beta1.TaskRun, startTime *metav1.Time) { var timeout time.Duration if tr.Spec.Timeout == nil { timeout = config.DefaultTimeoutMinutes * time.Minute @@ -233,7 +233,7 @@ func (t *TimeoutSet) WaitTaskRun(tr *v1alpha1.TaskRun, startTime *metav1.Time) { // WaitPipelineRun function creates a blocking function for pipelinerun to wait for // 1. Stop signal, 2. pipelinerun to complete or 3. pipelinerun to time out which is // determined by checking if the tr's timeout has occurred since the startTime -func (t *TimeoutSet) WaitPipelineRun(pr *v1alpha1.PipelineRun, startTime *metav1.Time) { +func (t *TimeoutSet) WaitPipelineRun(pr *v1beta1.PipelineRun, startTime *metav1.Time) { var timeout time.Duration if pr.Spec.Timeout == nil { timeout = config.DefaultTimeoutMinutes * time.Minute @@ -264,7 +264,7 @@ func (t *TimeoutSet) waitRun(runObj StatusKey, timeout time.Duration, startTime // the lifetime of the TaskRun no resources are released after the timer // fires. It is the caller's responsibility to Release() the TaskRun when // work with it has completed. -func (t *TimeoutSet) SetTaskRunTimer(tr *v1alpha1.TaskRun, d time.Duration) { +func (t *TimeoutSet) SetTaskRunTimer(tr *v1beta1.TaskRun, d time.Duration) { callback := t.taskRunCallbackFunc if callback == nil { t.logger.Errorf("attempted to set a timer for %q but no task run callback has been assigned", tr.Name) diff --git a/pkg/reconciler/timeout_handler_test.go b/pkg/reconciler/timeout_handler_test.go index b8112ca490b..ee78ac03186 100644 --- a/pkg/reconciler/timeout_handler_test.go +++ b/pkg/reconciler/timeout_handler_test.go @@ -22,11 +22,11 @@ import ( "testing" "time" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" - test "github.com/tektoncd/pipeline/test/v1alpha1" + test "github.com/tektoncd/pipeline/test" "go.uber.org/zap" "go.uber.org/zap/zaptest/observer" corev1 "k8s.io/api/core/v1" @@ -87,8 +87,8 @@ func TestTaskRunCheckTimeouts(t *testing.T) { )) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRunTimedout, taskRunRunning, taskRunDone, taskRunCancelled, taskRunRunningNilTimeout}, - Tasks: []*v1alpha1.Task{simpleTask}, + TaskRuns: []*v1beta1.TaskRun{taskRunTimedout, taskRunRunning, taskRunDone, taskRunCancelled, taskRunRunningNilTimeout}, + Tasks: []*v1beta1.Task{simpleTask}, Namespaces: []*corev1.Namespace{{ ObjectMeta: metav1.ObjectMeta{ Name: testNs, @@ -104,7 +104,7 @@ func TestTaskRunCheckTimeouts(t *testing.T) { th := NewTimeoutHandler(stopCh, zap.New(observer).Sugar()) gotCallback := sync.Map{} f := func(tr interface{}) { - trNew := tr.(*v1alpha1.TaskRun) + trNew := tr.(*v1beta1.TaskRun) gotCallback.Store(trNew.Name, struct{}{}) } @@ -113,7 +113,7 @@ func TestTaskRunCheckTimeouts(t *testing.T) { for _, tc := range []struct { name string - taskRun *v1alpha1.TaskRun + taskRun *v1beta1.TaskRun expectCallback bool }{{ name: "timedout", @@ -211,9 +211,9 @@ func TestPipelinRunCheckTimeouts(t *testing.T) { ), ) d := test.Data{ - PipelineRuns: []*v1alpha1.PipelineRun{prTimeout, prRunning, prDone, prCancelled, prRunningNilTimeout}, - Pipelines: []*v1alpha1.Pipeline{simplePipeline}, - Tasks: []*v1alpha1.Task{ts}, + PipelineRuns: []*v1beta1.PipelineRun{prTimeout, prRunning, prDone, prCancelled, prRunningNilTimeout}, + Pipelines: []*v1beta1.Pipeline{simplePipeline}, + Tasks: []*v1beta1.Task{ts}, Namespaces: []*corev1.Namespace{{ ObjectMeta: metav1.ObjectMeta{ Name: testNs, @@ -230,7 +230,7 @@ func TestPipelinRunCheckTimeouts(t *testing.T) { gotCallback := sync.Map{} f := func(pr interface{}) { - prNew := pr.(*v1alpha1.PipelineRun) + prNew := pr.(*v1beta1.PipelineRun) gotCallback.Store(prNew.Name, struct{}{}) } @@ -238,7 +238,7 @@ func TestPipelinRunCheckTimeouts(t *testing.T) { th.CheckTimeouts(c.Kube, c.Pipeline) for _, tc := range []struct { name string - pr *v1alpha1.PipelineRun + pr *v1beta1.PipelineRun expectCallback bool }{{ name: "pr-running", @@ -293,8 +293,8 @@ func TestWithNoFunc(t *testing.T) { )) d := test.Data{ - TaskRuns: []*v1alpha1.TaskRun{taskRunRunning}, - Tasks: []*v1alpha1.Task{simpleTask}, + TaskRuns: []*v1beta1.TaskRun{taskRunRunning}, + Tasks: []*v1beta1.Task{simpleTask}, Namespaces: []*corev1.Namespace{{ ObjectMeta: metav1.ObjectMeta{ Name: testNs, diff --git a/pkg/remote/oci/resolver_test.go b/pkg/remote/oci/resolver_test.go index 6e001122f2d..8f34a94d182 100644 --- a/pkg/remote/oci/resolver_test.go +++ b/pkg/remote/oci/resolver_test.go @@ -27,7 +27,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/registry" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/remote" "github.com/tektoncd/pipeline/test" "k8s.io/apimachinery/pkg/runtime" @@ -52,14 +52,14 @@ func TestOCIResolver(t *testing.T) { objs: []runtime.Object{ tb.Task("simple-task", tb.TaskType()), }, - listExpected: []remote.ResolvedObject{{Kind: "task", APIVersion: "v1alpha1", Name: "simple-task"}}, + listExpected: []remote.ResolvedObject{{Kind: "task", APIVersion: "v1beta1", Name: "simple-task"}}, }, { name: "cluster-task", objs: []runtime.Object{ tb.ClusterTask("simple-task", tb.ClusterTaskType()), }, - listExpected: []remote.ResolvedObject{{Kind: "clustertask", APIVersion: "v1alpha1", Name: "simple-task"}}, + listExpected: []remote.ResolvedObject{{Kind: "clustertask", APIVersion: "v1beta1", Name: "simple-task"}}, }, { name: "multiple-tasks", @@ -68,8 +68,8 @@ func TestOCIResolver(t *testing.T) { tb.Task("second-task", tb.TaskType()), }, listExpected: []remote.ResolvedObject{ - {Kind: "task", APIVersion: "v1alpha1", Name: "first-task"}, - {Kind: "task", APIVersion: "v1alpha1", Name: "second-task"}, + {Kind: "task", APIVersion: "v1beta1", Name: "first-task"}, + {Kind: "task", APIVersion: "v1beta1", Name: "second-task"}, }, }, } diff --git a/pkg/workspace/apply.go b/pkg/workspace/apply.go index a6188695b8b..844470c503f 100644 --- a/pkg/workspace/apply.go +++ b/pkg/workspace/apply.go @@ -3,7 +3,7 @@ package workspace import ( "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" ) @@ -26,7 +26,7 @@ func (nvm nameVolumeMap) setVolumeSource(workspaceName string, volumeName string // GetVolumes will return a dictionary where the keys are the names of the workspaces bound in // wb and the value is the 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. -func GetVolumes(wb []v1alpha1.WorkspaceBinding) map[string]corev1.Volume { +func GetVolumes(wb []v1beta1.WorkspaceBinding) map[string]corev1.Volume { pvcs := map[string]corev1.Volume{} v := make(nameVolumeMap) for _, w := range wb { @@ -55,7 +55,7 @@ func GetVolumes(wb []v1alpha1.WorkspaceBinding) map[string]corev1.Volume { return v } -func getDeclaredWorkspace(name string, w []v1alpha1.WorkspaceDeclaration) (*v1alpha1.WorkspaceDeclaration, error) { +func getDeclaredWorkspace(name string, w []v1beta1.WorkspaceDeclaration) (*v1beta1.WorkspaceDeclaration, error) { for _, workspace := range w { if workspace.Name == name { return &workspace, nil @@ -68,7 +68,7 @@ func getDeclaredWorkspace(name string, w []v1alpha1.WorkspaceDeclaration) (*v1al // Apply will update the StepTemplate and Volumes declaration in ts so that the workspaces // specified through wb combined with the declared workspaces in ts will be available for // all containers in the resulting pod. -func Apply(ts v1alpha1.TaskSpec, wb []v1alpha1.WorkspaceBinding) (*v1alpha1.TaskSpec, error) { +func Apply(ts v1beta1.TaskSpec, wb []v1beta1.WorkspaceBinding) (*v1beta1.TaskSpec, error) { // If there are no bound workspaces, we don't need to do anything if len(wb) == 0 { return &ts, nil diff --git a/pkg/workspace/apply_test.go b/pkg/workspace/apply_test.go index 88204440925..7adb2a52ffc 100644 --- a/pkg/workspace/apply_test.go +++ b/pkg/workspace/apply_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/workspace" "github.com/tektoncd/pipeline/test/names" @@ -15,11 +14,11 @@ func TestGetVolumes(t *testing.T) { names.TestingSeed() for _, tc := range []struct { name string - workspaces []v1alpha1.WorkspaceBinding + workspaces []v1beta1.WorkspaceBinding expectedVolumes map[string]corev1.Volume }{{ name: "binding a single workspace with a PVC", - workspaces: []v1alpha1.WorkspaceBinding{{ + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -38,7 +37,7 @@ func TestGetVolumes(t *testing.T) { }, }, { name: "binding a single workspace with emptyDir", - workspaces: []v1alpha1.WorkspaceBinding{{ + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", EmptyDir: &corev1.EmptyDirVolumeSource{ Medium: corev1.StorageMediumMemory, @@ -57,7 +56,7 @@ func TestGetVolumes(t *testing.T) { }, }, { name: "binding a single workspace with configMap", - workspaces: []v1alpha1.WorkspaceBinding{{ + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ @@ -88,7 +87,7 @@ func TestGetVolumes(t *testing.T) { }, }, { name: "binding a single workspace with secret", - workspaces: []v1alpha1.WorkspaceBinding{{ + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", Secret: &corev1.SecretVolumeSource{ SecretName: "foobarsecret", @@ -115,11 +114,11 @@ func TestGetVolumes(t *testing.T) { }, }, { name: "0 workspace bindings", - workspaces: []v1alpha1.WorkspaceBinding{}, + workspaces: []v1beta1.WorkspaceBinding{}, expectedVolumes: map[string]corev1.Volume{}, }, { name: "binding multiple workspaces", - workspaces: []v1alpha1.WorkspaceBinding{{ + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -151,7 +150,7 @@ func TestGetVolumes(t *testing.T) { }, }, { name: "multiple workspaces binding to the same volume with diff subpaths doesnt duplicate", - workspaces: []v1alpha1.WorkspaceBinding{{ + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -197,31 +196,31 @@ func TestApply(t *testing.T) { names.TestingSeed() for _, tc := range []struct { name string - ts v1alpha1.TaskSpec - workspaces []v1alpha1.WorkspaceBinding - expectedTaskSpec v1alpha1.TaskSpec + ts v1beta1.TaskSpec + workspaces []v1beta1.WorkspaceBinding + expectedTaskSpec v1beta1.TaskSpec }{{ name: "binding a single workspace with a PVC", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + ts: v1beta1.TaskSpec{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", }}, - }}, - workspaces: []v1alpha1.WorkspaceBinding{{ + }, + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", }, SubPath: "/foo/bar/baz", }}, - expectedTaskSpec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + expectedTaskSpec: v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-9l9zj", MountPath: "/workspace/custom", SubPath: "/foo/bar/baz", + }, }}, - }, Volumes: []corev1.Volume{{ Name: "ws-9l9zj", VolumeSource: corev1.VolumeSource{ @@ -230,25 +229,25 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", }}, - }}, + }, }, { name: "binding a single workspace with emptyDir", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + ts: v1beta1.TaskSpec{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", + }, }}, - }}, - workspaces: []v1alpha1.WorkspaceBinding{{ + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", EmptyDir: &corev1.EmptyDirVolumeSource{ Medium: corev1.StorageMediumMemory, }, SubPath: "/foo/bar/baz", }}, - expectedTaskSpec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + expectedTaskSpec: v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-mz4c7", @@ -264,13 +263,13 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", }}, - }}, + }, }, { name: "task spec already has volumes and stepTemplate", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + ts: v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{{ Name: "awesome-volume", @@ -283,18 +282,18 @@ func TestApply(t *testing.T) { EmptyDir: &corev1.EmptyDirVolumeSource{}, }, }}, - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", }}, - }}, - workspaces: []v1alpha1.WorkspaceBinding{{ + }, + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", EmptyDir: &corev1.EmptyDirVolumeSource{ Medium: corev1.StorageMediumMemory, }, SubPath: "/foo/bar/baz", }}, - expectedTaskSpec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + expectedTaskSpec: v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{{ Name: "awesome-volume", @@ -318,35 +317,35 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", }}, - }}, + }, }, { name: "0 workspace bindings", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{ + ts: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{ Container: corev1.Container{ Name: "foo", }}}, - }}, - workspaces: []v1alpha1.WorkspaceBinding{}, - expectedTaskSpec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{ + }, + workspaces: []v1beta1.WorkspaceBinding{}, + expectedTaskSpec: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{ Container: corev1.Container{ Name: "foo", }}}, - }}, + }, }, { name: "binding multiple workspaces", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + ts: v1beta1.TaskSpec{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", }, { Name: "even-more-custom", }}, - }}, - workspaces: []v1alpha1.WorkspaceBinding{{ + }, + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -358,7 +357,7 @@ func TestApply(t *testing.T) { ClaimName: "myotherpvc", }, }}, - expectedTaskSpec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + expectedTaskSpec: v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-78c5n", @@ -385,21 +384,21 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom"}, { Name: "even-more-custom", }}, - }}, + }, }, { name: "multiple workspaces binding to the same volume with diff subpaths doesnt duplicate", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + ts: v1beta1.TaskSpec{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", }, { Name: "custom2", }}, - }}, - workspaces: []v1alpha1.WorkspaceBinding{{ + }, + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", @@ -412,7 +411,7 @@ func TestApply(t *testing.T) { }, SubPath: "/very/professional/work/space", }}, - expectedTaskSpec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + expectedTaskSpec: v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-j2tds", @@ -432,27 +431,27 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", }, { Name: "custom2", }}, - }}, + }, }, { name: "non default mount path", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + ts: v1beta1.TaskSpec{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", }}, - }}, - workspaces: []v1alpha1.WorkspaceBinding{{ + }, + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", }, }}, - expectedTaskSpec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + expectedTaskSpec: v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-l22wn", @@ -467,27 +466,27 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", }}, - }}, + }, }, { name: "readOnly true marks volume mount readOnly", - ts: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + ts: v1beta1.TaskSpec{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", ReadOnly: true, }}, - }}, - workspaces: []v1alpha1.WorkspaceBinding{{ + }, + workspaces: []v1beta1.WorkspaceBinding{{ Name: "custom", PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ ClaimName: "mypvc", }, }}, - expectedTaskSpec: v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ + expectedTaskSpec: v1beta1.TaskSpec{ StepTemplate: &corev1.Container{ VolumeMounts: []corev1.VolumeMount{{ Name: "ws-twkr2", @@ -503,12 +502,12 @@ func TestApply(t *testing.T) { }, }, }}, - Workspaces: []v1alpha1.WorkspaceDeclaration{{ + Workspaces: []v1beta1.WorkspaceDeclaration{{ Name: "custom", MountPath: "/my/fancy/mount/path", ReadOnly: true, }}, - }}, + }, }} { t.Run(tc.name, func(t *testing.T) { ts, err := workspace.Apply(tc.ts, tc.workspaces) diff --git a/pkg/workspace/validate.go b/pkg/workspace/validate.go index 029a6a720f2..2738b270b7d 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/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/list" ) // ValidateBindings will return an error if the bound workspaces in wb don't satisfy the declared // workspaces in w. -func ValidateBindings(w []v1alpha1.WorkspaceDeclaration, wb []v1alpha1.WorkspaceBinding) error { +func ValidateBindings(w []v1beta1.WorkspaceDeclaration, wb []v1beta1.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 wb { diff --git a/test/artifact_bucket_test.go b/test/artifact_bucket_test.go index a0c406e5478..eaaed92b222 100644 --- a/test/artifact_bucket_test.go +++ b/test/artifact_bucket_test.go @@ -25,7 +25,7 @@ import ( "testing" "time" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" diff --git a/test/builder/task.go b/test/builder/task.go index c3a6b38f3cb..0fc21186fb0 100644 --- a/test/builder/task.go +++ b/test/builder/task.go @@ -84,10 +84,6 @@ type TaskRunInputsOp = v1alpha1.TaskRunInputsOp // Deprecated: moved to internal/builder/v1alpha1 type TaskRunOutputsOp = v1alpha1.TaskRunOutputsOp -// ResolvedTaskResourcesOp is an operation which modify a ResolvedTaskResources struct. -// Deprecated: moved to internal/builder/v1alpha1 -type ResolvedTaskResourcesOp = v1alpha1.ResolvedTaskResourcesOp - // StepStateOp is an operation which modifies a StepState struct. // Deprecated: moved to internal/builder/v1alpha1 type StepStateOp = v1alpha1.StepStateOp @@ -433,22 +429,4 @@ var ( // TaskRunWorkspaceVolumeClaimTemplate adds a workspace binding with a VolumeClaimTemplate volume source. // Deprecated: moved to internal/builder/v1alpha1 TaskRunWorkspaceVolumeClaimTemplate = v1alpha1.TaskRunWorkspaceVolumeClaimTemplate - - // ResolvedTaskResources creates a ResolvedTaskResources with default values. - // Any number of ResolvedTaskResources modifier can be passed to transform it. - // Deprecated: moved to internal/builder/v1alpha1 - ResolvedTaskResources = v1alpha1.ResolvedTaskResources - - // ResolvedTaskResourcesTaskSpec sets a TaskSpec to the ResolvedTaskResources. - // Any number of TaskSpec modifier can be passed to transform it. - // Deprecated: moved to internal/builder/v1alpha1 - ResolvedTaskResourcesTaskSpec = v1alpha1.ResolvedTaskResourcesTaskSpec - - // ResolvedTaskResourcesInputs adds an input PipelineResource, with specified name, to the ResolvedTaskResources. - // Deprecated: moved to internal/builder/v1alpha1 - ResolvedTaskResourcesInputs = v1alpha1.ResolvedTaskResourcesInputs - - // ResolvedTaskResourcesOutputs adds an output PipelineResource, with specified name, to the ResolvedTaskResources. - // Deprecated: moved to internal/builder/v1alpha1 - ResolvedTaskResourcesOutputs = v1alpha1.ResolvedTaskResourcesOutputs ) diff --git a/test/builder/task_test.go b/test/builder/task_test.go index 7ea83830f19..cb612e22b13 100644 --- a/test/builder/task_test.go +++ b/test/builder/task_test.go @@ -25,7 +25,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" @@ -421,40 +420,3 @@ func TestTaskRunWithPodTemplate(t *testing.T) { t.Fatalf("TaskRun diff -want, +got: %v", d) } } - -func TestResolvedTaskResources(t *testing.T) { - resolvedTaskResources := tb.ResolvedTaskResources( - tb.ResolvedTaskResourcesTaskSpec( - tb.Step("image", tb.StepCommand("/mycmd")), - ), - tb.ResolvedTaskResourcesInputs("foo", tb.PipelineResource("bar", tb.PipelineResourceNamespace("baz"))), - tb.ResolvedTaskResourcesOutputs("qux", tb.PipelineResource("quux", tb.PipelineResourceNamespace("quuz"))), - ) - expectedResolvedTaskResources := &resources.ResolvedTaskResources{ - TaskSpec: &v1alpha1.TaskSpec{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1alpha1.Step{{Container: corev1.Container{ - Image: "image", - Command: []string{"/mycmd"}, - }}}, - }}, - Inputs: map[string]*v1alpha1.PipelineResource{ - "foo": { - ObjectMeta: metav1.ObjectMeta{ - Name: "bar", - Namespace: "baz", - }, - }, - }, - Outputs: map[string]*v1alpha1.PipelineResource{ - "qux": { - ObjectMeta: metav1.ObjectMeta{ - Name: "quux", - Namespace: "quuz", - }, - }, - }, - } - if d := cmp.Diff(expectedResolvedTaskResources, resolvedTaskResources); d != "" { - t.Fatalf("ResolvedTaskResources diff -want, +got: %v", d) - } -} diff --git a/test/cluster_resource_test.go b/test/cluster_resource_test.go index c931e0a3958..d121e8c5e37 100644 --- a/test/cluster_resource_test.go +++ b/test/cluster_resource_test.go @@ -21,7 +21,7 @@ package test import ( "testing" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resources "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" diff --git a/test/dag_test.go b/test/dag_test.go index 9d81a45d45e..5fd16aded6d 100644 --- a/test/dag_test.go +++ b/test/dag_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resources "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" diff --git a/test/git_checkout_test.go b/test/git_checkout_test.go index e30b3b0dd35..f16fefe112b 100644 --- a/test/git_checkout_test.go +++ b/test/git_checkout_test.go @@ -22,7 +22,7 @@ import ( "strings" "testing" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resources "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" diff --git a/test/helm_task_test.go b/test/helm_task_test.go index c600dfc0b1f..2d1e17a2684 100644 --- a/test/helm_task_test.go +++ b/test/helm_task_test.go @@ -22,7 +22,7 @@ import ( "fmt" "testing" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resources "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" diff --git a/test/kaniko_task_test.go b/test/kaniko_task_test.go index bb86971926a..4d0f91d9325 100644 --- a/test/kaniko_task_test.go +++ b/test/kaniko_task_test.go @@ -25,7 +25,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resources "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" diff --git a/test/pipelinerun_test.go b/test/pipelinerun_test.go index f252a4e9436..8f6932c1147 100644 --- a/test/pipelinerun_test.go +++ b/test/pipelinerun_test.go @@ -25,7 +25,7 @@ import ( "testing" "time" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" diff --git a/test/remote_test.go b/test/remote_test.go index ca503bf7eec..10672b58e08 100644 --- a/test/remote_test.go +++ b/test/remote_test.go @@ -28,7 +28,7 @@ import ( "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/registry" "github.com/google/go-containerregistry/pkg/v1/remote" - tb "github.com/tektoncd/pipeline/internal/builder/v1alpha1" + tb "github.com/tektoncd/pipeline/internal/builder/v1beta1" ) func TestCreateImage(t *testing.T) { @@ -71,7 +71,7 @@ func TestCreateImage(t *testing.T) { if diff := cmp.Diff(m.Layers[0].Annotations["cdf.tekton.image.kind"], "task"); diff != "" { t.Error(diff) } - if diff := cmp.Diff(m.Layers[0].Annotations["cdf.tekton.image.apiVersion"], "v1alpha1"); diff != "" { + if diff := cmp.Diff(m.Layers[0].Annotations["cdf.tekton.image.apiVersion"], "v1beta1"); diff != "" { t.Error(diff) }