Run performs the get operation. TODO: remove the need to pass these arguments, like other commands.
(f cmdutil.Factory, args []string)
| 441 | // Run performs the get operation. |
| 442 | // TODO: remove the need to pass these arguments, like other commands. |
| 443 | func (o *GetOptions) Run(f cmdutil.Factory, args []string) error { |
| 444 | if len(o.Raw) > 0 { |
| 445 | restClient, err := f.RESTClient() |
| 446 | if err != nil { |
| 447 | return err |
| 448 | } |
| 449 | return rawhttp.RawGet(restClient, o.IOStreams, o.Raw) |
| 450 | } |
| 451 | if o.Watch || o.WatchOnly { |
| 452 | return o.watch(f, args) |
| 453 | } |
| 454 | |
| 455 | chunkSize := o.ChunkSize |
| 456 | if len(o.SortBy) > 0 { |
| 457 | // TODO(juanvallejo): in the future, we could have the client use chunking |
| 458 | // to gather all results, then sort them all at the end to reduce server load. |
| 459 | chunkSize = 0 |
| 460 | } |
| 461 | |
| 462 | r := f.NewBuilder(). |
| 463 | Unstructured(). |
| 464 | NamespaceParam(o.Namespace).DefaultNamespace().AllNamespaces(o.AllNamespaces). |
| 465 | FilenameParam(o.ExplicitNamespace, &o.FilenameOptions). |
| 466 | LabelSelectorParam(o.LabelSelector). |
| 467 | FieldSelectorParam(o.FieldSelector). |
| 468 | Subresource(o.Subresource). |
| 469 | RequestChunksOf(chunkSize). |
| 470 | ResourceTypeOrNameArgs(true, args...). |
| 471 | ContinueOnError(). |
| 472 | Latest(). |
| 473 | Flatten(). |
| 474 | TransformRequests(o.transformRequests). |
| 475 | Do() |
| 476 | |
| 477 | if o.IgnoreNotFound { |
| 478 | r.IgnoreErrors(apierrors.IsNotFound) |
| 479 | } |
| 480 | if err := r.Err(); err != nil { |
| 481 | return err |
| 482 | } |
| 483 | |
| 484 | if !o.IsHumanReadablePrinter { |
| 485 | return o.printGeneric(r) |
| 486 | } |
| 487 | |
| 488 | allErrs := []error{} |
| 489 | errs := sets.New[string]() |
| 490 | infos, err := r.Infos() |
| 491 | if err != nil { |
| 492 | allErrs = append(allErrs, err) |
| 493 | } |
| 494 | printWithKind := multipleGVKsRequested(infos) |
| 495 | |
| 496 | objs := make([]runtime.Object, len(infos)) |
| 497 | for ix := range infos { |
| 498 | objs[ix] = infos[ix].Object |
| 499 | } |
| 500 |