Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the Storage Version to V1 Types #6444

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I suppose these changes could have been done before in their dedicated PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is related to https://github.com/tektoncd/pipeline/pull/6444/files#r1227105161 and we might want to try to swap all the v1beta1 params for resolver to v1 in the same PR since the reconciler previously uses v1beta1 fields/CRDs until this PR?

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
}
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) {
afrittoli marked this conversation as resolved.
Show resolved Hide resolved
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