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

retain quotes in namespace transformer filter #4421

Merged
merged 15 commits into from Mar 23, 2022

Conversation

shanalily
Copy link
Contributor

should fix #4386

@k8s-ci-robot
Copy link
Contributor

@shanalily: 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
Copy link
Contributor

Welcome @shanalily!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kustomize has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 25, 2022
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 25, 2022

CLA Signed

The committers are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

Hi @shanalily. 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
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 25, 2022
api/filters/labels/example_test.go Outdated Show resolved Hide resolved
api/filters/namespace/example_test.go Outdated Show resolved Hide resolved
api/filters/filtersutil/setters.go Outdated Show resolved Hide resolved
@natasha41575
Copy link
Contributor

/ok-to-test

Thank you for working on this! Please sign the CLA

@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 Jan 26, 2022
@shanalily
Copy link
Contributor Author

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jan 26, 2022
@shanalily
Copy link
Contributor Author

@natasha41575 thank you for reviewing! I will work on resolving your comments including getting the CLA check passing (I didn't have an LF account before this PR).

@shanalily
Copy link
Contributor Author

I signed it

@natasha41575
Copy link
Contributor

Please make sure that your email is set on your commits correctly. There is a comment from the bot above with more details for how to do this.

@shanalily
Copy link
Contributor Author

I signed it

@shanalily
Copy link
Contributor Author

@natasha41575 I did set the user and email on my commits (to my github username and primary email) when I was first signing with git commit --amend --reset-author for all commits and then git push --force. Just tried name instead of username.
If I keep having issues I'll contact LF support but I assume it's some step I'm missing.

@natasha41575
Copy link
Contributor

natasha41575 commented Feb 2, 2022

@shanalily what is the output if you run the command git config --global user.name?

Also, please squash your commits.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 2, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 2, 2022
@shanalily
Copy link
Contributor Author

shanalily commented Feb 2, 2022

@natasha41575 output is shanalily, which I tried but also tried my full name in github and lf profiles

just squashed (and tests will fail right now because I need to fix the replicacount filter and some other stuff)

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2022
@shanalily shanalily force-pushed the int-namespace branch 2 times, most recently from 12c2453 to ac5f0a9 Compare February 26, 2022 01:58
@shanalily
Copy link
Contributor Author

Hi @monopole @KnVerey @natasha41575, wondering if someone can take a look, thank you!
Sorry about leaving this PR open in a state without tests passing for so long.

@natasha41575
Copy link
Contributor

Thanks! I will take a look first thing tomorrow.

Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

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

Overall this looks great! I just have some questions mostly to make sure that I understand the changes.

kyaml/yaml/rnode.go Outdated Show resolved Hide resolved
api/internal/generators/utils.go Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 4, 2022
@@ -140,7 +140,7 @@ metadata:
foo: 'bar'
data:
a: x
b: y
b: "y"
Copy link
Contributor

Choose a reason for hiding this comment

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

why does "y" get quoted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is because LoadMapIntoConfigMapData uses yaml.FieldSetter, so it will have the DoubleQuotedStyle added by the check in to FieldSetter.Filter since it's a yaml1.1 non-string and has the string tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured it's okay to change this test since this is an invalid config (I shared output in my comment in the linked issue #4386 showing issues with invalid yaml 1.1 values in config map data).

Any data that should be quoted and isn't passed through FieldSetter.Filter won't be corrected.

This won't fix #4472, idk if the env var gets passed through FieldSetter.Filter at all but the env var losing quotes in the example is not an invalid yaml 1.1 string and that config can be applied.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see. I had to do some research because I'm not a yaml expert, but TIL that "y" is the equivalent of "true" in yaml 1.1.

@natasha41575
Copy link
Contributor

@shanalily maybe I am missing something but I don't see your replies to my questions above?

#4421 (comment) and #4421 (comment)

kyaml/fn/framework/command/command_test.go Show resolved Hide resolved
kyaml/fn/framework/command/command_test.go Show resolved Hide resolved
@@ -52,7 +52,7 @@ func (ns Filter) run(node *yaml.RNode) (*yaml.RNode, error) {
// transformations based on data -- :)
err := node.PipeE(fsslice.Filter{
FsSlice: ns.FsSlice,
SetValue: ns.trackableSetter.SetScalar(ns.Namespace),
SetValue: ns.trackableSetter.SetEntry("", ns.Namespace, yaml.NodeTagString),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed changes to SetScalar and am using SetEntry("", ns.Namespace, <tag>) where a tag is needed, so as not to make any changes to public functions.
I only added tag to namespace and replicacount filters to minimize changes but could add to other filters (suffix, prefix, etc.) if requested so they don't also remove quotes.

I'm resolving the outdated comments with @natasha41575 but would like to know if using SetEntry is fine in these cases, since that allows moving the addition of the double quotes style to the FieldSetter func in the kyaml package, which should work whenever the scalar type tag is set on the rnode passed to it.

The other problems mentioned in the issue I opened (configmap "true|false" values, a separate env variable issue #4472) are not resolved by this PR.

cmd := framework.Command(resourceList, func() error {
for i := range resourceList.Items {
if err := resourceList.Items[i].PipeE(yaml.SetAnnotation("a-string-value",
fn := func(items []*yaml.RNode) ([]*yaml.RNode, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't impact tests passing or not but I think having this updated helps rule out whether this is the source of a bug in the run fs command unit tests. I can remove if a reviewer doesn't think this should be included.

api/internal/generators/utils.go Show resolved Hide resolved
@@ -140,7 +140,7 @@ metadata:
foo: 'bar'
data:
a: x
b: y
b: "y"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is because LoadMapIntoConfigMapData uses yaml.FieldSetter, so it will have the DoubleQuotedStyle added by the check in to FieldSetter.Filter since it's a yaml1.1 non-string and has the string tag.

@@ -140,7 +140,7 @@ metadata:
foo: 'bar'
data:
a: x
b: y
b: "y"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured it's okay to change this test since this is an invalid config (I shared output in my comment in the linked issue #4386 showing issues with invalid yaml 1.1 values in config map data).

Any data that should be quoted and isn't passed through FieldSetter.Filter won't be corrected.

This won't fix #4472, idk if the env var gets passed through FieldSetter.Filter at all but the env var losing quotes in the example is not an invalid yaml 1.1 string and that config can be applied.

@shanalily
Copy link
Contributor Author

@natasha41575 sorry I didn’t realize that “pending” meant the comment wasn’t posted! Hopefully shows up now

Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 23, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: natasha41575, shanalily

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 Mar 23, 2022
@k8s-ci-robot k8s-ci-robot merged commit 7b0ec99 into kubernetes-sigs:master Mar 23, 2022
koba1t pushed a commit to koba1t/kustomize that referenced this pull request Apr 14, 2022
* check tag values for double quoting

* reuse setentry

* don't override single quotes in merge and fix cm generator immutable val

* get rid of comment

* starlark annotation tests

* don't commit test image changes

* set network to bool

* isSet bool

* updating e2e config tool

* leave createtag

* fn command failing unmarshal test

* fn command test

* don't set style in run-fs

* use setentry to set tag

* remove e2e test changes and make IsStringValue an RNode method
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/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quotes are dropped from namespace in kustomization resource
4 participants