Merge pull request #23437 from DirectXMan12/bug/cannot-edit-across-gv

Automatic merge from submit-queue

Make kubectl edit not convert GV on edits

Previously, kubectl edit was using a decoder to load in edits that
converted to the internal version.  It would then re-encode this
decoded value to produce a patch.  However, if you were editing
in the object in a GroupVersion that was not the internal version,
this would cause the kubectl edit command to attempt to produce
a patch which changed the GroupVersion, which would fail.

Now, we use a plain deserializer instead, so no conversion or
defaulting occurs when loading in the edited file.

Ref #23378
This commit is contained in:
k8s-merge-robot 2016-04-15 16:32:17 -07:00
commit ed87db5040

View File

@ -146,7 +146,13 @@ func RunEdit(f *cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
ObjectTyper: typer, ObjectTyper: typer,
RESTMapper: mapper, RESTMapper: mapper,
ClientMapper: resource.ClientMapperFunc(f.ClientForMapping), ClientMapper: resource.ClientMapperFunc(f.ClientForMapping),
Decoder: f.Decoder(true),
// NB: we use `f.Decoder(false)` to get a plain deserializer for
// the resourceMapper, since it's used to read in edits and
// we don't want to convert into the internal version when
// reading in edits (this would cause us to potentially try to
// compare two different GroupVersions).
Decoder: f.Decoder(false),
} }
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)). r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).