kx-cli 0.0.2__tar.gz → 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. kx_cli-0.0.3/LICENSE +21 -0
  2. {kx_cli-0.0.2 → kx_cli-0.0.3}/PKG-INFO +30 -13
  3. {kx_cli-0.0.2 → kx_cli-0.0.3}/README.md +24 -11
  4. {kx_cli-0.0.2 → kx_cli-0.0.3}/pyproject.toml +4 -2
  5. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/commands/delete.py +6 -1
  6. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/commands/describe.py +3 -1
  7. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/commands/events.py +5 -5
  8. kx_cli-0.0.3/src/kx/commands/exec.py +28 -0
  9. kx_cli-0.0.3/src/kx/commands/get.py +46 -0
  10. kx_cli-0.0.3/src/kx/commands/logs.py +42 -0
  11. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/commands/port_forward.py +11 -2
  12. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/commands/state.py +1 -1
  13. kx_cli-0.0.3/src/kx/commands/tree.py +34 -0
  14. kx_cli-0.0.3/src/kx/console.py +281 -0
  15. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/events.py +4 -3
  16. kx_cli-0.0.3/src/kx/graph.py +231 -0
  17. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/index.py +21 -13
  18. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/k8s.py +2 -1
  19. kx_cli-0.0.3/src/kx/kinds.py +92 -0
  20. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/kubectl.py +3 -2
  21. kx_cli-0.0.3/src/kx/main.py +252 -0
  22. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/state.py +3 -3
  23. kx_cli-0.0.3/src/kx/types.py +7 -0
  24. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx_cli.egg-info/PKG-INFO +30 -13
  25. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx_cli.egg-info/SOURCES.txt +4 -0
  26. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx_cli.egg-info/requires.txt +3 -1
  27. kx_cli-0.0.3/tests/test_cli_get.py +79 -0
  28. kx_cli-0.0.3/tests/test_console.py +158 -0
  29. {kx_cli-0.0.2 → kx_cli-0.0.3}/tests/test_describe.py +12 -2
  30. {kx_cli-0.0.2 → kx_cli-0.0.3}/tests/test_edit.py +3 -1
  31. {kx_cli-0.0.2 → kx_cli-0.0.3}/tests/test_exec.py +1 -1
  32. kx_cli-0.0.3/tests/test_get.py +135 -0
  33. {kx_cli-0.0.2 → kx_cli-0.0.3}/tests/test_index.py +8 -6
  34. kx_cli-0.0.3/tests/test_logs.py +159 -0
  35. {kx_cli-0.0.2 → kx_cli-0.0.3}/tests/test_port_forward.py +22 -4
  36. {kx_cli-0.0.2 → kx_cli-0.0.3}/tests/test_state.py +26 -11
  37. kx_cli-0.0.2/src/kx/commands/exec.py +0 -20
  38. kx_cli-0.0.2/src/kx/commands/get.py +0 -28
  39. kx_cli-0.0.2/src/kx/commands/logs.py +0 -15
  40. kx_cli-0.0.2/src/kx/commands/tree.py +0 -16
  41. kx_cli-0.0.2/src/kx/graph.py +0 -91
  42. kx_cli-0.0.2/src/kx/kinds.py +0 -66
  43. kx_cli-0.0.2/src/kx/main.py +0 -142
  44. kx_cli-0.0.2/src/kx/types.py +0 -6
  45. kx_cli-0.0.2/tests/test_get.py +0 -62
  46. kx_cli-0.0.2/tests/test_logs.py +0 -46
  47. {kx_cli-0.0.2 → kx_cli-0.0.3}/setup.cfg +0 -0
  48. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/__init__.py +0 -0
  49. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/commands/__init__.py +0 -0
  50. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/commands/edit.py +0 -0
  51. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx/commands/yaml.py +0 -0
  52. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx_cli.egg-info/dependency_links.txt +0 -0
  53. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx_cli.egg-info/entry_points.txt +0 -0
  54. {kx_cli-0.0.2 → kx_cli-0.0.3}/src/kx_cli.egg-info/top_level.txt +0 -0
  55. {kx_cli-0.0.2 → kx_cli-0.0.3}/tests/test_kinds.py +0 -0
kx_cli-0.0.3/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joshua Alexander Zillwood
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,17 +1,34 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kx-cli
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: kubectl wrapper with index-based resource selection
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
7
- Requires-Dist: typer
7
+ License-File: LICENSE
8
+ Requires-Dist: typer==0.25.1
9
+ Requires-Dist: click
8
10
  Requires-Dist: kubernetes
