Merge pull request #88739 from julianvmodesto/diff-server-side-field-manager

Set field manager for kubectl diff --server-side

Kubernetes-commit: 58779450489888e1355357978311f09015b69d51
This commit is contained in:
Kubernetes Publisher 2020-03-09 18:57:35 -07:00
commit 9a3954bf65
4 changed files with 12 additions and 7 deletions

2
Godeps/Godeps.json generated
View File

@ -568,7 +568,7 @@
}, },
{ {
"ImportPath": "k8s.io/api", "ImportPath": "k8s.io/api",
"Rev": "510bcd53e1cf" "Rev": "b3bd583303d6"
}, },
{ {
"ImportPath": "k8s.io/apimachinery", "ImportPath": "k8s.io/apimachinery",

4
go.mod
View File

@ -37,7 +37,7 @@ require (
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7 golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7
gopkg.in/yaml.v2 v2.2.8 gopkg.in/yaml.v2 v2.2.8
gotest.tools v2.2.0+incompatible // indirect gotest.tools v2.2.0+incompatible // indirect
k8s.io/api v0.0.0-20200307122242-510bcd53e1cf k8s.io/api v0.0.0-20200309160345-b3bd583303d6
k8s.io/apimachinery v0.0.0-20200307122051-2b7fa1cb5395 k8s.io/apimachinery v0.0.0-20200307122051-2b7fa1cb5395
k8s.io/cli-runtime v0.0.0-20200307124427-99b536c4b997 k8s.io/cli-runtime v0.0.0-20200307124427-99b536c4b997
k8s.io/client-go v0.0.0-20200307122516-5194bac86967 k8s.io/client-go v0.0.0-20200307122516-5194bac86967
@ -54,7 +54,7 @@ require (
replace ( replace (
golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // pinned to release-branch.go1.13 golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // pinned to release-branch.go1.13
golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7 // pinned to release-branch.go1.13 golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7 // pinned to release-branch.go1.13
k8s.io/api => k8s.io/api v0.0.0-20200307122242-510bcd53e1cf k8s.io/api => k8s.io/api v0.0.0-20200309160345-b3bd583303d6
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20200307122051-2b7fa1cb5395 k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20200307122051-2b7fa1cb5395
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20200307124427-99b536c4b997 k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20200307124427-99b536c4b997
k8s.io/client-go => k8s.io/client-go v0.0.0-20200307122516-5194bac86967 k8s.io/client-go => k8s.io/client-go v0.0.0-20200307122516-5194bac86967

2
go.sum
View File

@ -306,7 +306,7 @@ gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.0.0-20200307122242-510bcd53e1cf/go.mod h1:4LcBtPb1OoMEmTvQLypv2jGrtMEK8ZRCPQyc+uOSi4o= k8s.io/api v0.0.0-20200309160345-b3bd583303d6/go.mod h1:4LcBtPb1OoMEmTvQLypv2jGrtMEK8ZRCPQyc+uOSi4o=
k8s.io/apimachinery v0.0.0-20200307122051-2b7fa1cb5395/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= k8s.io/apimachinery v0.0.0-20200307122051-2b7fa1cb5395/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA=
k8s.io/cli-runtime v0.0.0-20200307124427-99b536c4b997/go.mod h1:/iZjMCD5/3wfEqXl8DAqo58AJtq+BlFyUJOQUw3eeiw= k8s.io/cli-runtime v0.0.0-20200307124427-99b536c4b997/go.mod h1:/iZjMCD5/3wfEqXl8DAqo58AJtq+BlFyUJOQUw3eeiw=
k8s.io/client-go v0.0.0-20200307122516-5194bac86967/go.mod h1:Ys+cjVY1SiB17qdMz+qc3ItvCfnYLsgVt49tSUmvwTo= k8s.io/client-go v0.0.0-20200307122516-5194bac86967/go.mod h1:Ys+cjVY1SiB17qdMz+qc3ItvCfnYLsgVt49tSUmvwTo=

View File

@ -57,7 +57,7 @@ var (
KUBECTL_EXTERNAL_DIFF environment variable can be used to select your own KUBECTL_EXTERNAL_DIFF environment variable can be used to select your own
diff command. By default, the "diff" command available in your path will be diff command. By default, the "diff" command available in your path will be
run with "-u" (unified diff) and "-N" (treat absent files as empty) options. run with "-u" (unified diff) and "-N" (treat absent files as empty) options.
Exit status: Exit status:
0 0
No differences were found. No differences were found.
@ -92,6 +92,7 @@ type DiffOptions struct {
FilenameOptions resource.FilenameOptions FilenameOptions resource.FilenameOptions
ServerSideApply bool ServerSideApply bool
FieldManager string
ForceConflicts bool ForceConflicts bool
OpenAPISchema openapi.Resources OpenAPISchema openapi.Resources
@ -296,6 +297,7 @@ type InfoObject struct {
OpenAPI openapi.Resources OpenAPI openapi.Resources
Force bool Force bool
ServerSideApply bool ServerSideApply bool
FieldManager string
ForceConflicts bool ForceConflicts bool
genericclioptions.IOStreams genericclioptions.IOStreams
} }
@ -316,8 +318,9 @@ func (obj InfoObject) Merged() (runtime.Object, error) {
return nil, err return nil, err
} }
options := metav1.PatchOptions{ options := metav1.PatchOptions{
Force: &obj.ForceConflicts, Force: &obj.ForceConflicts,
DryRun: []string{metav1.DryRunAll}, FieldManager: obj.FieldManager,
DryRun: []string{metav1.DryRunAll},
} }
return resource.NewHelper(obj.Info.Client, obj.Info.Mapping).Patch( return resource.NewHelper(obj.Info.Client, obj.Info.Mapping).Patch(
obj.Info.Namespace, obj.Info.Namespace,
@ -441,6 +444,7 @@ func (o *DiffOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
} }
o.ServerSideApply = cmdutil.GetServerSideApplyFlag(cmd) o.ServerSideApply = cmdutil.GetServerSideApplyFlag(cmd)
o.FieldManager = cmdutil.GetFieldManagerFlag(cmd)
o.ForceConflicts = cmdutil.GetForceConflictsFlag(cmd) o.ForceConflicts = cmdutil.GetForceConflictsFlag(cmd)
if o.ForceConflicts && !o.ServerSideApply { if o.ForceConflicts && !o.ServerSideApply {
return fmt.Errorf("--force-conflicts only works with --server-side") return fmt.Errorf("--force-conflicts only works with --server-side")
@ -529,6 +533,7 @@ func (o *DiffOptions) Run() error {
OpenAPI: o.OpenAPISchema, OpenAPI: o.OpenAPISchema,
Force: force, Force: force,
ServerSideApply: o.ServerSideApply, ServerSideApply: o.ServerSideApply,
FieldManager: o.FieldManager,
ForceConflicts: o.ForceConflicts, ForceConflicts: o.ForceConflicts,
IOStreams: o.Diff.IOStreams, IOStreams: o.Diff.IOStreams,
} }