Project: Kui (App Definition and Development / Application Definition & Image Build)
File: kui_shell_plugin_kubectl.md

/ @kui-shell/plugin-kubectl Deployment: `Deployment1` \| `Deployment2` KubePartial<`R`\>: `Omit`<`R`, `"apiVersion"` \| `"kind"`\> | Name | Type | | : | : | | `R` | extends = | KubeResource<`Status`, `Metadata`\>: `ResourceWithMetadata` & & { `apiVersion`: `string` ; `isKubeResource`: `true` ; `isSimulacrum?`: `boolean` ; `kind`: `string` ; `metadata?`: `Metadata` ; `originatingCommand`: `Arguments`<\> ; `spec?`: `any` ; `status?`: `Status` } The basic Kubernetes resource | Name | Type | | : | :- | | `Status` | | | `Metadata` | `KubeMetadata` | KubeResourceWithSummary<`Status`\>: <`Status`\> & `KubeResourceWithSummary` allows plugins to provide their own Summary. Otherwise lib/views/modes/summary will try to fetch one automatically. | Name | Type | | :- | :- | | `Status` | | apiVersion: `"github.com/kui-shell/plugin-kubectl/v1alpha1"` kubectl: `string` logsMode: `"logs"` Parser: `Object` memory and cpu parsing | Name | Type | | :-- | :-- | | `cpuFraction` | (`str`: `string`) => `number` | | `cpuShare` | (`str`: `string`) => `number` | | `formatAsBytes` | (`mem`: `number`) => `string` | | `formatAsCpu` | (`cpu`: `number`) => `string` | | `fractionOfMemory` | (`num`: `string`, `denom`: `string`) => `string` | | `memShare` | (`str`: `string`) => `number` | | `reformatAsBytes` | (`mem`: `string`) => `string` | defaultFlags: `CommandOptions` computeDurations<`T`\>(`table`): `T` Turn START and END columns into a DURATION

