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

[address #4717] Re-do create template/metadata when using includeTemplates if not present #4805

Merged
merged 10 commits into from
Oct 11, 2022

Conversation

aibarbetta
Copy link
Contributor

Hi all, I'm attempting to re-do #4751 to fix #4717, I added a new test to reproduce the bug the old PR had.

It's not clear to me how can I add resource-specific fieldspecs for the includeTemplates flag in the labels plugin (as @KnVerey and @wolfmah mentioned here and here), can anyone provide some guidance?

Thanks!

@k8s-ci-robot
Copy link
Contributor

@aibarbetta: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 20, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 20, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @aibarbetta. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 20, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Sep 20, 2022

It's not clear to me how can I add resource-specific fieldspecs for the includeTemplates flag in the labels plugin (as @KnVerey and @wolfmah mentioned #4751 (comment) and #4751 (comment)), can anyone provide some guidance?

The full set of specs you'll need can be extracted from the CommonLabels config here. Look specifically at paths that end in /metadata/labels. I suggest trying to extract those ones into a separate constant, that then gets concatenated onto commonLabelFieldSpecs and a new templateLabelFieldSpecs for you to use. You'll then need to expose the templateLabelFieldSpecs through the functions in this file. And finally load them with fss.MergeAll like the function you're modifying is doing a couple lines earlier. Please include the various types this PR will support in your tests, in addition to Deployment.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 23, 2022
@aibarbetta aibarbetta marked this pull request as ready for review September 23, 2022 18:55
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 23, 2022
@aibarbetta
Copy link
Contributor Author

Thanks for the help @KnVerey! Changes are done, I added some tests for the rest of the types and they all pass. Can I get an ok-to-test to run the full suite here?

@KnVerey
Copy link
Contributor

KnVerey commented Sep 23, 2022

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 23, 2022
@aibarbetta
Copy link
Contributor Author

@KnVerey make lint runs successfully now, can we retest? 🙏🏻

@@ -7,6 +7,7 @@ import (
"log"
"sort"

"github.com/pkg/errors"
Copy link
Member

Choose a reason for hiding this comment

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

"github.com/pkg/errors" looks like an already unmaintained and archived.

Could you think of using fmt.Errorf() instead of errors.Wrap() if you don't have any reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"github.com/pkg/errors" looks like an already unmaintained and archived.

Could you think of using fmt.Errorf() instead of errors.Wrap() if you don't have any reason?

done! thanks for making me aware of that

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI the other errors package we often use in Kustomize is our own "sigs.k8s.io/kustomize/kyaml/errors", which provides errors.WrapPrefixf(err, msg, args...) for situations like these. We have plenty of fmt.Errorf usage as well though, so I don't feel strongly about this.

@aibarbetta
Copy link
Contributor Author

@KnVerey linter fix is done, can we retest?

@aibarbetta
Copy link
Contributor Author

/test all

@KnVerey
Copy link
Contributor

KnVerey commented Oct 4, 2022

Nice work! I have a couple very minor suggestions and will put a hold in case you want to take them (otherwise the bot will auto-merge immediately).

/hold
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 4, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 4, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aibarbetta, KnVerey

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 4, 2022
@aibarbetta
Copy link
Contributor Author

Nice work! I have a couple very minor suggestions and will put a hold in case you want to take them (otherwise the bot will auto-merge immediately).

/hold /lgtm /approve

Hi @KnVerey sure, please send me the suggestions

Copy link
Contributor

@KnVerey KnVerey left a comment

Choose a reason for hiding this comment

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

Seems like I accidentally didn't click the submit button on this review. Sorry for the confusion!

api/krusty/inlinelabels_test.go Outdated Show resolved Hide resolved
app.kubernetes.io/component: a
app.kubernetes.io/instance: b
app.kubernetes.io/name: c
app.kubernetes.io/part-of: d
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: for these extra Kinds tests, start with fewer labels to make it easier to see the before/after. In particular, I was confused at first because this test is starting with the exact same labels that are added by the transformer in the other tests.

@@ -7,6 +7,7 @@ import (
"log"
"sort"

"github.com/pkg/errors"
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI the other errors package we often use in Kustomize is our own "sigs.k8s.io/kustomize/kyaml/errors", which provides errors.WrapPrefixf(err, msg, args...) for situations like these. We have plenty of fmt.Errorf usage as well though, so I don't feel strongly about this.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 8, 2022
@aibarbetta
Copy link
Contributor Author

Thanks for the suggestions @KnVerey! all done :)

@KnVerey
Copy link
Contributor

KnVerey commented Oct 11, 2022

/unhold
/lgtm

Thank you for all your work on this one!

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Oct 11, 2022
@k8s-ci-robot k8s-ci-robot merged commit bf7a0f9 into kubernetes-sigs:master Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

includeTemplates doesn't work
4 participants