-
Notifications
You must be signed in to change notification settings - Fork 39k
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
Allow missing keys in templates by default #39486
Allow missing keys in templates by default #39486
Conversation
Will add test-cmd tests if this looks good |
@@ -2527,6 +2531,14 @@ func NewTemplatePrinter(tmpl []byte) (*TemplatePrinter, error) { | |||
}, nil | |||
} | |||
|
|||
func (p *TemplatePrinter) AllowMissingKeys(allow bool) { |
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 can take this bit out if we want to just apply this to the jsonpath printer for starters, as it is a slight behavior change (allow sets missingkey to zero instead of default). Or I could have allow set missingkey to default to retain the current behavior.
Jenkins Bazel Build failed for commit b89cf0f. Full PR test history. The magic incantation to run this job again is 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. |
Working on fixing compilation failures and some switches that I missed. Updates coming real soon. |
b89cf0f
to
e6a49a4
Compare
@soltysh fyi |
e6a49a4
to
9d556b3
Compare
Jenkins Kubemark GCE e2e failed for commit e6a49a4e5d6f5149cae9a40e3b8fc2ec51742b51. Full PR test history. The magic incantation to run this job again is 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. |
Jenkins verification failed for commit 9d556b3ef5ab81c33de89989aaf53b217f4b52e8. Full PR test history. The magic incantation to run this job again is 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. |
Jenkins kops AWS e2e failed for commit 9d556b3ef5ab81c33de89989aaf53b217f4b52e8. Full PR test history. The magic incantation to run this job again is 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. |
9d556b3
to
f079e3e
Compare
Looks good to me, want some opinions on naming (argument was not to use "--strict" because that's too generic) from sig cli. |
@k8s-bot test this |
Jenkins unit/integration failed for commit f079e3ebcd62c55b307b9071ed4e457607dfba7d. Full PR test history. The magic incantation to run this job again is 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. |
Jenkins GCI GCE e2e failed for commit f079e3ebcd62c55b307b9071ed4e457607dfba7d. Full PR test history. The magic incantation to run this job again is 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. |
I'd like |
LGTM, +1 for |
I'm not crazy about |
I am still struggling with readability vs brevity for this, so either of |
Assuming that the default will be to allow missing keys, I would err on the
side of readability for the flag's name.
…On Mon, Jan 9, 2017 at 6:46 AM Maciej Szulik ***@***.***> wrote:
I am still struggling with readability vs brevity for this, so either of
--allow-missing-keys or --allow-missing-template-keys works fine with me.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#39486 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAABYoxGbe-yoMXmFgg3fKkor3A3h2BVks5rQh4ngaJpZM4LcGQg>
.
|
I agree, this is not something to be used too often so readability > brevity. Update the PR and let's get this in. |
Yes! |
Switch to allowing missing keys in jsonpath templates by default. Add support for allowing/disallowing missing keys in go templates (default=allow). Add --allow-missing-template-keys flag to control this behavior (default=true / allow missing keys).
f079e3e
to
80c5cd8
Compare
if err != nil { | ||
return nil, false, fmt.Errorf("error parsing template %s, %v\n", formatArgument, err) | ||
} | ||
templatePrinter.AllowMissingKeys(allowMissingTemplateKeys) |
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.
How about extending NewTemplatePrinter
with that new flag since we're passing it every time we use it?
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.
Follow-up?
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.
Sure.
Neat, otherwise LGTM. |
LGTM |
Automatic merge from submit-queue (batch tested with PRs 39486, 37288, 39477, 39455, 39542) |
Do we want to cherrypick this to 1.5? |
I say - yes. |
Removing label |
…39895-#39038-upstream-release-1.5 Automatic merge from submit-queue Automated cherry pick of #39486 #39895 #39038 Cherry pick of #39486 #39895 #39038 on release-1.5. #39486: Allow missing keys in templates by default #39895: Fix expected error text #39038: Fix kubectl get -f <file> -o <nondefault printer>
Switch to allowing missing keys in jsonpath templates by default.
Add support for allowing/disallowing missing keys in go templates
(default=allow).
Add --allow-missing-template-keys flag to control this behavior (default=true /
allow missing keys).
Fixes #37991
@kubernetes/sig-cli-misc @kubernetes/api-reviewers @smarterclayton @fabianofranz @liggitt @pwittrock