From 7b9a98899e3892c2feb43cfb31b76b6a2eccb3c0 Mon Sep 17 00:00:00 2001 From: jessebot Date: Wed, 10 Jan 2024 20:14:59 +0100 Subject: [PATCH] fix #132: don't overwrite k3s custom config --- docs/assets/images/screenshots/help_text.svg | 152 +++++++++--------- pyproject.toml | 2 +- smol_k8s_lab/tui/distro_screen.py | 28 ++-- smol_k8s_lab/tui/distro_widgets/k3s_config.py | 5 - 4 files changed, 93 insertions(+), 94 deletions(-) diff --git a/docs/assets/images/screenshots/help_text.svg b/docs/assets/images/screenshots/help_text.svg index 166f553ee..01d193174 100644 --- a/docs/assets/images/screenshots/help_text.svg +++ b/docs/assets/images/screenshots/help_text.svg @@ -1,4 +1,4 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - term + term - + - -                           ๐Ÿงธsmol k8s lab - -Install slim Kubernetes distros + plus all your apps via Argo CD. - -Usage:smol-k8s-lab[OPTIONS] - -โ•ญโ”€ ส• แต”แดฅแต”ส” Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ -โ”‚โ”‚ -โ”‚-c--config CONFIG_FILEFull path and name of the YAML config file to parse. โ”‚ -โ”‚Defaults to $XDG_CONFIG_HOME/smol-k8s-lab/config.yamlโ”‚ -โ”‚โ”‚ -โ”‚-D--delete CLUSTER_NAMEDelete an existing cluster by name.                  โ”‚ -โ”‚โ”‚ -โ”‚-i--interactiveNew! โš™๏ธ Interactively configures  smol-k8s-labโ”‚ -โ”‚โ”‚ -โ”‚-v--versionPrint the version of smol-k8s-lab (v2.0.0)           โ”‚ -โ”‚โ”‚ -โ”‚-h--helpShow this message and exit.                          โ”‚ -โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ™ฅ docs: github.com/small-hack/smol-k8s-labโ”€โ•ฏ + +                           ๐Ÿงธsmol k8s lab + +Install slim Kubernetes distros + plus all your apps via Argo CD. + +Usage:smol-k8s-lab[OPTIONS] + +โ•ญโ”€ ส• แต”แดฅแต”ส” Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ +โ”‚โ”‚ +โ”‚-c--config CONFIG_FILEFull path and name of the YAML config file to parse. โ”‚ +โ”‚Defaults to $XDG_CONFIG_HOME/smol-k8s-lab/config.yamlโ”‚ +โ”‚โ”‚ +โ”‚-D--delete CLUSTER_NAMEDelete an existing cluster by name.                  โ”‚ +โ”‚โ”‚ +โ”‚-i--interactiveNew! โš™๏ธ Interactively configures  smol-k8s-labโ”‚ +โ”‚โ”‚ +โ”‚-v--versionPrint the version of smol-k8s-lab (v2.0.1)           โ”‚ +โ”‚โ”‚ +โ”‚-h--helpShow this message and exit.                          โ”‚ +โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ™ฅ docs: github.com/small-hack/smol-k8s-labโ”€โ•ฏ diff --git a/pyproject.toml b/pyproject.toml index 24d6d9ef6..d289a4734 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "smol_k8s_lab" -version = "2.0.0" +version = "2.0.1" description = "Bootstrap simple projects on Kubernetes with kind, k3d, and k3s." authors = ["Jesse Hitch ", "Max Roby "] diff --git a/smol_k8s_lab/tui/distro_screen.py b/smol_k8s_lab/tui/distro_screen.py index b7d698652..cd1608789 100755 --- a/smol_k8s_lab/tui/distro_screen.py +++ b/smol_k8s_lab/tui/distro_screen.py @@ -128,9 +128,9 @@ def on_mount(self) -> None: ) else: main_box.mount( - K3ConfigWidget( + K3sConfigWidget( self.current_distro, - DEFAULT_DISTRO_OPTIONS[self.current_distro], + self.cfg.get('k3s', DEFAULT_DISTRO_OPTIONS['k3s']), id=self.current_distro + "-pseudo-screen" ) ) @@ -158,7 +158,7 @@ def update_k8s_distro(self, event: Select.Changed) -> None: ) else: self.get_widget_by_id("distro-config-screen").mount( - K3ConfigWidget( + K3sConfigWidget( distro, DEFAULT_DISTRO_OPTIONS[distro], id=distro + "-pseudo-screen" @@ -253,11 +253,14 @@ def on_mount(self) -> None: # update tabbed content box tabbed_content = self.query_one(TabbedContent) - tabbed_content.border_title = ("Add [i]extra[/] options for " - "[#C1FF87]kind[/] config files") + tabbed_content.border_title = ( + "Add [i]extra[/] options for [#C1FF87]kind[/] config files" + ) + + subtitle = ( + "[b][@click=screen.launch_new_option_modal()] โž• kind option[/][/]" + ) - subtitle = ("[b][@click=screen.launch_new_option_modal()]" - "โž• kind option[/][/]") tabbed_content.border_subtitle = subtitle for tab in self.query("Tab"): @@ -273,13 +276,13 @@ def speak_when_tab_selected(self, event: TabbedContent.TabActivated) -> None: self.app.action_say(f"Selected tab is {event.tab.id}") -class K3ConfigWidget(Static): +class K3sConfigWidget(Static): """ a widget representing the entire kind configuration """ def __init__(self, distro: str, metadata: dict, id: str = "") -> None: - self.metadata = metadata self.distro = distro + self.metadata = metadata super().__init__(id=id) def compose(self) -> ComposeResult: @@ -289,8 +292,8 @@ def compose(self) -> ComposeResult: with Grid(classes="k8s-distro-config", id=f"{self.distro}-box"): # take number of nodes from config and make string - nodes = self.metadata.get('nodes', {'control_plane': 1, - 'workers': 0}) + nodes = self.metadata.get('nodes', + {'control_plane': 1, 'workers': 0}) control_nodes = str(nodes.get('control_plane', '1')) worker_nodes = str(nodes.get('workers', '0')) @@ -298,5 +301,6 @@ def compose(self) -> ComposeResult: yield NodeAdjustmentBox(self.distro, control_nodes, worker_nodes) # take extra k3s args if self.distro is k3s or k3d - yield K3sConfig(self.distro, self.metadata['k3s_yaml'], + yield K3sConfig(self.distro, + self.metadata['k3s_yaml'], id=f"{self.distro}-widget") diff --git a/smol_k8s_lab/tui/distro_widgets/k3s_config.py b/smol_k8s_lab/tui/distro_widgets/k3s_config.py index c02cb2e3f..19194e083 100644 --- a/smol_k8s_lab/tui/distro_widgets/k3s_config.py +++ b/smol_k8s_lab/tui/distro_widgets/k3s_config.py @@ -96,11 +96,6 @@ def on_mount(self) -> None: if arg: self.generate_row(arg, value) - # don't remember why we needed this, but testing breaks with these errors if it's on: - # RuntimeWarning: Enable tracemalloc to get the object allocation traceback - # RuntimeWarning: coroutine 'App.action_focus' was never awaited - # self.app.action_focus(self.query_one(".k3s-config-container")) - def on_button_pressed(self, event: Button.Pressed) -> None: """ get pressed button and act on it