TODO Kubectl gurus: Is there a way to get this directly from a jsonpath or go-template? I think so from the latter? | Name | Type | | : | : | | `T` | extends `Table`<`Row`\> \| `KResponse`<`any`\> | | Name | Type | | : | : | | `table` | `T` | `T` describer(`registrar`, `command`, `cli?`): `void` Register a command listener | Name | Type | Default value | | :- | :-- | : | | `registrar` | `CommandRegistrar` | `undefined` | | `command` | `string` | `undefined` | | `cli` | `string` | `command` | `void` `Const` doCreate(`verb`, `command?`): (`args`: `EvaluatorArgs`<\>) => `Promise`<`string` \| `number` \| `boolean` \| `HTMLElement` \| `Error` \| `MarkdownResponse` \| `ReactResponse` \| `MixedResponse` \| `CommentaryResponse` \| `TabLayoutModificationResponse`<`NewSplitRequest`\> \| `XtermResponse` \| `RandomErrorResponse1` \| `RandomErrorResponse2` \| `Table`<`Row`\> \| `AbortableResponse`<`ScalarResponse`<`Row`\>\> \| `NavResponse` \| `RadioTable` \| `UsageModel` \| `MetadataBearing`<`any`\> \| `RawResponse`<`any`\> \| `MetadataBearing`<`any`\>[]\> | Name | Type | Default value | | :-- | :- | : | | `verb` | `"create"` \| `"apply"` | `undefined` | | `command` | `string` | `'kubectl'` | `fn` (`args`): `Promise`<`string` \| `number` \| `boolean` \| `HTMLElement` \| `Error` \| `MarkdownResponse` \| `ReactResponse` \| `MixedResponse` \| `CommentaryResponse` \| `TabLayoutModificationResponse`<`NewSplitRequest`\> \| `XtermResponse` \| `RandomErrorResponse1` \| `RandomErrorResponse2` \| `Table`<`Row`\> \| `AbortableResponse`<`ScalarResponse`<`Row`\>\> \| `NavResponse` \| `RadioTable` \| `UsageModel` \| `MetadataBearing`<`any`\> \| `RawResponse`<`any`\> \| `MetadataBearing`<`any`\>[]\> | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | `Promise`<`string` \| `number` \| `boolean` \| `HTMLElement` \| `Error` \| `MarkdownResponse` \| `ReactResponse` \| `MixedResponse` \| `CommentaryResponse` \| `TabLayoutModificationResponse`<`NewSplitRequest`\> \| `XtermResponse` \| `RandomErrorResponse1` \| `RandomErrorResponse2` \| `Table`<`Row`\> \| `AbortableResponse`<`ScalarResponse`<`Row`\>\> \| `NavResponse` \| `RadioTable` \| `UsageModel` \| `MetadataBearing`<`any`\> \| `RawResponse`<`any`\> \| `MetadataBearing`<`any`\>[]\> `Const` doDelete(`command?`): (`args`: `EvaluatorArgs`<\>) => `Promise`<`string` \| `number` \| `boolean` \| `HTMLElement` \| `Error` \| `MarkdownResponse` \| `ReactResponse` \| `MixedResponse` \| `CommentaryResponse` \| `TabLayoutModificationResponse`<`NewSplitRequest`\> \| `XtermResponse` \| `RandomErrorResponse1` \| `RandomErrorResponse2` \| `Table`<`Row`\> \| `AbortableResponse`<`ScalarResponse`<`Row`\>\> \| `NavResponse` \| `RadioTable` \| `UsageModel` \| `MetadataBearing`<`any`\> \| `RawResponse`<`any`\> \| `MetadataBearing`<`any`\>[]\> | Name | Type | Default value | | :-- | :- | : | | `command` | `string` | `'kubectl'` | `fn` (`args`): `Promise`<`string` \| `number` \| `boolean` \| `HTMLElement` \| `Error` \| `MarkdownResponse` \| `ReactResponse` \| `MixedResponse` \| `CommentaryResponse` \| `TabLayoutModificationResponse`<`NewSplitRequest`\> \| `XtermResponse` \| `RandomErrorResponse1` \| `RandomErrorResponse2` \| `Table`<`Row`\> \| `AbortableResponse`<`ScalarResponse`<`Row`\>\> \| `NavResponse` \| `RadioTable` \| `UsageModel` \| `MetadataBearing`<`any`\> \| `RawResponse`<`any`\> \| `MetadataBearing`<`any`\>[]\> | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | `Promise`<`string` \| `number` \| `boolean` \| `HTMLElement` \| `Error` \| `MarkdownResponse` \| `ReactResponse` \| `MixedResponse` \| `CommentaryResponse` \| `TabLayoutModificationResponse`<`NewSplitRequest`\> \| `XtermResponse` \| `RandomErrorResponse1` \| `RandomErrorResponse2` \| `Table`<`Row`\> \| `AbortableResponse`<`ScalarResponse`<`Row`\>\> \| `NavResponse` \| `RadioTable` \| `UsageModel` \| `MetadataBearing`<`any`\> \| `RawResponse`<`any`\> \| `MetadataBearing`<`any`\>[]\> doExecRaw(`command`, `parsedOptions`, `execOptions`): `Promise`<`string`\> A convenience wrapper over `doNativeExec` that extracts only stdout, and discards the exit code and stderr. | Name | Type | | :-- | : | | `command` | `string` | | `parsedOptions` | | | `execOptions` | `ExecOptions` | `Promise`<`string`\> doExecWithMarkdown(`args`, `exec?`): `Promise`<`NavResponse`\> | Name | Type | | : | : | | `args` | `EvaluatorArgs`<\> | | `exec?` | `string` | `Promise`<`NavResponse`\> doExecWithPty<`Content`, `Response`, `O`\>(`args`, `prepare?`, `exec?`): `Promise`<`string` \| `Response`\> Execute the given command using a pty | Name | Type | | : | : | | `Content` | `void` | | `Response` | extends `KResponse`<`Content`\> = `KResponse`<`Content`\> | | `O` | extends = | | Name | Type | Default value | | :-- | :-- | : | | `args` | `EvaluatorArgs`<`O`\> | `undefined` | | `prepare` | `Prepare`<`O`\> | `NoPrepare` | | `exec?` | `string` | `undefined` | `Promise`<`string` \| `Response`\> doExecWithRadioTable<`Resource`\>(`resources`, `defaultSelectedIdx`, `onSelect`, `namedParameters?`): `Promise`<`RadioTable` \| `void`\> | Name | Type | | : | :-- | | `Resource` | extends `MetadataBearing`<`void`, `Resource`\> & <`void`, `Resource`\> & { `apiVersion`: `string` ; `isKubeResource`: `true` ; `isSimulacrum?`: `boolean` ; `kind`: `string` ; `metadata?`: `KubeMetadata` ; `originatingCommand`: `EvaluatorArgs`<\> ; `spec?`: `any` ; `status?`: } | | Name | Type | | :- | :-- | | `resources` | `Resource`[] | | `defaultSelectedIdx` | `number` | | `onSelect` | (`name`: `string`, `resource`: `Resource`) => `string` | | `namedParameters` | `Object` | | `namedParameters.nameColumnTitle` | `string` | | `namedParameters.title` | `string` | `Promise`<`RadioTable` \| `void`\> `Const` doExecWithStatus<`O`\>(`verb`, `finalState`, `command?`, `prepareForExec?`, `prepareForStatus?`): (`args`: `EvaluatorArgs`<`O`\>) => `Promise`<`KubeTableResponse`\> Execute a command, and then execute the status command which will poll until the given FinalState is reached. | Name | Type | | : | :-- | | `O` | extends | | Name | Type | Default value | | :-- | :-- | : | | `verb` | `string` | `undefined` | | `finalState` | `FinalState` | `undefined` | | `command` | `string` | `'kubectl'` | | `prepareForExec` | `Prepare`<`O`\> | `NoPrepare` | | `prepareForStatus` | `PrepareForStatus`<`O`\> | `DefaultPrepareForStatus` | `fn` (`args`): `Promise`<`KubeTableResponse`\> | Name | Type | | :-- | :-- | | `args` | `EvaluatorArgs`<`O`\> | `Promise`<`KubeTableResponse`\> doExecWithStdout<`O`\>(`args`, `prepare?`, `exec?`): `Promise`<`string`\> Behaves as does `exec`, except that it projects out just the `stdout` part -- thus ignoring the exit `code` and