9
11
  Requires-Dist: rich
10
12
  Provides-Extra: dev
11
13
  Requires-Dist: ruff; extra == "dev"
14
+ Requires-Dist: pre-commit; extra == "dev"
12
15
  Requires-Dist: pytest; extra == "dev"
16
+ Dynamic: license-file
13
17
 
14
- # kx
18
+ <div align="center">
19
+
20
+ ```
21
+ ██╗ ██╗██╗ ██╗
22
+ ██║ ██╔╝╚██╗██╔╝
23
+ █████╔╝ ╚███╔╝
24
+ ██╔═██╗ ██╔██╗
25
+ ██║ ██╗██╔╝ ██╗
26
+ ╚═╝ ╚═╝╚═╝ ╚═╝
27
+ ```
28
+
29
+ **kubectl, indexed.**
30
+
31
+ </div>
15
32
 
16
33
  `kx` is a kubectl wrapper that adds index-based resource selection. Run `kx get <resource>` once, then reference any result by number instead of typing full resource names.
17
34
 
@@ -26,10 +43,10 @@ pip install kx-cli
26
43
  ### List resources
27
44
 
28
45
  ```
29
- kx get <resource> [-n <namespace>]
46
+ kx get <resource> [--match|-m <substring>] [kubectl flags...]
30
47
  ```
31
48
 
32
- Fetches resources and assigns index numbers. Omitting `-n` uses the current context namespace.
49
+ Fetches resources and assigns index numbers. Any extra flags (e.g. `-n <namespace>`, `-A`) are passed through to kubectl. Use `--match`/`-m` to filter results by name (substring, case-insensitive).
33
50
 
34
51
  ```
35
52
  $ kx get pods
@@ -45,17 +62,17 @@ All subsequent commands reference resources by their `X` index from the last `kx
45
62
 
46
63
  | Command | Description |
47
64
  |---|---|
48
- | `kx get <resource> [-n ns]` | List resources with index numbers |
49
- | `kx describe <index>` | Show `kubectl describe` output for an indexed resource |
65
+ | `kx get <resource> [--match\|-m <str>] [kubectl flags...]` | List resources with index numbers; optionally filter by name substring |
66
+ | `kx describe <index> [kubectl flags...]` | Show `kubectl describe` output for an indexed resource |
50
67
  | `kx events <index>` | Show Kubernetes events for the resource |
51
- | `kx logs <index>` | Stream logs for a pod |
68
+ | `kx logs <index> [kubectl flags...]` | Stream logs; aggregates across pods for Deployments, StatefulSets, DaemonSets, and Services |
52
69
  | `kx yaml <index>` | Print the raw YAML manifest |
53
- | `kx exec <index> [cmd]` | Open an interactive shell in a pod (bash → sh fallback); pass a custom command with `cmd` |
54
- | `kx edit <index>` | Open the resource in your editor via `kubectl edit` |
70
+ | `kx exec <index> [cmd] [kubectl flags...]` | Open an interactive shell in a pod (bash → sh fallback); pass a custom command with `cmd` |
71
+ | `kx edit <index> [kubectl flags...]` | Open the resource in your editor via `kubectl edit` |
55
72
  | `kx delete <index> [-y]` | Delete the resource (prompts for confirmation; `-y` skips it) |
56
- | `kx tree <index>` | Show the ownership graph for a resource |
57
- | `kx port-forward <index> <port>` | Forward a local port to a resource (supports Pod, Deployment, ReplicaSet, StatefulSet, DaemonSet, Service) |
58
- | `kx state` | Show the current state (last `kx get` result) as JSON |
73
+ | `kx tree <index> [--index\|-i]` | Show the ownership graph for a resource; `--index` assigns indexes to tree nodes |
74
+ | `kx port-forward <index> <port> [kubectl flags...]` | Forward a local port to a resource (supports Pod, Deployment, ReplicaSet, StatefulSet, DaemonSet, Service) |
75
+ | `kx state` | Show the current state (namespace and indexed resources from the last `kx get`) |
59
76
 
60
77
  ### Example workflow
61
78
 
@@ -1,4 +1,17 @@
1
- # kx
1
+ <div align="center">
2
+
3
+ ```
4
+ ██╗ ██╗██╗ ██╗
5
+ ██║ ██╔╝╚██╗██╔╝
6
+ █████╔╝ ╚███╔╝
7
+ ██╔═██╗ ██╔██╗
8
+ ██║ ██╗██╔╝ ██╗
9
+ ╚═╝ ╚═╝╚═╝ ╚═╝
10
+ ```
11
+
12
+ **kubectl, indexed.**
13
+
14
+ </div>
2
15
 
