MCPcopy
hub / github.com/kubernetes/kubectl / Run

Method Run

pkg/cmd/diff/diff.go:686–782  ·  view source on GitHub ↗

Run uses the factory to parse file arguments, find the version to diff, and find each Info object for each files, and runs against the differ.

()

Source from the content-addressed store, hash-verified

684// diff, and find each Info object for each files, and runs against the
685// differ.
686func (o *DiffOptions) Run() error {
687 differ, err := NewDiffer("LIVE", "MERGED")
688 if err != nil {
689 return err
690 }
691 defer differ.TearDown()
692
693 printer := Printer{}
694
695 r := o.Builder.
696 Unstructured().
697 VisitorConcurrency(o.Concurrency).
698 NamespaceParam(o.CmdNamespace).DefaultNamespace().
699 FilenameParam(o.EnforceNamespace, &o.FilenameOptions).
700 LabelSelectorParam(o.Selector).
701 Flatten().
702 Do()
703 if err := r.Err(); err != nil {
704 return err
705 }
706
707 err = r.Visit(func(info *resource.Info, err error) error {
708 if err != nil {
709 return err
710 }
711
712 local := info.Object.DeepCopyObject()
713 for i := 1; i <= maxRetries; i++ {
714 if err = info.Get(); err != nil {
715 if !errors.IsNotFound(err) {
716 return err
717 }
718 info.Object = nil
719 }
720
721 force := i == maxRetries
722 if force {
723 klog.Warningf(
724 "Object (%v: %v) keeps changing, diffing without lock",
725 info.Object.GetObjectKind().GroupVersionKind(),
726 info.Name,
727 )
728 }
729 obj := InfoObject{
730 LocalObj: local,
731 Info: info,
732 Encoder: scheme.DefaultJSONEncoder(),
733 OpenAPIGetter: o.OpenAPIGetter,
734 OpenAPIV3Root: o.OpenAPIV3Root,
735 Force: force,
736 ServerSideApply: o.ServerSideApply,
737 FieldManager: o.FieldManager,
738 ForceConflicts: o.ForceConflicts,
739 IOStreams: o.Diff.IOStreams,
740 }
741
742 if o.tracker != nil {
743 o.tracker.MarkVisited(info)

Callers 1

NewCmdDiffFunction · 0.95

Calls 15

TearDownMethod · 0.95
DiffMethod · 0.95
RunMethod · 0.95
DefaultJSONEncoderFunction · 0.92
WarnIfDeletingFunction · 0.92
NewDifferFunction · 0.85
isConflictFunction · 0.85
getObjectNameFunction · 0.85
MarkVisitedMethod · 0.80
GetMethod · 0.65
VisitMethod · 0.45
DeepCopyObjectMethod · 0.45

Tested by

no test coverage detected