| Name | Type | | : | :-- | | `O` | extends | | Name | Type | Default value | | :-- | :-- | : | | `args` | `EvaluatorArgs`<`O`\> | `undefined` | | `prepare` | `Prepare`<`O`\> | `NoPrepare` | | `exec?` | `string` | `undefined` | `Promise`<`string`\> doExecWithStdoutViaPty<`O`\>(`args`, `prepare?`): `Promise`<`string`\> Execute the given command using a pty, but return a string | Name | Type | | : | : | | `O` | extends = | | Name | Type | Default value | | :-- | :-- | : | | `args` | `EvaluatorArgs`<`O`\> | `undefined` | | `prepare` | `Prepare`<`O`\> | `NoPrepare` | `Promise`<`string`\> doExecWithTable<`O`\>(`args`, `prepare?`, `command?`, `namedParameters?`): `Promise`<`Table` \| `MixedResponse`\> Behaves as does `exec`, except that it projects out just the `stdout` part and parses it into a Table model. | Name | Type | | : | :-- | | `O` | extends | | Name | Type | Default value | | : | :-- | : | | `args` | `EvaluatorArgs`<`O`\> | `undefined` | | `prepare` | `Prepare`<`O`\> | `NoPrepare` | | `command` | `string` | `'kubectl'` | | `namedParameters` | `Object` | `{}` | | `namedParameters.entityType?` | `string` | `undefined` | | `namedParameters.nameColumn?` | `string` | `undefined` | | `namedParameters.usePty?` | `boolean` | `undefined` | | `namedParameters.verb?` | `string` | `undefined` | `Promise`<`Table` \| `MixedResponse`\> `Const` doGet(`command`): (`args`: `EvaluatorArgs`<\>) => `Promise`<`KResponse`<`any`\>\> This is the main handler for `kubectl get`. Here, we act as a dispatcher: in `kubectl` a `get` can mean either get-as-table, get-as-entity, or get-as-custom, depending on the `-o`

