-
Notifications
You must be signed in to change notification settings - Fork 40k
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
let patch use --local flag like kubectl set image
#26722
Conversation
So this is mutually exclusive with |
I'd like to somehow make it more clear that if you specify that flag, you are applying the patch to the local file, a different behavior in comparison to |
Why would we patch the local file? We shouldn't write our inputs ever. On Thu, Jun 2, 2016 at 2:42 PM, Kubernetes Bot notifications@github.com
|
@@ -175,3 +228,24 @@ func RunPatch(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri | |||
} | |||
return nil | |||
} | |||
|
|||
func getPatchedJS(patchType api.PatchType, originalJS, patchJS []byte, obj runtime.Object) ([]byte, 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.
You're not getting a patched JavaScript so I feel like the method could be two letters longer
@smarterclayton That was an example to prove that it works. The actual use-case runs more like |
This is still read-only to the file. It's using it for input and outputing to stdout. I don't think we'd support something like |
Oh, I got the purpose now, sorry. I have mixed feelings then. Both the input and the output are different than the default behavior. Input: instead of using it to identify the resources (with either tuples in Output: instead of performing a patch you just print it, like Let me think a bit, but why couldn't you still use
And you could combine it with |
Updated the description to make it more clear that the primary case is for chaining from other commands, not messing around with files on disk. |
Which is pretty much what you are saying, but use |
@deads2k Why "local-file"? That's very unintuitive to me. |
@deads2k I highly value precedent and convention. They help users build a mental model of how the system works and to speculate and remember how to use numerous features -- remember the patterns, not just the specifics. What is similar? Template files. I'd say a What other commands need something like this? |
cc @caesarxuchao, since he's worked on patch |
Allowing pipes like this will make it easy to make something (minimal flags on create), easy to modify it (our existing mutation commands), and easy to transition to a compositional flow ( |
We've spent a fair amount of effort moving things out of kubectl so they'll be available to all clients, so I'm only on board with this if it's a specific interface that only makes sense for users of kubectl. I agree that --local-file is clumsy. -f means "input file" for most of our commands so, how about an --output or -o flag instead-- default "" would mean to server, but passing '-' would mean write to stdout. |
I also agree that a templating system has significant benefits. Templates can be versioned & upgraded, and I expect them to be much more readable and maintainable than imperative chains of kubectl calls. Basically the | chain looks like a big anti pattern to me, I'd be very unhappy to inherit an application deployment that was created that way. |
I'm not envisioning this as a way to build a script. I'm seeing it as a way to progress from "I know a few bits of this system" to "I speak runtime.Object json" without having to take a big leap. I think the most obvious usage is probably |
If this pipe line syntax is not intended to build a script, then I guess editing the config in an interactive editor doesn't seem to be any worse than typing such a long command. |
I kinda feel like |
I should say I do like |
I don't think we should override -o because you may want JSON or YAML On Mon, Jun 6, 2016 at 9:00 AM, Eric Paris notifications@github.com wrote:
|
It may look like an anti pattern, but the alternative is sed, which I think On Fri, Jun 3, 2016 at 3:11 PM, Daniel Smith notifications@github.com
|
FWIW we already have |
Great, I'll update to that when I'm back on Monday. |
kubectl set image
Updated to |
LGTM |
GCE e2e build/test passed for commit ac64404. |
this deserves a release note |
GCE e2e build/test passed for commit ac64404. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit ac64404. |
Automatic merge from submit-queue |
Adds the concept of a
--local
flag tokubectl patch
. This flag is similar tokubectl set image -f --local
because it will use the content of the file as the input to the patch operation instead of using the file content to file resource/name tuples.This pull lets you run something like
kubectl create deployment --dry-run -o yaml | kubectl set volume --local -f - -o yaml | kubectl patch --local -f - --patch {} | kubectl create -f -
As proof that it works, you can run against a local file just to mess around with it, but
--local -f -
is the most likely case.This is useful for setting rarely used, but immutable fields from
kubectl create
orkubectl convert
without dropping to an interactive editor.Some discussion here: #21648 (comment)
@smarterclayton @kubernetes/kubectl
@eparis @soltysh @stevekuznetsov we've talked about this separately