-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add validation for ClusterRepo #306
base: release/v0.4
Are you sure you want to change the base?
Conversation
f4d58c3
to
1b4c44f
Compare
pkg/resources/catalog.cattle.io/v1/clusterrepo/validator_test.go
Outdated
Show resolved
Hide resolved
pkg/resources/catalog.cattle.io/v1/clusterrepo/validator_test.go
Outdated
Show resolved
Hide resolved
41b859c
to
a07ab82
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit, otherwise LGTM.
a07ab82
to
f210e2a
Compare
f210e2a
to
5232c8b
Compare
5232c8b
to
3d67bf3
Compare
3d67bf3
to
7eb0f4d
Compare
7eb0f4d
to
e37fd5d
Compare
e37fd5d
to
e37659b
Compare
return admission.ResponseAllowed(), nil | ||
} | ||
|
||
func (a *admitter) validateFields(newClusterrepo *catalogv1.ClusterRepo) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
func (a *admitter) validateFields(newClusterrepo *catalogv1.ClusterRepo) error { | |
func (a *admitter) validateFields(repo *catalogv1.ClusterRepo) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why should I change it from newClusterRepo to repo? The resource name is ClusterRepo not just repo. Also,the new signifies it is the latest one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's up to you, hence I marked it as a nit. At a minimum, you might want to make the casing look better, so newClusterRepo
instead of newClusterrepo
.
But you sort of repeat this composite name after the type name, which reads strangely. And it doesn't matter whether the repo is the latest one, you simply validate its fields. But it's all up to you.
e37659b
to
6e552f4
Compare
Github Issue - https://github.com/rancherlabs/rancher-security/issues/1258
Add validation and mutation for ClusterRepo
New validations:
Both GitRepo and URl cannot exist simultaneously
Testing
Added unit tests