From de4b92582e17ec0b25f334599ca9187c79758030 Mon Sep 17 00:00:00 2001 From: Andrew Bayer Date: Mon, 19 Sep 2022 12:29:05 -0400 Subject: [PATCH] Move remote resolution out of alpha Closes #4710 Based on discussions around promoting features last week, I'm opting to skip the need for a `beta` flag and take remote resolution straight to `stable`. I'm confident in the API stability, so I don't think there's a reason to wait since v1 hasn't happened yet. And for that matter, v1 is expecting remote resolution to be on by default anyway. Deprecation of the legacy `taskRef.bundle` and `pipelineRef.bundle` syntax will be handled in a separate PR (#5514). Signed-off-by: Andrew Bayer --- cmd/webhook/main.go | 18 +- config/300-resolutionrequest.yaml | 8 +- config/resolvers/config-feature-flags.yaml | 16 +- docs/bundle-resolver.md | 2 +- docs/cluster-resolver.md | 2 +- docs/git-resolver.md | 2 +- docs/how-to-write-a-resolver.md | 2 +- docs/hub-resolver.md | 2 +- docs/install.md | 3 - docs/resolution-getting-started.md | 9 +- docs/resolver-template/README.md | 2 +- .../cmd/demoresolver/main.go | 9 +- .../cmd/demoresolver/main_test.go | 14 +- .../{alpha => }/bundles-resolver.yaml | 0 .../taskruns/{alpha => }/git-resolver.yaml | 0 .../taskruns/{alpha => }/hub-resolver.yaml | 0 hack/update-openapigen.sh | 2 +- pkg/apis/pipeline/v1/openapi_generated.go | 2 +- pkg/apis/pipeline/v1/pipeline_types.go | 10 - pkg/apis/pipeline/v1/pipeline_types_test.go | 20 +- .../pipeline/v1/pipelineref_validation.go | 20 +- .../v1/pipelineref_validation_test.go | 43 ++- pkg/apis/pipeline/v1/resolver_types.go | 3 +- pkg/apis/pipeline/v1/swagger.json | 2 +- pkg/apis/pipeline/v1/taskref_validation.go | 17 -- .../pipeline/v1/taskref_validation_test.go | 48 +--- .../pipeline/v1beta1/openapi_generated.go | 221 ++++++++-------- pkg/apis/pipeline/v1beta1/pipeline_types.go | 9 - .../pipeline/v1beta1/pipeline_types_test.go | 25 +- .../v1beta1/pipelineref_validation.go | 15 -- .../v1beta1/pipelineref_validation_test.go | 59 +---- pkg/apis/pipeline/v1beta1/resolver_types.go | 3 +- pkg/apis/pipeline/v1beta1/swagger.json | 245 +++++++++--------- .../pipeline/v1beta1/taskref_validation.go | 5 - .../v1beta1/taskref_validation_test.go | 54 +--- pkg/apis/resolution/register.go | 10 + .../v1beta1/resolution_request_types.go | 1 + pkg/reconciler/pipelinerun/controller.go | 2 +- .../pipelinerun/pipelinerun_test.go | 31 +-- .../pipelinerun/pipelinespec/pipelinespec.go | 4 +- .../pipelinespec/pipelinespec_test.go | 13 - .../pipelinerun/resources/pipelineref.go | 8 +- .../pipelinerun/resources/pipelineref_test.go | 16 +- .../resolutionrequest/controller.go | 4 +- .../resolutionrequest/resolutionrequest.go | 8 +- .../resolutionrequest_test.go | 44 ++-- pkg/reconciler/taskrun/controller.go | 2 +- pkg/reconciler/taskrun/resources/taskref.go | 8 +- .../taskrun/resources/taskref_test.go | 16 +- pkg/reconciler/taskrun/resources/taskspec.go | 4 +- .../taskrun/resources/taskspec_test.go | 13 - pkg/reconciler/taskrun/taskrun_test.go | 24 +- pkg/remote/resolution/resolver.go | 8 +- pkg/resolution/resolver/bundle/params.go | 34 ++- pkg/resolution/resolver/bundle/resolver.go | 5 +- .../resolver/bundle/resolver_test.go | 108 +++++--- pkg/resolution/resolver/cluster/resolver.go | 26 +- .../resolver/cluster/resolver_test.go | 130 ++++++---- .../resolver/framework/controller.go | 8 +- .../resolver/framework/fakeresolver.go | 21 +- .../resolver/framework/interface.go | 6 +- .../resolver/framework/reconciler.go | 24 +- .../resolver/framework/reconciler_test.go | 77 +++--- .../framework/testing/fakecontroller.go | 10 +- pkg/resolution/resolver/git/resolver.go | 32 ++- pkg/resolution/resolver/git/resolver_test.go | 90 +++++-- pkg/resolution/resolver/hub/resolver.go | 33 ++- pkg/resolution/resolver/hub/resolver_test.go | 30 ++- pkg/resolution/resource/crd_resource.go | 20 +- pkg/resolution/resource/name.go | 33 ++- pkg/resolution/resource/request.go | 8 +- pkg/resolution/resource/resource.go | 4 +- test/controller.go | 8 +- test/e2e-common.sh | 6 +- test/resolution.go | 20 +- test/resolvers_test.go | 3 - test/tektonbundles_test.go | 6 +- 77 files changed, 910 insertions(+), 940 deletions(-) rename examples/v1beta1/taskruns/{alpha => }/bundles-resolver.yaml (100%) rename examples/v1beta1/taskruns/{alpha => }/git-resolver.yaml (100%) rename examples/v1beta1/taskruns/{alpha => }/hub-resolver.yaml (100%) diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 93668dcd01d..5e46e349ead 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -27,7 +27,9 @@ import ( v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/resolution" resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + resolutionv1beta1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/configmap" @@ -66,6 +68,8 @@ var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{ // resolution // v1alpha1 resolutionv1alpha1.SchemeGroupVersion.WithKind("ResolutionRequest"): &resolutionv1alpha1.ResolutionRequest{}, + // v1beta1 + resolutionv1beta1.SchemeGroupVersion.WithKind("ResolutionRequest"): &resolutionv1beta1.ResolutionRequest{}, } func newDefaultingAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl { @@ -140,8 +144,10 @@ func newConfigValidationController(ctx context.Context, cmw configmap.Watcher) * func newConversionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl { // nolint: revive var ( - v1beta1GroupVersion = v1beta1.SchemeGroupVersion.Version - v1GroupVersion = v1.SchemeGroupVersion.Version + v1beta1GroupVersion = v1beta1.SchemeGroupVersion.Version + v1GroupVersion = v1.SchemeGroupVersion.Version + resolutionv1alpha1GroupVersion = resolutionv1alpha1.SchemeGroupVersion.Version + resolutionv1beta1GroupVersion = resolutionv1beta1.SchemeGroupVersion.Version ) return conversion.NewConversionController(ctx, // The path on which to serve the webhook @@ -182,6 +188,14 @@ func newConversionController(ctx context.Context, cmw configmap.Watcher) *contro v1GroupVersion: &v1.PipelineRun{}, }, }, + resolutionv1beta1.Kind("ResolutionRequest"): { + DefinitionName: resolution.ResolutionRequestResource.String(), + HubVersion: resolutionv1beta1GroupVersion, + Zygotes: map[string]conversion.ConvertibleObject{ + resolutionv1alpha1GroupVersion: &resolutionv1alpha1.ResolutionRequest{}, + resolutionv1beta1GroupVersion: &resolutionv1beta1.ResolutionRequest{}, + }, + }, }, // A function that infuses the context passed to ConvertTo/ConvertFrom/SetDefaults with custom metadata diff --git a/config/300-resolutionrequest.yaml b/config/300-resolutionrequest.yaml index b520d8adac4..99462c88238 100644 --- a/config/300-resolutionrequest.yaml +++ b/config/300-resolutionrequest.yaml @@ -33,8 +33,8 @@ spec: - resolutionrequests versions: - name: v1alpha1 - served: true - storage: true + served: false + storage: false subresources: status: {} schema: @@ -56,8 +56,8 @@ spec: type: string jsonPath: ".status.conditions[?(@.type=='Succeeded')].reason" - name: v1beta1 - served: false - storage: false + served: true + storage: true subresources: status: {} schema: diff --git a/config/resolvers/config-feature-flags.yaml b/config/resolvers/config-feature-flags.yaml index bdd40ec7de1..cc83a651135 100644 --- a/config/resolvers/config-feature-flags.yaml +++ b/config/resolvers/config-feature-flags.yaml @@ -23,18 +23,10 @@ metadata: app.kubernetes.io/part-of: tekton-pipelines data: # Setting this flag to "true" enables remote resolution of Tekton OCI bundles. - # This is an experimental feature and thus should still be considered - # an alpha feature. - enable-bundles-resolver: "false" + enable-bundles-resolver: "true" # Setting this flag to "true" enables remote resolution of tasks and pipelines via the Tekton Hub. - # This is an experimental feature and thus should still be considered - # an alpha feature. - enable-hub-resolver: "false" + enable-hub-resolver: "true" # Setting this flag to "true" enables remote resolution of tasks and pipelines from Git repositories. - # This is an experimental feature and thus should still be considered - # an alpha feature. - enable-git-resolver: "false" + enable-git-resolver: "true" # Setting this flag to "true" enables remote resolution of tasks and pipelines from other namespaces within the cluster. - # This is an experimental feature and thus should still be considered - # an alpha feature. - enable-cluster-resolver: "false" + enable-cluster-resolver: "true" diff --git a/docs/bundle-resolver.md b/docs/bundle-resolver.md index b53116af891..dae4fbfc428 100644 --- a/docs/bundle-resolver.md +++ b/docs/bundle-resolver.md @@ -15,7 +15,7 @@ This Resolver responds to type `bundles`. ## Requirements -- A cluster running Tekton Pipeline v0.40.0 or later, with the `alpha` feature gate enabled. +- A cluster running Tekton Pipeline v0.41.0 or later. - The [built-in remote resolvers installed](./install.md#installing-and-configuring-remote-task-and-pipeline-resolution). - The `enable-bundles-resolver` feature flag in the `resolvers-feature-flags` ConfigMap in the `tekton-pipelines-resolvers` namespace set to `true`. diff --git a/docs/cluster-resolver.md b/docs/cluster-resolver.md index 224ab04317c..daaab693396 100644 --- a/docs/cluster-resolver.md +++ b/docs/cluster-resolver.md @@ -14,7 +14,7 @@ This Resolver responds to type `cluster`. ## Requirements -- A cluster running Tekton Pipeline v0.40.0 or later, with the `alpha` feature gate enabled. +- A cluster running Tekton Pipeline v0.41.0 or later. - The [built-in remote resolvers installed](./install.md#installing-and-configuring-remote-task-and-pipeline-resolution). - The `enable-cluster-resolver` feature flag in the `resolvers-feature-flags` ConfigMap in the `tekton-pipelines-resolvers` namespace set to `true`. diff --git a/docs/git-resolver.md b/docs/git-resolver.md index 1a5de1a66fc..d1c2b0ba2a8 100644 --- a/docs/git-resolver.md +++ b/docs/git-resolver.md @@ -16,7 +16,7 @@ This Resolver responds to type `git`. ## Requirements -- A cluster running Tekton Pipeline v0.40.0 or later, with the `alpha` feature gate enabled. +- A cluster running Tekton Pipeline v0.41.0 or later. - The [built-in remote resolvers installed](./install.md#installing-and-configuring-remote-task-and-pipeline-resolution). - The `enable-git-resolver` feature flag in the `resolvers-feature-flags` ConfigMap in the `tekton-pipelines-resolvers` namespace set to `true`. diff --git a/docs/how-to-write-a-resolver.md b/docs/how-to-write-a-resolver.md index 1a8a067d859..e765d208980 100644 --- a/docs/how-to-write-a-resolver.md +++ b/docs/how-to-write-a-resolver.md @@ -368,7 +368,7 @@ pipeline. Create a file called `test-request.yaml` with the following content: ```yaml -apiVersion: resolution.tekton.dev/v1alpha1 +apiVersion: resolution.tekton.dev/v1beta1 kind: ResolutionRequest metadata: name: test-request diff --git a/docs/hub-resolver.md b/docs/hub-resolver.md index b6677c66cb3..7d1e18ce7be 100644 --- a/docs/hub-resolver.md +++ b/docs/hub-resolver.md @@ -13,7 +13,7 @@ Use resolver type `hub`. ## Requirements -- A cluster running Tekton Pipeline v0.40.0 or later, with the `alpha` feature gate enabled. +- A cluster running Tekton Pipeline v0.41.0 or later. - The [built-in remote resolvers installed](./install.md#installing-and-configuring-remote-task-and-pipeline-resolution). - The `enable-hub-resolver` feature flag in the `resolvers-feature-flags` ConfigMap in the `tekton-pipelines-resolvers` namespace set to `true`. diff --git a/docs/install.md b/docs/install.md index 2f1cefd8f31..e95d47824bf 100644 --- a/docs/install.md +++ b/docs/install.md @@ -269,8 +269,6 @@ data: ## Installing and configuring remote Task and Pipeline resolution -**NOTE**: Remote resolution is currently [an `alpha` feature](#alpha-features). - To install the latest release of the [built-in remote resolvers](#built-in-resolvers), run the following command: @@ -462,7 +460,6 @@ Features currently in "alpha" are: | [Propagated `Parameters`](./taskruns.md#propagated-parameters) | [TEP-0107](https://github.com/tektoncd/community/blob/main/teps/0107-propagating-parameters.md) | [v0.36.0](https://github.com/tektoncd/pipeline/releases/tag/v0.36.0) | | | [Propagated `Workspaces`](./pipelineruns.md#propagated-workspaces) | [TEP-0111](https://github.com/tektoncd/community/blob/main/teps/0111-propagating-workspaces.md) | | | | [Windows Scripts](./tasks.md#windows-scripts) | [TEP-0057](https://github.com/tektoncd/community/blob/main/teps/0057-windows-support.md) | [v0.28.0](https://github.com/tektoncd/pipeline/releases/tag/v0.28.0) | | -| [Remote Tasks](./taskruns.md#remote-tasks) and [Remote Pipelines](./pipelineruns.md#remote-pipelines) | [TEP-0060](https://github.com/tektoncd/community/blob/main/teps/0060-remote-resolution.md) | [v0.35.0](https://github.com/tektoncd/pipeline/releases/tag/v0.35.0) | | | [Debug](./debug.md) | [TEP-0042](https://github.com/tektoncd/community/blob/main/teps/0042-taskrun-breakpoint-on-failure.md) | [v0.26.0](https://github.com/tektoncd/pipeline/releases/tag/v0.26.0) | | | [Step and Sidecar Overrides](./taskruns.md#overriding-task-steps-and-sidecars) | [TEP-0094](https://github.com/tektoncd/community/blob/main/teps/0094-specifying-resource-requirements-at-runtime.md) | | | | [Matrix](./matrix.md) | [TEP-0090](https://github.com/tektoncd/community/blob/main/teps/0090-matrix.md) | [v0.38.0](https://github.com/tektoncd/pipeline/releases/tag/v0.38.0) | | diff --git a/docs/resolution-getting-started.md b/docs/resolution-getting-started.md index 7c30a86bbd6..98261024502 100644 --- a/docs/resolution-getting-started.md +++ b/docs/resolution-getting-started.md @@ -24,16 +24,11 @@ with a Pipeline stored in a git repo. See [the installation instructions for Tekton Pipeline](./install.md#installing-tekton-pipelines-on-kubernetes), and [the installation instructions for the built-in resolvers](./install.md#installing-and-configuring-remote-task-and-pipeline-resolution). -## Step 2: Configure Pipelines to enable alpha features and resolvers +## Step 2: Configure Pipelines to enable resolvers -Tekton Pipelines currently has its integration with remote resolution behind -the alpha feature gate, and enabling specific resolvers is controlled by feature -flags as well: +Remote resolvers for Tekton Pipelines are enabled by feature flags: ```sh -# update the feature-flags configmap in the tekton-pipelines namespace -kubectl patch -n tekton-pipelines configmap feature-flags -p '{"data":{"enable-api-fields":"alpha","enable-git-resolver":"true"}}' - # update the resolvers-feature-flags configmap in the tekton-pipelines-resolvers namespace kubectl patch -n tekton-pipelines-resolvers configmap resolvers-feature-flags -p '{"data":{"enable-git-resolver":"true"}}' ``` diff --git a/docs/resolver-template/README.md b/docs/resolver-template/README.md index 7d3f804ac90..fbd6a8b5355 100644 --- a/docs/resolver-template/README.md +++ b/docs/resolver-template/README.md @@ -58,7 +58,7 @@ Try creating a `ResolutionRequest` targeting `"demo"` with no parameters: ```bash $ cat < rrtest.yaml -apiVersion: resolution.tekton.dev/v1alpha1 +apiVersion: resolution.tekton.dev/v1beta1 kind: ResolutionRequest metadata: name: test-resolver-template diff --git a/docs/resolver-template/cmd/demoresolver/main.go b/docs/resolver-template/cmd/demoresolver/main.go index a48e0c58b9d..1e442ec2cd6 100644 --- a/docs/resolver-template/cmd/demoresolver/main.go +++ b/docs/resolver-template/cmd/demoresolver/main.go @@ -17,7 +17,8 @@ import ( "context" "errors" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" filteredinformerfactory "knative.dev/pkg/client/injection/kube/informers/factory/filtered" @@ -25,7 +26,7 @@ import ( ) func main() { - ctx := filteredinformerfactory.WithSelectors(context.Background(), v1alpha1.ManagedByLabelKey) + ctx := filteredinformerfactory.WithSelectors(context.Background(), v1beta1.ManagedByLabelKey) sharedmain.MainWithContext(ctx, "controller", framework.NewController(ctx, &resolver{}), ) @@ -51,7 +52,7 @@ func (r *resolver) GetSelector(context.Context) map[string]string { } // ValidateParams ensures parameters from a request are as expected. -func (r *resolver) ValidateParams(ctx context.Context, params map[string]string) error { +func (r *resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { if len(params) > 0 { return errors.New("no params allowed") } @@ -59,7 +60,7 @@ func (r *resolver) ValidateParams(ctx context.Context, params map[string]string) } // Resolve uses the given params to resolve the requested file or resource. -func (r *resolver) Resolve(ctx context.Context, params map[string]string) (framework.ResolvedResource, error) { +func (r *resolver) Resolve(ctx context.Context, params []pipelinev1beta1.Param) (framework.ResolvedResource, error) { return &myResolvedResource{}, nil } diff --git a/docs/resolver-template/cmd/demoresolver/main_test.go b/docs/resolver-template/cmd/demoresolver/main_test.go index 8fb0bf3f76b..137aed1b96b 100644 --- a/docs/resolver-template/cmd/demoresolver/main_test.go +++ b/docs/resolver-template/cmd/demoresolver/main_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" frtesting "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework/testing" @@ -35,9 +35,9 @@ func TestResolver(t *testing.T) { r := &resolver{} - request := &v1alpha1.ResolutionRequest{ + request := &v1beta1.ResolutionRequest{ TypeMeta: metav1.TypeMeta{ - APIVersion: "resolution.tekton.dev/v1alpha1", + APIVersion: "resolution.tekton.dev/v1beta1", Kind: "ResolutionRequest", }, ObjectMeta: metav1.ObjectMeta{ @@ -48,14 +48,14 @@ func TestResolver(t *testing.T) { resolutioncommon.LabelKeyResolverType: "demo", }, }, - Spec: v1alpha1.ResolutionRequestSpec{}, + Spec: v1beta1.ResolutionRequestSpec{}, } d := test.Data{ - ResolutionRequests: []*v1alpha1.ResolutionRequest{request}, + ResolutionRequests: []*v1beta1.ResolutionRequest{request}, } - expectedStatus := &v1alpha1.ResolutionRequestStatus{ - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{ + expectedStatus := &v1beta1.ResolutionRequestStatus{ + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString([]byte(pipeline)), }, } diff --git a/examples/v1beta1/taskruns/alpha/bundles-resolver.yaml b/examples/v1beta1/taskruns/bundles-resolver.yaml similarity index 100% rename from examples/v1beta1/taskruns/alpha/bundles-resolver.yaml rename to examples/v1beta1/taskruns/bundles-resolver.yaml diff --git a/examples/v1beta1/taskruns/alpha/git-resolver.yaml b/examples/v1beta1/taskruns/git-resolver.yaml similarity index 100% rename from examples/v1beta1/taskruns/alpha/git-resolver.yaml rename to examples/v1beta1/taskruns/git-resolver.yaml diff --git a/examples/v1beta1/taskruns/alpha/hub-resolver.yaml b/examples/v1beta1/taskruns/hub-resolver.yaml similarity index 100% rename from examples/v1beta1/taskruns/alpha/hub-resolver.yaml rename to examples/v1beta1/taskruns/hub-resolver.yaml diff --git a/hack/update-openapigen.sh b/hack/update-openapigen.sh index 5b9fce309b2..f47748b9b1c 100755 --- a/hack/update-openapigen.sh +++ b/hack/update-openapigen.sh @@ -39,7 +39,7 @@ do input_dirs=./pkg/apis/pipeline/${APIVERSION},./pkg/apis/pipeline/pod,knative.dev/pkg/apis,knative.dev/pkg/apis/duck/v1beta1 if [ ${APIVERSION} = "v1beta1" ] then - input_dirs=${input_dirs},./pkg/apis/resource/v1alpha1,./pkg/apis/resolution/v1alpha1 + input_dirs=${input_dirs},./pkg/apis/resource/v1alpha1,./pkg/apis/resolution/v1beta1 fi echo "Generating OpenAPI specification for ${APIVERSION} ..." diff --git a/pkg/apis/pipeline/v1/openapi_generated.go b/pkg/apis/pipeline/v1/openapi_generated.go index 8245f6026cb..c4eed7e87ca 100644 --- a/pkg/apis/pipeline/v1/openapi_generated.go +++ b/pkg/apis/pipeline/v1/openapi_generated.go @@ -1985,7 +1985,7 @@ func schema_pkg_apis_pipeline_v1_ResolverRef(ref common.ReferenceCallback) commo return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo. This feature is in alpha and these fields are only available when the alpha feature gate is enabled.", + Description: "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "resolver": { diff --git a/pkg/apis/pipeline/v1/pipeline_types.go b/pkg/apis/pipeline/v1/pipeline_types.go index 9062358aa14..d9d8b44fe52 100644 --- a/pkg/apis/pipeline/v1/pipeline_types.go +++ b/pkg/apis/pipeline/v1/pipeline_types.go @@ -246,7 +246,6 @@ func (pt PipelineTask) validateCustomTask() (errs *apis.FieldError) { // validateTask validates a pipeline task or a final task for taskRef and taskSpec func (pt PipelineTask) validateTask(ctx context.Context) (errs *apis.FieldError) { - cfg := config.FromContextOrDefaults(ctx) // Validate TaskSpec if it's present if pt.TaskSpec != nil { errs = errs.Also(pt.TaskSpec.Validate(ctx).ViaField("taskSpec")) @@ -260,15 +259,6 @@ func (pt PipelineTask) validateTask(ctx context.Context) (errs *apis.FieldError) } else if pt.TaskRef.Resolver == "" { errs = errs.Also(apis.ErrInvalidValue("taskRef must specify name", "taskRef.name")) } - if cfg.FeatureFlags.EnableAPIFields != config.AlphaAPIFields { - // fail if resolver or resource are present when enable-api-fields is false. - if pt.TaskRef.Resolver != "" { - errs = errs.Also(apis.ErrDisallowedFields("taskref.resolver")) - } - if len(pt.TaskRef.Params) > 0 { - errs = errs.Also(apis.ErrDisallowedFields("taskref.params")) - } - } } return errs } diff --git a/pkg/apis/pipeline/v1/pipeline_types_test.go b/pkg/apis/pipeline/v1/pipeline_types_test.go index 31e84124adc..32452cfbb5f 100644 --- a/pkg/apis/pipeline/v1/pipeline_types_test.go +++ b/pkg/apis/pipeline/v1/pipeline_types_test.go @@ -202,17 +202,15 @@ func TestPipelineTask_ValidateRegularTask_Success(t *testing.T) { TaskSpec: &EmbeddedTask{TaskSpec: getTaskSpec()}, }, }, { - name: "pipeline task - use of resolver with the feature flag set", + name: "pipeline task - use of resolver", tasks: PipelineTask{ TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resolver: "bar"}}, - }, - enableAPIFields: true, + }, enableAPIFields: true, }, { - name: "pipeline task - use of resolver params with the feature flag set", + name: "pipeline task - use of resolver params", tasks: PipelineTask{ TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{{}}}}, }, - enableAPIFields: true, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -268,18 +266,6 @@ func TestPipelineTask_ValidateRegularTask_Failure(t *testing.T) { Message: `invalid value: taskRef must specify name`, Paths: []string{"taskRef.name"}, }, - }, { - name: "pipeline task - use of resolver without the feature flag set", - task: PipelineTask{ - TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resolver: "bar"}}, - }, - expectedError: *apis.ErrDisallowedFields("taskref.resolver"), - }, { - name: "pipeline task - use of resolver params without the feature flag set", - task: PipelineTask{ - TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{{}}}}, - }, - expectedError: *apis.ErrDisallowedFields("taskref.params"), }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1/pipelineref_validation.go b/pkg/apis/pipeline/v1/pipelineref_validation.go index 8fd971828cf..62698edd650 100644 --- a/pkg/apis/pipeline/v1/pipelineref_validation.go +++ b/pkg/apis/pipeline/v1/pipelineref_validation.go @@ -19,8 +19,6 @@ package v1 import ( "context" - "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/version" "knative.dev/pkg/apis" ) @@ -32,10 +30,20 @@ func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) { } switch { - case ref.Resolver != "": - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) - if ref.Name != "" { - errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + case ref.Resolver != "" || ref.Params != nil: + if ref.Resolver != "" { + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + } + } + if ref.Params != nil { + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) + } + if ref.Resolver == "" { + errs = errs.Also(apis.ErrMissingField("resolver")) + } + errs = errs.Also(ValidateParameters(ctx, ref.Params)) } case ref.Name == "": errs = errs.Also(apis.ErrMissingField("name")) diff --git a/pkg/apis/pipeline/v1/pipelineref_validation_test.go b/pkg/apis/pipeline/v1/pipelineref_validation_test.go index e97bd2fb603..20b0e28b431 100644 --- a/pkg/apis/pipeline/v1/pipelineref_validation_test.go +++ b/pkg/apis/pipeline/v1/pipelineref_validation_test.go @@ -21,7 +21,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/config" v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/test/diff" "knative.dev/pkg/apis" @@ -38,13 +37,13 @@ func TestPipelineRef_Invalid(t *testing.T) { ref: &v1.PipelineRef{}, wantErr: apis.ErrMissingField("name"), }, { - name: "pipelineref resolver disallowed without alpha feature gate", + name: "pipelineref params disallowed without resolver", ref: &v1.PipelineRef{ ResolverRef: v1.ResolverRef{ - Resolver: "foo", + Params: []v1.Param{}, }, }, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), + wantErr: apis.ErrMissingField("resolver"), }, { name: "pipelineref resolver disallowed in conjunction with pipelineref name", ref: &v1.PipelineRef{ @@ -53,8 +52,37 @@ func TestPipelineRef_Invalid(t *testing.T) { Resolver: "bar", }, }, - wantErr: apis.ErrMultipleOneOf("name", "resolver"), - withContext: config.EnableAlphaAPIFields, + wantErr: apis.ErrMultipleOneOf("name", "resolver"), + }, { + name: "pipelineref params disallowed in conjunction with pipelineref name", + ref: &v1.PipelineRef{ + Name: "bar", + ResolverRef: v1.ResolverRef{ + Params: []v1.Param{{ + Name: "foo", + Value: v1.ParamValue{ + Type: v1.ParamTypeString, + StringVal: "bar", + }, + }}, + }, + }, + wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), + }, { + name: "pipelineref param object requires alpha", + ref: &v1.PipelineRef{ + ResolverRef: v1.ResolverRef{ + Resolver: "some-resolver", + Params: []v1.Param{{ + Name: "foo", + Value: v1.ParamValue{ + Type: v1.ParamTypeObject, + ObjectVal: map[string]string{"bar": "baz"}, + }, + }}, + }, + }, + wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), }} for _, tc := range tests { @@ -80,9 +108,8 @@ func TestPipelineRef_Valid(t *testing.T) { name: "no pipelineRef", ref: nil, }, { - name: "alpha feature: valid resolver", + name: "valid resolver", ref: &v1.PipelineRef{ResolverRef: v1.ResolverRef{Resolver: "git"}}, - wc: config.EnableAlphaAPIFields, }} for _, ts := range tests { diff --git a/pkg/apis/pipeline/v1/resolver_types.go b/pkg/apis/pipeline/v1/resolver_types.go index 140a3ffb7a0..972e6f8dda5 100644 --- a/pkg/apis/pipeline/v1/resolver_types.go +++ b/pkg/apis/pipeline/v1/resolver_types.go @@ -21,8 +21,7 @@ package v1 type ResolverName string // ResolverRef can be used to refer to a Pipeline or Task in a remote -// location like a git repo. This feature is in alpha and these fields -// are only available when the alpha feature gate is enabled. +// location like a git repo. type ResolverRef struct { // Resolver is the name of the resolver that should perform // resolution of the referenced Tekton resource, such as "git". diff --git a/pkg/apis/pipeline/v1/swagger.json b/pkg/apis/pipeline/v1/swagger.json index b48f98ce5e7..81f47d0c023 100644 --- a/pkg/apis/pipeline/v1/swagger.json +++ b/pkg/apis/pipeline/v1/swagger.json @@ -989,7 +989,7 @@ } }, "v1.ResolverRef": { - "description": "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo. This feature is in alpha and these fields are only available when the alpha feature gate is enabled.", + "description": "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo.", "type": "object", "properties": { "params": { diff --git a/pkg/apis/pipeline/v1/taskref_validation.go b/pkg/apis/pipeline/v1/taskref_validation.go index 87f8bb4c54a..284824db313 100644 --- a/pkg/apis/pipeline/v1/taskref_validation.go +++ b/pkg/apis/pipeline/v1/taskref_validation.go @@ -18,10 +18,7 @@ package v1 import ( "context" - "fmt" - "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/version" "knative.dev/pkg/apis" ) @@ -34,13 +31,11 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { if ref.Resolver != "" || ref.Params != nil { if ref.Resolver != "" { - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) if ref.Name != "" { errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) } } if ref.Params != nil { - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "params", config.AlphaAPIFields).ViaField("params")) if ref.Name != "" { errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) } @@ -48,21 +43,9 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { errs = errs.Also(apis.ErrMissingField("resolver")) } errs = errs.Also(ValidateParameters(ctx, ref.Params)) - errs = errs.Also(validateResolutionParamTypes(ref.Params).ViaField("params")) } } else if ref.Name == "" { errs = errs.Also(apis.ErrMissingField("name")) } return } - -func validateResolutionParamTypes(params []Param) (errs *apis.FieldError) { - for i, p := range params { - if p.Value.Type == ParamTypeArray || p.Value.Type == ParamTypeObject { - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("remote resolution parameter type must be %s, not %s", - string(ParamTypeString), string(p.Value.Type))).ViaIndex(i)) - } - } - - return errs -} diff --git a/pkg/apis/pipeline/v1/taskref_validation_test.go b/pkg/apis/pipeline/v1/taskref_validation_test.go index c0ddadf5bc4..18f663c9b89 100644 --- a/pkg/apis/pipeline/v1/taskref_validation_test.go +++ b/pkg/apis/pipeline/v1/taskref_validation_test.go @@ -21,7 +21,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/config" v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/test/diff" "knative.dev/pkg/apis" @@ -38,11 +37,10 @@ func TestTaskRef_Valid(t *testing.T) { name: "simple taskref", taskRef: &v1.TaskRef{Name: "taskrefname"}, }, { - name: "alpha feature: valid resolver", + name: "valid resolver", taskRef: &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git"}}, - wc: config.EnableAlphaAPIFields, }, { - name: "alpha feature: valid resolver with resource parameters", + name: "valid resolver with resource parameters", taskRef: &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git", Params: []v1.Param{{ Name: "repo", Value: *v1.NewStructuredValues("https://github.com/tektoncd/pipeline.git"), @@ -50,7 +48,6 @@ func TestTaskRef_Valid(t *testing.T) { Name: "branch", Value: *v1.NewStructuredValues("baz"), }}}}, - wc: config.EnableAlphaAPIFields, }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { @@ -75,22 +72,6 @@ func TestTaskRef_Invalid(t *testing.T) { name: "missing taskref name", taskRef: &v1.TaskRef{}, wantErr: apis.ErrMissingField("name"), - }, { - name: "taskref resolver disallowed without alpha feature gate", - taskRef: &v1.TaskRef{ - ResolverRef: v1.ResolverRef{ - Resolver: "git", - }, - }, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), - }, { - name: "taskref resource disallowed without alpha feature gate", - taskRef: &v1.TaskRef{ - ResolverRef: v1.ResolverRef{ - Params: []v1.Param{}, - }, - }, - wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), }, { name: "taskref resolver params disallowed without resolver", taskRef: &v1.TaskRef{ @@ -99,7 +80,6 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMissingField("resolver"), - wc: config.EnableAlphaAPIFields, }, { name: "taskref resolver disallowed in conjunction with taskref name", taskRef: &v1.TaskRef{ @@ -109,7 +89,6 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("name", "resolver"), - wc: config.EnableAlphaAPIFields, }, { name: "taskref resolver params disallowed in conjunction with taskref name", taskRef: &v1.TaskRef{ @@ -122,24 +101,6 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), - wc: config.EnableAlphaAPIFields, - }, { - name: "taskref param array not allowed", - taskRef: &v1.TaskRef{ - ResolverRef: v1.ResolverRef{ - Resolver: "some-resolver", - Params: []v1.Param{{ - Name: "foo", - Value: v1.ParamValue{ - Type: v1.ParamTypeArray, - ArrayVal: []string{"bar", "baz"}, - }, - }}, - }, - }, - wantErr: apis.ErrGeneric("remote resolution parameter type must be string, not array"). - Also(apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")). - Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), }, { name: "taskref param object requires alpha", taskRef: &v1.TaskRef{ @@ -154,10 +115,7 @@ func TestTaskRef_Invalid(t *testing.T) { }}, }, }, - wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""). - Also(apis.ErrGeneric("remote resolution parameter type must be string, not object")). - Also(apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")). - Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), + wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1beta1/openapi_generated.go b/pkg/apis/pipeline/v1beta1/openapi_generated.go index 885182db906..19e46c4d3f8 100644 --- a/pkg/apis/pipeline/v1beta1/openapi_generated.go +++ b/pkg/apis/pipeline/v1beta1/openapi_generated.go @@ -30,97 +30,97 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.AffinityAssistantTemplate": schema_pkg_apis_pipeline_pod_AffinityAssistantTemplate(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.Template": schema_pkg_apis_pipeline_pod_Template(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ChildStatusReference": schema_pkg_apis_pipeline_v1beta1_ChildStatusReference(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDelivery": schema_pkg_apis_pipeline_v1beta1_CloudEventDelivery(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDeliveryState": schema_pkg_apis_pipeline_v1beta1_CloudEventDeliveryState(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTask": schema_pkg_apis_pipeline_v1beta1_ClusterTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTaskList": schema_pkg_apis_pipeline_v1beta1_ClusterTaskList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CustomRun": schema_pkg_apis_pipeline_v1beta1_CustomRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CustomRunList": schema_pkg_apis_pipeline_v1beta1_CustomRunList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CustomRunSpec": schema_pkg_apis_pipeline_v1beta1_CustomRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedCustomRunSpec": schema_pkg_apis_pipeline_v1beta1_EmbeddedCustomRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedTask": schema_pkg_apis_pipeline_v1beta1_EmbeddedTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.InternalTaskModifier": schema_pkg_apis_pipeline_v1beta1_InternalTaskModifier(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Matrix": schema_pkg_apis_pipeline_v1beta1_Matrix(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param": schema_pkg_apis_pipeline_v1beta1_Param(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamSpec": schema_pkg_apis_pipeline_v1beta1_ParamSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamValue": schema_pkg_apis_pipeline_v1beta1_ParamValue(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Pipeline": schema_pkg_apis_pipeline_v1beta1_Pipeline(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineDeclaredResource": schema_pkg_apis_pipeline_v1beta1_PipelineDeclaredResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineList": schema_pkg_apis_pipeline_v1beta1_PipelineList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRef": schema_pkg_apis_pipeline_v1beta1_PipelineRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceBinding": schema_pkg_apis_pipeline_v1beta1_PipelineResourceBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceRef": schema_pkg_apis_pipeline_v1beta1_PipelineResourceRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceResult": schema_pkg_apis_pipeline_v1beta1_PipelineResourceResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResult": schema_pkg_apis_pipeline_v1beta1_PipelineResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRun": schema_pkg_apis_pipeline_v1beta1_PipelineRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunList": schema_pkg_apis_pipeline_v1beta1_PipelineRunList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunResult": schema_pkg_apis_pipeline_v1beta1_PipelineRunResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatusFields": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatusFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunTaskRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunTaskRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineSpec": schema_pkg_apis_pipeline_v1beta1_PipelineSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTask": schema_pkg_apis_pipeline_v1beta1_PipelineTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskInputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskInputResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskMetadata": schema_pkg_apis_pipeline_v1beta1_PipelineTaskMetadata(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskOutputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskOutputResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskParam": schema_pkg_apis_pipeline_v1beta1_PipelineTaskParam(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskResources": schema_pkg_apis_pipeline_v1beta1_PipelineTaskResources(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRun": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineWorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_PipelineWorkspaceDeclaration(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PropertySpec": schema_pkg_apis_pipeline_v1beta1_PropertySpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverRef": schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResultRef": schema_pkg_apis_pipeline_v1beta1_ResultRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Sidecar": schema_pkg_apis_pipeline_v1beta1_Sidecar(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SidecarState": schema_pkg_apis_pipeline_v1beta1_SidecarState(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SkippedTask": schema_pkg_apis_pipeline_v1beta1_SkippedTask(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Step": schema_pkg_apis_pipeline_v1beta1_Step(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepOutputConfig": schema_pkg_apis_pipeline_v1beta1_StepOutputConfig(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepState": schema_pkg_apis_pipeline_v1beta1_StepState(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepTemplate": schema_pkg_apis_pipeline_v1beta1_StepTemplate(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Task": schema_pkg_apis_pipeline_v1beta1_Task(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskList": schema_pkg_apis_pipeline_v1beta1_TaskList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRef": schema_pkg_apis_pipeline_v1beta1_TaskRef(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResource": schema_pkg_apis_pipeline_v1beta1_TaskResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResourceBinding": schema_pkg_apis_pipeline_v1beta1_TaskResourceBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResources": schema_pkg_apis_pipeline_v1beta1_TaskResources(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResult": schema_pkg_apis_pipeline_v1beta1_TaskResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRun": schema_pkg_apis_pipeline_v1beta1_TaskRun(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunDebug": schema_pkg_apis_pipeline_v1beta1_TaskRunDebug(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunInputs": schema_pkg_apis_pipeline_v1beta1_TaskRunInputs(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunList": schema_pkg_apis_pipeline_v1beta1_TaskRunList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunOutputs": schema_pkg_apis_pipeline_v1beta1_TaskRunOutputs(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResources": schema_pkg_apis_pipeline_v1beta1_TaskRunResources(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResult": schema_pkg_apis_pipeline_v1beta1_TaskRunResult(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSidecarOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunSidecarOverride(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSpec": schema_pkg_apis_pipeline_v1beta1_TaskRunSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus": schema_pkg_apis_pipeline_v1beta1_TaskRunStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatusFields": schema_pkg_apis_pipeline_v1beta1_TaskRunStatusFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStepOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunStepOverride(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskSpec": schema_pkg_apis_pipeline_v1beta1_TaskSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TimeoutFields": schema_pkg_apis_pipeline_v1beta1_TimeoutFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression": schema_pkg_apis_pipeline_v1beta1_WhenExpression(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceBinding": schema_pkg_apis_pipeline_v1beta1_WorkspaceBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_WorkspaceDeclaration(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspacePipelineTaskBinding": schema_pkg_apis_pipeline_v1beta1_WorkspacePipelineTaskBinding(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage": schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref), - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequest": schema_pkg_apis_resolution_v1alpha1_ResolutionRequest(ref), - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestList": schema_pkg_apis_resolution_v1alpha1_ResolutionRequestList(ref), - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestSpec": schema_pkg_apis_resolution_v1alpha1_ResolutionRequestSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestStatus": schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestStatusFields": schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatusFields(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResource": schema_pkg_apis_resource_v1alpha1_PipelineResource(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceList": schema_pkg_apis_resource_v1alpha1_PipelineResourceList(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceSpec": schema_pkg_apis_resource_v1alpha1_PipelineResourceSpec(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceStatus": schema_pkg_apis_resource_v1alpha1_PipelineResourceStatus(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceDeclaration": schema_pkg_apis_resource_v1alpha1_ResourceDeclaration(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceParam": schema_pkg_apis_resource_v1alpha1_ResourceParam(ref), - "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.SecretParam": schema_pkg_apis_resource_v1alpha1_SecretParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.AffinityAssistantTemplate": schema_pkg_apis_pipeline_pod_AffinityAssistantTemplate(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.Template": schema_pkg_apis_pipeline_pod_Template(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ChildStatusReference": schema_pkg_apis_pipeline_v1beta1_ChildStatusReference(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDelivery": schema_pkg_apis_pipeline_v1beta1_CloudEventDelivery(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CloudEventDeliveryState": schema_pkg_apis_pipeline_v1beta1_CloudEventDeliveryState(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTask": schema_pkg_apis_pipeline_v1beta1_ClusterTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ClusterTaskList": schema_pkg_apis_pipeline_v1beta1_ClusterTaskList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CustomRun": schema_pkg_apis_pipeline_v1beta1_CustomRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CustomRunList": schema_pkg_apis_pipeline_v1beta1_CustomRunList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.CustomRunSpec": schema_pkg_apis_pipeline_v1beta1_CustomRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedCustomRunSpec": schema_pkg_apis_pipeline_v1beta1_EmbeddedCustomRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.EmbeddedTask": schema_pkg_apis_pipeline_v1beta1_EmbeddedTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.InternalTaskModifier": schema_pkg_apis_pipeline_v1beta1_InternalTaskModifier(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Matrix": schema_pkg_apis_pipeline_v1beta1_Matrix(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param": schema_pkg_apis_pipeline_v1beta1_Param(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamSpec": schema_pkg_apis_pipeline_v1beta1_ParamSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ParamValue": schema_pkg_apis_pipeline_v1beta1_ParamValue(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Pipeline": schema_pkg_apis_pipeline_v1beta1_Pipeline(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineDeclaredResource": schema_pkg_apis_pipeline_v1beta1_PipelineDeclaredResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineList": schema_pkg_apis_pipeline_v1beta1_PipelineList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRef": schema_pkg_apis_pipeline_v1beta1_PipelineRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceBinding": schema_pkg_apis_pipeline_v1beta1_PipelineResourceBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceRef": schema_pkg_apis_pipeline_v1beta1_PipelineResourceRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResourceResult": schema_pkg_apis_pipeline_v1beta1_PipelineResourceResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineResult": schema_pkg_apis_pipeline_v1beta1_PipelineResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRun": schema_pkg_apis_pipeline_v1beta1_PipelineRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunList": schema_pkg_apis_pipeline_v1beta1_PipelineRunList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunResult": schema_pkg_apis_pipeline_v1beta1_PipelineRunResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunStatusFields": schema_pkg_apis_pipeline_v1beta1_PipelineRunStatusFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunTaskRunStatus": schema_pkg_apis_pipeline_v1beta1_PipelineRunTaskRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineSpec": schema_pkg_apis_pipeline_v1beta1_PipelineSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTask": schema_pkg_apis_pipeline_v1beta1_PipelineTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskInputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskInputResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskMetadata": schema_pkg_apis_pipeline_v1beta1_PipelineTaskMetadata(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskOutputResource": schema_pkg_apis_pipeline_v1beta1_PipelineTaskOutputResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskParam": schema_pkg_apis_pipeline_v1beta1_PipelineTaskParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskResources": schema_pkg_apis_pipeline_v1beta1_PipelineTaskResources(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRun": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineTaskRunSpec": schema_pkg_apis_pipeline_v1beta1_PipelineTaskRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineWorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_PipelineWorkspaceDeclaration(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PropertySpec": schema_pkg_apis_pipeline_v1beta1_PropertySpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResolverRef": schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.ResultRef": schema_pkg_apis_pipeline_v1beta1_ResultRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Sidecar": schema_pkg_apis_pipeline_v1beta1_Sidecar(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SidecarState": schema_pkg_apis_pipeline_v1beta1_SidecarState(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SkippedTask": schema_pkg_apis_pipeline_v1beta1_SkippedTask(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Step": schema_pkg_apis_pipeline_v1beta1_Step(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepOutputConfig": schema_pkg_apis_pipeline_v1beta1_StepOutputConfig(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepState": schema_pkg_apis_pipeline_v1beta1_StepState(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepTemplate": schema_pkg_apis_pipeline_v1beta1_StepTemplate(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Task": schema_pkg_apis_pipeline_v1beta1_Task(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskList": schema_pkg_apis_pipeline_v1beta1_TaskList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRef": schema_pkg_apis_pipeline_v1beta1_TaskRef(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResource": schema_pkg_apis_pipeline_v1beta1_TaskResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResourceBinding": schema_pkg_apis_pipeline_v1beta1_TaskResourceBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResources": schema_pkg_apis_pipeline_v1beta1_TaskResources(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskResult": schema_pkg_apis_pipeline_v1beta1_TaskResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRun": schema_pkg_apis_pipeline_v1beta1_TaskRun(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunDebug": schema_pkg_apis_pipeline_v1beta1_TaskRunDebug(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunInputs": schema_pkg_apis_pipeline_v1beta1_TaskRunInputs(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunList": schema_pkg_apis_pipeline_v1beta1_TaskRunList(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunOutputs": schema_pkg_apis_pipeline_v1beta1_TaskRunOutputs(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResources": schema_pkg_apis_pipeline_v1beta1_TaskRunResources(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunResult": schema_pkg_apis_pipeline_v1beta1_TaskRunResult(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSidecarOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunSidecarOverride(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunSpec": schema_pkg_apis_pipeline_v1beta1_TaskRunSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatus": schema_pkg_apis_pipeline_v1beta1_TaskRunStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStatusFields": schema_pkg_apis_pipeline_v1beta1_TaskRunStatusFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskRunStepOverride": schema_pkg_apis_pipeline_v1beta1_TaskRunStepOverride(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TaskSpec": schema_pkg_apis_pipeline_v1beta1_TaskSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.TimeoutFields": schema_pkg_apis_pipeline_v1beta1_TimeoutFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WhenExpression": schema_pkg_apis_pipeline_v1beta1_WhenExpression(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceBinding": schema_pkg_apis_pipeline_v1beta1_WorkspaceBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_WorkspaceDeclaration(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspacePipelineTaskBinding": schema_pkg_apis_pipeline_v1beta1_WorkspacePipelineTaskBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage": schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequest": schema_pkg_apis_resolution_v1beta1_ResolutionRequest(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequestList": schema_pkg_apis_resolution_v1beta1_ResolutionRequestList(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequestSpec": schema_pkg_apis_resolution_v1beta1_ResolutionRequestSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequestStatus": schema_pkg_apis_resolution_v1beta1_ResolutionRequestStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequestStatusFields": schema_pkg_apis_resolution_v1beta1_ResolutionRequestStatusFields(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResource": schema_pkg_apis_resource_v1alpha1_PipelineResource(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceList": schema_pkg_apis_resource_v1alpha1_PipelineResourceList(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceSpec": schema_pkg_apis_resource_v1alpha1_PipelineResourceSpec(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceStatus": schema_pkg_apis_resource_v1alpha1_PipelineResourceStatus(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceDeclaration": schema_pkg_apis_resource_v1alpha1_ResourceDeclaration(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.ResourceParam": schema_pkg_apis_resource_v1alpha1_ResourceParam(ref), + "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.SecretParam": schema_pkg_apis_resource_v1alpha1_SecretParam(ref), } } @@ -2853,7 +2853,7 @@ func schema_pkg_apis_pipeline_v1beta1_ResolverRef(ref common.ReferenceCallback) return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo. This feature is in alpha and these fields are only available when the alpha feature gate is enabled.", + Description: "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "resolver": { @@ -5607,7 +5607,7 @@ func schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref common.ReferenceCallbac } } -func schema_pkg_apis_resolution_v1alpha1_ResolutionRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_resolution_v1beta1_ResolutionRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -5638,25 +5638,25 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequest(ref common.ReferenceC SchemaProps: spec.SchemaProps{ Description: "Spec holds the information for the request part of the resource request.", Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestSpec"), + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequestSpec"), }, }, "status": { SchemaProps: spec.SchemaProps{ Description: "Status communicates the state of the request and, ultimately, the content of the resolved resource.", Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestStatus"), + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequestStatus"), }, }, }, }, }, Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestSpec", "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequestStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequestSpec", "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequestStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } -func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestList(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_resolution_v1beta1_ResolutionRequestList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -5690,7 +5690,7 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestList(ref common.Refere Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequest"), + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequest"), }, }, }, @@ -5701,11 +5701,11 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestList(ref common.Refere }, }, Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ResolutionRequest", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ResolutionRequest", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, } } -func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_resolution_v1beta1_ResolutionRequestSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -5713,16 +5713,19 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestSpec(ref common.Refere Type: []string{"object"}, Properties: map[string]spec.Schema{ "params": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "Parameters are the runtime attributes passed to the resolver to help it figure out how to resolve the resource being requested. For example: repo URL, commit SHA, path to file, the kind of authentication to leverage, etc.", - Type: []string{"object"}, - AdditionalProperties: &spec.SchemaOrBool{ - Allows: true, + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Default: map[string]interface{}{}, + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param"), }, }, }, @@ -5731,10 +5734,12 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestSpec(ref common.Refere }, }, }, + Dependencies: []string{ + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Param"}, } } -func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_resolution_v1beta1_ResolutionRequestStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -5801,7 +5806,7 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatus(ref common.Refe } } -func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatusFields(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_resolution_v1beta1_ResolutionRequestStatusFields(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ diff --git a/pkg/apis/pipeline/v1beta1/pipeline_types.go b/pkg/apis/pipeline/v1beta1/pipeline_types.go index 6102977c04c..54ec3f06978 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types.go @@ -299,15 +299,6 @@ func (pt PipelineTask) validateTask(ctx context.Context) (errs *apis.FieldError) if !cfg.FeatureFlags.EnableTektonOCIBundles && pt.TaskRef.Bundle != "" { errs = errs.Also(apis.ErrDisallowedFields("taskref.bundle")) } - if cfg.FeatureFlags.EnableAPIFields != config.AlphaAPIFields { - // fail if resolver or resource are present when enable-api-fields is false. - if pt.TaskRef.Resolver != "" { - errs = errs.Also(apis.ErrDisallowedFields("taskref.resolver")) - } - if len(pt.TaskRef.Params) > 0 { - errs = errs.Also(apis.ErrDisallowedFields("taskref.resource")) - } - } } return errs } diff --git a/pkg/apis/pipeline/v1beta1/pipeline_types_test.go b/pkg/apis/pipeline/v1beta1/pipeline_types_test.go index 3e495fbcb1a..f15b76c8cbd 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_types_test.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_types_test.go @@ -247,17 +247,15 @@ func TestPipelineTask_ValidateRegularTask_Success(t *testing.T) { TaskSpec: &EmbeddedTask{TaskSpec: getTaskSpec()}, }, }, { - name: "pipeline task - use of resolver with the feature flag set", + name: "pipeline task - use of resolver", tasks: PipelineTask{ TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resolver: "bar"}}, }, - enableAPIFields: true, }, { - name: "pipeline task - use of params with the feature flag set", + name: "pipeline task - use of params", tasks: PipelineTask{ TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{}}}, }, - enableAPIFields: true, }, { name: "pipeline task - use of bundle with the feature flag set", tasks: PipelineTask{ @@ -330,25 +328,6 @@ func TestPipelineTask_ValidateRegularTask_Failure(t *testing.T) { TaskRef: &TaskRef{Name: "bar", Bundle: "docker.io/foo"}, }, expectedError: *apis.ErrDisallowedFields("taskref.bundle"), - }, { - name: "pipeline task - use of resolver without the feature flag set", - task: PipelineTask{ - TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resolver: "bar"}}, - }, - expectedError: *apis.ErrDisallowedFields("taskref.resolver"), - }, { - name: "pipeline task - use of resolver params without the feature flag set", - task: PipelineTask{ - TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{{ - Name: "bar", - Value: ParamValue{ - Type: ParamTypeString, - StringVal: "baz", - }, - }}, - }}, - }, - expectedError: *apis.ErrDisallowedFields("taskref.resource"), }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1beta1/pipelineref_validation.go b/pkg/apis/pipeline/v1beta1/pipelineref_validation.go index 2c7efd57c73..c52e2d1de35 100644 --- a/pkg/apis/pipeline/v1beta1/pipelineref_validation.go +++ b/pkg/apis/pipeline/v1beta1/pipelineref_validation.go @@ -22,7 +22,6 @@ import ( "github.com/google/go-containerregistry/pkg/name" "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/version" "knative.dev/pkg/apis" ) @@ -35,7 +34,6 @@ func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) { if ref.Resolver != "" || ref.Params != nil { if ref.Resolver != "" { - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) if ref.Name != "" { errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) } @@ -44,7 +42,6 @@ func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) { } } if ref.Params != nil { - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "params", config.AlphaAPIFields).ViaField("params")) if ref.Name != "" { errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) } @@ -55,7 +52,6 @@ func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) { errs = errs.Also(apis.ErrMissingField("resolver")) } errs = errs.Also(ValidateParameters(ctx, ref.Params)) - errs = errs.Also(validateResolutionParamTypes(ref.Params).ViaField("params")) } } else { if ref.Name == "" { @@ -80,14 +76,3 @@ func validateBundleFeatureFlag(ctx context.Context, featureName string, wantValu } return nil } - -func validateResolutionParamTypes(params []Param) (errs *apis.FieldError) { - for i, p := range params { - if p.Value.Type == ParamTypeArray || p.Value.Type == ParamTypeObject { - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("remote resolution parameter type must be %s, not %s", - string(ParamTypeString), string(p.Value.Type))).ViaIndex(i)) - } - } - - return errs -} diff --git a/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go b/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go index f7bc45aca2e..d871ef7ea78 100644 --- a/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go @@ -62,22 +62,6 @@ func TestPipelineRef_Invalid(t *testing.T) { name: "pipelineRef without Pipeline Name", ref: &v1beta1.PipelineRef{}, wantErr: apis.ErrMissingField("name"), - }, { - name: "pipelineref resolver disallowed without alpha feature gate", - ref: &v1beta1.PipelineRef{ - ResolverRef: v1beta1.ResolverRef{ - Resolver: "foo", - }, - }, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), - }, { - name: "pipelineref params disallowed without alpha feature gate", - ref: &v1beta1.PipelineRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{}, - }, - }, - wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), }, { name: "pipelineref params disallowed without resolver", ref: &v1beta1.PipelineRef{ @@ -85,8 +69,7 @@ func TestPipelineRef_Invalid(t *testing.T) { Params: []v1beta1.Param{}, }, }, - wantErr: apis.ErrMissingField("resolver"), - withContext: config.EnableAlphaAPIFields, + wantErr: apis.ErrMissingField("resolver"), }, { name: "pipelineref resolver disallowed in conjunction with pipelineref name", ref: &v1beta1.PipelineRef{ @@ -95,8 +78,7 @@ func TestPipelineRef_Invalid(t *testing.T) { Resolver: "bar", }, }, - wantErr: apis.ErrMultipleOneOf("name", "resolver"), - withContext: config.EnableAlphaAPIFields, + wantErr: apis.ErrMultipleOneOf("name", "resolver"), }, { name: "pipelineref resolver disallowed in conjunction with pipelineref bundle", ref: &v1beta1.PipelineRef{ @@ -106,7 +88,7 @@ func TestPipelineRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("bundle", "resolver"), - withContext: config.EnableAlphaAPIFields, + withContext: enableTektonOCIBundles(t), }, { name: "pipelineref params disallowed in conjunction with pipelineref name", ref: &v1beta1.PipelineRef{ @@ -121,8 +103,7 @@ func TestPipelineRef_Invalid(t *testing.T) { }}, }, }, - wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), - withContext: config.EnableAlphaAPIFields, + wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), }, { name: "pipelineref params disallowed in conjunction with pipelineref bundle", ref: &v1beta1.PipelineRef{ @@ -138,26 +119,9 @@ func TestPipelineRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("bundle", "params").Also(apis.ErrMissingField("resolver")), - withContext: config.EnableAlphaAPIFields, - }, { - name: "pipelineref param array not allowed", - ref: &v1beta1.PipelineRef{ - ResolverRef: v1beta1.ResolverRef{ - Resolver: "some-resolver", - Params: []v1beta1.Param{{ - Name: "foo", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeArray, - ArrayVal: []string{"bar", "baz"}, - }, - }}, - }, - }, - wantErr: apis.ErrGeneric("remote resolution parameter type must be string, not array"). - Also(apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")). - Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), + withContext: enableTektonOCIBundles(t), }, { - name: "pipelineref param object not allowed", + name: "pipelineref param object requires alpha", ref: &v1beta1.PipelineRef{ ResolverRef: v1beta1.ResolverRef{ Resolver: "some-resolver", @@ -170,10 +134,7 @@ func TestPipelineRef_Invalid(t *testing.T) { }}, }, }, - wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""). - Also(apis.ErrGeneric("remote resolution parameter type must be string, not object")). - Also(apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")). - Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), + wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), }} for _, tc := range tests { @@ -199,11 +160,10 @@ func TestPipelineRef_Valid(t *testing.T) { name: "no pipelineRef", ref: nil, }, { - name: "alpha feature: valid resolver", + name: "valid resolver", ref: &v1beta1.PipelineRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}}, - wc: config.EnableAlphaAPIFields, }, { - name: "alpha feature: valid resolver with params", + name: "valid resolver with params", ref: &v1beta1.PipelineRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git", Params: []v1beta1.Param{{ Name: "repo", Value: v1beta1.ParamValue{ @@ -217,7 +177,6 @@ func TestPipelineRef_Valid(t *testing.T) { StringVal: "baz", }, }}}}, - wc: config.EnableAlphaAPIFields, }} for _, ts := range tests { diff --git a/pkg/apis/pipeline/v1beta1/resolver_types.go b/pkg/apis/pipeline/v1beta1/resolver_types.go index 2da2fae52fa..1cb0c85fe25 100644 --- a/pkg/apis/pipeline/v1beta1/resolver_types.go +++ b/pkg/apis/pipeline/v1beta1/resolver_types.go @@ -21,8 +21,7 @@ package v1beta1 type ResolverName string // ResolverRef can be used to refer to a Pipeline or Task in a remote -// location like a git repo. This feature is in alpha and these fields -// are only available when the alpha feature gate is enabled. +// location like a git repo. type ResolverRef struct { // Resolver is the name of the resolver that should perform // resolution of the referenced Tekton resource, such as "git". diff --git a/pkg/apis/pipeline/v1beta1/swagger.json b/pkg/apis/pipeline/v1beta1/swagger.json index 6a831aaa724..8a33cd82e91 100644 --- a/pkg/apis/pipeline/v1beta1/swagger.json +++ b/pkg/apis/pipeline/v1beta1/swagger.json @@ -234,127 +234,6 @@ "description": "PipelineResourceStatus does not contain anything because PipelineResources on their own do not have a status Deprecated", "type": "object" }, - "v1alpha1.ResolutionRequest": { - "description": "ResolutionRequest is an object for requesting the content of a Tekton resource like a pipeline.yaml.", - "type": "object", - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {}, - "$ref": "#/definitions/v1.ObjectMeta" - }, - "spec": { - "description": "Spec holds the information for the request part of the resource request.", - "default": {}, - "$ref": "#/definitions/v1alpha1.ResolutionRequestSpec" - }, - "status": { - "description": "Status communicates the state of the request and, ultimately, the content of the resolved resource.", - "default": {}, - "$ref": "#/definitions/v1alpha1.ResolutionRequestStatus" - } - } - }, - "v1alpha1.ResolutionRequestList": { - "description": "ResolutionRequestList is a list of ResolutionRequests.", - "type": "object", - "required": [ - "items" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1alpha1.ResolutionRequest" - } - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {}, - "$ref": "#/definitions/v1.ListMeta" - } - } - }, - "v1alpha1.ResolutionRequestSpec": { - "description": "ResolutionRequestSpec are all the fields in the spec of the ResolutionRequest CRD.", - "type": "object", - "properties": { - "params": { - "description": "Parameters are the runtime attributes passed to the resolver to help it figure out how to resolve the resource being requested. For example: repo URL, commit SHA, path to file, the kind of authentication to leverage, etc.", - "type": "object", - "additionalProperties": { - "type": "string", - "default": "" - } - } - } - }, - "v1alpha1.ResolutionRequestStatus": { - "description": "ResolutionRequestStatus are all the fields in a ResolutionRequest's status subresource.", - "type": "object", - "required": [ - "data" - ], - "properties": { - "annotations": { - "description": "Annotations is additional Status fields for the Resource to save some additional State as well as convey more information to the user. This is roughly akin to Annotations on any k8s resource, just the reconciler conveying richer information outwards.", - "type": "object", - "additionalProperties": { - "type": "string", - "default": "" - } - }, - "conditions": { - "description": "Conditions the latest available observations of a resource's current state.", - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/knative.Condition" - }, - "x-kubernetes-patch-merge-key": "type", - "x-kubernetes-patch-strategy": "merge" - }, - "data": { - "description": "Data is a string representation of the resolved content of the requested resource in-lined into the ResolutionRequest object.", - "type": "string", - "default": "" - }, - "observedGeneration": { - "description": "ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.", - "type": "integer", - "format": "int64" - } - } - }, - "v1alpha1.ResolutionRequestStatusFields": { - "description": "ResolutionRequestStatusFields are the ResolutionRequest-specific fields for the status subresource.", - "type": "object", - "required": [ - "data" - ], - "properties": { - "data": { - "description": "Data is a string representation of the resolved content of the requested resource in-lined into the ResolutionRequest object.", - "type": "string", - "default": "" - } - } - }, "v1alpha1.ResourceDeclaration": { "description": "ResourceDeclaration defines an input or output PipelineResource declared as a requirement by another type such as a Task or Condition. The Name field will be used to refer to these PipelineResources within the type's definition, and when provided as an Input, the Name will be the path to the volume mounted containing this PipelineResource as an input (e.g. an input Resource named `workspace` will be mounted at `/workspace`).", "type": "object", @@ -1737,8 +1616,130 @@ } } }, + "v1beta1.ResolutionRequest": { + "description": "ResolutionRequest is an object for requesting the content of a Tekton resource like a pipeline.yaml.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "default": {}, + "$ref": "#/definitions/v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds the information for the request part of the resource request.", + "default": {}, + "$ref": "#/definitions/v1beta1.ResolutionRequestSpec" + }, + "status": { + "description": "Status communicates the state of the request and, ultimately, the content of the resolved resource.", + "default": {}, + "$ref": "#/definitions/v1beta1.ResolutionRequestStatus" + } + } + }, + "v1beta1.ResolutionRequestList": { + "description": "ResolutionRequestList is a list of ResolutionRequests.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1beta1.ResolutionRequest" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "default": {}, + "$ref": "#/definitions/v1.ListMeta" + } + } + }, + "v1beta1.ResolutionRequestSpec": { + "description": "ResolutionRequestSpec are all the fields in the spec of the ResolutionRequest CRD.", + "type": "object", + "properties": { + "params": { + "description": "Parameters are the runtime attributes passed to the resolver to help it figure out how to resolve the resource being requested. For example: repo URL, commit SHA, path to file, the kind of authentication to leverage, etc.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1beta1.Param" + }, + "x-kubernetes-list-type": "atomic" + } + } + }, + "v1beta1.ResolutionRequestStatus": { + "description": "ResolutionRequestStatus are all the fields in a ResolutionRequest's status subresource.", + "type": "object", + "required": [ + "data" + ], + "properties": { + "annotations": { + "description": "Annotations is additional Status fields for the Resource to save some additional State as well as convey more information to the user. This is roughly akin to Annotations on any k8s resource, just the reconciler conveying richer information outwards.", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + }, + "conditions": { + "description": "Conditions the latest available observations of a resource's current state.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/knative.Condition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "data": { + "description": "Data is a string representation of the resolved content of the requested resource in-lined into the ResolutionRequest object.", + "type": "string", + "default": "" + }, + "observedGeneration": { + "description": "ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.", + "type": "integer", + "format": "int64" + } + } + }, + "v1beta1.ResolutionRequestStatusFields": { + "description": "ResolutionRequestStatusFields are the ResolutionRequest-specific fields for the status subresource.", + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "description": "Data is a string representation of the resolved content of the requested resource in-lined into the ResolutionRequest object.", + "type": "string", + "default": "" + } + } + }, "v1beta1.ResolverRef": { - "description": "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo. This feature is in alpha and these fields are only available when the alpha feature gate is enabled.", + "description": "ResolverRef can be used to refer to a Pipeline or Task in a remote location like a git repo.", "type": "object", "properties": { "params": { diff --git a/pkg/apis/pipeline/v1beta1/taskref_validation.go b/pkg/apis/pipeline/v1beta1/taskref_validation.go index 0abaa47ce35..971a78498b7 100644 --- a/pkg/apis/pipeline/v1beta1/taskref_validation.go +++ b/pkg/apis/pipeline/v1beta1/taskref_validation.go @@ -20,8 +20,6 @@ import ( "context" "github.com/google/go-containerregistry/pkg/name" - "github.com/tektoncd/pipeline/pkg/apis/config" - "github.com/tektoncd/pipeline/pkg/apis/version" "knative.dev/pkg/apis" ) @@ -34,7 +32,6 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { if ref.Resolver != "" || ref.Params != nil { if ref.Resolver != "" { - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver")) if ref.Name != "" { errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) } @@ -43,7 +40,6 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { } } if ref.Params != nil { - errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "params", config.AlphaAPIFields).ViaField("params")) if ref.Name != "" { errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) } @@ -54,7 +50,6 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { errs = errs.Also(apis.ErrMissingField("resolver")) } errs = errs.Also(ValidateParameters(ctx, ref.Params)) - errs = errs.Also(validateResolutionParamTypes(ref.Params).ViaField("params")) } } else { if ref.Name == "" { diff --git a/pkg/apis/pipeline/v1beta1/taskref_validation_test.go b/pkg/apis/pipeline/v1beta1/taskref_validation_test.go index 71379970a6d..7d68f04ef8c 100644 --- a/pkg/apis/pipeline/v1beta1/taskref_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/taskref_validation_test.go @@ -21,7 +21,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/test/diff" "knative.dev/pkg/apis" @@ -38,11 +37,10 @@ func TestTaskRef_Valid(t *testing.T) { name: "simple taskref", taskRef: &v1beta1.TaskRef{Name: "taskrefname"}, }, { - name: "alpha feature: valid resolver", + name: "valid resolver", taskRef: &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}}, - wc: config.EnableAlphaAPIFields, }, { - name: "alpha feature: valid resolver with params", + name: "valid resolver with params", taskRef: &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git", Params: []v1beta1.Param{{ Name: "repo", Value: v1beta1.ParamValue{ @@ -56,13 +54,12 @@ func TestTaskRef_Valid(t *testing.T) { StringVal: "baz", }, }}}}, - wc: config.EnableAlphaAPIFields, }, { name: "valid bundle", taskRef: &v1beta1.TaskRef{ Name: "bundled-task", Bundle: "gcr.io/my-bundle"}, - wc: config.EnableAlphaAPIFields, + wc: enableTektonOCIBundles(t), }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { @@ -109,22 +106,6 @@ func TestTaskRef_Invalid(t *testing.T) { }, wantErr: apis.ErrInvalidValue("invalid bundle reference", "bundle", "could not parse reference: invalid reference"), wc: enableTektonOCIBundles(t), - }, { - name: "taskref resolver disallowed without alpha feature gate", - taskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Resolver: "git", - }, - }, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), - }, { - name: "taskref params disallowed without alpha feature gate", - taskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Params: []v1beta1.Param{}, - }, - }, - wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), }, { name: "taskref params disallowed without resolver", taskRef: &v1beta1.TaskRef{ @@ -133,7 +114,6 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMissingField("resolver"), - wc: config.EnableAlphaAPIFields, }, { name: "taskref resolver disallowed in conjunction with taskref name", taskRef: &v1beta1.TaskRef{ @@ -143,7 +123,6 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("name", "resolver"), - wc: config.EnableAlphaAPIFields, }, { name: "taskref resolver disallowed in conjunction with taskref bundle", taskRef: &v1beta1.TaskRef{ @@ -153,7 +132,7 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("bundle", "resolver"), - wc: config.EnableAlphaAPIFields, + wc: enableTektonOCIBundles(t), }, { name: "taskref params disallowed in conjunction with taskref name", taskRef: &v1beta1.TaskRef{ @@ -169,7 +148,6 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), - wc: config.EnableAlphaAPIFields, }, { name: "taskref params disallowed in conjunction with taskref bundle", taskRef: &v1beta1.TaskRef{ @@ -185,24 +163,7 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("bundle", "params").Also(apis.ErrMissingField("resolver")), - wc: config.EnableAlphaAPIFields, - }, { - name: "taskref param array not allowed", - taskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Resolver: "some-resolver", - Params: []v1beta1.Param{{ - Name: "foo", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeArray, - ArrayVal: []string{"bar", "baz"}, - }, - }}, - }, - }, - wantErr: apis.ErrGeneric("remote resolution parameter type must be string, not array"). - Also(apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")). - Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), + wc: enableTektonOCIBundles(t), }, { name: "taskref param object requires alpha", taskRef: &v1beta1.TaskRef{ @@ -217,10 +178,7 @@ func TestTaskRef_Invalid(t *testing.T) { }}, }, }, - wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""). - Also(apis.ErrGeneric("remote resolution parameter type must be string, not object")). - Also(apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")). - Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"")), + wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { diff --git a/pkg/apis/resolution/register.go b/pkg/apis/resolution/register.go index d83bf6eb483..4fd869637eb 100644 --- a/pkg/apis/resolution/register.go +++ b/pkg/apis/resolution/register.go @@ -16,7 +16,17 @@ limitations under the License. package resolution +import "k8s.io/apimachinery/pkg/runtime/schema" + const ( // GroupName is the name of the API group. GroupName = "resolution.tekton.dev" ) + +var ( + // ResolutionRequestResource represents a Tekton ResolutionRequest + ResolutionRequestResource = schema.GroupResource{ + Group: GroupName, + Resource: "resolutionrequests", + } +) diff --git a/pkg/apis/resolution/v1beta1/resolution_request_types.go b/pkg/apis/resolution/v1beta1/resolution_request_types.go index 2fc33139308..e74c6eaaa3f 100644 --- a/pkg/apis/resolution/v1beta1/resolution_request_types.go +++ b/pkg/apis/resolution/v1beta1/resolution_request_types.go @@ -62,6 +62,7 @@ type ResolutionRequestSpec struct { // resource being requested. For example: repo URL, commit SHA, // path to file, the kind of authentication to leverage, etc. // +optional + // +listType=atomic Params []pipelinev1beta1.Param `json:"params,omitempty"` } diff --git a/pkg/reconciler/pipelinerun/controller.go b/pkg/reconciler/pipelinerun/controller.go index fc4649c48ad..080313f6eec 100644 --- a/pkg/reconciler/pipelinerun/controller.go +++ b/pkg/reconciler/pipelinerun/controller.go @@ -28,7 +28,7 @@ import ( taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun" pipelinerunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun" resolutionclient "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" - resolutioninformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest" + resolutioninformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest" resourceinformer "github.com/tektoncd/pipeline/pkg/client/resource/injection/informers/resource/v1alpha1/pipelineresource" "github.com/tektoncd/pipeline/pkg/pipelinerunmetrics" cloudeventclient "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 29349afd47a..967d55907cc 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -7400,10 +7400,7 @@ spec: serviceAccountName: default `) - cms := []*corev1.ConfigMap{withEnabledAlphaAPIFields(newFeatureFlagsConfigMap())} - d := test.Data{ - ConfigMaps: cms, PipelineRuns: []*v1beta1.PipelineRun{pr}, ServiceAccounts: []*corev1.ServiceAccount{{ ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.ServiceAccountName, Namespace: "foo"}, @@ -7417,7 +7414,7 @@ spec: pipelinerun, _ := prt.reconcileRun(pr.Namespace, pr.Name, wantEvents, false) checkPipelineRunConditionStatusAndReason(t, pipelinerun, corev1.ConditionUnknown, ReasonResolvingPipelineRef) - client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1alpha1().ResolutionRequests("default") + client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1beta1().ResolutionRequests("default") resolutionrequests, err := client.List(prt.TestAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error listing resource requests: %v", err) @@ -7478,10 +7475,7 @@ spec: serviceAccountName: default `) - cms := []*corev1.ConfigMap{withEnabledAlphaAPIFields(newFeatureFlagsConfigMap())} - d := test.Data{ - ConfigMaps: cms, PipelineRuns: []*v1beta1.PipelineRun{pr}, ServiceAccounts: []*corev1.ServiceAccount{{ ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.ServiceAccountName, Namespace: "foo"}, @@ -7495,7 +7489,7 @@ spec: pipelinerun, _ := prt.reconcileRun(pr.Namespace, pr.Name, wantEvents, false) checkPipelineRunConditionStatusAndReason(t, pipelinerun, corev1.ConditionUnknown, ReasonResolvingPipelineRef) - client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1alpha1().ResolutionRequests("default") + client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1beta1().ResolutionRequests("default") resolutionrequests, err := client.List(prt.TestAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error listing resource requests: %v", err) @@ -7540,10 +7534,7 @@ spec: serviceAccountName: default `) - cms := []*corev1.ConfigMap{withEnabledAlphaAPIFields(newFeatureFlagsConfigMap())} - d := test.Data{ - ConfigMaps: cms, PipelineRuns: []*v1beta1.PipelineRun{pr}, ServiceAccounts: []*corev1.ServiceAccount{{ ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.ServiceAccountName, Namespace: "foo"}, @@ -7557,7 +7548,7 @@ spec: pipelinerun, _ := prt.reconcileRun(pr.Namespace, pr.Name, wantEvents, false) checkPipelineRunConditionStatusAndReason(t, pipelinerun, corev1.ConditionUnknown, v1beta1.TaskRunReasonResolvingTaskRef) - client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1alpha1().ResolutionRequests("default") + client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1beta1().ResolutionRequests("default") resolutionrequests, err := client.List(prt.TestAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error listing resource requests: %v", err) @@ -7605,10 +7596,7 @@ spec: serviceAccountName: default `) - cms := []*corev1.ConfigMap{withEnabledAlphaAPIFields(newFeatureFlagsConfigMap())} - d := test.Data{ - ConfigMaps: cms, PipelineRuns: []*v1beta1.PipelineRun{pr}, ServiceAccounts: []*corev1.ServiceAccount{{ ObjectMeta: metav1.ObjectMeta{Name: pr.Spec.ServiceAccountName, Namespace: "foo"}, @@ -7622,7 +7610,7 @@ spec: pipelinerun, _ := prt.reconcileRun(pr.Namespace, pr.Name, wantEvents, false) checkPipelineRunConditionStatusAndReason(t, pipelinerun, corev1.ConditionUnknown, v1beta1.TaskRunReasonResolvingTaskRef) - client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1alpha1().ResolutionRequests("default") + client := prt.TestAssets.Clients.ResolutionRequests.ResolutionV1beta1().ResolutionRequests("default") resolutionrequests, err := client.List(prt.TestAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error listing resource requests: %v", err) @@ -7637,9 +7625,14 @@ spec: if resolutionRequestType != resolverName { t.Fatalf("expected resource request type %q but saw %q", resolutionRequestType, resolverName) } - reqParams := resreq.Spec.Parameters - if reqParams["foo"] != "bar" { - t.Fatalf("expected resource request parameter 'bar', but got '%s'", reqParams["foo"]) + fooVal := "" + for _, p := range resreq.Spec.Params { + if p.Name == "foo" { + fooVal = p.Value.StringVal + } + } + if fooVal != "bar" { + t.Fatalf("expected resource request parameter 'bar', but got '%s'", fooVal) } taskBytes := []byte(` diff --git a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go index 8d8da72a0ff..8e1bdd29951 100644 --- a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go +++ b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -35,7 +34,6 @@ type GetPipeline func(context.Context, string) (v1beta1.PipelineObject, error) func GetPipelineData(ctx context.Context, pipelineRun *v1beta1.PipelineRun, getPipeline GetPipeline) (*metav1.ObjectMeta, *v1beta1.PipelineSpec, error) { pipelineMeta := metav1.ObjectMeta{} pipelineSpec := v1beta1.PipelineSpec{} - cfg := config.FromContextOrDefaults(ctx) switch { case pipelineRun.Spec.PipelineRef != nil && pipelineRun.Spec.PipelineRef.Name != "": // Get related pipeline for pipelinerun @@ -49,7 +47,7 @@ func GetPipelineData(ctx context.Context, pipelineRun *v1beta1.PipelineRun, getP case pipelineRun.Spec.PipelineSpec != nil: pipelineMeta = pipelineRun.ObjectMeta pipelineSpec = *pipelineRun.Spec.PipelineSpec - case cfg.FeatureFlags.EnableAPIFields == config.AlphaAPIFields && pipelineRun.Spec.PipelineRef != nil && pipelineRun.Spec.PipelineRef.Resolver != "": + case pipelineRun.Spec.PipelineRef != nil && pipelineRun.Spec.PipelineRef.Resolver != "": pipeline, err := getPipeline(ctx, "") switch { case err != nil: diff --git a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go index 289f3ef0a80..9580486ccbe 100644 --- a/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go +++ b/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/test/diff" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -154,11 +153,7 @@ func TestGetPipelineData_ResolutionSuccess(t *testing.T) { Spec: *sourceSpec.DeepCopy(), }, nil } - // Enable alpha fields for remote resolution ctx := context.Background() - cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields - ctx = config.ToContext(ctx, cfg) resolvedMeta, resolvedSpec, err := GetPipelineData(ctx, pr, getPipeline) if err != nil { t.Fatalf("Unexpected error getting mocked data: %v", err) @@ -207,11 +202,7 @@ func TestGetPipelineData_ResolutionError(t *testing.T) { getPipeline := func(ctx context.Context, n string) (v1beta1.PipelineObject, error) { return nil, errors.New("something went wrong") } - // Enable alpha fields for remote resolution ctx := context.Background() - cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields - ctx = config.ToContext(ctx, cfg) _, _, err := GetPipelineData(ctx, pr, getPipeline) if err == nil { t.Fatalf("Expected error when unable to find referenced Pipeline but got none") @@ -234,11 +225,7 @@ func TestGetPipelineData_ResolvedNilPipeline(t *testing.T) { getPipeline := func(ctx context.Context, n string) (v1beta1.PipelineObject, error) { return nil, nil } - // Enable alpha fields for remote resolution ctx := context.Background() - cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields - ctx = config.ToContext(ctx, cfg) _, _, err := GetPipelineData(ctx, pr, getPipeline) if err == nil { t.Fatalf("Expected error when unable to find referenced Pipeline but got none") diff --git a/pkg/reconciler/pipelinerun/resources/pipelineref.go b/pkg/reconciler/pipelinerun/resources/pipelineref.go index acd35b4a7f9..780f3c42eee 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelineref.go +++ b/pkg/reconciler/pipelinerun/resources/pipelineref.go @@ -70,18 +70,14 @@ func GetPipelineFunc(ctx context.Context, k8s kubernetes.Interface, tekton clien resolver := oci.NewResolver(pr.Bundle, kc) return resolvePipeline(ctx, resolver, name) }, nil - case cfg.FeatureFlags.EnableAPIFields == config.AlphaAPIFields && pr != nil && pr.Resolver != "" && requester != nil: + case pr != nil && pr.Resolver != "" && requester != nil: return func(ctx context.Context, name string) (v1beta1.PipelineObject, error) { - params := map[string]string{} stringReplacements, arrayReplacements, objectReplacements := paramsFromPipelineRun(ctx, pipelineRun) for k, v := range getContextReplacements("", pipelineRun) { stringReplacements[k] = v } replacedParams := replaceParamValues(pr.Params, stringReplacements, arrayReplacements, objectReplacements) - for _, p := range replacedParams { - params[p.Name] = p.Value.StringVal - } - resolver := resolution.NewResolver(requester, pipelineRun, string(pr.Resolver), "", "", params) + resolver := resolution.NewResolver(requester, pipelineRun, string(pr.Resolver), "", "", replacedParams) return resolvePipeline(ctx, resolver, name) }, nil default: diff --git a/pkg/reconciler/pipelinerun/resources/pipelineref_test.go b/pkg/reconciler/pipelinerun/resources/pipelineref_test.go index f160d4d3b01..5c486d165b9 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelineref_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelineref_test.go @@ -264,7 +264,6 @@ func TestGetPipelineFuncSpecAlreadyFetched(t *testing.T) { func TestGetPipelineFunc_RemoteResolution(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields ctx = config.ToContext(ctx, cfg) pipeline := parse.MustParsePipeline(t, pipelineYAMLString) pipelineRef := &v1beta1.PipelineRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} @@ -299,7 +298,6 @@ func TestGetPipelineFunc_RemoteResolution(t *testing.T) { func TestGetPipelineFunc_RemoteResolution_ReplacedParams(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields ctx = config.ToContext(ctx, cfg) pipeline := parse.MustParsePipeline(t, pipelineYAMLString) pipelineRef := &v1beta1.PipelineRef{ @@ -322,10 +320,13 @@ func TestGetPipelineFunc_RemoteResolution_ReplacedParams(t *testing.T) { resolved := test.NewResolvedResource([]byte(pipelineYAML), nil, nil) requester := &test.Requester{ ResolvedResource: resolved, - Params: map[string]string{ - "foo": "bar", - "bar": "test-pipeline", - }, + Params: []v1beta1.Param{{ + Name: "foo", + Value: *v1beta1.NewStructuredValues("bar"), + }, { + Name: "bar", + Value: *v1beta1.NewStructuredValues("test-pipeline"), + }}, } fn, err := resources.GetPipelineFunc(ctx, nil, nil, requester, &v1beta1.PipelineRun{ ObjectMeta: metav1.ObjectMeta{ @@ -389,7 +390,7 @@ func TestGetPipelineFunc_RemoteResolution_ReplacedParams(t *testing.T) { if err == nil { t.Fatal("expected error for non-matching params, did not get one") } - if !strings.Contains(err.Error(), "expected foo param to be bar, but was banana") { + if !strings.Contains(err.Error(), `StringVal: "banana"`) { t.Fatalf("did not receive expected error, got '%s'", err.Error()) } } @@ -397,7 +398,6 @@ func TestGetPipelineFunc_RemoteResolution_ReplacedParams(t *testing.T) { func TestGetPipelineFunc_RemoteResolutionInvalidData(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields ctx = config.ToContext(ctx, cfg) pipelineRef := &v1beta1.PipelineRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} resolvesTo := []byte("INVALID YAML") diff --git a/pkg/reconciler/resolutionrequest/controller.go b/pkg/reconciler/resolutionrequest/controller.go index 7aa19391ff9..eda11f6bd81 100644 --- a/pkg/reconciler/resolutionrequest/controller.go +++ b/pkg/reconciler/resolutionrequest/controller.go @@ -23,8 +23,8 @@ import ( "knative.dev/pkg/configmap" "knative.dev/pkg/controller" - resolutionrequestinformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest" - resolutionrequestreconciler "github.com/tektoncd/pipeline/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest" + resolutionrequestinformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest" + resolutionrequestreconciler "github.com/tektoncd/pipeline/pkg/client/resolution/injection/reconciler/resolution/v1beta1/resolutionrequest" ) // NewController returns a func that returns a knative controller for processing diff --git a/pkg/reconciler/resolutionrequest/resolutionrequest.go b/pkg/reconciler/resolutionrequest/resolutionrequest.go index 88d4e21c4c2..38da3fea352 100644 --- a/pkg/reconciler/resolutionrequest/resolutionrequest.go +++ b/pkg/reconciler/resolutionrequest/resolutionrequest.go @@ -21,8 +21,8 @@ import ( "fmt" "time" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" - rrreconciler "github.com/tektoncd/pipeline/pkg/client/resolution/injection/reconciler/resolution/v1alpha1/resolutionrequest" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" + rrreconciler "github.com/tektoncd/pipeline/pkg/client/resolution/injection/reconciler/resolution/v1beta1/resolutionrequest" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" "k8s.io/utils/clock" "knative.dev/pkg/apis" @@ -44,7 +44,7 @@ const defaultMaximumResolutionDuration = 1 * time.Minute // ReconcileKind processes updates to ResolutionRequests, sets status // fields on it, and returns any errors experienced along the way. -func (r *Reconciler) ReconcileKind(ctx context.Context, rr *v1alpha1.ResolutionRequest) reconciler.Event { +func (r *Reconciler) ReconcileKind(ctx context.Context, rr *v1beta1.ResolutionRequest) reconciler.Event { if rr == nil { return nil } @@ -72,7 +72,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, rr *v1alpha1.ResolutionR // requestDuration returns the amount of time that has passed since a // given ResolutionRequest was created. -func requestDuration(rr *v1alpha1.ResolutionRequest) time.Duration { +func requestDuration(rr *v1beta1.ResolutionRequest) time.Duration { creationTime := rr.ObjectMeta.CreationTimestamp.DeepCopy().Time.UTC() return time.Now().UTC().Sub(creationTime) } diff --git a/pkg/reconciler/resolutionrequest/resolutionrequest_test.go b/pkg/reconciler/resolutionrequest/resolutionrequest_test.go index 1d8e8c7b9a4..d1f28244eaf 100644 --- a/pkg/reconciler/resolutionrequest/resolutionrequest_test.go +++ b/pkg/reconciler/resolutionrequest/resolutionrequest_test.go @@ -24,7 +24,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/test" @@ -87,21 +87,21 @@ func initializeResolutionRequestControllerAssets(t *testing.T, d test.Data) (tes func TestReconcile(t *testing.T) { testCases := []struct { name string - input *v1alpha1.ResolutionRequest - expectedStatus *v1alpha1.ResolutionRequestStatus + input *v1beta1.ResolutionRequest + expectedStatus *v1beta1.ResolutionRequestStatus }{ { name: "new request", - input: &v1alpha1.ResolutionRequest{ + input: &v1beta1.ResolutionRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "rr", Namespace: "foo", CreationTimestamp: metav1.Time{Time: time.Now()}, }, - Spec: v1alpha1.ResolutionRequestSpec{}, - Status: v1alpha1.ResolutionRequestStatus{}, + Spec: v1beta1.ResolutionRequestSpec{}, + Status: v1beta1.ResolutionRequestStatus{}, }, - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{{ Type: apis.ConditionSucceeded, @@ -110,20 +110,20 @@ func TestReconcile(t *testing.T) { Message: resolutioncommon.MessageWaitingForResolver, }}, }, - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{}, + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{}, }, }, { name: "timed out request", - input: &v1alpha1.ResolutionRequest{ + input: &v1beta1.ResolutionRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "rr", Namespace: "foo", CreationTimestamp: metav1.Time{Time: time.Now().Add(-2 * time.Minute)}, }, - Spec: v1alpha1.ResolutionRequestSpec{}, - Status: v1alpha1.ResolutionRequestStatus{}, + Spec: v1beta1.ResolutionRequestSpec{}, + Status: v1beta1.ResolutionRequestStatus{}, }, - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{{ Type: apis.ConditionSucceeded, @@ -132,31 +132,31 @@ func TestReconcile(t *testing.T) { Message: timeoutMessage(), }}, }, - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{}, + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{}, }, }, { name: "populated request", - input: &v1alpha1.ResolutionRequest{ + input: &v1beta1.ResolutionRequest{ ObjectMeta: metav1.ObjectMeta{ Name: "rr", Namespace: "foo", CreationTimestamp: metav1.Time{Time: time.Now()}, }, - Spec: v1alpha1.ResolutionRequestSpec{}, - Status: v1alpha1.ResolutionRequestStatus{ - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{ + Spec: v1beta1.ResolutionRequestSpec{}, + Status: v1beta1.ResolutionRequestStatus{ + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: "some data", }, }, }, - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, }}, }, - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{ + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: "some data", }, }, @@ -166,7 +166,7 @@ func TestReconcile(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { d := test.Data{ - ResolutionRequests: []*v1alpha1.ResolutionRequest{tc.input}, + ResolutionRequests: []*v1beta1.ResolutionRequest{tc.input}, } testAssets, cancel := getResolutionRequestController(t, d) @@ -178,7 +178,7 @@ func TestReconcile(t *testing.T) { t.Fatalf("did not expect an error, but got %v", err) } } - reconciledRR, err := testAssets.Clients.ResolutionRequests.ResolutionV1alpha1().ResolutionRequests(tc.input.Namespace).Get(testAssets.Ctx, tc.input.Name, metav1.GetOptions{}) + reconciledRR, err := testAssets.Clients.ResolutionRequests.ResolutionV1beta1().ResolutionRequests(tc.input.Namespace).Get(testAssets.Ctx, tc.input.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated ResolutionRequest: %v", err) } @@ -190,6 +190,6 @@ func TestReconcile(t *testing.T) { } } -func getRequestName(rr *v1alpha1.ResolutionRequest) string { +func getRequestName(rr *v1beta1.ResolutionRequest) string { return strings.Join([]string{rr.Namespace, rr.Name}, "/") } diff --git a/pkg/reconciler/taskrun/controller.go b/pkg/reconciler/taskrun/controller.go index 493fb08ac7e..9e2b07a9044 100644 --- a/pkg/reconciler/taskrun/controller.go +++ b/pkg/reconciler/taskrun/controller.go @@ -26,7 +26,7 @@ import ( taskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun" taskrunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun" resolutionclient "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" - resolutioninformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest" + resolutioninformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest" resourceinformer "github.com/tektoncd/pipeline/pkg/client/resource/injection/informers/resource/v1alpha1/pipelineresource" "github.com/tektoncd/pipeline/pkg/pod" cloudeventclient "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" diff --git a/pkg/reconciler/taskrun/resources/taskref.go b/pkg/reconciler/taskrun/resources/taskref.go index 742556ecd8b..54c0bb84605 100644 --- a/pkg/reconciler/taskrun/resources/taskref.go +++ b/pkg/reconciler/taskrun/resources/taskref.go @@ -100,11 +100,10 @@ func GetTaskFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset return resolveTask(ctx, resolver, name, kind) }, nil - case cfg.FeatureFlags.EnableAPIFields == config.AlphaAPIFields && tr != nil && tr.Resolver != "" && requester != nil: + case tr != nil && tr.Resolver != "" && requester != nil: // Return an inline function that implements GetTask by calling Resolver.Get with the specified task type and // casting it to a TaskObject. return func(ctx context.Context, name string) (v1beta1.TaskObject, error) { - params := map[string]string{} var replacedParams []v1beta1.Param if ownerAsTR, ok := owner.(*v1beta1.TaskRun); ok { stringReplacements, arrayReplacements := paramsFromTaskRun(ctx, ownerAsTR) @@ -118,10 +117,7 @@ func GetTaskFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset } else { replacedParams = append(replacedParams, tr.Params...) } - for _, p := range replacedParams { - params[p.Name] = p.Value.StringVal - } - resolver := resolution.NewResolver(requester, owner, string(tr.Resolver), trName, namespace, params) + resolver := resolution.NewResolver(requester, owner, string(tr.Resolver), trName, namespace, replacedParams) return resolveTask(ctx, resolver, name, kind) }, nil diff --git a/pkg/reconciler/taskrun/resources/taskref_test.go b/pkg/reconciler/taskrun/resources/taskref_test.go index 45914c8d08c..001853ca525 100644 --- a/pkg/reconciler/taskrun/resources/taskref_test.go +++ b/pkg/reconciler/taskrun/resources/taskref_test.go @@ -509,7 +509,6 @@ echo hello func TestGetTaskFunc_RemoteResolution(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields ctx = config.ToContext(ctx, cfg) task := parse.MustParseTask(t, taskYAMLString) taskRef := &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} @@ -545,7 +544,6 @@ func TestGetTaskFunc_RemoteResolution(t *testing.T) { func TestGetTaskFunc_RemoteResolution_ReplacedParams(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields ctx = config.ToContext(ctx, cfg) task := parse.MustParseTask(t, taskYAMLString) taskRef := &v1beta1.TaskRef{ @@ -568,10 +566,13 @@ func TestGetTaskFunc_RemoteResolution_ReplacedParams(t *testing.T) { resolved := test.NewResolvedResource([]byte(taskYAML), nil, nil) requester := &test.Requester{ ResolvedResource: resolved, - Params: map[string]string{ - "foo": "bar", - "bar": "test-task", - }, + Params: []v1beta1.Param{{ + Name: "foo", + Value: *v1beta1.NewStructuredValues("bar"), + }, { + Name: "bar", + Value: *v1beta1.NewStructuredValues("test-task"), + }}, } tr := &v1beta1.TaskRun{ ObjectMeta: metav1.ObjectMeta{ @@ -637,7 +638,7 @@ func TestGetTaskFunc_RemoteResolution_ReplacedParams(t *testing.T) { if err == nil { t.Fatal("expected error for non-matching params, did not get one") } - if !strings.Contains(err.Error(), "expected foo param to be bar, but was banana") { + if !strings.Contains(err.Error(), `StringVal: "banana"`) { t.Fatalf("did not receive expected error, got '%s'", err.Error()) } } @@ -645,7 +646,6 @@ func TestGetTaskFunc_RemoteResolution_ReplacedParams(t *testing.T) { func TestGetPipelineFunc_RemoteResolutionInvalidData(t *testing.T) { ctx := context.Background() cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields ctx = config.ToContext(ctx, cfg) taskRef := &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "git"}} resolvesTo := []byte("INVALID YAML") diff --git a/pkg/reconciler/taskrun/resources/taskspec.go b/pkg/reconciler/taskrun/resources/taskspec.go index 85cb76bb422..22515be9f6d 100644 --- a/pkg/reconciler/taskrun/resources/taskspec.go +++ b/pkg/reconciler/taskrun/resources/taskspec.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -41,7 +40,6 @@ type GetClusterTask func(name string) (v1beta1.TaskObject, error) func GetTaskData(ctx context.Context, taskRun *v1beta1.TaskRun, getTask GetTask) (*metav1.ObjectMeta, *v1beta1.TaskSpec, error) { taskMeta := metav1.ObjectMeta{} taskSpec := v1beta1.TaskSpec{} - cfg := config.FromContextOrDefaults(ctx) switch { case taskRun.Spec.TaskRef != nil && taskRun.Spec.TaskRef.Name != "": // Get related task for taskrun @@ -55,7 +53,7 @@ func GetTaskData(ctx context.Context, taskRun *v1beta1.TaskRun, getTask GetTask) case taskRun.Spec.TaskSpec != nil: taskMeta = taskRun.ObjectMeta taskSpec = *taskRun.Spec.TaskSpec - case cfg.FeatureFlags.EnableAPIFields == config.AlphaAPIFields && taskRun.Spec.TaskRef != nil && taskRun.Spec.TaskRef.Resolver != "": + case taskRun.Spec.TaskRef != nil && taskRun.Spec.TaskRef.Resolver != "": task, err := getTask(ctx, taskRun.Name) switch { case err != nil: diff --git a/pkg/reconciler/taskrun/resources/taskspec_test.go b/pkg/reconciler/taskrun/resources/taskspec_test.go index deb68382d64..6279f36c2de 100644 --- a/pkg/reconciler/taskrun/resources/taskspec_test.go +++ b/pkg/reconciler/taskrun/resources/taskspec_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/test/diff" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -167,11 +166,7 @@ func TestGetTaskData_ResolutionSuccess(t *testing.T) { Spec: *sourceSpec.DeepCopy(), }, nil } - // Enable alpha fields for remote resolution ctx := context.Background() - cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields - ctx = config.ToContext(ctx, cfg) resolvedMeta, resolvedSpec, err := GetTaskData(ctx, tr, getTask) if err != nil { t.Fatalf("Unexpected error getting mocked data: %v", err) @@ -200,11 +195,7 @@ func TestGetPipelineData_ResolutionError(t *testing.T) { getTask := func(ctx context.Context, n string) (v1beta1.TaskObject, error) { return nil, errors.New("something went wrong") } - // Enable alpha fields for remote resolution ctx := context.Background() - cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields - ctx = config.ToContext(ctx, cfg) _, _, err := GetTaskData(ctx, tr, getTask) if err == nil { t.Fatalf("Expected error when unable to find referenced Task but got none") @@ -227,11 +218,7 @@ func TestGetTaskData_ResolvedNilTask(t *testing.T) { getTask := func(ctx context.Context, n string) (v1beta1.TaskObject, error) { return nil, nil } - // Enable alpha fields for remote resolution ctx := context.Background() - cfg := config.FromContextOrDefaults(ctx) - cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields - ctx = config.ToContext(ctx, cfg) _, _, err := GetTaskData(ctx, tr, getTask) if err == nil { t.Fatalf("Expected error when unable to find referenced Task but got none") diff --git a/pkg/reconciler/taskrun/taskrun_test.go b/pkg/reconciler/taskrun/taskrun_test.go index 2c9b9da8956..8b8b7333ff2 100644 --- a/pkg/reconciler/taskrun/taskrun_test.go +++ b/pkg/reconciler/taskrun/taskrun_test.go @@ -1376,16 +1376,8 @@ spec: serviceAccountName: default `) - cms := []*corev1.ConfigMap{{ - ObjectMeta: metav1.ObjectMeta{Namespace: system.Namespace(), Name: config.GetFeatureFlagsConfigName()}, - Data: map[string]string{ - "enable-api-fields": config.AlphaAPIFields, - }, - }} - d := test.Data{ - ConfigMaps: cms, - TaskRuns: []*v1beta1.TaskRun{tr}, + TaskRuns: []*v1beta1.TaskRun{tr}, ServiceAccounts: []*corev1.ServiceAccount{{ ObjectMeta: metav1.ObjectMeta{Name: tr.Spec.ServiceAccountName, Namespace: "foo"}, }}, @@ -1411,7 +1403,7 @@ spec: t.Errorf("expected no error. Got error %v", err) } - client := testAssets.Clients.ResolutionRequests.ResolutionV1alpha1().ResolutionRequests("default") + client := testAssets.Clients.ResolutionRequests.ResolutionV1beta1().ResolutionRequests("default") resolutionrequests, err := client.List(testAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error listing resource requests: %v", err) @@ -1484,16 +1476,8 @@ spec: serviceAccountName: default `) - cms := []*corev1.ConfigMap{{ - ObjectMeta: metav1.ObjectMeta{Namespace: system.Namespace(), Name: config.GetFeatureFlagsConfigName()}, - Data: map[string]string{ - "enable-api-fields": config.AlphaAPIFields, - }, - }} - d := test.Data{ - ConfigMaps: cms, - TaskRuns: []*v1beta1.TaskRun{tr}, + TaskRuns: []*v1beta1.TaskRun{tr}, ServiceAccounts: []*corev1.ServiceAccount{{ ObjectMeta: metav1.ObjectMeta{Name: tr.Spec.ServiceAccountName, Namespace: "foo"}, }}, @@ -1519,7 +1503,7 @@ spec: t.Errorf("expected no error. Got error %v", err) } - client := testAssets.Clients.ResolutionRequests.ResolutionV1alpha1().ResolutionRequests("default") + client := testAssets.Clients.ResolutionRequests.ResolutionV1beta1().ResolutionRequests("default") resolutionrequests, err := client.List(testAssets.Ctx, metav1.ListOptions{}) if err != nil { t.Fatalf("unexpected error listing resource requests: %v", err) diff --git a/pkg/remote/resolution/resolver.go b/pkg/remote/resolution/resolver.go index 5f0cd53b276..fb79f9e14f9 100644 --- a/pkg/remote/resolution/resolver.go +++ b/pkg/remote/resolution/resolver.go @@ -18,6 +18,8 @@ import ( "errors" "fmt" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme" "github.com/tektoncd/pipeline/pkg/remote" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" @@ -34,7 +36,7 @@ type Resolver struct { requester remoteresource.Requester owner kmeta.OwnerRefable resolverName string - params map[string]string + params []v1beta1.Param targetName string targetNamespace string } @@ -43,7 +45,7 @@ var _ remote.Resolver = &Resolver{} // NewResolver returns an implementation of remote.Resolver capable // of performing asynchronous remote resolution. -func NewResolver(requester remoteresource.Requester, owner kmeta.OwnerRefable, resolverName string, targetName string, targetNamespace string, params map[string]string) remote.Resolver { +func NewResolver(requester remoteresource.Requester, owner kmeta.OwnerRefable, resolverName string, targetName string, targetNamespace string, params []v1beta1.Param) remote.Resolver { return &Resolver{ requester: requester, owner: owner, @@ -87,7 +89,7 @@ func (resolver *Resolver) List(_ context.Context) ([]remote.ResolvedObject, erro return nil, nil } -func buildRequest(resolverName string, owner kmeta.OwnerRefable, name string, namespace string, params map[string]string) (*resolutionRequest, error) { +func buildRequest(resolverName string, owner kmeta.OwnerRefable, name string, namespace string, params []v1beta1.Param) (*resolutionRequest, error) { if name == "" { name = owner.GetObjectMeta().GetName() namespace = owner.GetObjectMeta().GetNamespace() diff --git a/pkg/resolution/resolver/bundle/params.go b/pkg/resolution/resolver/bundle/params.go index 66620871522..94024e45055 100644 --- a/pkg/resolution/resolver/bundle/params.go +++ b/pkg/resolution/resolver/bundle/params.go @@ -18,6 +18,7 @@ import ( "fmt" "github.com/google/go-containerregistry/pkg/name" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" ) @@ -38,50 +39,55 @@ const ParamKind = "kind" // OptionsFromParams parses the params from a resolution request and // converts them into options to pass as part of a bundle request. -func OptionsFromParams(ctx context.Context, params map[string]string) (RequestOptions, error) { +func OptionsFromParams(ctx context.Context, params []pipelinev1beta1.Param) (RequestOptions, error) { opts := RequestOptions{} conf := framework.GetResolverConfigFromContext(ctx) - saVal, ok := params[ParamServiceAccount] + paramsMap := make(map[string]pipelinev1beta1.ParamValue) + for _, p := range params { + paramsMap[p.Name] = p.Value + } + + saVal, ok := paramsMap[ParamServiceAccount] sa := "" - if !ok || saVal == "" { + if !ok || saVal.StringVal == "" { if saString, ok := conf[ConfigServiceAccount]; ok { sa = saString } else { return opts, fmt.Errorf("default Service Account was not set during installation of the bundle resolver") } } else { - sa = saVal + sa = saVal.StringVal } - bundleVal, ok := params[ParamBundle] - if !ok || bundleVal == "" { + bundleVal, ok := paramsMap[ParamBundle] + if !ok || bundleVal.StringVal == "" { return opts, fmt.Errorf("parameter %q required", ParamBundle) } - if _, err := name.ParseReference(bundleVal); err != nil { + if _, err := name.ParseReference(bundleVal.StringVal); err != nil { return opts, fmt.Errorf("invalid bundle reference: %w", err) } - nameVal, ok := params[ParamName] - if !ok || nameVal == "" { + nameVal, ok := paramsMap[ParamName] + if !ok || nameVal.StringVal == "" { return opts, fmt.Errorf("parameter %q required", ParamName) } - kindVal, ok := params[ParamKind] + kindVal, ok := paramsMap[ParamKind] kind := "" - if !ok || kindVal == "" { + if !ok || kindVal.StringVal == "" { if kindString, ok := conf[ConfigKind]; ok { kind = kindString } else { return opts, fmt.Errorf("default resource Kind was not set during installation of the bundle resolver") } } else { - kind = kindVal + kind = kindVal.StringVal } opts.ServiceAccount = sa - opts.Bundle = bundleVal - opts.EntryName = nameVal + opts.Bundle = bundleVal.StringVal + opts.EntryName = nameVal.StringVal opts.Kind = kind return opts, nil diff --git a/pkg/resolution/resolver/bundle/resolver.go b/pkg/resolution/resolver/bundle/resolver.go index bcec7f9c3b4..e78324c278e 100644 --- a/pkg/resolution/resolver/bundle/resolver.go +++ b/pkg/resolution/resolver/bundle/resolver.go @@ -23,6 +23,7 @@ import ( "github.com/google/go-containerregistry/pkg/authn/k8schain" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" "k8s.io/client-go/kubernetes" @@ -68,7 +69,7 @@ func (r *Resolver) GetSelector(context.Context) map[string]string { } // ValidateParams ensures parameters from a request are as expected. -func (r *Resolver) ValidateParams(ctx context.Context, params map[string]string) error { +func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { if r.isDisabled(ctx) { return errors.New(disabledError) } @@ -79,7 +80,7 @@ func (r *Resolver) ValidateParams(ctx context.Context, params map[string]string) } // Resolve uses the given params to resolve the requested file or resource. -func (r *Resolver) Resolve(ctx context.Context, params map[string]string) (framework.ResolvedResource, error) { +func (r *Resolver) Resolve(ctx context.Context, params []pipelinev1beta1.Param) (framework.ResolvedResource, error) { if r.isDisabled(ctx) { return nil, errors.New(disabledError) } diff --git a/pkg/resolution/resolver/bundle/resolver_test.go b/pkg/resolution/resolver/bundle/resolver_test.go index b79c4aa1a1a..401eb0f0129 100644 --- a/pkg/resolution/resolver/bundle/resolver_test.go +++ b/pkg/resolution/resolver/bundle/resolver_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" frtesting "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework/testing" "github.com/tektoncd/pipeline/test/diff" @@ -39,22 +40,37 @@ func TestGetSelector(t *testing.T) { func TestValidateParams(t *testing.T) { resolver := Resolver{} - paramsWithTask := map[string]string{ - ParamKind: "task", - ParamName: "foo", - ParamBundle: "bar", - ParamServiceAccount: "baz", - } + paramsWithTask := []pipelinev1beta1.Param{{ + Name: ParamKind, + Value: *pipelinev1beta1.NewStructuredValues("task"), + }, { + Name: ParamName, + Value: *pipelinev1beta1.NewStructuredValues("foo"), + }, { + Name: ParamBundle, + Value: *pipelinev1beta1.NewStructuredValues("bar"), + }, { + Name: ParamServiceAccount, + Value: *pipelinev1beta1.NewStructuredValues("baz"), + }} + if err := resolver.ValidateParams(resolverContext(), paramsWithTask); err != nil { t.Fatalf("unexpected error validating params: %v", err) } - paramsWithPipeline := map[string]string{ - ParamKind: "pipeline", - ParamName: "foo", - ParamBundle: "bar", - ParamServiceAccount: "baz", - } + paramsWithPipeline := []pipelinev1beta1.Param{{ + Name: ParamKind, + Value: *pipelinev1beta1.NewStructuredValues("pipeline"), + }, { + Name: ParamName, + Value: *pipelinev1beta1.NewStructuredValues("foo"), + }, { + Name: ParamBundle, + Value: *pipelinev1beta1.NewStructuredValues("bar"), + }, { + Name: ParamServiceAccount, + Value: *pipelinev1beta1.NewStructuredValues("baz"), + }} if err := resolver.ValidateParams(resolverContext(), paramsWithPipeline); err != nil { t.Fatalf("unexpected error validating params: %v", err) } @@ -65,12 +81,19 @@ func TestValidateParamsDisabled(t *testing.T) { var err error - params := map[string]string{ - ParamKind: "task", - ParamName: "foo", - ParamBundle: "bar", - ParamServiceAccount: "baz", - } + params := []pipelinev1beta1.Param{{ + Name: ParamKind, + Value: *pipelinev1beta1.NewStructuredValues("task"), + }, { + Name: ParamName, + Value: *pipelinev1beta1.NewStructuredValues("foo"), + }, { + Name: ParamBundle, + Value: *pipelinev1beta1.NewStructuredValues("bar"), + }, { + Name: ParamServiceAccount, + Value: *pipelinev1beta1.NewStructuredValues("baz"), + }} err = resolver.ValidateParams(context.Background(), params) if err == nil { t.Fatalf("expected disabled err") @@ -86,21 +109,31 @@ func TestValidateParamsMissing(t *testing.T) { var err error - paramsMissingBundle := map[string]string{ - ParamKind: "pipeline", - ParamName: "foo", - ParamServiceAccount: "baz", - } + paramsMissingBundle := []pipelinev1beta1.Param{{ + Name: ParamKind, + Value: *pipelinev1beta1.NewStructuredValues("task"), + }, { + Name: ParamName, + Value: *pipelinev1beta1.NewStructuredValues("foo"), + }, { + Name: ParamServiceAccount, + Value: *pipelinev1beta1.NewStructuredValues("baz"), + }} err = resolver.ValidateParams(resolverContext(), paramsMissingBundle) if err == nil { t.Fatalf("expected missing kind err") } - paramsMissingName := map[string]string{ - ParamKind: "pipeline", - ParamBundle: "bar", - ParamServiceAccount: "baz", - } + paramsMissingName := []pipelinev1beta1.Param{{ + Name: ParamKind, + Value: *pipelinev1beta1.NewStructuredValues("task"), + }, { + Name: ParamBundle, + Value: *pipelinev1beta1.NewStructuredValues("bar"), + }, { + Name: ParamServiceAccount, + Value: *pipelinev1beta1.NewStructuredValues("baz"), + }} err = resolver.ValidateParams(resolverContext(), paramsMissingName) if err == nil { t.Fatalf("expected missing name err") @@ -113,12 +146,19 @@ func TestResolveDisabled(t *testing.T) { var err error - params := map[string]string{ - ParamKind: "task", - ParamName: "foo", - ParamBundle: "bar", - ParamServiceAccount: "baz", - } + params := []pipelinev1beta1.Param{{ + Name: ParamKind, + Value: *pipelinev1beta1.NewStructuredValues("task"), + }, { + Name: ParamName, + Value: *pipelinev1beta1.NewStructuredValues("foo"), + }, { + Name: ParamBundle, + Value: *pipelinev1beta1.NewStructuredValues("bar"), + }, { + Name: ParamServiceAccount, + Value: *pipelinev1beta1.NewStructuredValues("baz"), + }} _, err = resolver.Resolve(context.Background(), params) if err == nil { t.Fatalf("expected disabled err") diff --git a/pkg/resolution/resolver/cluster/resolver.go b/pkg/resolution/resolver/cluster/resolver.go index cca1b275fbc..f605825acd3 100644 --- a/pkg/resolution/resolver/cluster/resolver.go +++ b/pkg/resolution/resolver/cluster/resolver.go @@ -23,6 +23,7 @@ import ( "strings" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" pipelineclient "github.com/tektoncd/pipeline/pkg/client/injection/client" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" @@ -75,7 +76,7 @@ func (r *Resolver) GetSelector(_ context.Context) map[string]string { // ValidateParams returns an error if the given parameter map is not // valid for a resource request targeting the cluster resolver. -func (r *Resolver) ValidateParams(ctx context.Context, params map[string]string) error { +func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { if r.isDisabled(ctx) { return errors.New(disabledError) } @@ -86,7 +87,7 @@ func (r *Resolver) ValidateParams(ctx context.Context, params map[string]string) // Resolve performs the work of fetching a resource from a namespace with the given // parameters. -func (r *Resolver) Resolve(ctx context.Context, origParams map[string]string) (framework.ResolvedResource, error) { +func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1beta1.Param) (framework.ResolvedResource, error) { if r.isDisabled(ctx) { return nil, errors.New(disabledError) } @@ -179,32 +180,45 @@ func (r *ResolvedClusterResource) Annotations() map[string]string { } } -func populateParamsWithDefaults(ctx context.Context, params map[string]string) (map[string]string, error) { +func populateParamsWithDefaults(ctx context.Context, origParams []pipelinev1beta1.Param) (map[string]string, error) { conf := framework.GetResolverConfigFromContext(ctx) + paramsMap := make(map[string]pipelinev1beta1.ParamValue) + for _, p := range origParams { + paramsMap[p.Name] = p.Value + } + + params := make(map[string]string) + var missingParams []string - if _, ok := params[KindParam]; !ok { + if pKind, ok := paramsMap[KindParam]; !ok || pKind.StringVal == "" { if kindVal, ok := conf[DefaultKindKey]; !ok { missingParams = append(missingParams, KindParam) } else { params[KindParam] = kindVal } + } else { + params[KindParam] = pKind.StringVal } if kindVal, ok := params[KindParam]; ok && kindVal != "task" && kindVal != "pipeline" { return nil, fmt.Errorf("unknown or unsupported resource kind '%s'", kindVal) } - if _, ok := params[NameParam]; !ok { + if pName, ok := paramsMap[NameParam]; !ok || pName.StringVal == "" { missingParams = append(missingParams, NameParam) + } else { + params[NameParam] = pName.StringVal } - if _, ok := params[NamespaceParam]; !ok { + if pNS, ok := paramsMap[NamespaceParam]; !ok || pNS.StringVal == "" { if nsVal, ok := conf[DefaultNamespaceKey]; !ok { missingParams = append(missingParams, NamespaceParam) } else { params[NamespaceParam] = nsVal } + } else { + params[NamespaceParam] = pNS.StringVal } if len(missingParams) > 0 { diff --git a/pkg/resolution/resolver/cluster/resolver_test.go b/pkg/resolution/resolver/cluster/resolver_test.go index feeb80e8148..31149711e72 100644 --- a/pkg/resolution/resolver/cluster/resolver_test.go +++ b/pkg/resolution/resolver/cluster/resolver_test.go @@ -26,8 +26,8 @@ import ( "github.com/google/go-cmp/cmp" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" @@ -57,11 +57,16 @@ func TestGetSelector(t *testing.T) { func TestValidateParams(t *testing.T) { resolver := Resolver{} - params := map[string]string{ - KindParam: "task", - NamespaceParam: "foo", - NameParam: "baz", - } + params := []pipelinev1beta1.Param{{ + Name: KindParam, + Value: *pipelinev1beta1.NewStructuredValues("task"), + }, { + Name: NamespaceParam, + Value: *pipelinev1beta1.NewStructuredValues("foo"), + }, { + Name: NameParam, + Value: *pipelinev1beta1.NewStructuredValues("baz"), + }} ctx := framework.InjectResolverConfigToContext(resolverContext(), map[string]string{ AllowedNamespacesKey: "foo,bar", @@ -78,11 +83,16 @@ func TestValidateParamsNotEnabled(t *testing.T) { var err error - params := map[string]string{ - KindParam: "task", - NamespaceParam: "foo", - NameParam: "baz", - } + params := []pipelinev1beta1.Param{{ + Name: KindParam, + Value: *pipelinev1beta1.NewStructuredValues("task"), + }, { + Name: NamespaceParam, + Value: *pipelinev1beta1.NewStructuredValues("foo"), + }, { + Name: NameParam, + Value: *pipelinev1beta1.NewStructuredValues("baz"), + }} err = resolver.ValidateParams(context.Background(), params) if err == nil { t.Fatalf("expected disabled err") @@ -153,7 +163,15 @@ func TestValidateParamsFailure(t *testing.T) { if len(tc.conf) > 0 { ctx = framework.InjectResolverConfigToContext(ctx, tc.conf) } - err := resolver.ValidateParams(ctx, tc.params) + + var asParams []pipelinev1beta1.Param + for k, v := range tc.params { + asParams = append(asParams, pipelinev1beta1.Param{ + Name: k, + Value: *pipelinev1beta1.NewStructuredValues(v), + }) + } + err := resolver.ValidateParams(ctx, asParams) if err == nil { t.Fatalf("got no error, but expected: %s", tc.expectedErr) } @@ -167,18 +185,18 @@ func TestValidateParamsFailure(t *testing.T) { func TestResolve(t *testing.T) { defaultNS := "pipeline-ns" - exampleTask := &v1beta1.Task{ + exampleTask := &pipelinev1beta1.Task{ ObjectMeta: metav1.ObjectMeta{ Name: "example-task", Namespace: "task-ns", ResourceVersion: "00002", }, TypeMeta: metav1.TypeMeta{ - Kind: string(v1beta1.NamespacedTaskKind), + Kind: string(pipelinev1beta1.NamespacedTaskKind), APIVersion: "tekton.dev/v1beta1", }, - Spec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{ + Spec: pipelinev1beta1.TaskSpec{ + Steps: []pipelinev1beta1.Step{{ Name: "some-step", Image: "some-image", Command: []string{"something"}, @@ -190,7 +208,7 @@ func TestResolve(t *testing.T) { t.Fatalf("couldn't marshal task: %v", err) } - examplePipeline := &v1beta1.Pipeline{ + examplePipeline := &pipelinev1beta1.Pipeline{ ObjectMeta: metav1.ObjectMeta{ Name: "example-pipeline", Namespace: defaultNS, @@ -200,12 +218,12 @@ func TestResolve(t *testing.T) { Kind: "Pipeline", APIVersion: "tekton.dev/v1beta1", }, - Spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ + Spec: pipelinev1beta1.PipelineSpec{ + Tasks: []pipelinev1beta1.PipelineTask{{ Name: "some-pipeline-task", - TaskRef: &v1beta1.TaskRef{ + TaskRef: &pipelinev1beta1.TaskRef{ Name: "some-task", - Kind: v1beta1.NamespacedTaskKind, + Kind: pipelinev1beta1.NamespacedTaskKind, }, }}, }, @@ -222,7 +240,7 @@ func TestResolve(t *testing.T) { namespace string allowedNamespaces string blockedNamespaces string - expectedStatus *v1alpha1.ResolutionRequestStatus + expectedStatus *v1beta1.ResolutionRequestStatus expectedErr error }{ { @@ -230,9 +248,9 @@ func TestResolve(t *testing.T) { kind: "task", resourceName: exampleTask.Name, namespace: exampleTask.Namespace, - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{}, - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{ + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString(taskAsYAML), }, }, @@ -241,9 +259,9 @@ func TestResolve(t *testing.T) { kind: "pipeline", resourceName: examplePipeline.Name, namespace: examplePipeline.Namespace, - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{}, - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{ + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString(pipelineAsYAML), }, }, @@ -251,9 +269,9 @@ func TestResolve(t *testing.T) { name: "default namespace", kind: "pipeline", resourceName: examplePipeline.Name, - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{}, - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{ + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString(pipelineAsYAML), }, }, @@ -261,9 +279,9 @@ func TestResolve(t *testing.T) { name: "default kind", resourceName: exampleTask.Name, namespace: exampleTask.Namespace, - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{}, - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{ + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString(taskAsYAML), }, }, @@ -272,7 +290,7 @@ func TestResolve(t *testing.T) { kind: "task", resourceName: exampleTask.Name, namespace: "other-ns", - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{{ Type: apis.ConditionSucceeded, @@ -292,7 +310,7 @@ func TestResolve(t *testing.T) { resourceName: exampleTask.Name, namespace: "other-ns", allowedNamespaces: "foo,bar", - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{{ Type: apis.ConditionSucceeded, @@ -311,7 +329,7 @@ func TestResolve(t *testing.T) { resourceName: exampleTask.Name, namespace: "other-ns", blockedNamespaces: "foo,other-ns,bar", - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{{ Type: apis.ConditionSucceeded, @@ -360,25 +378,28 @@ func TestResolve(t *testing.T) { "enable-cluster-resolver": "true", }, }}, - Pipelines: []*v1beta1.Pipeline{examplePipeline}, - ResolutionRequests: []*v1alpha1.ResolutionRequest{request}, - Tasks: []*v1beta1.Task{exampleTask}, + Pipelines: []*pipelinev1beta1.Pipeline{examplePipeline}, + ResolutionRequests: []*v1beta1.ResolutionRequest{request}, + Tasks: []*pipelinev1beta1.Task{exampleTask}, } resolver := &Resolver{} - var expectedStatus *v1alpha1.ResolutionRequestStatus + var expectedStatus *v1beta1.ResolutionRequestStatus if tc.expectedStatus != nil { expectedStatus = tc.expectedStatus.DeepCopy() if tc.expectedErr == nil { - reqParams := request.Spec.Parameters + reqParams := make(map[string]pipelinev1beta1.ParamValue) + for _, p := range request.Spec.Params { + reqParams[p.Name] = p.Value + } if expectedStatus.Annotations == nil { expectedStatus.Annotations = make(map[string]string) } - expectedStatus.Annotations[ResourceNameAnnotation] = reqParams[NameParam] - if reqParams[NamespaceParam] != "" { - expectedStatus.Annotations[ResourceNamespaceAnnotation] = reqParams[NamespaceParam] + expectedStatus.Annotations[ResourceNameAnnotation] = reqParams[NameParam].StringVal + if reqParams[NamespaceParam].StringVal != "" { + expectedStatus.Annotations[ResourceNamespaceAnnotation] = reqParams[NamespaceParam].StringVal } else { expectedStatus.Annotations[ResourceNamespaceAnnotation] = defaultNS } @@ -392,10 +413,10 @@ func TestResolve(t *testing.T) { } } -func createRequest(kind, name, namespace string) *v1alpha1.ResolutionRequest { - rr := &v1alpha1.ResolutionRequest{ +func createRequest(kind, name, namespace string) *v1beta1.ResolutionRequest { + rr := &v1beta1.ResolutionRequest{ TypeMeta: metav1.TypeMeta{ - APIVersion: "resolution.tekton.dev/v1alpha1", + APIVersion: "resolution.tekton.dev/v1beta1", Kind: "ResolutionRequest", }, ObjectMeta: metav1.ObjectMeta{ @@ -406,17 +427,24 @@ func createRequest(kind, name, namespace string) *v1alpha1.ResolutionRequest { resolutioncommon.LabelKeyResolverType: LabelValueClusterResolverType, }, }, - Spec: v1alpha1.ResolutionRequestSpec{ - Parameters: map[string]string{ - NameParam: name, - }, + Spec: v1beta1.ResolutionRequestSpec{ + Params: []pipelinev1beta1.Param{{ + Name: NameParam, + Value: *pipelinev1beta1.NewStructuredValues(name), + }}, }, } if kind != "" { - rr.Spec.Parameters[KindParam] = kind + rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + Name: KindParam, + Value: *pipelinev1beta1.NewStructuredValues(kind), + }) } if namespace != "" { - rr.Spec.Parameters[NamespaceParam] = namespace + rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + Name: NamespaceParam, + Value: *pipelinev1beta1.NewStructuredValues(namespace), + }) } return rr diff --git a/pkg/resolution/resolver/framework/controller.go b/pkg/resolution/resolver/framework/controller.go index 2145a46626d..fe61144e509 100644 --- a/pkg/resolution/resolver/framework/controller.go +++ b/pkg/resolution/resolver/framework/controller.go @@ -21,10 +21,10 @@ import ( "fmt" "strings" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" rrclient "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client" - rrinformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest" - rrlister "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1alpha1" + rrinformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest" + rrlister "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1beta1" "github.com/tektoncd/pipeline/pkg/resolution/common" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" @@ -100,7 +100,7 @@ func NewController(ctx context.Context, resolver Resolver, modifiers ...Reconcil func filterResolutionRequestsBySelector(selector map[string]string) func(obj interface{}) bool { return func(obj interface{}) bool { - rr, ok := obj.(*v1alpha1.ResolutionRequest) + rr, ok := obj.(*v1beta1.ResolutionRequest) if !ok { return false } diff --git a/pkg/resolution/resolver/framework/fakeresolver.go b/pkg/resolution/resolver/framework/fakeresolver.go index 40987e5e85e..5582e0ab8e4 100644 --- a/pkg/resolution/resolver/framework/fakeresolver.go +++ b/pkg/resolution/resolver/framework/fakeresolver.go @@ -23,6 +23,7 @@ import ( "strings" "time" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" ) @@ -94,7 +95,12 @@ func (r *FakeResolver) GetSelector(_ context.Context) map[string]string { // ValidateParams returns an error if the given parameter map is not // valid for a resource request targeting the fake resolver. -func (r *FakeResolver) ValidateParams(_ context.Context, params map[string]string) error { +func (r *FakeResolver) ValidateParams(_ context.Context, params []pipelinev1beta1.Param) error { + paramsMap := make(map[string]pipelinev1beta1.ParamValue) + for _, p := range params { + paramsMap[p.Name] = p.Value + } + required := []string{ FakeParamName, } @@ -103,8 +109,8 @@ func (r *FakeResolver) ValidateParams(_ context.Context, params map[string]strin missing = required } else { for _, p := range required { - v, has := params[p] - if !has || v == "" { + v, has := paramsMap[p] + if !has || v.StringVal == "" { missing = append(missing, p) } } @@ -118,8 +124,13 @@ func (r *FakeResolver) ValidateParams(_ context.Context, params map[string]strin // Resolve performs the work of fetching a file from the fake resolver given a map of // parameters. -func (r *FakeResolver) Resolve(_ context.Context, params map[string]string) (ResolvedResource, error) { - paramValue := params[FakeParamName] +func (r *FakeResolver) Resolve(_ context.Context, params []pipelinev1beta1.Param) (ResolvedResource, error) { + paramsMap := make(map[string]pipelinev1beta1.ParamValue) + for _, p := range params { + paramsMap[p.Name] = p.Value + } + + paramValue := paramsMap[FakeParamName].StringVal frr, ok := r.ForParam[paramValue] if !ok { diff --git a/pkg/resolution/resolver/framework/interface.go b/pkg/resolution/resolver/framework/interface.go index 118f7a70f57..df31743668d 100644 --- a/pkg/resolution/resolver/framework/interface.go +++ b/pkg/resolution/resolver/framework/interface.go @@ -19,6 +19,8 @@ package framework import ( "context" "time" + + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) // Resolver is the interface to implement for type-specific resource @@ -39,7 +41,7 @@ type Resolver interface { // ValidateParams is given the parameters from a resource // request and should return an error if any are missing or invalid. - ValidateParams(context.Context, map[string]string) error + ValidateParams(context.Context, []pipelinev1beta1.Param) error // Resolve receives the parameters passed via a resource request // and returns the resolved data along with any annotations @@ -47,7 +49,7 @@ type Resolver interface { // should be returned instead. If a resolution.Error // is returned then its Reason and Message are used as part of the // response to the request. - Resolve(context.Context, map[string]string) (ResolvedResource, error) + Resolve(context.Context, []pipelinev1beta1.Param) (ResolvedResource, error) } // ConfigWatcher is the interface to implement if your resolver accepts diff --git a/pkg/resolution/resolver/framework/reconciler.go b/pkg/resolution/resolver/framework/reconciler.go index be03ae57975..4b0dee54857 100644 --- a/pkg/resolution/resolver/framework/reconciler.go +++ b/pkg/resolution/resolver/framework/reconciler.go @@ -24,9 +24,9 @@ import ( "fmt" "time" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" rrclient "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" - rrv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1alpha1" + rrv1beta1 "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1beta1" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -51,7 +51,7 @@ type Reconciler struct { resolver Resolver kubeClientSet kubernetes.Interface - resolutionRequestLister rrv1alpha1.ResolutionRequestLister + resolutionRequestLister rrv1beta1.ResolutionRequestLister resolutionRequestClientSet rrclient.Interface configStore *ConfigStore @@ -100,7 +100,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, key string) error { return r.resolve(ctx, key, rr) } -func (r *Reconciler) resolve(ctx context.Context, key string, rr *v1alpha1.ResolutionRequest) error { +func (r *Reconciler) resolve(ctx context.Context, key string, rr *v1beta1.ResolutionRequest) error { errChan := make(chan error) resourceChan := make(chan ResolvedResource) @@ -116,7 +116,7 @@ func (r *Reconciler) resolve(ctx context.Context, key string, rr *v1alpha1.Resol defer cancelFn() go func() { - validationError := r.resolver.ValidateParams(resolutionCtx, rr.Spec.Parameters) + validationError := r.resolver.ValidateParams(resolutionCtx, rr.Spec.Params) if validationError != nil { errChan <- &resolutioncommon.ErrorInvalidRequest{ ResolutionRequestKey: key, @@ -124,7 +124,7 @@ func (r *Reconciler) resolve(ctx context.Context, key string, rr *v1alpha1.Resol } return } - resource, resolveErr := r.resolver.Resolve(resolutionCtx, rr.Spec.Parameters) + resource, resolveErr := r.resolver.Resolve(resolutionCtx, rr.Spec.Params) if resolveErr != nil { errChan <- &resolutioncommon.ErrorGettingResource{ ResolverName: r.resolver.GetName(resolutionCtx), @@ -154,7 +154,7 @@ func (r *Reconciler) resolve(ctx context.Context, key string, rr *v1alpha1.Resol // OnError is used to handle any situation where a ResolutionRequest has // reached a terminal situation that cannot be recovered from. -func (r *Reconciler) OnError(ctx context.Context, rr *v1alpha1.ResolutionRequest, err error) error { +func (r *Reconciler) OnError(ctx context.Context, rr *v1beta1.ResolutionRequest, err error) error { if rr == nil { return controller.NewPermanentError(err) } @@ -168,10 +168,10 @@ func (r *Reconciler) OnError(ctx context.Context, rr *v1alpha1.ResolutionRequest // MarkFailed updates a ResolutionRequest as having failed. It returns // errors that occur during the update process or nil if the update // appeared to succeed. -func (r *Reconciler) MarkFailed(ctx context.Context, rr *v1alpha1.ResolutionRequest, resolutionErr error) error { +func (r *Reconciler) MarkFailed(ctx context.Context, rr *v1beta1.ResolutionRequest, resolutionErr error) error { key := fmt.Sprintf("%s/%s", rr.Namespace, rr.Name) reason, resolutionErr := resolutioncommon.ReasonError(resolutionErr) - latestGeneration, err := r.resolutionRequestClientSet.ResolutionV1alpha1().ResolutionRequests(rr.Namespace).Get(ctx, rr.Name, metav1.GetOptions{}) + latestGeneration, err := r.resolutionRequestClientSet.ResolutionV1beta1().ResolutionRequests(rr.Namespace).Get(ctx, rr.Name, metav1.GetOptions{}) if err != nil { logging.FromContext(ctx).Warnf("error getting latest generation of resolutionrequest %q: %v", key, err) return err @@ -180,7 +180,7 @@ func (r *Reconciler) MarkFailed(ctx context.Context, rr *v1alpha1.ResolutionRequ return nil } latestGeneration.Status.MarkFailed(reason, resolutionErr.Error()) - _, err = r.resolutionRequestClientSet.ResolutionV1alpha1().ResolutionRequests(rr.Namespace).UpdateStatus(ctx, latestGeneration, metav1.UpdateOptions{}) + _, err = r.resolutionRequestClientSet.ResolutionV1beta1().ResolutionRequests(rr.Namespace).UpdateStatus(ctx, latestGeneration, metav1.UpdateOptions{}) if err != nil { logging.FromContext(ctx).Warnf("error marking resolutionrequest %q as failed: %v", key, err) return err @@ -196,7 +196,7 @@ type statusDataPatch struct { Data string `json:"data"` } -func (r *Reconciler) writeResolvedData(ctx context.Context, rr *v1alpha1.ResolutionRequest, resource ResolvedResource) error { +func (r *Reconciler) writeResolvedData(ctx context.Context, rr *v1beta1.ResolutionRequest, resource ResolvedResource) error { encodedData := base64.StdEncoding.Strict().EncodeToString(resource.Data()) patchBytes, err := json.Marshal(map[string]statusDataPatch{ "status": { @@ -210,7 +210,7 @@ func (r *Reconciler) writeResolvedData(ctx context.Context, rr *v1alpha1.Resolut Original: fmt.Errorf("error serializing resource request patch: %w", err), }) } - _, err = r.resolutionRequestClientSet.ResolutionV1alpha1().ResolutionRequests(rr.Namespace).Patch(ctx, rr.Name, types.MergePatchType, patchBytes, metav1.PatchOptions{}, "status") + _, err = r.resolutionRequestClientSet.ResolutionV1beta1().ResolutionRequests(rr.Namespace).Patch(ctx, rr.Name, types.MergePatchType, patchBytes, metav1.PatchOptions{}, "status") if err != nil { return r.OnError(ctx, rr, &resolutioncommon.ErrorUpdatingRequest{ ResolutionRequestKey: fmt.Sprintf("%s/%s", rr.Namespace, rr.Name), diff --git a/pkg/resolution/resolver/framework/reconciler_test.go b/pkg/resolution/resolver/framework/reconciler_test.go index bbda378a782..3ff533b712c 100644 --- a/pkg/resolution/resolver/framework/reconciler_test.go +++ b/pkg/resolution/resolver/framework/reconciler_test.go @@ -26,7 +26,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/test" @@ -56,17 +57,17 @@ var ( func TestReconcile(t *testing.T) { testCases := []struct { name string - inputRequest *v1alpha1.ResolutionRequest + inputRequest *v1beta1.ResolutionRequest paramMap map[string]*FakeResolvedResource reconcilerTimeout time.Duration - expectedStatus *v1alpha1.ResolutionRequestStatus + expectedStatus *v1beta1.ResolutionRequestStatus expectedErr error }{ { name: "unknown value", - inputRequest: &v1alpha1.ResolutionRequest{ + inputRequest: &v1beta1.ResolutionRequest{ TypeMeta: metav1.TypeMeta{ - APIVersion: "resolution.tekton.dev/v1alpha1", + APIVersion: "resolution.tekton.dev/v1beta1", Kind: "ResolutionRequest", }, ObjectMeta: metav1.ObjectMeta{ @@ -77,19 +78,20 @@ func TestReconcile(t *testing.T) { resolutioncommon.LabelKeyResolverType: LabelValueFakeResolverType, }, }, - Spec: v1alpha1.ResolutionRequestSpec{ - Parameters: map[string]string{ - FakeParamName: "bar", - }, + Spec: v1beta1.ResolutionRequestSpec{ + Params: []pipelinev1beta1.Param{{ + Name: FakeParamName, + Value: *pipelinev1beta1.NewStructuredValues("bar"), + }}, }, - Status: v1alpha1.ResolutionRequestStatus{}, + Status: v1beta1.ResolutionRequestStatus{}, }, expectedErr: errors.New("error getting \"Fake\" \"foo/rr\": couldn't find resource for param value bar"), }, { name: "known value", - inputRequest: &v1alpha1.ResolutionRequest{ + inputRequest: &v1beta1.ResolutionRequest{ TypeMeta: metav1.TypeMeta{ - APIVersion: "resolution.tekton.dev/v1alpha1", + APIVersion: "resolution.tekton.dev/v1beta1", Kind: "ResolutionRequest", }, ObjectMeta: metav1.ObjectMeta{ @@ -100,12 +102,13 @@ func TestReconcile(t *testing.T) { resolutioncommon.LabelKeyResolverType: LabelValueFakeResolverType, }, }, - Spec: v1alpha1.ResolutionRequestSpec{ - Parameters: map[string]string{ - FakeParamName: "bar", - }, + Spec: v1beta1.ResolutionRequestSpec{ + Params: []pipelinev1beta1.Param{{ + Name: FakeParamName, + Value: *pipelinev1beta1.NewStructuredValues("bar"), + }}, }, - Status: v1alpha1.ResolutionRequestStatus{}, + Status: v1beta1.ResolutionRequestStatus{}, }, paramMap: map[string]*FakeResolvedResource{ "bar": { @@ -113,21 +116,21 @@ func TestReconcile(t *testing.T) { AnnotationMap: map[string]string{"foo": "bar"}, }, }, - expectedStatus: &v1alpha1.ResolutionRequestStatus{ + expectedStatus: &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{ Annotations: map[string]string{ "foo": "bar", }, }, - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{ + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString([]byte("some content")), }, }, }, { name: "error resolving", - inputRequest: &v1alpha1.ResolutionRequest{ + inputRequest: &v1beta1.ResolutionRequest{ TypeMeta: metav1.TypeMeta{ - APIVersion: "resolution.tekton.dev/v1alpha1", + APIVersion: "resolution.tekton.dev/v1beta1", Kind: "ResolutionRequest", }, ObjectMeta: metav1.ObjectMeta{ @@ -138,12 +141,13 @@ func TestReconcile(t *testing.T) { resolutioncommon.LabelKeyResolverType: LabelValueFakeResolverType, }, }, - Spec: v1alpha1.ResolutionRequestSpec{ - Parameters: map[string]string{ - FakeParamName: "bar", - }, + Spec: v1beta1.ResolutionRequestSpec{ + Params: []pipelinev1beta1.Param{{ + Name: FakeParamName, + Value: *pipelinev1beta1.NewStructuredValues("bar"), + }}, }, - Status: v1alpha1.ResolutionRequestStatus{}, + Status: v1beta1.ResolutionRequestStatus{}, }, paramMap: map[string]*FakeResolvedResource{ "bar": { @@ -153,9 +157,9 @@ func TestReconcile(t *testing.T) { expectedErr: errors.New(`error getting "Fake" "foo/rr": fake failure`), }, { name: "timeout", - inputRequest: &v1alpha1.ResolutionRequest{ + inputRequest: &v1beta1.ResolutionRequest{ TypeMeta: metav1.TypeMeta{ - APIVersion: "resolution.tekton.dev/v1alpha1", + APIVersion: "resolution.tekton.dev/v1beta1", Kind: "ResolutionRequest", }, ObjectMeta: metav1.ObjectMeta{ @@ -166,12 +170,13 @@ func TestReconcile(t *testing.T) { resolutioncommon.LabelKeyResolverType: LabelValueFakeResolverType, }, }, - Spec: v1alpha1.ResolutionRequestSpec{ - Parameters: map[string]string{ - FakeParamName: "bar", - }, + Spec: v1beta1.ResolutionRequestSpec{ + Params: []pipelinev1beta1.Param{{ + Name: FakeParamName, + Value: *pipelinev1beta1.NewStructuredValues("bar"), + }}, }, - Status: v1alpha1.ResolutionRequestStatus{}, + Status: v1beta1.ResolutionRequestStatus{}, }, paramMap: map[string]*FakeResolvedResource{ "bar": { @@ -186,7 +191,7 @@ func TestReconcile(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { d := test.Data{ - ResolutionRequests: []*v1alpha1.ResolutionRequest{tc.inputRequest}, + ResolutionRequests: []*v1beta1.ResolutionRequest{tc.inputRequest}, } fakeResolver := &FakeResolver{ForParam: tc.paramMap} @@ -213,7 +218,7 @@ func TestReconcile(t *testing.T) { } } - c := testAssets.Clients.ResolutionRequests.ResolutionV1alpha1() + c := testAssets.Clients.ResolutionRequests.ResolutionV1beta1() reconciledRR, err := c.ResolutionRequests(tc.inputRequest.Namespace).Get(testAssets.Ctx, tc.inputRequest.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated ResolutionRequest: %v", err) @@ -253,7 +258,7 @@ func getResolverFrameworkController(ctx context.Context, t *testing.T, d test.Da }, cancel } -func getRequestName(rr *v1alpha1.ResolutionRequest) string { +func getRequestName(rr *v1beta1.ResolutionRequest) string { return strings.Join([]string{rr.Namespace, rr.Name}, "/") } diff --git a/pkg/resolution/resolver/framework/testing/fakecontroller.go b/pkg/resolution/resolver/framework/testing/fakecontroller.go index 031657db0d1..b15e823930b 100644 --- a/pkg/resolution/resolver/framework/testing/fakecontroller.go +++ b/pkg/resolution/resolver/framework/testing/fakecontroller.go @@ -26,7 +26,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" "github.com/tektoncd/pipeline/test" "github.com/tektoncd/pipeline/test/diff" @@ -57,8 +57,8 @@ type ResolverReconcileTestModifier = func(resolver framework.Resolver, testAsset // ResolutionRequestStatus and error, both of which can be nil. It instantiates a controller for that resolver and // reconciles the given request. It then checks for the expected error, if any, and compares the resulting status with // the expected status. -func RunResolverReconcileTest(ctx context.Context, t *testing.T, d test.Data, resolver framework.Resolver, request *v1alpha1.ResolutionRequest, - expectedStatus *v1alpha1.ResolutionRequestStatus, expectedErr error, resolverModifiers ...ResolverReconcileTestModifier) { +func RunResolverReconcileTest(ctx context.Context, t *testing.T, d test.Data, resolver framework.Resolver, request *v1beta1.ResolutionRequest, + expectedStatus *v1beta1.ResolutionRequestStatus, expectedErr error, resolverModifiers ...ResolverReconcileTestModifier) { t.Helper() testAssets, cancel := GetResolverFrameworkController(ctx, t, d, resolver, setClockOnReconciler) @@ -82,7 +82,7 @@ func RunResolverReconcileTest(ctx context.Context, t *testing.T, d test.Data, re } } - c := testAssets.Clients.ResolutionRequests.ResolutionV1alpha1() + c := testAssets.Clients.ResolutionRequests.ResolutionV1beta1() reconciledRR, err := c.ResolutionRequests(request.Namespace).Get(testAssets.Ctx, request.Name, metav1.GetOptions{}) if err != nil { t.Fatalf("getting updated ResolutionRequest: %v", err) @@ -142,7 +142,7 @@ func initializeResolverFrameworkControllerAssets(ctx context.Context, t *testing }, cancel } -func getRequestName(rr *v1alpha1.ResolutionRequest) string { +func getRequestName(rr *v1beta1.ResolutionRequest) string { return strings.Join([]string{rr.Namespace, rr.Name}, "/") } diff --git a/pkg/resolution/resolver/git/resolver.go b/pkg/resolution/resolver/git/resolver.go index 3a9e1618cd8..5fcef5b2ab7 100644 --- a/pkg/resolution/resolver/git/resolver.go +++ b/pkg/resolution/resolver/git/resolver.go @@ -33,6 +33,7 @@ import ( "github.com/go-git/go-git/v5/storage/memory" "github.com/jenkins-x/go-scm/scm/factory" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" "go.uber.org/zap" @@ -102,7 +103,7 @@ func (r *Resolver) GetSelector(_ context.Context) map[string]string { // ValidateParams returns an error if the given parameter map is not // valid for a resource request targeting the gitresolver. -func (r *Resolver) ValidateParams(ctx context.Context, params map[string]string) error { +func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { if r.isDisabled(ctx) { return errors.New(disabledError) } @@ -116,7 +117,7 @@ func (r *Resolver) ValidateParams(ctx context.Context, params map[string]string) // Resolve performs the work of fetching a file from git given a map of // parameters. -func (r *Resolver) Resolve(ctx context.Context, origParams map[string]string) (framework.ResolvedResource, error) { +func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1beta1.Param) (framework.ResolvedResource, error) { if r.isDisabled(ctx) { return nil, errors.New(disabledError) } @@ -381,38 +382,43 @@ func (r *Resolver) getAPIToken(ctx context.Context) ([]byte, error) { return secretVal, nil } -func populateDefaultParams(ctx context.Context, params map[string]string) (map[string]string, error) { +func populateDefaultParams(ctx context.Context, params []pipelinev1beta1.Param) (map[string]string, error) { conf := framework.GetResolverConfigFromContext(ctx) + paramsMap := make(map[string]string) + for _, p := range params { + paramsMap[p.Name] = p.Value.StringVal + } + var missingParams []string - if _, ok := params[revisionParam]; !ok { + if _, ok := paramsMap[revisionParam]; !ok { if defaultRevision, ok := conf[defaultRevisionKey]; ok { - params[revisionParam] = defaultRevision + paramsMap[revisionParam] = defaultRevision } else { missingParams = append(missingParams, revisionParam) } } - if _, ok := params[pathParam]; !ok { + if _, ok := paramsMap[pathParam]; !ok { missingParams = append(missingParams, pathParam) } - if params[urlParam] != "" && params[repoParam] != "" { + if paramsMap[urlParam] != "" && paramsMap[repoParam] != "" { return nil, fmt.Errorf("cannot specify both '%s' and '%s'", urlParam, repoParam) } - if params[urlParam] == "" && params[repoParam] == "" { + if paramsMap[urlParam] == "" && paramsMap[repoParam] == "" { if urlString, ok := conf[defaultURLKey]; ok { - params[urlParam] = urlString + paramsMap[urlParam] = urlString } else { return nil, fmt.Errorf("must specify one of '%s' or '%s'", urlParam, repoParam) } } - if params[repoParam] != "" { - if _, ok := params[orgParam]; !ok { + if paramsMap[repoParam] != "" { + if _, ok := paramsMap[orgParam]; !ok { if defaultOrg, ok := conf[defaultOrgKey]; ok { - params[orgParam] = defaultOrg + paramsMap[orgParam] = defaultOrg } else { return nil, fmt.Errorf("'%s' is required when '%s' is specified", orgParam, repoParam) } @@ -424,5 +430,5 @@ func populateDefaultParams(ctx context.Context, params map[string]string) (map[s // TODO(sbwsg): validate repo url is well-formed, git:// or https:// // TODO(sbwsg): validate pathInRepo is valid relative pathInRepo - return params, nil + return paramsMap, nil } diff --git a/pkg/resolution/resolver/git/resolver_test.go b/pkg/resolution/resolver/git/resolver_test.go index e9f78de28a0..4a47f7f7097 100644 --- a/pkg/resolution/resolver/git/resolver_test.go +++ b/pkg/resolution/resolver/git/resolver_test.go @@ -33,7 +33,8 @@ import ( "github.com/go-git/go-git/v5/plumbing/object" "github.com/google/go-cmp/cmp" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" ttesting "github.com/tektoncd/pipeline/pkg/reconciler/testing" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" @@ -68,7 +69,7 @@ func TestValidateParams(t *testing.T) { revisionParam: "baz", } - if err := resolver.ValidateParams(resolverContext(), paramsWithRevision); err != nil { + if err := resolver.ValidateParams(resolverContext(), toParams(paramsWithRevision)); err != nil { t.Fatalf("unexpected error validating params: %v", err) } } @@ -82,7 +83,7 @@ func TestValidateParamsNotEnabled(t *testing.T) { pathParam: "bar", revisionParam: "baz", } - err = resolver.ValidateParams(context.Background(), someParams) + err = resolver.ValidateParams(context.Background(), toParams(someParams)) if err == nil { t.Fatalf("expected disabled err") } @@ -135,7 +136,7 @@ func TestValidateParams_Failure(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { resolver := &Resolver{} - err := resolver.ValidateParams(resolverContext(), tc.params) + err := resolver.ValidateParams(resolverContext(), toParams(tc.params)) if err == nil { t.Fatalf("got no error, but expected: %s", tc.expectedErr) } @@ -178,7 +179,7 @@ func TestResolveNotEnabled(t *testing.T) { pathParam: "bar", revisionParam: "baz", } - _, err = resolver.Resolve(context.Background(), someParams) + _, err = resolver.Resolve(context.Background(), toParams(someParams)) if err == nil { t.Fatalf("expected disabled err") } @@ -219,7 +220,7 @@ func TestResolve(t *testing.T) { pathInRepo string config map[string]string apiToken string - expectedStatus *v1alpha1.ResolutionRequestStatus + expectedStatus *v1beta1.ResolutionRequestStatus expectedErr error }{ { @@ -456,15 +457,18 @@ func TestResolve(t *testing.T) { "enable-git-resolver": "true", }, }}, - ResolutionRequests: []*v1alpha1.ResolutionRequest{request}, + ResolutionRequests: []*v1beta1.ResolutionRequest{request}, } - var expectedStatus *v1alpha1.ResolutionRequestStatus + var expectedStatus *v1beta1.ResolutionRequestStatus if tc.expectedStatus != nil { expectedStatus = tc.expectedStatus.DeepCopy() if tc.expectedErr == nil { - reqParams := request.Spec.Parameters + reqParams := make(map[string]string) + for _, p := range request.Spec.Params { + reqParams[p.Name] = p.Value.StringVal + } if expectedStatus.Annotations == nil { expectedStatus.Annotations = make(map[string]string) } @@ -640,10 +644,10 @@ func withTemporaryGitConfig(t *testing.T) { t.Setenv(key, filepath.Join(gitConfigDir, "config")) } -func createRequest(repoURL, apiOrg, apiRepo, pathInRepo, revision, specificCommit string, useNthCommit int, commitsByBranch map[string][]string) *v1alpha1.ResolutionRequest { - rr := &v1alpha1.ResolutionRequest{ +func createRequest(repoURL, apiOrg, apiRepo, pathInRepo, revision, specificCommit string, useNthCommit int, commitsByBranch map[string][]string) *v1beta1.ResolutionRequest { + rr := &v1beta1.ResolutionRequest{ TypeMeta: metav1.TypeMeta{ - APIVersion: "resolution.tekton.dev/v1alpha1", + APIVersion: "resolution.tekton.dev/v1beta1", Kind: "ResolutionRequest", }, ObjectMeta: metav1.ObjectMeta{ @@ -654,27 +658,46 @@ func createRequest(repoURL, apiOrg, apiRepo, pathInRepo, revision, specificCommi resolutioncommon.LabelKeyResolverType: labelValueGitResolverType, }, }, - Spec: v1alpha1.ResolutionRequestSpec{ - Parameters: map[string]string{ - pathParam: pathInRepo, - }, + Spec: v1beta1.ResolutionRequestSpec{ + Params: []pipelinev1beta1.Param{{ + Name: pathParam, + Value: *pipelinev1beta1.NewStructuredValues(pathInRepo), + }}, }, } switch { case useNthCommit > 0: - rr.Spec.Parameters[revisionParam] = commitsByBranch[plumbing.Master.Short()][useNthCommit] + rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + Name: revisionParam, + Value: *pipelinev1beta1.NewStructuredValues(commitsByBranch[plumbing.Master.Short()][useNthCommit]), + }) case specificCommit != "": - rr.Spec.Parameters[revisionParam] = hex.EncodeToString([]byte(specificCommit)) + rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + Name: revisionParam, + Value: *pipelinev1beta1.NewStructuredValues(hex.EncodeToString([]byte(specificCommit))), + }) case revision != "": - rr.Spec.Parameters[revisionParam] = revision + rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + Name: revisionParam, + Value: *pipelinev1beta1.NewStructuredValues(revision), + }) } if repoURL != "" { - rr.Spec.Parameters[urlParam] = repoURL + rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + Name: urlParam, + Value: *pipelinev1beta1.NewStructuredValues(repoURL), + }) } else { - rr.Spec.Parameters[repoParam] = apiRepo - rr.Spec.Parameters[orgParam] = apiOrg + rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + Name: repoParam, + Value: *pipelinev1beta1.NewStructuredValues(apiRepo), + }) + rr.Spec.Params = append(rr.Spec.Params, pipelinev1beta1.Param{ + Name: orgParam, + Value: *pipelinev1beta1.NewStructuredValues(apiOrg), + }) } return rr @@ -684,17 +707,17 @@ func resolverContext() context.Context { return frtesting.ContextWithGitResolverEnabled(context.Background()) } -func createStatus(content []byte) *v1alpha1.ResolutionRequestStatus { - return &v1alpha1.ResolutionRequestStatus{ +func createStatus(content []byte) *v1beta1.ResolutionRequestStatus { + return &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{}, - ResolutionRequestStatusFields: v1alpha1.ResolutionRequestStatusFields{ + ResolutionRequestStatusFields: v1beta1.ResolutionRequestStatusFields{ Data: base64.StdEncoding.Strict().EncodeToString(content), }, } } -func createFailureStatus() *v1alpha1.ResolutionRequestStatus { - return &v1alpha1.ResolutionRequestStatus{ +func createFailureStatus() *v1beta1.ResolutionRequestStatus { + return &v1beta1.ResolutionRequestStatus{ Status: duckv1.Status{ Conditions: duckv1.Conditions{{ Type: apis.ConditionSucceeded, @@ -712,3 +735,16 @@ func createError(msg string) error { Original: errors.New(msg), } } + +func toParams(m map[string]string) []pipelinev1beta1.Param { + var params []pipelinev1beta1.Param + + for k, v := range m { + params = append(params, pipelinev1beta1.Param{ + Name: k, + Value: *pipelinev1beta1.NewStructuredValues(v), + }) + } + + return params +} diff --git a/pkg/resolution/resolver/hub/resolver.go b/pkg/resolution/resolver/hub/resolver.go index 2e157f1053d..421500632e2 100644 --- a/pkg/resolution/resolver/hub/resolver.go +++ b/pkg/resolution/resolver/hub/resolver.go @@ -22,6 +22,7 @@ import ( "net/http" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" ) @@ -63,18 +64,22 @@ func (r *Resolver) GetSelector(context.Context) map[string]string { } // ValidateParams ensures parameters from a request are as expected. -func (r *Resolver) ValidateParams(ctx context.Context, params map[string]string) error { +func (r *Resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error { if r.isDisabled(ctx) { return errors.New(disabledError) } - if _, ok := params[ParamName]; !ok { + paramsMap := make(map[string]pipelinev1beta1.ParamValue) + for _, p := range params { + paramsMap[p.Name] = p.Value + } + if _, ok := paramsMap[ParamName]; !ok { return errors.New("must include name param") } - if _, ok := params[ParamVersion]; !ok { + if _, ok := paramsMap[ParamVersion]; !ok { return errors.New("must include version param") } - if kind, ok := params[ParamKind]; ok { - if kind != "task" && kind != "pipeline" { + if kind, ok := paramsMap[ParamKind]; ok { + if kind.StringVal != "task" && kind.StringVal != "pipeline" { return errors.New("kind param must be task or pipeline") } } @@ -90,21 +95,27 @@ type hubResponse struct { } // Resolve uses the given params to resolve the requested file or resource. -func (r *Resolver) Resolve(ctx context.Context, params map[string]string) (framework.ResolvedResource, error) { +func (r *Resolver) Resolve(ctx context.Context, params []pipelinev1beta1.Param) (framework.ResolvedResource, error) { if r.isDisabled(ctx) { return nil, errors.New(disabledError) } conf := framework.GetResolverConfigFromContext(ctx) - if _, ok := params[ParamCatalog]; !ok { + + paramsMap := make(map[string]string) + for _, p := range params { + paramsMap[p.Name] = p.Value.StringVal + } + + if _, ok := paramsMap[ParamCatalog]; !ok { if catalogString, ok := conf[ConfigCatalog]; ok { - params[ParamCatalog] = catalogString + paramsMap[ParamCatalog] = catalogString } else { return nil, fmt.Errorf("default catalog was not set during installation of the hub resolver") } } - kind, ok := params[ParamKind] + kind, ok := paramsMap[ParamKind] if !ok { if kindString, ok := conf[ConfigKind]; ok { kind = kindString @@ -116,8 +127,8 @@ func (r *Resolver) Resolve(ctx context.Context, params map[string]string) (frame return nil, fmt.Errorf("kind param must be task or pipeline") } - params[ParamKind] = kind - url := fmt.Sprintf(r.HubURL, params[ParamCatalog], params[ParamKind], params[ParamName], params[ParamVersion]) + paramsMap[ParamKind] = kind + url := fmt.Sprintf(r.HubURL, paramsMap[ParamCatalog], paramsMap[ParamKind], paramsMap[ParamName], paramsMap[ParamVersion]) // #nosec G107 -- URL cannot be constant in this case. resp, err := http.Get(url) if err != nil { diff --git a/pkg/resolution/resolver/hub/resolver_test.go b/pkg/resolution/resolver/hub/resolver_test.go index 31bdda3d7df..6974ebc2ac7 100644 --- a/pkg/resolution/resolver/hub/resolver_test.go +++ b/pkg/resolution/resolver/hub/resolver_test.go @@ -24,6 +24,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" frtesting "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework/testing" "github.com/tektoncd/pipeline/test/diff" @@ -48,7 +49,7 @@ func TestValidateParams(t *testing.T) { ParamVersion: "bar", ParamCatalog: "baz", } - if err := resolver.ValidateParams(resolverContext(), paramsWithTask); err != nil { + if err := resolver.ValidateParams(resolverContext(), toParams(paramsWithTask)); err != nil { t.Fatalf("unexpected error validating params: %v", err) } @@ -58,7 +59,7 @@ func TestValidateParams(t *testing.T) { ParamVersion: "bar", ParamCatalog: "baz", } - if err := resolver.ValidateParams(resolverContext(), paramsWithPipeline); err != nil { + if err := resolver.ValidateParams(resolverContext(), toParams(paramsWithPipeline)); err != nil { t.Fatalf("unexpected error validating params: %v", err) } } @@ -74,7 +75,7 @@ func TestValidateParamsDisabled(t *testing.T) { ParamVersion: "bar", ParamCatalog: "baz", } - err = resolver.ValidateParams(context.Background(), params) + err = resolver.ValidateParams(context.Background(), toParams(params)) if err == nil { t.Fatalf("expected missing name err") } @@ -93,7 +94,7 @@ func TestValidateParamsMissing(t *testing.T) { ParamKind: "foo", ParamVersion: "bar", } - err = resolver.ValidateParams(resolverContext(), paramsMissingName) + err = resolver.ValidateParams(resolverContext(), toParams(paramsMissingName)) if err == nil { t.Fatalf("expected missing name err") } @@ -102,7 +103,7 @@ func TestValidateParamsMissing(t *testing.T) { ParamKind: "foo", ParamName: "bar", } - err = resolver.ValidateParams(resolverContext(), paramsMissingVersion) + err = resolver.ValidateParams(resolverContext(), toParams(paramsMissingVersion)) if err == nil { t.Fatalf("expected missing version err") } @@ -116,7 +117,7 @@ func TestValidateParamsConflictingKindName(t *testing.T) { ParamVersion: "bar", ParamCatalog: "baz", } - err := resolver.ValidateParams(resolverContext(), params) + err := resolver.ValidateParams(resolverContext(), toParams(params)) if err == nil { t.Fatalf("expected err due to conflicting kind param") } @@ -133,7 +134,7 @@ func TestResolveDisabled(t *testing.T) { ParamVersion: "bar", ParamCatalog: "baz", } - _, err = resolver.Resolve(context.Background(), params) + _, err = resolver.Resolve(context.Background(), toParams(params)) if err == nil { t.Fatalf("expected missing name err") } @@ -206,7 +207,7 @@ func TestResolve(t *testing.T) { ParamCatalog: tc.catalog, } - output, err := resolver.Resolve(resolverContext(), params) + output, err := resolver.Resolve(resolverContext(), toParams(params)) if tc.expectedErr != nil { if err == nil { t.Fatalf("expected err '%v' but didn't get one", tc.expectedErr) @@ -234,3 +235,16 @@ func TestResolve(t *testing.T) { func resolverContext() context.Context { return frtesting.ContextWithHubResolverEnabled(context.Background()) } + +func toParams(m map[string]string) []pipelinev1beta1.Param { + var params []pipelinev1beta1.Param + + for k, v := range m { + params = append(params, pipelinev1beta1.Param{ + Name: k, + Value: *pipelinev1beta1.NewStructuredValues(v), + }) + } + + return params +} diff --git a/pkg/resolution/resource/crd_resource.go b/pkg/resolution/resource/crd_resource.go index 814f8845c80..47346e3944f 100644 --- a/pkg/resolution/resource/crd_resource.go +++ b/pkg/resolution/resource/crd_resource.go @@ -22,9 +22,9 @@ import ( "errors" "fmt" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" rrclient "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned" - rrlisters "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1alpha1" + rrlisters "github.com/tektoncd/pipeline/pkg/client/resolution/listers/resolution/v1beta1" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" @@ -78,9 +78,9 @@ func (r *CRDRequester) Submit(ctx context.Context, resolver ResolverName, req Re } func (r *CRDRequester) createResolutionRequest(ctx context.Context, resolver ResolverName, req Request) error { - rr := &v1alpha1.ResolutionRequest{ + rr := &v1beta1.ResolutionRequest{ TypeMeta: metav1.TypeMeta{ - APIVersion: "resolution.tekton.dev/v1alpha1", + APIVersion: "resolution.tekton.dev/v1beta1", Kind: "ResolutionRequest", }, ObjectMeta: metav1.ObjectMeta{ @@ -90,16 +90,16 @@ func (r *CRDRequester) createResolutionRequest(ctx context.Context, resolver Res resolutioncommon.LabelKeyResolverType: string(resolver), }, }, - Spec: v1alpha1.ResolutionRequestSpec{ - Parameters: req.Params(), + Spec: v1beta1.ResolutionRequestSpec{ + Params: req.Params(), }, } appendOwnerReference(rr, req) - _, err := r.clientset.ResolutionV1alpha1().ResolutionRequests(rr.Namespace).Create(ctx, rr, metav1.CreateOptions{}) + _, err := r.clientset.ResolutionV1beta1().ResolutionRequests(rr.Namespace).Create(ctx, rr, metav1.CreateOptions{}) return err } -func appendOwnerReference(rr *v1alpha1.ResolutionRequest, req Request) { +func appendOwnerReference(rr *v1beta1.ResolutionRequest, req Request) { if ownedReq, ok := req.(OwnedRequest); ok { newOwnerRef := ownedReq.OwnerRef() isOwner := false @@ -123,12 +123,12 @@ func ownerRefsAreEqual(a, b metav1.OwnerReference) bool { // Resource interface without exposing the underlying API // object. type readOnlyResolutionRequest struct { - req *v1alpha1.ResolutionRequest + req *v1beta1.ResolutionRequest } var _ ResolvedResource = readOnlyResolutionRequest{} -func crdIntoResource(rr *v1alpha1.ResolutionRequest) readOnlyResolutionRequest { +func crdIntoResource(rr *v1beta1.ResolutionRequest) readOnlyResolutionRequest { return readOnlyResolutionRequest{req: rr} } diff --git a/pkg/resolution/resource/name.go b/pkg/resolution/resource/name.go index c64915717e8..be92a45ff42 100644 --- a/pkg/resolution/resource/name.go +++ b/pkg/resolution/resource/name.go @@ -21,6 +21,8 @@ import ( "hash" "hash/fnv" "sort" + + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" ) // nameHasher returns the hash.Hash to use when generating names. @@ -33,22 +35,33 @@ func nameHasher() hash.Hash { // will have the format {prefix}-{hash} where {prefix} is // given and {hash} is nameHasher(base) + nameHasher(param1) + // nameHasher(param2) + ... -func GenerateDeterministicName(prefix, base string, params map[string]string) (string, error) { - paramKeys := []string{} - for key := range params { - paramKeys = append(paramKeys, key) - } +func GenerateDeterministicName(prefix, base string, params []v1beta1.Param) (string, error) { hasher := nameHasher() if _, err := hasher.Write([]byte(base)); err != nil { return "", err } - sort.Strings(paramKeys) - for _, key := range paramKeys { - if _, err := hasher.Write([]byte(key)); err != nil { + + sortedParams := make([]v1beta1.Param, len(params)) + sort.SliceStable(sortedParams, func(i, j int) bool { + return sortedParams[i].Name < sortedParams[j].Name + }) + for _, p := range sortedParams { + if _, err := hasher.Write([]byte(p.Name)); err != nil { return "", err } - if _, err := hasher.Write([]byte(params[key])); err != nil { - return "", err + switch p.Value.Type { + case v1beta1.ParamTypeString: + if _, err := hasher.Write([]byte(p.Value.StringVal)); err != nil { + return "", err + } + case v1beta1.ParamTypeArray, v1beta1.ParamTypeObject: + asJSON, err := p.Value.MarshalJSON() + if err != nil { + return "", err + } + if _, err := hasher.Write(asJSON); err != nil { + return "", err + } } } return fmt.Sprintf("%s-%x", prefix, hasher.Sum(nil)), nil diff --git a/pkg/resolution/resource/request.go b/pkg/resolution/resource/request.go index cefee59929d..40e1d34caad 100644 --- a/pkg/resolution/resource/request.go +++ b/pkg/resolution/resource/request.go @@ -16,18 +16,20 @@ limitations under the License. package resource +import "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + var _ Request = &BasicRequest{} // BasicRequest holds the fields needed to submit a new resource request. type BasicRequest struct { name string namespace string - params map[string]string + params []v1beta1.Param } // NewRequest returns an instance of a BasicRequest with the given name, // namespace and params. -func NewRequest(name, namespace string, params map[string]string) Request { +func NewRequest(name, namespace string, params []v1beta1.Param) Request { return &BasicRequest{name, namespace, params} } @@ -44,6 +46,6 @@ func (req *BasicRequest) Namespace() string { } // Params are the map of parameters associated with this request -func (req *BasicRequest) Params() map[string]string { +func (req *BasicRequest) Params() []v1beta1.Param { return req.params } diff --git a/pkg/resolution/resource/resource.go b/pkg/resolution/resource/resource.go index 2c23a388222..921bd8f2f52 100644 --- a/pkg/resolution/resource/resource.go +++ b/pkg/resolution/resource/resource.go @@ -19,6 +19,8 @@ package resource import ( "context" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -43,7 +45,7 @@ type Requester interface { type Request interface { Name() string Namespace() string - Params() map[string]string + Params() []v1beta1.Param } // OwnedRequest is implemented by any type implementing Request that also needs diff --git a/test/controller.go b/test/controller.go index 0c9b74232f6..2053da862bb 100644 --- a/test/controller.go +++ b/test/controller.go @@ -26,7 +26,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + resolutionv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" fakepipelineclientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/fake" informersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1" @@ -39,9 +39,9 @@ import ( faketaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/task/fake" faketaskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun/fake" fakeresolutionclientset "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/fake" - resolutioninformersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution/v1alpha1" + resolutioninformersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution/v1beta1" fakeresolutionrequestclient "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client/fake" - fakeresolutionrequestinformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1alpha1/resolutionrequest/fake" + fakeresolutionrequestinformer "github.com/tektoncd/pipeline/pkg/client/resolution/injection/informers/resolution/v1beta1/resolutionrequest/fake" fakeresourceclientset "github.com/tektoncd/pipeline/pkg/client/resource/clientset/versioned/fake" resourceinformersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resource/informers/externalversions/resource/v1alpha1" fakeresourceclient "github.com/tektoncd/pipeline/pkg/client/resource/injection/client/fake" @@ -275,7 +275,7 @@ func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers c.ResolutionRequests.PrependReactor("*", "resolutionrequests", AddToInformer(t, i.ResolutionRequest.Informer().GetIndexer())) for _, rr := range d.ResolutionRequests { rr := rr.DeepCopy() // Avoid assumptions that the informer's copy is modified. - if _, err := c.ResolutionRequests.ResolutionV1alpha1().ResolutionRequests(rr.Namespace).Create(ctx, rr, metav1.CreateOptions{}); err != nil { + if _, err := c.ResolutionRequests.ResolutionV1beta1().ResolutionRequests(rr.Namespace).Create(ctx, rr, metav1.CreateOptions{}); err != nil { t.Fatal(err) } } diff --git a/test/e2e-common.sh b/test/e2e-common.sh index 1106d64fd20..be0206f90b9 100755 --- a/test/e2e-common.sh +++ b/test/e2e-common.sh @@ -29,10 +29,8 @@ function install_pipeline_crd() { verify_pipeline_installation - if [ "${PIPELINE_FEATURE_GATE}" == "alpha" ]; then - ko apply -f config/resolvers || fail_test "Resolvers installation failed" - verify_resolvers_installation - fi + ko apply -f config/resolvers || fail_test "Resolvers installation failed" + verify_resolvers_installation export SYSTEM_NAMESPACE=tekton-pipelines } diff --git a/test/resolution.go b/test/resolution.go index 42389633300..4f976a5049d 100644 --- a/test/resolution.go +++ b/test/resolution.go @@ -6,6 +6,10 @@ import ( "fmt" "strings" + "github.com/google/go-cmp/cmp" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/test/diff" + resolution "github.com/tektoncd/pipeline/pkg/resolution/resource" ) @@ -41,7 +45,7 @@ type Requester struct { // An error to return when a request is submitted. SubmitErr error // Params that should match those on the request in order to return the resolved resource - Params map[string]string + Params []v1beta1.Param } // Submit implements resolution.Requester, accepting the name of a @@ -51,15 +55,17 @@ func (r *Requester) Submit(ctx context.Context, resolverName resolution.Resolver if len(r.Params) == 0 { return r.ResolvedResource, r.SubmitErr } - reqParams := make(map[string]string) - for k, v := range req.Params() { - reqParams[k] = v + reqParams := make(map[string]v1beta1.ParamValue) + for _, p := range req.Params() { + reqParams[p.Name] = p.Value } var wrongParams []string - for k, v := range r.Params { - if reqValue, ok := reqParams[k]; !ok || reqValue != v { - wrongParams = append(wrongParams, fmt.Sprintf("expected %s param to be %s, but was %s", k, v, reqValue)) + for _, p := range r.Params { + if reqValue, ok := reqParams[p.Name]; !ok { + wrongParams = append(wrongParams, fmt.Sprintf("expected %s param to be %#v, but was %#v", p.Name, p.Value, reqValue)) + } else if d := cmp.Diff(p.Value, reqValue); d != "" { + wrongParams = append(wrongParams, fmt.Sprintf("%s param did not match: %s", p.Name, diff.PrintWantGot(d))) } } if len(wrongParams) > 0 { diff --git a/test/resolvers_test.go b/test/resolvers_test.go index d6ff68ce436..f3a2f42f322 100644 --- a/test/resolvers_test.go +++ b/test/resolvers_test.go @@ -62,17 +62,14 @@ var ( hubFeatureFlags = requireAllGates(map[string]string{ "enable-hub-resolver": "true", - "enable-api-fields": "alpha", }) gitFeatureFlags = requireAllGates(map[string]string{ "enable-git-resolver": "true", - "enable-api-fields": "alpha", }) clusterFeatureFlags = requireAllGates(map[string]string{ "enable-cluster-resolver": "true", - "enable-api-fields": "alpha", }) ) diff --git a/test/tektonbundles_test.go b/test/tektonbundles_test.go index be8f46e81d2..9dca8b08dcd 100644 --- a/test/tektonbundles_test.go +++ b/test/tektonbundles_test.go @@ -54,6 +54,10 @@ var requireFeatureFlags = requireAnyGate(map[string]string{ "enable-api-fields": "alpha", }) +var resolverFeatureFlags = requireAnyGate(map[string]string{ + "enable-bundles-resolver": "true", +}) + // TestTektonBundlesSimpleWorkingExample is an integration test which tests a simple, working Tekton bundle using OCI // images. func TestTektonBundlesSimpleWorkingExample(t *testing.T) { @@ -197,7 +201,7 @@ spec: // images using the remote resolution bundles resolver. func TestTektonBundlesResolver(t *testing.T) { ctx := context.Background() - c, namespace := setup(ctx, t, withRegistry, requireFeatureFlags) + c, namespace := setup(ctx, t, withRegistry, resolverFeatureFlags) t.Parallel()