| Name | Type | | :-- | :- | | `command` | `string` | `fn` (`args`): `Promise`<`KResponse`<`any`\>\> | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | `Promise`<`KResponse`<`any`\>\> doHelp<`O`\>(`command`, `args`, `prepare?`): `Promise`<`KResponse`\> | Name | Type | | : | :-- | | `O` | extends | | Name | Type | Default value | | :-- | :-- | : | | `command` | `string` | `undefined` | | `args` | `EvaluatorArgs`<`O`\> | `undefined` | | `prepare` | `Prepare`<`O`\> | `NoPrepare` | `Promise`<`KResponse`\> doNativeExec(`args`): `Promise`<`RawResponse`\> | Name | Type | | :-- | :-- | | `args` | `Args` | `Promise`<`RawResponse`\> `Const` doRun(`command?`): (`args`: `EvaluatorArgs`<\>) => `Promise`<`KResponse`<`any`\>\> | Name | Type | Default value | | :-- | :- | : | | `command` | `string` | `'kubectl'` | `fn` (`args`): `Promise`<`KResponse`<`any`\>\> | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | `Promise`<`KResponse`<`any`\>\> emitKubectlConfigChangeEvent(`type`, `namespace?`, `context?`): `void` | Name | Type | | :-- | :- | | `type` | `"SetNamespaceOrContext"` \| `"CreateOrDeleteNamespace"` | | `namespace?` | `string` | | `context?` | `string` | `void` fetchFileString(`args`, `url`, `headers?`): `Promise`<(`void` \| `string`)[]\> same as fetchFile, but returning a string rather than a Buffer | Name | Type | | : | :- | | `args` | `ContextArgs` | | `url` | `string` | | `headers?` | `Record`<`string`, `string`\> | `Promise`<(`void` \| `string`)[]\> flags(`booleans?`): `CommandOptions` | Name | Type | Default value | | : | : | : | | `booleans` | `string`[] | `[]` | `CommandOptions` `Const` formatTable<`O`\>(`command`, `verb`, `entityTypeFromCommandLine`, `args`, `preTable`, `nameColumn?`): `Promise`<`Table`<`Row`\>\> | Name | Type | | : | :-- | | `O` | extends | | Name | Type | Default value | | :-- | :-- | : | | `command` | `string` | `undefined` | | `verb` | `string` | `undefined` | | `entityTypeFromCommandLine` | `string` | `undefined` | | `args` | `EvaluatorArgs`<`O`\> | `undefined` | | `preTable` | `Pair` | `undefined` | | `nameColumn` | `string` | `'NAME'` | `Promise`<`Table`<`Row`\>\> fqn(`apiVersion`, `kind`, `name`, `namespace`): `string` | Name | Type | | :-- | :- | | `apiVersion` | `string` | | `kind` | `string` | | `name` | `string` | | `namespace` | `string` | `string` fqnOf(`resource`): `string` | Name | Type | | : | : | | `resource` | <, `KubeMetadata`\> | `string` getAllContexts(`namedParameters`): `Promise`<[]\> | Name | Type | | :-- | :-- | | `namedParameters` | `Object` | | `namedParameters.REPL` | `default` | `Promise`<[]\> a list of `KubeContext` for all known contexts getAsMMRTransformer(`args`, `resource`): `Promise`<`MultiModalResponse`<\>\> `kubectl get` as entity response | Name | Type | | : | : | | `args` | `EvaluatorArgs`<\> | | `resource` | <, `KubeMetadata`\> | `Promise`<`MultiModalResponse`<\>\> `Const` getCommandFromArgs(`args`): `string` | Name | Type | | :-- | : | | `args` | `Pick`<`EvaluatorArgs`<`ParsedOptions`\>, `"argvNoOptions"`\> | `string` getContainer(`args`, `verb`): `string` e.g. for kubectl logs | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | | `verb` | `string` | `string` getCurrentContext(`namedParameters`): `Promise`<\> | Name | Type | | :-- | :-- | | `namedParameters` | `Object` | | `namedParameters.REPL` | `default` | `Promise`<\> a `KubeContext` representing the current context getCurrentContextName(`namedParameters`): `Promise`<`string`\> | Name | Type | | :-- | :-- | | `namedParameters` | `Object` | | `namedParameters.REPL` | `default` | `Promise`<`string`\> getCurrentDefaultContextName(`namedParameters`): `string` \| `Promise`<`string`\> | Name | Type | | : | : | | `namedParameters` | `ContextArgs` | `string` \| `Promise`<`string`\> the relevant context for the given args/command line getCurrentDefaultNamespace(`args`): `Promise`<`string`\> | Name | Type | | :-- | : | | `args` | `ContextArgs` | `Promise`<`string`\> the relevant namespace for the given args/command line getKind(`command`, `args`, `kindAsProvidedByUser`): `Promise`<`string`\> | Name | Type | Description | | : | :-- | :- | | `command` | `string` | - | | `args` | `EvaluatorArgs`<`ParsedOptions`\> | - | | `kindAsProvidedByUser` | `string` | e.g. pod or po | `Promise`<`string`\> e.g. Pod getLabel(`namedParameters`): `string` | Name | Type | | : | :- | | `namedParameters` | `Pick`<`EvaluatorArgs`<\>, `"parsedOptions"`\> | `string` getLabelForArgv(`args`): `string` | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | `string` getNamespace(`args`): `Promise`<`string`\> | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | `Promise`<`string`\> the namespace as expressed in the command line, or the default from context getNamespaceForArgv(`args`): `string` A variant of getNamespace where you only want to use what was provided by the user in their command