3
16
  `kx` is a kubectl wrapper that adds index-based resource selection. Run `kx get <resource>` once, then reference any result by number instead of typing full resource names.
4
17
 
@@ -13,10 +26,10 @@ pip install kx-cli
13
26
  ### List resources
14
27
 
15
28
  ```
16
- kx get <resource> [-n <namespace>]
29
+ kx get <resource> [--match|-m <substring>] [kubectl flags...]
17
30
  ```
18
31
 
19
- Fetches resources and assigns index numbers. Omitting `-n` uses the current context namespace.
32
+ Fetches resources and assigns index numbers. Any extra flags (e.g. `-n <namespace>`, `-A`) are passed through to kubectl. Use `--match`/`-m` to filter results by name (substring, case-insensitive).
20
33
 
21
34
  ```
22
35
  $ kx get pods
@@ -32,17 +45,17 @@ All subsequent commands reference resources by their `X` index from the last `kx
32
45
 
33
46
  | Command | Description |
34
47
  |---|---|
35
- | `kx get <resource> [-n ns]` | List resources with index numbers |
36
- | `kx describe <index>` | Show `kubectl describe` output for an indexed resource |
48
+ | `kx get <resource> [--match\|-m <str>] [kubectl flags...]` | List resources with index numbers; optionally filter by name substring |
49
+ | `kx describe <index> [kubectl flags...]` | Show `kubectl describe` output for an indexed resource |
37
50
  | `kx events <index>` | Show Kubernetes events for the resource |
38
- | `kx logs <index>` | Stream logs for a pod |
51
+ | `kx logs <index> [kubectl flags...]` | Stream logs; aggregates across pods for Deployments, StatefulSets, DaemonSets, and Services |
39
52
  | `kx yaml <index>` | Print the raw YAML manifest |
40
- | `kx exec <index> [cmd]` | Open an interactive shell in a pod (bash → sh fallback); pass a custom command with `cmd` |
41
- | `kx edit <index>` | Open the resource in your editor via `kubectl edit` |
53
+ | `kx exec <index> [cmd] [kubectl flags...]` | Open an interactive shell in a pod (bash → sh fallback); pass a custom command with `cmd` |
54
+ | `kx edit <index> [kubectl flags...]` | Open the resource in your editor via `kubectl edit` |
42
55
  | `kx delete <index> [-y]` | Delete the resource (prompts for confirmation; `-y` skips it) |
43
- | `kx tree <index>` | Show the ownership graph for a resource |
44
- | `kx port-forward <index> <port>` | Forward a local port to a resource (supports Pod, Deployment, ReplicaSet, StatefulSet, DaemonSet, Service) |
45
- | `kx state` | Show the current state (last `kx get` result) as JSON |
56
+ | `kx tree <index> [--index\|-i]` | Show the ownership graph for a resource; `--index` assigns indexes to tree nodes |
57
+ | `kx port-forward <index> <port> [kubectl flags...]` | Forward a local port to a resource (supports Pod, Deployment, ReplicaSet, StatefulSet, DaemonSet, Service) |
58
+ | `kx state` | Show the current state (namespace and indexed resources from the last `kx get`) |
46
59
 
47
60
  ### Example workflow
48
61
 
@@ -1,11 +1,12 @@
1
1
  [project]
2
2
  name = "kx-cli"
3
- version = "0.0.2"
3
+ version = "0.0.3"
4
4
  description = "kubectl wrapper with index-based resource selection"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
7
7
  dependencies = [
8
- "typer",
8
+ "typer==0.25.1",
9
+ "click",
9
10
  "kubernetes",
10
11
  "rich",
11
12
  ]
