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

Allow PipelineTaskRunSpec.Metadata to be optional. #4914

Merged
merged 1 commit into from
May 27, 2022
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
Allow PipelineTaskRunSpec.Metadata to be optional.
Previously, this was using a non-pointer value, which means that the
field was not actually optional and was being included in client
requests. If this request was sent to an older server, this would break
during unmarshalling because the field doesn't exist yet for older
servers.

This changes the type to use a pointer so it will actually be omitted in
newer clients if it is not set.

Co-authored-by: Scott Nichols <n3wscott@chainguard.dev>
Signed-off-by: Billy Lynch <billy@chainguard.dev>
  • Loading branch information
wlynch and n3wscott committed May 27, 2022
commit ee3370cff1ffc0cf92a72589910814289983f219
3 changes: 1 addition & 2 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.

2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ type PipelineTaskRunSpec struct {
SidecarOverrides []TaskRunSidecarOverride `json:"sidecarOverrides,omitempty"`

// +optional
Metadata PipelineTaskMetadata `json:"metadata,omitempty"`
Metadata *PipelineTaskMetadata `json:"metadata,omitempty"`
}

// GetTaskRunSpec returns the task specific spec for a given
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,6 @@
"type": "object",
"properties": {
"metadata": {
"default": {},
"$ref": "#/definitions/v1beta1.PipelineTaskMetadata"
},
"pipelineTaskName": {
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go

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

8 changes: 6 additions & 2 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,9 @@ func combineTaskRunAndTaskSpecLabels(pr *v1beta1.PipelineRun, pipelineTask *v1be
labels := make(map[string]string)

taskRunSpec := pr.GetTaskRunSpec(pipelineTask.Name)
addMetadataByPrecedence(labels, taskRunSpec.Metadata.Labels)
if taskRunSpec.Metadata != nil {
addMetadataByPrecedence(labels, taskRunSpec.Metadata.Labels)
}

addMetadataByPrecedence(labels, getTaskrunLabels(pr, pipelineTask.Name, true))

Expand All @@ -1039,7 +1041,9 @@ func combineTaskRunAndTaskSpecAnnotations(pr *v1beta1.PipelineRun, pipelineTask
annotations := make(map[string]string)

taskRunSpec := pr.GetTaskRunSpec(pipelineTask.Name)
addMetadataByPrecedence(annotations, taskRunSpec.Metadata.Annotations)
if taskRunSpec.Metadata != nil {
addMetadataByPrecedence(annotations, taskRunSpec.Metadata.Annotations)
}

addMetadataByPrecedence(annotations, getTaskrunAnnotations(pr))

Expand Down