Skip to content

Commit

Permalink
specify an id for the kubelet widget so that we can generate rows for it
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebot committed Jan 12, 2024
1 parent 92a1c5b commit ab9ac27
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions smol_k8s_lab/tui/css/kind.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ KubeletConfig {
}

/* kubelet config container */
#kubelet-config-container {
.kubelet-config-container {
padding: 1;
grid-rows: 0.25fr 1fr;
align: center middle;
}

#kubelet-config-scroll {
.kubelet-config-scroll {
align: center middle;
scrollbar-background: $dark_gray;
scrollbar-background-active: $dark_gray;
Expand Down
19 changes: 14 additions & 5 deletions smol_k8s_lab/tui/distro_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,30 @@ def update_k8s_distro(self, event: Select.Changed) -> None:
def action_launch_new_option_modal(self) -> None:
def add_new_row(option: str):
if option and self.current_distro != 'kind':
k3s_widget = self.get_widget_by_id(f"{self.current_distro}-widget")
if self.query_one(TabbedContent).active == "k3s-yaml-tab":
k3s_widget = self.get_widget_by_id(f"{self.current_distro}-widget")
else:
k3s_widget = self.get_widget_by_id(
f"kubelet-config-{self.current_distro}"
)
k3s_widget.generate_row(option)

elif option and self.current_distro == 'kind':
if self.query_one(TabbedContent).active == "kind-networking-tab":
kind_widget = self.query_one(KindNetworkingConfig)
kind_widget.generate_row(option)
else:
kind_widget = self.query_one(KubeletConfig)
kind_widget.generate_row(option)
kind_widget = self.get_widget_by_id(
f"kubelet-config-{self.current_distro}"
)
kind_widget.generate_row(option)
else:
return

if self.current_distro != 'kind':
if self.query_one(TabbedContent).active == "k3s-kubelet-tab":
existing_keys = self.cfg[self.current_distro]['k3s_yaml'].get("kubelet-arg", [])
existing_keys = self.cfg[self.current_distro]['k3s_yaml'].get(
"kubelet-arg", []
)
trigger = "k3s kubelet"
else:
existing_keys = self.cfg[self.current_distro]['k3s_yaml'].keys()
Expand Down
10 changes: 6 additions & 4 deletions smol_k8s_lab/tui/distro_widgets/kubelet_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ class KubeletConfig(Widget):
def __init__(self, distro: str, kubelet_extra_args: list = []) -> None:
self.distro = distro
self.kubelet_extra_args = kubelet_extra_args
super().__init__()
super().__init__(id=f"kubelet-config-{distro}")

def compose(self) -> ComposeResult:
with Grid(id="kubelet-config-container"):
with Grid(id=f"kubelet-config-container-{self.distro}",
classes="kubelet-config-container"):
yield Label(kubelet_help, classes="help-text")
yield VerticalScroll(id="kubelet-config-scroll")
yield VerticalScroll(id=f"kubelet-config-scroll-{self.distro}",
classes="kubelet-config-scroll")

def on_mount(self) -> None:
if self.kubelet_extra_args:
Expand Down Expand Up @@ -146,7 +148,7 @@ def generate_row(self, param: str = "", value: str = "") -> Grid:
del_button = Button("🚮", id=f"kind-kubelet-delete-{param}-button")
del_button.tooltip = "Delete this kubelet parameter"

self.get_widget_by_id("kubelet-config-scroll").mount(
self.get_widget_by_id(f"kubelet-config-scroll-{self.distro}").mount(
Grid(label, param_value_input, del_button,
classes="label-input-delete-row")
)

0 comments on commit ab9ac27

Please sign in to comment.