Skip to content

Commit

Permalink
Move remote resolution out of alpha
Browse files Browse the repository at this point in the history
Closes #4710

Based on discussions around promoting features last week, I'm opting to skip the need for a `beta` flag and take remote resolution straight to `stable`. I'm confident in the API stability, so I don't think there's a reason to wait since v1 hasn't happened yet. And for that matter, v1 is expecting remote resolution to be on by default anyway.

Deprecation of the legacy `taskRef.bundle` and `pipelineRef.bundle` syntax will be handled in a separate PR (#5514).

Signed-off-by: Andrew Bayer <[email protected]>
  • Loading branch information
abayer committed Sep 19, 2022
1 parent a5970b1 commit de4b925
Show file tree
Hide file tree
Showing 77 changed files with 910 additions and 940 deletions.
18 changes: 16 additions & 2 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions config/300-resolutionrequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ spec:
- resolutionrequests
versions:
- name: v1alpha1
served: true
storage: true
served: false
storage: false
subresources:
status: {}
schema:
Expand All @@ -56,8 +56,8 @@ spec:
type: string
jsonPath: ".status.conditions[?(@.type=='Succeeded')].reason"
- name: v1beta1
served: false
storage: false
served: true
storage: true
subresources:
status: {}
schema:
Expand Down
16 changes: 4 additions & 12 deletions config/resolvers/config-feature-flags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion docs/bundle-resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion docs/cluster-resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion docs/git-resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-write-a-resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ pipeline. Create a file called `test-request.yaml` with the following
content:

```yaml
apiVersion: resolution.tekton.dev/v1alpha1
apiVersion: resolution.tekton.dev/v1beta1
kind: ResolutionRequest
metadata:
name: test-request
Expand Down
2 changes: 1 addition & 1 deletion docs/hub-resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
3 changes: 0 additions & 3 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ data:

## Installing and configuring remote Task and Pipeline resolution

**NOTE**: Remote resolution is currently [an `alpha` feature](#alpha-features).

To install the latest release of the [built-in remote resolvers](#built-in-resolvers),
run the following command:

Expand Down Expand Up @@ -462,7 +460,6 @@ Features currently in "alpha" are:
| [Propagated `Parameters`](./taskruns.md#propagated-parameters) | [TEP-0107](https://github.com/tektoncd/community/blob/main/teps/0107-propagating-parameters.md) | [v0.36.0](https://github.com/tektoncd/pipeline/releases/tag/v0.36.0) | |
| [Propagated `Workspaces`](./pipelineruns.md#propagated-workspaces) | [TEP-0111](https://github.com/tektoncd/community/blob/main/teps/0111-propagating-workspaces.md) | | |
| [Windows Scripts](./tasks.md#windows-scripts) | [TEP-0057](https://github.com/tektoncd/community/blob/main/teps/0057-windows-support.md) | [v0.28.0](https://github.com/tektoncd/pipeline/releases/tag/v0.28.0) | |
| [Remote Tasks](./taskruns.md#remote-tasks) and [Remote Pipelines](./pipelineruns.md#remote-pipelines) | [TEP-0060](https://github.com/tektoncd/community/blob/main/teps/0060-remote-resolution.md) | [v0.35.0](https://github.com/tektoncd/pipeline/releases/tag/v0.35.0) | |
| [Debug](./debug.md) | [TEP-0042](https://github.com/tektoncd/community/blob/main/teps/0042-taskrun-breakpoint-on-failure.md) | [v0.26.0](https://github.com/tektoncd/pipeline/releases/tag/v0.26.0) | |
| [Step and Sidecar Overrides](./taskruns.md#overriding-task-steps-and-sidecars) | [TEP-0094](https://github.com/tektoncd/community/blob/main/teps/0094-specifying-resource-requirements-at-runtime.md) | | |
| [Matrix](./matrix.md) | [TEP-0090](https://github.com/tektoncd/community/blob/main/teps/0090-matrix.md) | [v0.38.0](https://github.com/tektoncd/pipeline/releases/tag/v0.38.0) | |
Expand Down
9 changes: 2 additions & 7 deletions docs/resolution-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ with a Pipeline stored in a git repo.
See [the installation instructions for Tekton Pipeline](./install.md#installing-tekton-pipelines-on-kubernetes), and
[the installation instructions for the built-in resolvers](./install.md#installing-and-configuring-remote-task-and-pipeline-resolution).

## Step 2: Configure Pipelines to enable alpha features and resolvers
## Step 2: Configure Pipelines to enable resolvers

Tekton Pipelines currently has its integration with remote resolution behind
the alpha feature gate, and enabling specific resolvers is controlled by feature
flags as well:
Remote resolvers for Tekton Pipelines are enabled by feature flags:

```sh
# update the feature-flags configmap in the tekton-pipelines namespace
kubectl patch -n tekton-pipelines configmap feature-flags -p '{"data":{"enable-api-fields":"alpha","enable-git-resolver":"true"}}'

# update the resolvers-feature-flags configmap in the tekton-pipelines-resolvers namespace
kubectl patch -n tekton-pipelines-resolvers configmap resolvers-feature-flags -p '{"data":{"enable-git-resolver":"true"}}'
```
Expand Down
2 changes: 1 addition & 1 deletion docs/resolver-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Try creating a `ResolutionRequest` targeting `"demo"` with no parameters:

```bash
$ cat <<EOF > rrtest.yaml
apiVersion: resolution.tekton.dev/v1alpha1
apiVersion: resolution.tekton.dev/v1beta1
kind: ResolutionRequest
metadata:
name: test-resolver-template
Expand Down
9 changes: 5 additions & 4 deletions docs/resolver-template/cmd/demoresolver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ 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"
"knative.dev/pkg/injection/sharedmain"
)

