use preprocessing to handle the first time apply with inventorypolicy#1382
use preprocessing to handle the first time apply with inventorypolicy#1382mortent merged 3 commits intokptdev:masterfrom
Conversation
seans3
left a comment
There was a problem hiding this comment.
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-policyflags added, users have two options:strictandadopt.strictmeans an object can be updated/pruned only when theowning-inventoryannotation matches with the current inventory object.adoptmeans that an object can be updated/pruned when theowning-inventoryannotation 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-policyflag. 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 beadoptso that the resources will be added theowning-inventoryannotation.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