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..14dde39bbad 100644 --- a/config/300-resolutionrequest.yaml +++ b/config/300-resolutionrequest.yaml @@ -34,7 +34,8 @@ spec: versions: - name: v1alpha1 served: true - storage: true + deprecated: true + storage: false subresources: status: {} schema: @@ -56,8 +57,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 bf82a29434f..079495cae67 100644 --- a/docs/how-to-write-a-resolver.md +++ b/docs/how-to-write-a-resolver.md @@ -185,13 +185,12 @@ We'll also need to add another import for this package at the top: ```go import ( "context" - - // Add this one; it defines LabelKeyResolverType we use in GetSelector + + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" +// Add this one; it defines LabelKeyResolverType we use in GetSelector "github.com/tektoncd/pipeline/pkg/resolution/common" - "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" "knative.dev/pkg/injection/sharedmain" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" ) ``` @@ -263,7 +262,7 @@ func (*myResolvedResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. None atm. -func (*myResolvedResource) Source() *v1alpha1.ConfigSource { +func (*myResolvedResource) Source() *v1beta1.ConfigSource { return nil } ``` @@ -276,8 +275,8 @@ following example. ```go // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (*myResolvedResource) Source() *v1alpha1.ConfigSource { - return &v1alpha1.ConfigSource{ +func (*myResolvedResource) Source() *v1beta1.ConfigSource { + return &v1beta1.ConfigSource{ URI: "https://github.com/user/example", Digest: map[string]string{ "sha1": "example", @@ -394,7 +393,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 60295d6b6e5..c67249b349e 100644 --- a/docs/install.md +++ b/docs/install.md @@ -86,6 +86,10 @@ To install Tekton Pipelines on a Kubernetes cluster: kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.notags.yaml ``` +1. **Note**: To install Tekton Pipelines without including [the built-in remote resolvers](#installing-and-configuring-remote-task-and-pipeline-resolution) + follow the directions above, but replace `release.yaml` or `release.notags.yaml` with `minimal-release.yaml` or + `minimal-release.notags.yaml` as appropriate. + 1. **Note**: Some cloud providers (such as [GKE](https://github.com/tektoncd/pipeline/issues/3317#issuecomment-708066087)) may also require you to allow port 8443 in your firewall rules so that the Tekton Pipelines webhook is reachable. @@ -270,10 +274,14 @@ data: ## Installing and configuring remote Task and Pipeline resolution -**NOTE**: Remote resolution is currently [an `alpha` feature](#alpha-features). +By default, when Tekton Pipelines is installed using `release.yaml` or `release.notags.yaml`, the +[built-in resolvers](#built-in-resolvers) are installed into the `tekton-pipelines-resolvers` namespace. + +### Installing built-in remote resolvers with a minimal Tekton Pipelines installation -To install the latest release of the [built-in remote resolvers](#built-in-resolvers), -run the following command: +If you have installed Tekton Pipelines using `minimal-release.yaml` or `minimal-release.notags.yaml` and +wish to add the [built-in remote resolvers](#built-in-resolvers) later, you can install them separately +by running the following command: ```bash kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/resolvers.yaml @@ -464,7 +472,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) | v0.40.0 | | | [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) | [v0.34.0](https://github.com/tektoncd/pipeline/releases/tag/v0.34.0) | | | [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/pipeline-api.md b/docs/pipeline-api.md index 959d8ef5557..fed492b981d 100644 --- a/docs/pipeline-api.md +++ b/docs/pipeline-api.md @@ -29,6 +29,63 @@ weight: 1000 Resource Types: +

ConfigSource +

+

+(Appears on:ResolutionRequestStatusFields) +

+
+

ConfigSource records where the task/pipeline file came from.

+
+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+uri
+ +string + +
+

URI indicating the identity of the source of the config. +https://github.com/in-toto/attestation/blob/main/spec/field_types.md#ResourceURI +Example: https://github.com/tektoncd/catalog

+
+digest
+ +map[string]string + +
+

Digest is a collection of cryptographic digests for the contents of the artifact specified by URI. +https://github.com/in-toto/attestation/blob/main/spec/field_types.md#DigestSet +Example: {“sha1”: “f99d13e554ffcb696dee719fa85b695cb5b0f428”}

+
+entryPoint
+ +string + +
+

EntryPoint identifying the entry point into the build. This is often a path to a +configuration file and/or a target label within that file. +Example: “task/git-clone/0.8/git-clone.yaml”

+

ResolutionRequest

@@ -221,6 +278,20 @@ of the requested resource in-lined into the ResolutionRequest object.

+ + +source
+ + +ConfigSource + + + + +

Source is the source reference of the remote data that records where the remote +file came from including the url, digest and the entrypoint.

+ +
@@ -229,6 +300,63 @@ object.

Resource Types: +

ConfigSource +

+

+(Appears on:ResolutionRequestStatusFields) +

+
+

ConfigSource records where the task/pipeline file came from.

+
+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+uri
+ +string + +
+

URI indicating the identity of the source of the config. +https://github.com/in-toto/attestation/blob/main/spec/field_types.md#ResourceURI +Example: https://github.com/tektoncd/catalog

+
+digest
+ +map[string]string + +
+

