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

Disallow unknown fields from resources struct #1081

Merged
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 cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func main() {
v1alpha1.SchemeGroupVersion.WithKind("TaskRun"): &v1alpha1.TaskRun{},
v1alpha1.SchemeGroupVersion.WithKind("PipelineRun"): &v1alpha1.PipelineRun{},
},
Logger: logger,

Logger: logger,
DisallowUnknownFields: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

For my own curiosity: is this a feature that got added somewhere recently, or something we could have been using all along?

Copy link
Collaborator

Choose a reason for hiding this comment

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

and p.s. if it's not new, do you happen to know why ppl looking at this issue before thought we couldn't easily fix it? (#297 (comment))

Copy link
Member Author

Choose a reason for hiding this comment

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

It was added with knative/pkg#338, so ~4month ago 😉

// Decorate contexts with the current state of the config.
WithContext: func(ctx context.Context) context.Context {
return v1alpha1.WithDefaultConfigurationName(store.ToContext(ctx))
Expand Down
2 changes: 0 additions & 2 deletions examples/pipelineruns/clustertask-pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@ metadata:
spec:
pipelineRef:
name: sample-pipeline-cluster-task-4
trigger:
type: manual
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤦‍♀

serviceAccount: 'default'
6 changes: 3 additions & 3 deletions examples/pipelineruns/pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ spec:
description: Okay this is a hack, but I didn't feel right hard-codeing `-d1` down below
- name: yamlPathToImage
description: The path to the image to replace in the yaml manifest (arg to yq)
clusters:
- name: targetCluster
description: Not yet used, kubectl command below should use this cluster
#clusters:
Copy link
Member Author

Choose a reason for hiding this comment

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

Wasn't sure where this comes from. I am guessing we should remove this altogether most likely 👼

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh wow! yeah feel free to remove it, this is leftover from a really old version of the spec XD

Copy link
Member Author

Choose a reason for hiding this comment

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

forgot to update before removing the hold 😅

Choose a reason for hiding this comment

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

Could you perhaps have a test, which actually validates this behavior. Would feel better when not only the happy-paths are tested.

Copy link
Member Author

Choose a reason for hiding this comment

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

@abergmeier yes, working on it (once I land somewhere 🤭)

#- name: targetCluster
# description: Not yet used, kubectl command below should use this cluster
steps:
- name: replace-image
image: mikefarah/yq
Expand Down
10 changes: 5 additions & 5 deletions examples/taskruns/gcs-resource-spec-taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ metadata:
name: list-file
spec:
taskSpec:
inputs:
resources:
- name: workspace
type: storage
inputs:
resources:
- name: rules
type: storage
steps:
- name: list
image: ubuntu
command: ["/bin/bash"]
args: ['-c', 'ls -al /workspace/rules/rules_docker-master'] # tests build-gcs resource
inputs:
resources:
- name: workspace
- name: rules
resourceSpec:
type: storage
params:
Expand Down
10 changes: 5 additions & 5 deletions examples/taskruns/git-resource-spec-taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ metadata:
name: read-file
spec:
taskSpec:
inputs:
resources:
- name: workspace
type: git
targetPath: skaffold
inputs:
resources:
- name: workspace
type: git
targetPath: skaffold
steps:
- name: read
image: ubuntu
Expand Down
2 changes: 0 additions & 2 deletions examples/taskruns/task-multiple-output-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ metadata:
spec:
taskRef:
name: multiple-build-push-kaniko
trigger:
type: manual
inputs:
resources:
- name: sourcerepo
Expand Down