| Name | Type | | :-- | :- | | `args` | `Pick`<`EvaluatorArgs`<\>, `"parsedOptions"`\> | `string` getPodsCommand(`resource`, `args?`): `string` | Name | Type | | : | : | | `resource` | <, `KubeMetadata`\> | | `args?` | `Pick`<`EvaluatorArgs`<`ParsedOptions`\>, `"argvNoOptions"`\> | `string` getTabState(`tab`, `key`): `any` | Name | Type | | :- | :-- | | `tab` | `default` | | `key` | `string` | `any` getTransformer(`args`, `response`): `Promise`<`ReturnType`<typeof \> \| `Table`\> KubeResource -> MultiModalResponse view transformer | Name | Type | | : | : | | `args` | `EvaluatorArgs`<\> | | `response` | `KResponse`<`any`\> | `Promise`<`ReturnType`<typeof \> \| `Table`\> getter(`registrar`, `command`, `cli?`): `void` Register a command listener | Name | Type | Default value | | :- | :-- | : | | `registrar` | `CommandRegistrar` | `undefined` | | `command` | `string` | `undefined` | | `cli` | `string` | `command` | `void` hasLabel(`args`): `boolean` Due to deficiencies in yargs-parser (used by @kui-shell/core), the form -lapp=name (i.e. without a whitespace after the -l) is not parsed properly. | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | `boolean` isCrudableKubeResource(`entity`): entity is KubeResource<KubeStatus, KubeMetadata\> is the command response a kube resource that can responds to "kubectl delete",