Digest is a collection of cryptographic digests for the contents of the artifact specified by URI. +https://github.com/in-toto/attestation/blob/main/spec/field_types.md#DigestSet +Example: {“sha1”: “f99d13e554ffcb696dee719fa85b695cb5b0f428”}

+
+entryPoint
+ +string + +
+

EntryPoint identifying the entry point into the build. This is often a path to a +configuration file and/or a target label within that file. +Example: “task/git-clone/0.8/git-clone.yaml”

+

ResolutionRequest

@@ -425,6 +553,20 @@ of the requested resource in-lined into the ResolutionRequest object.

+ + +source
+ + +ConfigSource + + + + +

Source is the source reference of the remote data that records the url, digest +and the entrypoint.

+ +
@@ -2880,8 +3022,8 @@ requested.

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. This feature is in beta and these fields +are only available when the beta feature gate is enabled.

@@ -4761,6 +4903,9 @@ Kubernetes core/v1.ResourceRequirements + +

TaskRunCancelledByPipelineMsg indicates that the PipelineRun of which this TaskRun was a part of has been cancelled.

"TaskRun cancelled as the PipelineRun it belongs to has timed out."

TaskRunCancelledByPipelineTimeoutMsg indicates that the TaskRun was cancelled because the PipelineRun running it timed out.

+

TaskRunStatus @@ -10273,8 +10418,7 @@ requested.

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.