@@ -13,6 +14,7 @@ dependencies = [
13
14
  [project.optional-dependencies]
14
15
  dev = [
15
16
  "ruff",
17
+ "pre-commit",
16
18
  "pytest",
17
19
  ]
18
20
 
@@ -4,7 +4,12 @@ from kx.types import Confirm
4
4
 
5
5
 
6
6
  class DeleteCommand:
7
- def __init__(self, state: StateServiceProtocol, kubectl: KubectlServiceProtocol, confirm: Confirm):
7
+ def __init__(
8
+ self,
9
+ state: StateServiceProtocol,
10
+ kubectl: KubectlServiceProtocol,
11
+ confirm: Confirm,
12
+ ):
8
13
  self.state = state
9
14
  self.kubectl = kubectl
10
15
  self.confirm = confirm
@@ -13,4 +13,6 @@ class DescribeCommand:
13
13
 
14
14
  def execute(self, index: int, extra_args: list[str] = []) -> None:
15
15
  name, namespace, kind = self.state.fields(index)
16
- self.kubectl.run_interactive(["describe", kind, name, "-n", namespace, *extra_args])
16
+ self.kubectl.run_interactive(
17
+ ["describe", kind, name, "-n", namespace, *extra_args]
18
+ )
@@ -16,11 +16,11 @@ class EventsCommand:
16
16
  return "No events found"
17
17
 
18
18
  output = []
19
- for e in filtered:
20
- obj = e.involved_object
19
+ for event in filtered:
20
+ obj = event.involved_object
21
21
  output.append(
22
- f"{e.type:8} {e.reason:30} "
23
- f"{obj.kind:10} {e.metadata.creation_timestamp} "
24
- f"{e.message}"
22
+ f"{event.type:8} {event.reason:30} "
23
+ f"{obj.kind:10} {event.metadata.creation_timestamp} "
24
+ f"{event.message}"
25
25
  )
26
26
  return "\n".join(output)
@@ -0,0 +1,28 @@
1
+ from kx.kinds import Kind
2
+ from kx.kubectl import KubectlServiceProtocol
3
+ from kx.state import StateServiceProtocol
4
+
5
+
6
+ class ExecCommand:
7
+ def __init__(self, state: StateServiceProtocol, kubectl: KubectlServiceProtocol):
8
+ self.state = state
9
+ self.kubectl = kubectl
10
+
11
+ def execute(
12
+ self, index: int, cmd: list[str] | None, extra_args: list[str] = []
13
+ ) -> None:
14
+ name, namespace, kind = self.state.fields(index)
15
+ if kind != Kind.Pod:
16
+ raise ValueError("exec is only supported for pods.")
17
+ if cmd:
18
+ self.kubectl.run_interactive(
19
+ ["exec", "-it", name, "-n", namespace, *extra_args, "--", *cmd]
20
+ )
21
+ else:
22
+ rc = self.kubectl.run_interactive(
23
+ ["exec", "-it", name, "-n", namespace, *extra_args, "--", "bash"]
24
+ )
25
+ if rc != 0:
26
+ self.kubectl.run_interactive(
27
+ ["exec", "-it", name, "-n", namespace, *extra_args, "--", "sh"]
28
+ )
@@ -0,0 +1,46 @@
1
+ from kx.index import IndexServiceProtocol
2
+ from kx.kinds import normalize_kind
3
+ from kx.kubectl import KubectlServiceProtocol
4
+ from kx.state import State, StateServiceProtocol
5
+
6
+
7
+ def _extract_namespace(extra_args: list[str]) -> str | None:
8
+ for index, arg in enumerate(extra_args):
9
+ if arg in ("-n", "--namespace") and index + 1 < len(extra_args):
10
+ return extra_args[index + 1]
11
+ if arg.startswith("--namespace="):
12
+ return arg.split("=", 1)[1]
13
+ return None
14
+
15
+
16
+ class GetCommand:
17
+ def __init__(
18
+ self,
19
+ kubectl: KubectlServiceProtocol,
20
+ state: StateServiceProtocol,
21
+ index: IndexServiceProtocol,
22
+ ):
23
+ self.kubectl = kubectl
24
+ self.state = state
25
+ self.index = index
26
+
27
+ def execute(
28
+ self,
29
+ resource: str,
30
+ filter_term: str | None = None,
31
+ extra_args: list[str] = [],
32
+ ) -> str:
33
+ output = self.kubectl.run(["get", resource, *extra_args])
34
+ if filter_term:
35
+ output = self.index.filter(output, filter_term)
36
+ indexed_output, names = self.index.add(output)
37
+ all_namespaces = any(arg in ("-A", "--all-namespaces") for arg in extra_args)
38
+ if names and not all_namespaces:
39
+ namespace = (
40
+ _extract_namespace(extra_args) or self.kubectl.current_namespace()
41
+ )
42
+ kind = normalize_kind(resource)
43
+ self.state.save(
44
+ State(resources={name: kind for name in names}, namespace=namespace)
45
+ )
46
+ return indexed_output
@@ -0,0 +1,42 @@
1
+ import json
2
+
3
+ from kx.kinds import Kind
4
+ from kx.kubectl import KubectlServiceProtocol
5
+ from kx.state import StateServiceProtocol
6
+
7
+ _AGGREGATE_KINDS = {Kind.Deployment, Kind.StatefulSet, Kind.DaemonSet, Kind.Service}
8
+
9
+
10
+ class LogsCommand:
11
+ def __init__(self, state: StateServiceProtocol, kubectl: KubectlServiceProtocol):
12
+ self.state = state
13
+ self.kubectl = kubectl
14
+
15
+ def execute(self, index: int, extra_args: list[str] = []) -> None:
16
+ name, namespace, kind = self.state.fields(index)
17
+ if kind == Kind.Pod:
18
+ self.kubectl.run_interactive(["logs", name, "-n", namespace, *extra_args])
19
+ elif kind in _AGGREGATE_KINDS:
20
+ selector = self._selector(name, namespace, kind)
21
+ self.kubectl.run_interactive(
22
+ ["logs", "-l", selector, "--prefix=true", "-n", namespace, *extra_args]
23
+ )
24
+ else:
25
+ raise ValueError(f"Logs are not supported for '{kind}'.")
26
+
27
+ def _selector(self, name: str, namespace: str, kind: str) -> str:
28
+ raw = self.kubectl.run(["get", kind, name, "-n", namespace, "-o", "json"])
29
+ obj = json.loads(raw)
30
+ labels = self._extract_labels(obj, kind)
31
+ if not labels:
32
+ raise ValueError(
33
+ f"{kind}/{name} has no pod selector; cannot aggregate logs."
34
+ )
35
+ return ",".join(f"{k}={v}" for k, v in labels.items())
36
+
37
+ @staticmethod
38
+ def _extract_labels(obj: dict, kind: str) -> dict:
39
+ spec = obj.get("spec", {})
40
+ if kind == Kind.Service:
41
+ return spec.get("selector") or {}
42
+ return (spec.get("selector") or {}).get("matchLabels") or {}
@@ -2,7 +2,14 @@ from kx.kinds import Kind
2
2
  from kx.kubectl import KubectlServiceProtocol
3
3
  from kx.state import StateServiceProtocol
4
4
 
5
- _SUPPORTED_KINDS = {Kind.Pod, Kind.Deployment, Kind.ReplicaSet, Kind.StatefulSet, Kind.DaemonSet, Kind.Service}
5
+ _SUPPORTED_KINDS = {
6
+ Kind.Pod,
7
+ Kind.Deployment,
8
+ Kind.ReplicaSet,
9
+ Kind.StatefulSet,
10
+ Kind.DaemonSet,
11
+ Kind.Service,
12
+ }
6
13
 
7
14
 
8
15
  class PortForwardCommand:
@@ -14,4 +21,6 @@ class PortForwardCommand:
14
21
  name, namespace, kind = self.state.fields(index)
15
22
  if kind not in _SUPPORTED_KINDS:
16
23
  raise ValueError(f"port-forward is not supported for '{kind}'.")
17
- self.kubectl.run_interactive(["port-forward", f"{kind}/{name}", port, "-n", namespace, *extra_args])
24
+ self.kubectl.run_interactive(
25
+ ["port-forward", f"{kind}/{name}", port, "-n", namespace, *extra_args]
26
+ )
@@ -10,4 +10,4 @@ class StateCommand:
10
10
 
11
11
  def execute(self) -> State:
12
12
  state = self.state.load()
13
- return json.dumps(asdict(state), indent=2)
13
+ return json.dumps(asdict(state), indent=2)
@@ -0,0 +1,34 @@
1
+ from rich.tree import Tree
2
+
3
+ from kx.kubectl import KubectlServiceProtocol
4
+ from kx.state import State, StateServiceProtocol
5
+ from kx.types import BuildIndexedTree, BuildTree
6
+
7
+
8
+ class TreeCommand:
9
+ def __init__(
10
+ self,
11
+ state: StateServiceProtocol,
12
+ kubectl: KubectlServiceProtocol,
13
+ build_tree: BuildTree,
14
+ build_indexed_tree: BuildIndexedTree,
15
+ ):
16
+ self.state = state
17
+ self.kubectl = kubectl
18
+ self.build_tree = build_tree
19
+ self.build_indexed_tree = build_indexed_tree
20
+
21
+ def execute(self, index: int, indexed: bool = False) -> Tree:
22
+ name, namespace, kind = self.state.fields(index)
23
+ if indexed:
24
+ tree, resources = self.build_indexed_tree(kind, name, namespace)
25
+ if resources:
26
+ self.state.save(
27
+ State(
28
+ resources={name: kind for name, kind in resources},
29
+ namespace=namespace,
30
+ )
31
+ )
32
+ else:
33
+ tree = self.build_tree(kind, name, namespace)
34
+ return tree