func main() {
ctx := filteredinformerfactory.WithSelectors(context.Background(), v1alpha1.ManagedByLabelKey)
ctx := filteredinformerfactory.WithSelectors(context.Background(), v1beta1.ManagedByLabelKey)
sharedmain.MainWithContext(ctx, "controller",
framework.NewController(ctx, &resolver{}),
)
Expand All @@ -51,15 +52,15 @@ 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")
}
return nil
}

// 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
}

Expand Down
14 changes: 7 additions & 7 deletions docs/resolver-template/cmd/demoresolver/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand All @@ -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)),
},
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion hack/update-openapigen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} ..."
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions pkg/apis/pipeline/v1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ func (pt PipelineTask) validateCustomTask() (errs *apis.FieldError) {

// validateTask validates a pipeline task or a final task for taskRef and taskSpec
func (pt PipelineTask) validateTask(ctx context.Context) (errs *apis.FieldError) {
cfg := config.FromContextOrDefaults(ctx)
// Validate TaskSpec if it's present
if pt.TaskSpec != nil {
errs = errs.Also(pt.TaskSpec.Validate(ctx).ViaField("taskSpec"))
Expand All @@ -260,15 +259,6 @@ func (pt PipelineTask) validateTask(ctx context.Context) (errs *apis.FieldError)
} else if pt.TaskRef.Resolver == "" {
errs = errs.Also(apis.ErrInvalidValue("taskRef must specify name", "taskRef.name"))
}
if cfg.FeatureFlags.EnableAPIFields != config.AlphaAPIFields {
// fail if resolver or resource are present when enable-api-fields is false.
if pt.TaskRef.Resolver != "" {
errs = errs.Also(apis.ErrDisallowedFields("taskref.resolver"))
}
if len(pt.TaskRef.Params) > 0 {
errs = errs.Also(apis.ErrDisallowedFields("taskref.params"))
}
}
}
return errs
}
Expand Down
20 changes: 3 additions & 17 deletions pkg/apis/pipeline/v1/pipeline_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,15 @@ func TestPipelineTask_ValidateRegularTask_Success(t *testing.T) {
TaskSpec: &EmbeddedTask{TaskSpec: getTaskSpec()},
},
}, {
name: "pipeline task - use of resolver with the feature flag set",
name: "pipeline task - use of resolver",
tasks: PipelineTask{
TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resolver: "bar"}},
},
enableAPIFields: true,
}, enableAPIFields: true,
}, {
name: "pipeline task - use of resolver params with the feature flag set",
name: "pipeline task - use of resolver params",
tasks: PipelineTask{
TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{{}}}},
},
enableAPIFields: true,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -268,18 +266,6 @@ func TestPipelineTask_ValidateRegularTask_Failure(t *testing.T) {
Message: `invalid value: taskRef must specify name`,
Paths: []string{"taskRef.name"},
},
}, {
name: "pipeline task - use of resolver without the feature flag set",
task: PipelineTask{
TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Resolver: "bar"}},
},
expectedError: *apis.ErrDisallowedFields("taskref.resolver"),
}, {
name: "pipeline task - use of resolver params without the feature flag set",
task: PipelineTask{
TaskRef: &TaskRef{Name: "boo", ResolverRef: ResolverRef{Params: []Param{{}}}},
},
expectedError: *apis.ErrDisallowedFields("taskref.params"),
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
20 changes: 14 additions & 6 deletions pkg/apis/pipeline/v1/pipelineref_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package v1
import (
"context"

"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/version"
"knative.dev/pkg/apis"
)

Expand All @@ -32,10 +30,20 @@ func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) {
}

switch {
case ref.Resolver != "":
errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "resolver", config.AlphaAPIFields).ViaField("resolver"))
if ref.Name != "" {
errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver"))
case ref.Resolver != "" || ref.Params != nil:
if ref.Resolver != "" {
if ref.Name != "" {
errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver"))
}
}
if ref.Params != nil {
if ref.Name != "" {
errs = errs.Also(apis.ErrMultipleOneOf("name", "params"))
}
if ref.Resolver == "" {
errs = errs.Also(apis.ErrMissingField("resolver"))
}
errs = errs.Also(ValidateParameters(ctx, ref.Params))
}
case ref.Name == "":
errs = errs.Also(apis.ErrMissingField("name"))
Expand Down
Loading

0 comments on commit de4b925

Please sign in to comment.