-
Notifications
You must be signed in to change notification settings - Fork 226
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 preprocessing to handle the first time apply with inventorypolicy #1382
Conversation
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 question about consts
@seans3 Addressed the comments. It's ready for another review. |
I think this looks good. Would the use of cobra command wrappers be simplified if we just implement the commands in kpt instead of cli-utils? |
Yes, it would simplify the implementation a lot. We don't need to inject the preprocessing from the wrapper to the actual cli.
I'm also thinking about this. The existing e2e test, specifically the one for testing |
@mortent I added unit tests for the pre processing function. PTAL |
looks good to me. I'll let Morten also sign-off. |
/lgtm |
With
inventory-policy
flags added, users have two options:strict
andadopt
.strict
means an object can be updated/pruned only when theowning-inventory
annotation matches with the current inventory object.adopt
means that an object can be updated/pruned when theowning-inventory
annotation matches or this annotation is not present. The default option isstrict
.When package was applied by previous version of
kpt
, which doesn't have theinventory-policy
flag. We need to handle the first time apply when user switches to the new version ofkpt
. In the first time apply, the inventory-policy should beadopt
so that the resources will be added theowning-inventory
annotation.In this change, the first time apply is detected by checking the label "apps.kubernetes.io./managed-by". If this label is missing, we treat it as the first time apply and add this label to the inventory object.
This PR depends on kubernetes-sigs/cli-utils#316