Skip to content

Commit

Permalink
Change the Storage Version to V1 Types
Browse files Browse the repository at this point in the history
Prior to this PR, CRDs are stored in etcd as V1beta1 apiVersion. This commit swaps the storage version to V1 Types for Task, TaskRun, Pipeline and PipelineRun CRDs. From now on we could make changes only to the V1 APIs.

This PR makes the following changes:
- switch storage to v1beta1 for Task, TaskRun, Pipeline and PipelineRun CRDs(config/)
- use V1 types in controllers
- convert v1 CRDs to v1beta1 for reconciling features that are not moved to V1 ie. CustomTask
  - it exports the ConvertFrom functions for v1beta1 Params, Workspaces and TaskRefs for v1beta1
    required fields to be reconciled when we swap to v1 storage version.
- migrate the v1beta1 Yamls and tests following the [migration guide](https://github.com/tektoncd/pipeline/blob/main/docs/migrating-v1beta1-to-v1.md)
- swap the RefSource and Params in remote resolution API from V1beta1 to V1
- for tests and examples that are enabled on default in v1beta1, add beta to  for features that are not defaulted in v1 but in v1beta1 ie. resolver_tests and move the examples which requires enable-api-fields to beta under a beta folder
  • Loading branch information
JeromeJu authored and tekton-robot committed Jun 16, 2023
1 parent 8933dc6 commit 7384a67
Show file tree
Hide file tree
Showing 175 changed files with 8,541 additions and 8,606 deletions.
4 changes: 2 additions & 2 deletions config/300-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
versions:
- name: v1beta1
served: true
storage: true
storage: false
subresources:
status: {}
schema:
Expand All @@ -43,7 +43,7 @@ spec:
x-kubernetes-preserve-unknown-fields: true
- name: v1
served: true
storage: false
storage: true
schema:
openAPIV3Schema:
type: object
Expand Down
4 changes: 2 additions & 2 deletions config/300-pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
versions:
- name: v1beta1
served: true
storage: true
storage: false
schema:
openAPIV3Schema:
type: object
Expand Down Expand Up @@ -58,7 +58,7 @@ spec:
status: {}
- name: v1
served: true
storage: false
storage: true
schema:
openAPIV3Schema:
type: object
Expand Down
4 changes: 2 additions & 2 deletions config/300-task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
versions:
- name: v1beta1
served: true
storage: true
storage: false
schema:
openAPIV3Schema:
type: object
Expand All @@ -45,7 +45,7 @@ spec:
status: {}
- name: v1
served: true
storage: false
storage: true
schema:
openAPIV3Schema:
type: object
Expand Down
4 changes: 2 additions & 2 deletions config/300-taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
versions:
- name: v1beta1
served: true
storage: true
storage: false
schema:
openAPIV3Schema:
type: object
Expand Down Expand Up @@ -58,7 +58,7 @@ spec:
status: {}
- name: v1
served: true
storage: false
storage: true
schema:
openAPIV3Schema:
type: object
Expand Down
8 changes: 4 additions & 4 deletions docs/how-to-write-a-resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ import (
"github.com/tektoncd/pipeline/pkg/resolution/common"
"github.com/tektoncd/pipeline/pkg/resolution/resolver/framework"
"knative.dev/pkg/injection/sharedmain"
pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
)
```

Expand Down Expand Up @@ -269,7 +269,7 @@ func (*myResolvedResource) Annotations() map[string]string {

// RefSource 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) RefSource() *pipelinev1beta1.RefSource {
func (*myResolvedResource) RefSource() *pipelinev1.RefSource {
return nil
}
```
Expand All @@ -282,8 +282,8 @@ following example.
```go
// RefSource 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) RefSource() *pipelinev1beta1.RefSource {
return &v1alpha1.RefSource{
func (*myResolvedResource) RefSource() *pipelinev1.RefSource {
return &v1.RefSource{
URI: "https://github.com/user/example",
Digest: map[string]string{
"sha1": "example",
Expand Down
23 changes: 13 additions & 10 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ object.</p>
<td>
<code>refSource</code><br/>
<em>
<a href="#tekton.dev/v1beta1.RefSource">
<a href="#tekton.dev/v1.RefSource">
RefSource
</a>
</em>
Expand Down Expand Up @@ -291,7 +291,7 @@ ResolutionRequestSpec
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.Param">
<a href="#tekton.dev/v1.Param">
[]Param
</a>
</em>
Expand Down Expand Up @@ -345,7 +345,7 @@ ResolutionRequest CRD.</p>
<td>
<code>params</code><br/>
<em>
<a href="#tekton.dev/v1beta1.Param">
<a href="#tekton.dev/v1.Param">
[]Param
</a>
</em>
Expand Down Expand Up @@ -443,8 +443,8 @@ object.</p>
<td>
<code>source</code><br/>
<em>
<a href="#tekton.dev/v1beta1.ConfigSource">
ConfigSource
<a href="#tekton.dev/v1.RefSource">
RefSource
</a>
</em>
</td>
Expand All @@ -456,7 +456,7 @@ ConfigSource
<td>
<code>refSource</code><br/>
<em>
<a href="#tekton.dev/v1beta1.RefSource">
<a href="#tekton.dev/v1.RefSource">
RefSource
</a>
</em>
Expand Down Expand Up @@ -1569,6 +1569,9 @@ IncludeParamsList
</table>
<h3 id="tekton.dev/v1.Param">Param
</h3>
<p>
(<em>Appears on:</em><a href="#resolution.tekton.dev/v1beta1.ResolutionRequestSpec">ResolutionRequestSpec</a>)
</p>
<div>
<p>Param declares an ParamValues to use for the parameter called name.</p>
</div>
Expand Down Expand Up @@ -3125,7 +3128,7 @@ github.com/tektoncd/pipeline/pkg/apis/config.FeatureFlags
<h3 id="tekton.dev/v1.RefSource">RefSource
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1.Provenance">Provenance</a>)
(<em>Appears on:</em><a href="#tekton.dev/v1.Provenance">Provenance</a>, <a href="#resolution.tekton.dev/v1alpha1.ResolutionRequestStatusFields">ResolutionRequestStatusFields</a>, <a href="#resolution.tekton.dev/v1beta1.ResolutionRequestStatusFields">ResolutionRequestStatusFields</a>)
</p>
<div>
<p>RefSource contains the information that can uniquely identify where a remote
Expand Down Expand Up @@ -8825,7 +8828,7 @@ int32
<h3 id="tekton.dev/v1beta1.ConfigSource">ConfigSource
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.Provenance">Provenance</a>, <a href="#resolution.tekton.dev/v1beta1.ResolutionRequestStatusFields">ResolutionRequestStatusFields</a>)
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.Provenance">Provenance</a>)
</p>
<div>
<p>ConfigSource contains the information that can uniquely identify where a remote
Expand Down Expand Up @@ -9348,7 +9351,7 @@ IncludeParamsList
<h3 id="tekton.dev/v1beta1.Param">Param
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.TaskRunInputs">TaskRunInputs</a>, <a href="#resolution.tekton.dev/v1beta1.ResolutionRequestSpec">ResolutionRequestSpec</a>)
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.TaskRunInputs">TaskRunInputs</a>)
</p>
<div>
<p>Param declares an ParamValues to use for the parameter called name.</p>
Expand Down Expand Up @@ -11258,7 +11261,7 @@ github.com/tektoncd/pipeline/pkg/apis/config.FeatureFlags
<h3 id="tekton.dev/v1beta1.RefSource">RefSource
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.Provenance">Provenance</a>, <a href="#resolution.tekton.dev/v1alpha1.ResolutionRequestStatusFields">ResolutionRequestStatusFields</a>, <a href="#resolution.tekton.dev/v1beta1.ResolutionRequestStatusFields">ResolutionRequestStatusFields</a>)
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.Provenance">Provenance</a>)
</p>
<div>
<p>RefSource contains the information that can uniquely identify where a remote
Expand Down
10 changes: 5 additions & 5 deletions docs/resolver-template/cmd/demoresolver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"context"
"errors"

pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1"
"github.com/tektoncd/pipeline/pkg/resolution/common"
"github.com/tektoncd/pipeline/pkg/resolution/resolver/framework"
Expand Down Expand Up @@ -52,21 +52,21 @@ func (r *resolver) GetSelector(context.Context) map[string]string {
}

// ValidateParams ensures parameters from a request are as expected.
func (r *resolver) ValidateParams(ctx context.Context, params []pipelinev1beta1.Param) error {
func (r *resolver) ValidateParams(ctx context.Context, params []pipelinev1.Param) error {
if len(params) > 0 {
return errors.New("no params allowed")
}
return nil
}

// Resolve uses the given params to resolve the requested file or resource.
func (r *resolver) Resolve(ctx context.Context, params []pipelinev1beta1.Param) (framework.ResolvedResource, error) {
func (r *resolver) Resolve(ctx context.Context, params []pipelinev1.Param) (framework.ResolvedResource, error) {
return &myResolvedResource{}, nil
}

// our hard-coded resolved file to return
const pipeline = `
apiVersion: tekton.dev/v1beta1
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: my-pipeline
Expand Down Expand Up @@ -95,6 +95,6 @@ func (*myResolvedResource) Annotations() map[string]string {

// RefSource 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) RefSource() *pipelinev1beta1.RefSource {
func (*myResolvedResource) RefSource() *pipelinev1.RefSource {
return nil
}
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions pkg/apis/pipeline/v1beta1/openapi_generated.go

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

3 changes: 2 additions & 1 deletion pkg/apis/pipeline/v1beta1/param_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func (p Param) convertTo(ctx context.Context, sink *v1.Param) {
sink.Value = newValue
}

func (p *Param) convertFrom(ctx context.Context, source v1.Param) {
// ConvertFrom converts v1beta1 Param from v1 Param
func (p *Param) ConvertFrom(ctx context.Context, source v1.Param) {
p.Name = source.Name
newValue := ParamValue{}
newValue.convertFrom(ctx, source.Value)
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/pipeline/v1beta1/pipeline_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (pt *PipelineTask) convertFrom(ctx context.Context, source v1.PipelineTask,
pt.Description = source.Description
if source.TaskRef != nil {
newTaskRef := TaskRef{}
newTaskRef.convertFrom(ctx, *source.TaskRef)
newTaskRef.ConvertFrom(ctx, *source.TaskRef)
pt.TaskRef = &newTaskRef
}
if source.TaskSpec != nil {
Expand All @@ -213,7 +213,7 @@ func (pt *PipelineTask) convertFrom(ctx context.Context, source v1.PipelineTask,
pt.Params = nil
for _, p := range source.Params {
new := Param{}
new.convertFrom(ctx, p)
new.ConvertFrom(ctx, p)
pt.Params = append(pt.Params, new)
}
pt.Matrix = nil
Expand Down Expand Up @@ -280,15 +280,15 @@ func (m *Matrix) convertTo(ctx context.Context, sink *v1.Matrix) {
func (m *Matrix) convertFrom(ctx context.Context, source v1.Matrix) {
for _, param := range source.Params {
new := Param{}
new.convertFrom(ctx, param)
new.ConvertFrom(ctx, param)
m.Params = append(m.Params, new)
}

for i, include := range source.Include {
m.Include = append(m.Include, IncludeParams{Name: include.Name})
for _, p := range include.Params {
new := Param{}
new.convertFrom(ctx, p)
new.ConvertFrom(ctx, p)
m.Include[i].Params = append(m.Include[i].Params, new)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1beta1/pipelinerun_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (prs *PipelineRunSpec) ConvertFrom(ctx context.Context, source *v1.Pipeline
prs.Params = nil
for _, p := range source.Params {
new := Param{}
new.convertFrom(ctx, p)
new.ConvertFrom(ctx, p)
prs.Params = append(prs.Params, new)
}
prs.ServiceAccountName = source.TaskRunTemplate.ServiceAccountName
Expand All @@ -137,7 +137,7 @@ func (prs *PipelineRunSpec) ConvertFrom(ctx context.Context, source *v1.Pipeline
prs.Workspaces = nil
for _, w := range source.Workspaces {
new := WorkspaceBinding{}
new.convertFrom(ctx, w)
new.ConvertFrom(ctx, w)
prs.Workspaces = append(prs.Workspaces, new)
}
prs.TaskRunSpecs = nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/resolver_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (rr *ResolverRef) convertFrom(ctx context.Context, source v1.ResolverRef) {
rr.Params = nil
for _, r := range source.Params {
new := Param{}
new.convertFrom(ctx, r)
new.ConvertFrom(ctx, r)
rr.Params = append(rr.Params, new)
}
}
Loading

0 comments on commit 7384a67

Please sign in to comment.