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

Use SchemeGroupVersion for tekton objects in cluster resolver #5705

Merged
merged 1 commit into from
Nov 3, 2022
Merged
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
5 changes: 3 additions & 2 deletions pkg/resolution/resolver/cluster/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1beta1.Par
}

var data []byte
groupVersion := pipelinev1beta1.SchemeGroupVersion.String()
Copy link
Member

Choose a reason for hiding this comment

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

Thanks Chuang! I was wondering if there is any way we can link this to the storage version?

Copy link
Member

Choose a reason for hiding this comment

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

What could happen if the version is not correctly specified?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry for the delay @JeromeJu .

I was wondering if there is any way we can link this to the storage version?

Not sure how we can get the storage version. I think pipelinev1beta1.SchemeGroupVersion.String() might be sufficient here as andrew suggested here. Once we switched to v1, we need to change the imported pkg and this version will be changed accordingly I think.

What could happen if the version is not correctly specified?

That's a good question. I just played around this. If the typemeta i.e. the version or kind is not set correctly, the resolution will still succeed, but the code of converting the retrieved content to the runtime object will fail. And it will complain "no kind "Task" is registered for version "v1" in scheme ...", which makes sense because we don't serve the v1 CRD in the cluster.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the findings Chuang, and yeah I think that is very reasonable.


switch params[KindParam] {
case "task":
Expand All @@ -110,7 +111,7 @@ func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1beta1.Par
return nil, err
}
task.Kind = "Task"
task.APIVersion = "tekton.dev/v1beta1"
task.APIVersion = groupVersion
data, err = yaml.Marshal(task)
if err != nil {
logger.Infof("failed to marshal task %s from namespace %s: %v", params[NameParam], params[NamespaceParam], err)
Expand All @@ -123,7 +124,7 @@ func (r *Resolver) Resolve(ctx context.Context, origParams []pipelinev1beta1.Par
return nil, err
}
pipeline.Kind = "Pipeline"
pipeline.APIVersion = "tekton.dev/v1beta1"
pipeline.APIVersion = groupVersion
data, err = yaml.Marshal(pipeline)
if err != nil {
logger.Infof("failed to marshal pipeline %s from namespace %s: %v", params[NameParam], params[NamespaceParam], err)
Expand Down