Set field manager for kubectl diff --server-side.
Bonus: check diff only dry-runs without persisting. Co-authored-by: Takahiro HATORI <tahatori@zlab.co.jp> Kubernetes-commit: bacc2c49605f608d3f919109e0c37ebf6e1d7036
This commit is contained in:
parent
206f22581e
commit
87fc988437
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -317,6 +319,7 @@ func (obj InfoObject) Merged() (runtime.Object, error) {
|
||||||
}
|
}
|
||||||
options := metav1.PatchOptions{
|
options := metav1.PatchOptions{
|
||||||
Force: &obj.ForceConflicts,
|
Force: &obj.ForceConflicts,
|
||||||
|
FieldManager: obj.FieldManager,
|
||||||
DryRun: []string{metav1.DryRunAll},
|
DryRun: []string{metav1.DryRunAll},
|
||||||
}
|
}
|
||||||
return resource.NewHelper(obj.Info.Client, obj.Info.Mapping).Patch(
|
return resource.NewHelper(obj.Info.Client, obj.Info.Mapping).Patch(
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue