-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
retain quotes in namespace transformer filter #4421
Conversation
@shanalily: This PR has multiple commits, and the default merge method is: merge. 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. |
Welcome @shanalily! |
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 Once the patch is verified, the new status will be reflected by the 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. |
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. |
274667b
to
19dbdd8
Compare
/ok-to-test Thank you for working on this! Please sign the CLA |
/label tide/merge-method-squash |
@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). |
I signed it |
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. |
5e8a7df
to
ff186e7
Compare
I signed it |
@natasha41575 I did set the user and email on my commits (to my github username and primary email) when I was first signing with |
@shanalily what is the output if you run the command Also, please squash your commits. |
42c3731
to
0c05a1b
Compare
0c05a1b
to
bbf5d82
Compare
@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) |
bbf5d82
to
c9c982e
Compare
ad9d019
to
c98a310
Compare
12c2453
to
ac5f0a9
Compare
ac5f0a9
to
71570f8
Compare
Hi @monopole @KnVerey @natasha41575, wondering if someone can take a look, thank you! |
Thanks! I will take a look first thing tomorrow. |
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.
Overall this looks great! I just have some questions mostly to make sure that I understand the changes.
@@ -140,7 +140,7 @@ metadata: | |||
foo: 'bar' | |||
data: | |||
a: x | |||
b: y | |||
b: "y" |
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.
why does "y" get quoted?
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 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.
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 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.
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.
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.
@shanalily maybe I am missing something but I don't see your replies to my questions above? |
@@ -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), |
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 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) { |
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 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.
@@ -140,7 +140,7 @@ metadata: | |||
foo: 'bar' | |||
data: | |||
a: x | |||
b: y | |||
b: "y" |
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 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" |
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 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.
@natasha41575 sorry I didn’t realize that “pending” meant the comment wasn’t posted! Hopefully shows up now |
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
/approve
[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 |
* 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
should fix #4386