| Name | Type | | :- | :- | | `entity` | `MetadataBearing`<`void`\> | entity is KubeResource<KubeStatus, KubeMetadata\> isDeployment(`resource`): resource is Deployment | Name | Type | | : | : | | `resource` | <, `KubeMetadata`\> | resource is Deployment whether the given resource is an instance of a Deployment isForAllNamespaces(`parsedOptions`): `boolean` | Name | Type | | :-- | : | | `parsedOptions` | | `boolean` isHelpRequest(`args`): `boolean` | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | `boolean` isJob(`resource`): resource is Job | Name | Type | | : | :- | | `resource` | `Pick`<<, `KubeMetadata`\>, `"apiVersion"` \| `"kind"`\> | resource is Job whether the given resource is an instance of a Deploymemt isKubeItems(`resource`): resource is KubeItems<KubeResource<KubeStatus, KubeMetadata\>\> | Name | Type | | : | : | | `resource` | <, `KubeMetadata`\> | resource is KubeItems<KubeResource<KubeStatus, KubeMetadata\>\> isKubeItemsOfKind<`Item`\>(`resource`, `isOfKind`): resource is KubeItems<Item\> | Name | Type | | :-- | :- | | `Item` | extends `MetadataBearing`<`void`, `Item`\> & <`void`, `Item`\> & { `apiVersion`: `string` ; `isKubeResource`: `true` ; `isSimulacrum?`: `boolean` ; `kind`: `string` ; `metadata?`: `KubeMetadata` ; `originatingCommand`: `EvaluatorArgs`<\> ; `spec?`: `any` ; `status?`: } = <, `KubeMetadata`\> | | Name | Type | | : | :-- | | `resource` | <, `KubeMetadata`\> | | `isOfKind` | (`item`: <, `KubeMetadata`\>) => item is Item | resource is KubeItems<Item\> isKubeResource(`entity`): entity is KubeResource<KubeStatus, KubeMetadata\> is the command response a Kubernetes resource? note: excluding any ones we simulate in kubeui | Name | Type | | :- | : | | `entity` | `MetadataBearing`<`void`\> \| `KResponse`<`any`\> | entity is KubeResource<KubeStatus, KubeMetadata\> isPod(`resource`): resource is Pod | Name | Type | | : | : | | `resource` | <, `KubeMetadata`\> | resource is Pod whether the given resource is an instance of a Pod isPodList(`resource`): resource is PodList | Name | Type | | : | : | | `resource` | <, `KubeMetadata`\> | resource is PodList isSecret(`resource`): resource is Secret<Record<string, any\>\> | Name | Type | | : | : | | `resource` | <, `KubeMetadata`\> | resource is Secret<Record<string, any\>\> isTableRequest(`args`): `boolean` | Name | Type | | :-- | :- | | `args` | `Pick`<`EvaluatorArgs`<\>, `"parsedOptions"`\> | `boolean` `Const` isUsage(`args`): `boolean` | Name | Type | | :-- | : | | `args` | `EvaluatorArgs`<\> | `boolean` isWatchRequest(`args`): `boolean` | Name | Type | | :-- | :- | | `args` | `Pick`<`EvaluatorArgs`<\>, `"parsedOptions"`\> | `boolean` offKubectlConfigChangeEvents(`handler`): `void` | Name | Type | | :-- | :-- | | `handler` | `Handler` | `void` onKubectlConfigChangeEvents(`handler`): `void` | Name | Type | | :-- | :-- | | `handler` | `Handler` | `void` parseName(`resource`): { `app`: `string` ; `name`: `string` ; `nameHash`: `string` ; `version`: `string` } \| { `app`: `undefined` ; `name`: `string` ; `nameHash`: `string` ; `version`: `string` } \| { `app`: `undefined` ; `name`: `undefined` ; `nameHash`: `undefined` ; `version`: `undefined` } Separate the app and generated parts of a resource name | Name | Type | | : | : | | `resource` | <, `KubeMetadata`\> | { `app`: `string` ; `name`: `string` ; `nameHash`: `string` ; `version`: `string` } \| { `app`: `undefined` ; `name`: `string` ; `nameHash`: `string` ; `version`: `string` } \| { `app`: `undefined` ; `name`: `undefined` ; `nameHash`: `undefined` ; `version`: `undefined` } `Const` preprocessTable(`raw`): `Pair`[] Find the column splits | Name | Type | | :- | : | | `raw` | `string`[] | `Pair`[] registerApplySubcommands(`registrar`, `cmd`): `void` | Name | Type | | :- | :-- | | `registrar` | `CommandRegistrar` | | `cmd` | `string`