Skip to content

Commit

Permalink
tui: clean up tabs and borders for k3s.yaml and kubelet args specific…
Browse files Browse the repository at this point in the history
…ally
  • Loading branch information
jessebot committed Jan 11, 2024
1 parent 1d61edc commit c217b22
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
22 changes: 22 additions & 0 deletions smol_k8s_lab/tui/css/k3s.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ $navy: rgb(35,35,54);
grid-rows: 0.25fr 1fr;
}

/* TabbedContent box for the kind widget */
#k3s-tabbed-content {
border: round $cornflower;
border-title-color: $sky_blue;
border-subtitle-color: $lavender;
background: $navy 60%;
width: 100%;
height: 100%;
link-background-hover: $navy;
link-color-hover: $orange;
}

/* tabpane 1 */
#k3s-yaml-tab {
height: auto;
}

/* tabpane 2 */
#k3s-kubelet-tab {
height: auto;
}

/* k3s container itself */
.k3s-arg-scroll {
align: center middle;
Expand Down
8 changes: 4 additions & 4 deletions smol_k8s_lab/tui/distro_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,18 @@ def compose(self) -> ComposeResult:


# Add the TabbedContent widget for kind config
with TabbedContent(initial="kind-networking-tab", id="kind-tabbed-content"):
with TabbedContent(initial="k3s-yaml-tab", id="k3s-tabbed-content"):
# tab 1 - networking options
with TabPane("Networking options", id="kind-networking-tab"):
with TabPane("k3s.yaml", id="k3s-yaml-tab"):
# take extra k3s args if self.distro is k3s or k3d
yield K3sConfig(self.distro,
self.metadata['k3s_yaml'],
id=f"{self.distro}-widget")

# tab 2 - kubelet options
with TabPane("Kubelet Config Options", id="kind-kubelet-tab"):
with TabPane("Kubelet Config Options", id="k3s-kubelet-tab"):
# kubelet config section for kind only
kubelet_args = self.metadata['k3s_yaml'].get('kubelet-args', '')
kubelet_args = self.metadata['k3s_yaml'].get('kubelet-arg', '')
yield KubeletConfig('k3s', kubelet_args)

def on_mount(self) -> None:
Expand Down
5 changes: 3 additions & 2 deletions smol_k8s_lab/tui/distro_widgets/k3s_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def compose(self) -> ComposeResult:
"Add extra [steel_blue][b][link=https://docs.k3s.io/cli/server]"
"k3s options[/][/][/] to pass to the k3s install script via a "
"[steel_blue][b][link=https://docs.k3s.io/installation/configuration#"
f"configuration-file]config file[/][/][/] stored in {CFG_FILE}",
f"configuration-file]config file[/][/][/] stored in {CFG_FILE}. "
"Please use the second tab for extra kubelet args.",
classes="help-text"
)

Expand All @@ -84,7 +85,7 @@ def on_mount(self) -> None:
# if we've been passed k3s args already, generate rows
if self.k3s_args:
for arg, value in self.k3s_args.items():
if arg:
if arg and arg != "kubelet-arg":
self.generate_row(arg, value)

def on_button_pressed(self, event: Button.Pressed) -> None:
Expand Down
4 changes: 2 additions & 2 deletions smol_k8s_lab/tui/distro_widgets/kubelet_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def on_button_pressed(self, event: Button.Pressed) -> None:

# this isn't beautiful, but should get the job done
if self.distro == "k3s":
k3s_args = app_yaml['k3s_yaml']['kubelet-args']
k3s_args = app_yaml['k3s_yaml']['kubelet-arg']
pop_item = None

if input_key:
Expand Down Expand Up @@ -114,7 +114,7 @@ def update_base_yaml(self, event: Input.Changed | Input.Submitted) -> None:

# k3s uses a list
if self.distro == "k3s":
args = distro_cfg["k3s_yaml"]['kubelet-args']
args = distro_cfg["k3s_yaml"]['kubelet-arg']
if isinstance(args, list):
args.append(f"{event.input.name}={event.input.value}")
else:
Expand Down

0 comments on commit c217b22

Please sign in to comment.