diff --git a/docs/resolution-getting-started.md b/docs/resolution-getting-started.md index 7c30a86bbd6..aea5284ae5b 100644 --- a/docs/resolution-getting-started.md +++ b/docs/resolution-getting-started.md @@ -24,19 +24,12 @@ 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: Ensure Pipelines is configured 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: - -```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"}}' -``` +Starting with v0.41.0, remote resolvers for Tekton Pipelines are enabled by default, +but can be disabled via feature flags in the `resolvers-feature-flags` configmap in +the `tekton-pipelines-resolvers` namespace. Check that configmap to verify that the +resolvers you wish to have enabled are set to `"true"`. The feature flags for the built-in resolvers are: 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 d7196bfab56..52386d248a0 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 } @@ -94,6 +95,6 @@ func (*myResolvedResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. None atm. -func (*myResolvedResource) Source() *v1alpha1.ConfigSource { +func (*myResolvedResource) Source() *v1beta1.ConfigSource { return 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/go.sum b/go.sum index cfa50aee6fe..519064a4bd4 100644 --- a/go.sum +++ b/go.sum @@ -828,8 +828,6 @@ github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/in-toto/in-toto-golang v0.3.4-0.20211211042327-af1f9fb822bf h1:FU8tuL4IWx/Hq55AO4+13AZn3Kd6uk3Z44OCIZ9coTw= -github.com/in-toto/in-toto-golang v0.3.4-0.20211211042327-af1f9fb822bf/go.mod h1:twl9XmClqj6/h/HANQQYaJZVKPPW/Mz53bd2t6UXGQA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= 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 e11dcc0507c..49a52e627ae 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. This feature is in beta and these fields are only available when the beta feature gate is enabled.", 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..40a69d12924 100644 --- a/pkg/apis/pipeline/v1/pipeline_types.go +++ b/pkg/apis/pipeline/v1/pipeline_types.go @@ -260,7 +260,7 @@ 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 { + if cfg.FeatureFlags.EnableAPIFields != config.BetaAPIFields && 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")) diff --git a/pkg/apis/pipeline/v1/pipeline_types_test.go b/pkg/apis/pipeline/v1/pipeline_types_test.go index 31e84124adc..3e9d00ef33e 100644 --- a/pkg/apis/pipeline/v1/pipeline_types_test.go +++ b/pkg/apis/pipeline/v1/pipeline_types_test.go @@ -186,9 +186,10 @@ func TestPipelineTask_ValidateCustomTask(t *testing.T) { func TestPipelineTask_ValidateRegularTask_Success(t *testing.T) { tests := []struct { - name string - tasks PipelineTask - enableAPIFields bool + name string + tasks PipelineTask + enableAlphaAPIFields bool + enableBetaAPIFields bool }{{ name: "pipeline task - valid taskRef name", tasks: PipelineTask{ @@ -206,13 +207,19 @@ func TestPipelineTask_ValidateRegularTask_Success(t *testing.T) { tasks: PipelineTask{ TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resolver: "bar"}}, }, - enableAPIFields: true, + enableBetaAPIFields: true, + }, { + name: "pipeline task - use of resolver with the feature flag set to alpha", + tasks: PipelineTask{ + TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resolver: "bar"}}, + }, + enableAlphaAPIFields: true, }, { name: "pipeline task - use of resolver params with the feature flag set", tasks: PipelineTask{ TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{{}}}}, }, - enableAPIFields: true, + enableBetaAPIFields: true, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -220,8 +227,10 @@ func TestPipelineTask_ValidateRegularTask_Success(t *testing.T) { cfg := &config.Config{ FeatureFlags: &config.FeatureFlags{}, } - if tt.enableAPIFields { + if tt.enableAlphaAPIFields { cfg.FeatureFlags.EnableAPIFields = config.AlphaAPIFields + } else if tt.enableBetaAPIFields { + cfg.FeatureFlags.EnableAPIFields = config.BetaAPIFields } ctx = config.ToContext(ctx, cfg) ctx = config.SkipValidationDueToPropagatedParametersAndWorkspaces(ctx, false) diff --git a/pkg/apis/pipeline/v1/pipelineref_validation.go b/pkg/apis/pipeline/v1/pipelineref_validation.go index 59d1d621635..e68b7751150 100644 --- a/pkg/apis/pipeline/v1/pipelineref_validation.go +++ b/pkg/apis/pipeline/v1/pipelineref_validation.go @@ -18,7 +18,6 @@ package v1 import ( "context" - "fmt" "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/version" @@ -34,13 +33,13 @@ 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")) + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).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")) + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "params", config.BetaAPIFields).ViaField("params")) if ref.Name != "" { errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) } @@ -48,21 +47,9 @@ 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 == "" { 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/pipelineref_validation_test.go b/pkg/apis/pipeline/v1/pipelineref_validation_test.go index 03714cf3d2f..ccda88ecd0f 100644 --- a/pkg/apis/pipeline/v1/pipelineref_validation_test.go +++ b/pkg/apis/pipeline/v1/pipelineref_validation_test.go @@ -38,21 +38,21 @@ func TestPipelineRef_Invalid(t *testing.T) { ref: &v1.PipelineRef{}, wantErr: apis.ErrMissingField("name"), }, { - name: "pipelineref resolver disallowed without alpha feature gate", + name: "pipelineref resolver disallowed without beta feature gate", ref: &v1.PipelineRef{ ResolverRef: v1.ResolverRef{ Resolver: "foo", }, }, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), + wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\""), }, { - name: "pipelineref params disallowed without alpha feature gate", + name: "pipelineref params disallowed without beta feature gate", ref: &v1.PipelineRef{ 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\"")), + wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")), }, { name: "pipelineref params disallowed without resolver", ref: &v1.PipelineRef{ @@ -61,7 +61,7 @@ func TestPipelineRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMissingField("resolver"), - withContext: config.EnableAlphaAPIFields, + withContext: config.EnableBetaAPIFields, }, { name: "pipelineref resolver disallowed in conjunction with pipelineref name", ref: &v1.PipelineRef{ @@ -71,7 +71,7 @@ func TestPipelineRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("name", "resolver"), - withContext: config.EnableAlphaAPIFields, + withContext: config.EnableBetaAPIFields, }, { name: "pipelineref params disallowed in conjunction with pipelineref name", ref: &v1.PipelineRef{ @@ -87,24 +87,7 @@ func TestPipelineRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), - withContext: config.EnableAlphaAPIFields, - }, { - name: "pipelineref param array not allowed", - ref: &v1.PipelineRef{ - 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\"")), + withContext: config.EnableBetaAPIFields, }, { name: "pipelineref param object not allowed", ref: &v1.PipelineRef{ @@ -119,10 +102,8 @@ 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 \"beta\""), + withContext: config.EnableBetaAPIFields, }} for _, tc := range tests { @@ -148,7 +129,11 @@ func TestPipelineRef_Valid(t *testing.T) { name: "no pipelineRef", ref: nil, }, { - name: "alpha feature: valid resolver", + name: "beta feature: valid resolver", + ref: &v1.PipelineRef{ResolverRef: v1.ResolverRef{Resolver: "git"}}, + wc: config.EnableBetaAPIFields, + }, { + name: "beta feature: valid resolver with alpha flag", ref: &v1.PipelineRef{ResolverRef: v1.ResolverRef{Resolver: "git"}}, wc: config.EnableAlphaAPIFields, }, { diff --git a/pkg/apis/pipeline/v1/resolver_types.go b/pkg/apis/pipeline/v1/resolver_types.go index 140a3ffb7a0..c27b0decfcf 100644 --- a/pkg/apis/pipeline/v1/resolver_types.go +++ b/pkg/apis/pipeline/v1/resolver_types.go @@ -21,8 +21,8 @@ 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. This feature is in beta and these fields +// are only available when the beta feature gate is enabled. 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 12d6f4d9b71..b6a5ce78e18 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. This feature is in beta and these fields are only available when the beta feature gate is enabled.", "type": "object", "properties": { "params": { diff --git a/pkg/apis/pipeline/v1/taskref_validation.go b/pkg/apis/pipeline/v1/taskref_validation.go index 95bc05df142..9de49405174 100644 --- a/pkg/apis/pipeline/v1/taskref_validation.go +++ b/pkg/apis/pipeline/v1/taskref_validation.go @@ -33,13 +33,13 @@ 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")) + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).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")) + errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "params", config.BetaAPIFields).ViaField("params")) if ref.Name != "" { errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) } @@ -47,7 +47,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 == "" { errs = errs.Also(apis.ErrMissingField("name")) diff --git a/pkg/apis/pipeline/v1/taskref_validation_test.go b/pkg/apis/pipeline/v1/taskref_validation_test.go index 88eaa52f9ad..b3e28e192a6 100644 --- a/pkg/apis/pipeline/v1/taskref_validation_test.go +++ b/pkg/apis/pipeline/v1/taskref_validation_test.go @@ -38,11 +38,15 @@ func TestTaskRef_Valid(t *testing.T) { name: "simple taskref", taskRef: &v1.TaskRef{Name: "taskrefname"}, }, { - name: "alpha feature: valid resolver", + name: "beta feature: valid resolver", + taskRef: &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git"}}, + wc: config.EnableBetaAPIFields, + }, { + name: "beta feature: valid resolver with alpha flag", taskRef: &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git"}}, wc: config.EnableAlphaAPIFields, }, { - name: "alpha feature: valid resolver with params", + name: "beta feature: valid resolver with params", taskRef: &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "git", Params: []v1.Param{{ Name: "repo", Value: v1.ParamValue{ @@ -56,7 +60,7 @@ func TestTaskRef_Valid(t *testing.T) { StringVal: "baz", }, }}}}, - wc: config.EnableAlphaAPIFields, + wc: config.EnableBetaAPIFields, }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { @@ -82,21 +86,21 @@ func TestTaskRef_Invalid(t *testing.T) { taskRef: &v1.TaskRef{}, wantErr: apis.ErrMissingField("name"), }, { - name: "taskref resolver disallowed without alpha feature gate", + name: "taskref resolver disallowed without beta 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\""), + wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\""), }, { - name: "taskref params disallowed without alpha feature gate", + name: "taskref params disallowed without beta 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\"")), + wantErr: apis.ErrMissingField("resolver").Also(apis.ErrGeneric("params requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")), }, { name: "taskref params disallowed without resolver", taskRef: &v1.TaskRef{ @@ -105,7 +109,7 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMissingField("resolver"), - wc: config.EnableAlphaAPIFields, + wc: config.EnableBetaAPIFields, }, { name: "taskref resolver disallowed in conjunction with taskref name", taskRef: &v1.TaskRef{ @@ -115,7 +119,7 @@ func TestTaskRef_Invalid(t *testing.T) { }, }, wantErr: apis.ErrMultipleOneOf("name", "resolver"), - wc: config.EnableAlphaAPIFields, + wc: config.EnableBetaAPIFields, }, { name: "taskref params disallowed in conjunction with taskref name", taskRef: &v1.TaskRef{ @@ -131,24 +135,7 @@ 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\"")), + wc: config.EnableBetaAPIFields, }, { name: "taskref param object requires alpha", taskRef: &v1.TaskRef{ @@ -163,10 +150,8 @@ 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\"")), + wc: config.EnableBetaAPIFields, + wantErr: apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"beta\""), }} 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 dab741f5a40..24d208f3e9c 100644 --- a/pkg/apis/pipeline/v1beta1/openapi_generated.go +++ b/pkg/apis/pipeline/v1beta1/openapi_generated.go @@ -30,98 +30,98 @@ 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.ConfigSource": schema_pkg_apis_resolution_v1alpha1_ConfigSource(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.ConfigSource": schema_pkg_apis_resolution_v1beta1_ConfigSource(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), } } @@ -2854,7 +2854,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": { @@ -5608,7 +5608,7 @@ func schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref common.ReferenceCallbac } } -func schema_pkg_apis_resolution_v1alpha1_ConfigSource(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_resolution_v1beta1_ConfigSource(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -5651,7 +5651,7 @@ func schema_pkg_apis_resolution_v1alpha1_ConfigSource(ref common.ReferenceCallba } } -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{ @@ -5682,25 +5682,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{ @@ -5734,7 +5734,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"), }, }, }, @@ -5745,11 +5745,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{ @@ -5757,16 +5757,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"), }, }, }, @@ -5775,10 +5778,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{ @@ -5838,8 +5843,8 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatus(ref common.Refe }, "source": { SchemaProps: spec.SchemaProps{ - Description: "Source is the source reference of the remote data that records where the remote file came from including the url, digest and the entrypoint.", - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ConfigSource"), + Description: "Source is the source reference of the remote data that records the url, digest and the entrypoint.", + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ConfigSource"), }, }, }, @@ -5847,11 +5852,11 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatus(ref common.Refe }, }, Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ConfigSource", "knative.dev/pkg/apis.Condition"}, + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ConfigSource", "knative.dev/pkg/apis.Condition"}, } } -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{ @@ -5868,8 +5873,8 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatusFields(ref commo }, "source": { SchemaProps: spec.SchemaProps{ - Description: "Source is the source reference of the remote data that records where the remote file came from including the url, digest and the entrypoint.", - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ConfigSource"), + Description: "Source is the source reference of the remote data that records the url, digest and the entrypoint.", + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ConfigSource"), }, }, }, @@ -5877,7 +5882,7 @@ func schema_pkg_apis_resolution_v1alpha1_ResolutionRequestStatusFields(ref commo }, }, Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1.ConfigSource"}, + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1.ConfigSource"}, } } 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 adbb63394cb..a771f39241e 100644 --- a/pkg/apis/pipeline/v1beta1/swagger.json +++ b/pkg/apis/pipeline/v1beta1/swagger.json @@ -140,28 +140,6 @@ } } }, - "v1alpha1.ConfigSource": { - "description": "ConfigSource records where the task/pipeline file came from.", - "type": "object", - "properties": { - "digest": { - "description": "Digest is a collection of cryptographic digests for the contents of the artifact specified by URI. https://github.com/in-toto/attestation/blob/main/spec/field_types.md#DigestSet Example: {\"sha1\": \"f99d13e554ffcb696dee719fa85b695cb5b0f428\"}", - "type": "object", - "additionalProperties": { - "type": "string", - "default": "" - } - }, - "entryPoint": { - "description": "EntryPoint identifying the entry point into the build. This is often a path to a configuration file and/or a target label within that file. Example: \"task/git-clone/0.8/git-clone.yaml\"", - "type": "string" - }, - "uri": { - "description": "URI indicating the identity of the source of the config. https://github.com/in-toto/attestation/blob/main/spec/field_types.md#ResourceURI Example: https://github.com/tektoncd/catalog", - "type": "string" - } - } - }, "v1alpha1.PipelineResource": { "description": "PipelineResource describes a resource that is an input to or output from a Task.", "type": "object", @@ -256,137 +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", - "source" - ], - "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" - }, - "source": { - "description": "Source is the source reference of the remote data that records where the remote file came from including the url, digest and the entrypoint.", - "$ref": "#/definitions/v1alpha1.ConfigSource" - } - } - }, - "v1alpha1.ResolutionRequestStatusFields": { - "description": "ResolutionRequestStatusFields are the ResolutionRequest-specific fields for the status subresource.", - "type": "object", - "required": [ - "data", - "source" - ], - "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": "" - }, - "source": { - "description": "Source is the source reference of the remote data that records where the remote file came from including the url, digest and the entrypoint.", - "$ref": "#/definitions/v1alpha1.ConfigSource" - } - } - }, "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", @@ -583,6 +430,28 @@ } } }, + "v1beta1.ConfigSource": { + "description": "ConfigSource records where the task/pipeline file came from.", + "type": "object", + "properties": { + "digest": { + "description": "Digest is a collection of cryptographic digests for the contents of the artifact specified by URI. https://github.com/in-toto/attestation/blob/main/spec/field_types.md#DigestSet Example: {\"sha1\": \"f99d13e554ffcb696dee719fa85b695cb5b0f428\"}", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + }, + "entryPoint": { + "description": "EntryPoint identifying the entry point into the build. This is often a path to a configuration file and/or a target label within that file. Example: \"task/git-clone/0.8/git-clone.yaml\"", + "type": "string" + }, + "uri": { + "description": "URI indicating the identity of the source of the config. https://github.com/in-toto/attestation/blob/main/spec/field_types.md#ResourceURI Example: https://github.com/tektoncd/catalog", + "type": "string" + } + } + }, "v1beta1.CustomRun": { "description": "CustomRun represents a single execution of a Custom Task.", "type": "object", @@ -1769,8 +1638,140 @@ } } }, + "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", + "source" + ], + "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" + }, + "source": { + "description": "Source is the source reference of the remote data that records the url, digest and the entrypoint.", + "$ref": "#/definitions/v1beta1.ConfigSource" + } + } + }, + "v1beta1.ResolutionRequestStatusFields": { + "description": "ResolutionRequestStatusFields are the ResolutionRequest-specific fields for the status subresource.", + "type": "object", + "required": [ + "data", + "source" + ], + "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": "" + }, + "source": { + "description": "Source is the source reference of the remote data that records the url, digest and the entrypoint.", + "$ref": "#/definitions/v1beta1.ConfigSource" + } + } + }, "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 446a5d40bfc..5fe1876e3d1 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/apis/version/version_validation.go b/pkg/apis/version/version_validation.go index 18e75595204..17feebd6b1b 100644 --- a/pkg/apis/version/version_validation.go +++ b/pkg/apis/version/version_validation.go @@ -30,20 +30,20 @@ import ( func ValidateEnabledAPIFields(ctx context.Context, featureName string, wantVersion string) *apis.FieldError { currentVersion := config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields var errs *apis.FieldError - message := `%s requires "enable-api-fields" feature gate to be %q but it is %q` + message := `%s requires "enable-api-fields" feature gate to be %s but it is %q` switch wantVersion { case config.StableAPIFields: // If the feature is stable, it doesn't matter what the current version is case config.BetaAPIFields: // If the feature requires "beta" fields to be enabled, the current version may be "beta" or "alpha" if currentVersion != config.BetaAPIFields && currentVersion != config.AlphaAPIFields { - message = fmt.Sprintf(message, featureName, fmt.Sprintf("%s or %s", config.AlphaAPIFields, config.BetaAPIFields), currentVersion) + message = fmt.Sprintf(message, featureName, fmt.Sprintf("%q or %q", config.AlphaAPIFields, config.BetaAPIFields), currentVersion) errs = apis.ErrGeneric(message) } case config.AlphaAPIFields: // If the feature requires "alpha" fields to be enabled, the current version must be "alpha" if currentVersion != wantVersion { - message = fmt.Sprintf(message, featureName, config.AlphaAPIFields, currentVersion) + message = fmt.Sprintf(message, featureName, fmt.Sprintf("%q", config.AlphaAPIFields), currentVersion) errs = apis.ErrGeneric(message) } default: 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 3888e8bc87b..a2782348ca8 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -7399,10 +7399,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"}, @@ -7416,7 +7413,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) @@ -7477,10 +7474,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"}, @@ -7494,7 +7488,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) @@ -7539,10 +7533,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"}, @@ -7556,7 +7547,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) @@ -7604,10 +7595,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"}, @@ -7621,7 +7609,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) @@ -7636,9 +7624,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 9a0009aa097..56d5e1ca87d 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/bundle.go b/pkg/resolution/resolver/bundle/bundle.go index 6547076d21f..c20648aa979 100644 --- a/pkg/resolution/resolver/bundle/bundle.go +++ b/pkg/resolution/resolver/bundle/bundle.go @@ -25,7 +25,7 @@ import ( "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/remote" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" ) @@ -47,7 +47,7 @@ type RequestOptions struct { type ResolvedResource struct { data []byte annotations map[string]string - source *v1alpha1.ConfigSource + source *v1beta1.ConfigSource } var _ framework.ResolvedResource = &ResolvedResource{} @@ -65,7 +65,7 @@ func (br *ResolvedResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (br *ResolvedResource) Source() *v1alpha1.ConfigSource { +func (br *ResolvedResource) Source() *v1beta1.ConfigSource { return br.source } 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 3a565ab418a..de54267d995 100644 --- a/pkg/resolution/resolver/cluster/resolver.go +++ b/pkg/resolution/resolver/cluster/resolver.go @@ -23,7 +23,8 @@ import ( "strings" 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" 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" @@ -76,7 +77,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) } @@ -87,7 +88,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) } @@ -182,36 +183,49 @@ func (r *ResolvedClusterResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (r ResolvedClusterResource) Source() *v1alpha1.ConfigSource { +func (r ResolvedClusterResource) Source() *v1beta1.ConfigSource { return nil } -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 9fd16fa0bb3..ac2930b6e80 100644 --- a/pkg/resolution/resolver/framework/fakeresolver.go +++ b/pkg/resolution/resolver/framework/fakeresolver.go @@ -23,7 +23,8 @@ import ( "strings" "time" - "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" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" ) @@ -50,7 +51,7 @@ var _ Resolver = &FakeResolver{} type FakeResolvedResource struct { Content string AnnotationMap map[string]string - ContentSource *v1alpha1.ConfigSource + ContentSource *v1beta1.ConfigSource ErrorWith string WaitFor time.Duration } @@ -67,7 +68,7 @@ func (f *FakeResolvedResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (f *FakeResolvedResource) Source() *v1alpha1.ConfigSource { +func (f *FakeResolvedResource) Source() *v1beta1.ConfigSource { return f.ContentSource } @@ -102,7 +103,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, } @@ -111,8 +117,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) } } @@ -126,8 +132,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 2b01790e7fd..32edef20f56 100644 --- a/pkg/resolution/resolver/framework/interface.go +++ b/pkg/resolution/resolver/framework/interface.go @@ -20,7 +20,8 @@ import ( "context" "time" - "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" ) // Resolver is the interface to implement for type-specific resource @@ -41,7 +42,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 @@ -49,7 +50,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 @@ -96,5 +97,5 @@ type TimedResolution interface { type ResolvedResource interface { Data() []byte Annotations() map[string]string - Source() *v1alpha1.ConfigSource + Source() *v1beta1.ConfigSource } diff --git a/pkg/resolution/resolver/framework/reconciler.go b/pkg/resolution/resolver/framework/reconciler.go index 8446b30bf45..9d339064e3c 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 @@ -192,12 +192,12 @@ func (r *Reconciler) MarkFailed(ctx context.Context, rr *v1alpha1.ResolutionRequ // a ResolutionRequest with its data and annotations once successfully // resolved. type statusDataPatch struct { - Annotations map[string]string `json:"annotations"` - Data string `json:"data"` - Source *v1alpha1.ConfigSource `json:"source"` + Annotations map[string]string `json:"annotations"` + Data string `json:"data"` + Source *v1beta1.ConfigSource `json:"source"` } -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": { @@ -212,7 +212,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 ac4ddf065ed..76e7a04c32c 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,18 +102,19 @@ 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": { Content: "some content", AnnotationMap: map[string]string{"foo": "bar"}, - ContentSource: &v1alpha1.ConfigSource{ + ContentSource: &v1beta1.ConfigSource{ URI: "https://abc.com", Digest: map[string]string{ "sha1": "xyz", @@ -120,15 +123,15 @@ func TestReconcile(t *testing.T) { }, }, }, - 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")), - Source: &v1alpha1.ConfigSource{ + Source: &v1beta1.ConfigSource{ URI: "https://abc.com", Digest: map[string]string{ "sha1": "xyz", @@ -139,9 +142,9 @@ func TestReconcile(t *testing.T) { }, }, { 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{ @@ -152,12 +155,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": { @@ -167,9 +171,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{ @@ -180,12 +184,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": { @@ -200,7 +205,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} @@ -227,7 +232,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) @@ -267,7 +272,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 3ab97bb50f2..4fd8c313972 100644 --- a/pkg/resolution/resolver/git/resolver.go +++ b/pkg/resolution/resolver/git/resolver.go @@ -34,7 +34,8 @@ import ( "github.com/jenkins-x/go-scm/scm" "github.com/jenkins-x/go-scm/scm/factory" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - "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" resolutioncommon "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" "go.uber.org/zap" @@ -110,7 +111,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) } @@ -124,7 +125,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) } @@ -332,7 +333,7 @@ func (r *resolvedGitResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (r *resolvedGitResource) Source() *v1alpha1.ConfigSource { +func (r *resolvedGitResource) Source() *v1beta1.ConfigSource { return nil } @@ -403,38 +404,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) } @@ -446,5 +452,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 d29bb916af4..cd007823dc2 100644 --- a/pkg/resolution/resolver/git/resolver_test.go +++ b/pkg/resolution/resolver/git/resolver_test.go @@ -36,7 +36,8 @@ import ( "github.com/jenkins-x/go-scm/scm/driver/fake" "github.com/jenkins-x/go-scm/scm/factory" resolverconfig "github.com/tektoncd/pipeline/pkg/apis/config/resolver" - "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" @@ -71,7 +72,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) } } @@ -85,7 +86,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") } @@ -138,7 +139,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) } @@ -181,7 +182,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") } @@ -222,7 +223,7 @@ func TestResolve(t *testing.T) { pathInRepo string config map[string]string apiToken string - expectedStatus *v1alpha1.ResolutionRequestStatus + expectedStatus *v1beta1.ResolutionRequestStatus expectedErr error }{ { @@ -472,15 +473,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) } @@ -657,10 +661,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{ @@ -671,27 +675,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 @@ -701,17 +724,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, @@ -729,3 +752,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 d6c75063eba..628eac62f2b 100644 --- a/pkg/resolution/resolver/hub/resolver.go +++ b/pkg/resolution/resolver/hub/resolver.go @@ -22,7 +22,8 @@ import ( "net/http" 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" "github.com/tektoncd/pipeline/pkg/resolution/common" "github.com/tektoncd/pipeline/pkg/resolution/resolver/framework" ) @@ -64,18 +65,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") } } @@ -91,21 +96,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 @@ -117,8 +128,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 { @@ -163,7 +174,7 @@ func (*ResolvedHubResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (rr *ResolvedHubResource) Source() *v1alpha1.ConfigSource { +func (rr *ResolvedHubResource) Source() *v1beta1.ConfigSource { return 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 854003cb666..21c65043b74 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} } @@ -153,6 +153,6 @@ func (r readOnlyResolutionRequest) Data() ([]byte, error) { return decodedBytes, nil } -func (r readOnlyResolutionRequest) Source() *v1alpha1.ConfigSource { +func (r readOnlyResolutionRequest) Source() *v1beta1.ConfigSource { return r.req.Status.Source } 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 9a6e73fd29d..0ebcf34b88c 100644 --- a/pkg/resolution/resource/resource.go +++ b/pkg/resolution/resource/resource.go @@ -19,7 +19,8 @@ package resource import ( "context" - "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" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -44,7 +45,7 @@ type Requester interface { type Request interface { Name() string Namespace() string - Params() map[string]string + Params() []pipelinev1beta1.Param } // OwnedRequest is implemented by any type implementing Request that also needs @@ -59,5 +60,5 @@ type OwnedRequest interface { type ResolvedResource interface { Data() ([]byte, error) Annotations() map[string]string - Source() *v1alpha1.ConfigSource + Source() *v1beta1.ConfigSource } diff --git a/tekton/publish.yaml b/tekton/publish.yaml index 47d44387d71..cc515debc14 100644 --- a/tekton/publish.yaml +++ b/tekton/publish.yaml @@ -163,12 +163,14 @@ spec: # The real "tagging" will happen with the "create-release" pipeline. git tag $(params.versionTag) - ko resolve --platform=$(params.platforms) --preserve-import-paths -t $(params.versionTag) -l 'app.kubernetes.io/component!=resolvers' -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.yaml + ko resolve --platform=$(params.platforms) --preserve-import-paths -t $(params.versionTag) -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.yaml + ko resolve --platform=$(params.platforms) --preserve-import-paths -t $(params.versionTag) -l 'app.kubernetes.io/component!=resolvers' -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/minimal-release.yaml ko resolve --platform=$(params.platforms) --preserve-import-paths -t $(params.versionTag) -f ${PROJECT_ROOT}/config/resolvers > $OUTPUT_RELEASE_DIR/resolvers.yaml # Publish images and create release.notags.yaml # This is useful if your container runtime doesn't support the `image-reference:tag@digest` notation # This is currently the case for `cri-o` (and most likely others) - ko resolve --platform=$(params.platforms) --preserve-import-paths -l 'app.kubernetes.io/component!=resolvers' -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.notags.yaml + ko resolve --platform=$(params.platforms) --preserve-import-paths -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.notags.yaml + ko resolve --platform=$(params.platforms) --preserve-import-paths -l 'app.kubernetes.io/component!=resolvers' -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/minimal-release.notags.yaml ko resolve --platform=$(params.platforms) --preserve-import-paths -f ${PROJECT_ROOT}/config/resolvers > $OUTPUT_RELEASE_DIR/resolvers.notags.yaml # Rewrite "devel" to params.versionTag @@ -188,9 +190,9 @@ spec: IMAGES="${IMAGES} ${IMAGES_PATH}/cmd/${cmd}:$(params.versionTag)" done - # Parse the built images from the release.yaml generated by ko + # Parse the built images from the minimal-release.yaml generated by ko koparse \ - --path $OUTPUT_RELEASE_DIR/release.yaml \ + --path $OUTPUT_RELEASE_DIR/minimal-release.yaml \ --base ${IMAGES_PATH} --images ${IMAGES} > /workspace/built_images for cmd in $(params.resolverImages) diff --git a/tekton/release-pipeline.yaml b/tekton/release-pipeline.yaml index 985143cab59..61b4fc07316 100644 --- a/tekton/release-pipeline.yaml +++ b/tekton/release-pipeline.yaml @@ -192,6 +192,10 @@ spec: description: The full URL of the release file in the bucket - name: release-no-tag description: The full URL of the release file (no tag) in the bucket + - name: minimal-release + description: The full URL of the minimal release (without resolvers) file in the bucket + - name: minimal-release-no-tag + description: The full URL of the minimal release file (without resolvers, no tag) in the bucket - name: resolvers description: The full URL of the resolvers release file in the bucket - name: resolvers-no-tag @@ -210,5 +214,7 @@ spec: BASE_URL=$(echo ${BASE_URL} | sed 's,gs://,https://storage.googleapis.com/,g') echo "${BASE_URL}/release.yaml" > $(results.release.path) echo "${BASE_URL}/release.notag.yaml" > $(results.release-no-tag.path) + echo "${BASE_URL}/minimal-release.yaml" > $(results.minimal-release.path) + echo "${BASE_URL}/minimal-release.notag.yaml" > $(results.minimal-release-no-tag.path) echo "${BASE_URL}/resolvers.yaml" > $(results.resolvers.path) echo "${BASE_URL}/resolvers.notags.yaml" > $(results.resolvers-no-tag.path) 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..5ef47f77e81 100755 --- a/test/e2e-common.sh +++ b/test/e2e-common.sh @@ -21,18 +21,14 @@ source $(git rev-parse --show-toplevel)/vendor/github.com/tektoncd/plumbing/scri function install_pipeline_crd() { echo ">> Deploying Tekton Pipelines" local ko_target="$(mktemp)" - ko resolve -l 'app.kubernetes.io/component!=resolvers' -R -f config/ > "${ko_target}" || fail_test "Pipeline image resolve failed" + ko resolve -R -f config/ > "${ko_target}" || fail_test "Pipeline image resolve failed" cat "${ko_target}" | sed -e 's%"level": "info"%"level": "debug"%' \ | sed -e 's%loglevel.controller: "info"%loglevel.controller: "debug"%' \ | sed -e 's%loglevel.webhook: "info"%loglevel.webhook: "debug"%' \ | kubectl apply -R -f - || fail_test "Build pipeline installation failed" verify_pipeline_installation - - if [ "${PIPELINE_FEATURE_GATE}" == "alpha" ]; then - ko apply -f config/resolvers || fail_test "Resolvers installation failed" - verify_resolvers_installation - fi + verify_resolvers_installation export SYSTEM_NAMESPACE=tekton-pipelines } @@ -42,7 +38,8 @@ function install_pipeline_crd_version() { echo ">> Deploying Tekton Pipelines of Version $1" kubectl apply -f "https://github.com/tektoncd/pipeline/releases/download/$1/release.yaml" || fail_test "Build pipeline installation failed of Version $1" - if [ "${PIPELINE_FEATURE_GATE}" == "alpha" ]; then + # If the version to be installed is v0.40.x, we need to install resolvers.yaml separately. + if [[ "${1}" == v0.40.* ]]; then kubectl apply -f "https://github.com/tektoncd/pipeline/releases/download/$1/resolvers.yaml" || fail_test "Resolvers installation failed of Version $1" fi diff --git a/test/resolution.go b/test/resolution.go index 22cf006b941..6c7c322a3da 100644 --- a/test/resolution.go +++ b/test/resolution.go @@ -6,8 +6,11 @@ import ( "fmt" "strings" - "github.com/tektoncd/pipeline/pkg/apis/resolution/v1alpha1" + "github.com/google/go-cmp/cmp" + pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1" resolution "github.com/tektoncd/pipeline/pkg/resolution/resource" + "github.com/tektoncd/pipeline/test/diff" ) var _ resolution.Requester = &Requester{} @@ -42,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 []pipelinev1beta1.Param } // Submit implements resolution.Requester, accepting the name of a @@ -52,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]pipelinev1beta1.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 { @@ -81,7 +86,7 @@ type ResolvedResource struct { // Annotations to return when resolution is complete. ResolvedAnnotations map[string]string // ResolvedSource to return the source reference of the remote data - ResolvedSource *v1alpha1.ConfigSource + ResolvedSource *v1beta1.ConfigSource } // Data implements resolution.ResolvedResource and returns the mock @@ -98,6 +103,6 @@ func (r *ResolvedResource) Annotations() map[string]string { // Source is the source reference of the remote data that records where the remote // file came from including the url, digest and the entrypoint. -func (r *ResolvedResource) Source() *v1alpha1.ConfigSource { +func (r *ResolvedResource) Source() *v1beta1.ConfigSource { return r.ResolvedSource } 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()