-
Notifications
You must be signed in to change notification settings - Fork 20
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
Extract the registry deployment into component. Add missing unit tests #36
Conversation
3d84177
to
b42ac2e
Compare
…e new component A new component is introduced in `./pkg/component/registrycaches`. The component deploys registry caches. It implements the well-known `component.DeployWaiter` interface. This commit also moves the existing controller from `./pkg/controller` to dedicated pkg `./pkg/controller/extension`. The controller name is changed from `registry-cache` to `extension-controller`. This commit also introduces a new pkg `./pkg/constants`. It exports constants that are used from 2 or more packages.
b42ac2e
to
d47ee7c
Compare
/test pull-gardener-extension-registry-cache-e2e-kind |
Maybe it would make sense to have envtest for the webhook instead of unit tests. Let me check on this. /hold |
I had a quick look. It seems that /unhold |
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.
Nice PR! I just saw some minor nits.
} | ||
|
||
func computeResourcesDataForRegistryCache(cache *v1alpha1.RegistryCache, image string) ([]client.Object, error) { | ||
if cache.Size == nil { |
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.
This is checked in the validation, must we also check for it here?
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.
I tried to follow defensive programming paradigm to fail with a more meaningful error instead of a panic (would cause a crash of the whole process) if the defaulting or validation (in registry-cache-admission) don't work for some reason.
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.
Alright, I just remember from some reviews that we did in g/g that we avoid such checks when there is validation/defaulting, but I don't really mind tbh.
if cache.Size == nil { | ||
return nil, fmt.Errorf("registry cache size is required") | ||
} | ||
if cache.GarbageCollectionEnabled == nil { |
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.
This is defaulted to not be nil. Is this check necessary?
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.
Same as #36 (comment).
vendor/github.com/gardener/gardener/pkg/mock/controller-runtime/client/doc.go
Show resolved
Hide resolved
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.
/lgtm
LGTM label has been added. Git tree hash: 6f57588ff020eb88dc2cc2c47c74178a7d36858d
|
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ialidzhikov, plkokanov The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
How to categorize this PR?
/kind enhancement
What this PR does / why we need it:
This PR:
./pkg/admission/validator
../pkg/controller
to dedicated pkg./pkg/controller/extension
. The controller name is changed fromregistry-cache
toextension-controller
../pkg/constants
. It exports constants that are used from 2 or more packages.Which issue(s) this PR fixes:
Part of #3
Special notes for your reviewer:
N/A
Release note: