Skip to content

Commit

Permalink
Make kubectl edit not convert GV on edits
Browse files Browse the repository at this point in the history
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.

Fixes #23378
  • Loading branch information
DirectXMan12 committed Mar 24, 2016
1 parent f3af5d2 commit bc41430
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/kubectl/cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ func RunEdit(f *cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
ObjectTyper: typer,
RESTMapper: mapper,
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)).
Expand Down

1 comment on commit bc41430

@k8s-teamcity-mesosphere

Choose a reason for hiding this comment

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

TeamCity OSS :: Kubernetes Mesos :: 4 - Smoke Tests Build 19887 outcome was SUCCESS
Summary: Tests passed: 1, ignored: 267 Build time: 00:05:25

Please sign in to comment.