Skip to content

Commit

Permalink
change trigger to tab, and add k3s kubelet + k3s k3s_yaml as potentia…
Browse files Browse the repository at this point in the history
…l tabs
  • Loading branch information
jessebot committed Jan 12, 2024
1 parent c217b22 commit 7a5d73c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
8 changes: 6 additions & 2 deletions smol_k8s_lab/tui/distro_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,12 @@ def add_new_row(option: str):
return

if self.current_distro != 'kind':
existing_keys = self.cfg[self.current_distro]['k3s_yaml'].keys()
trigger = "k3s"
if self.query_one(TabbedContent).active == "k3s-kubelet-tab":
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()
trigger = "k3s k3s_yaml"
else:
kind_cfg = self.cfg['kind']
if self.query_one(TabbedContent).active == "kind-networking-tab":
Expand Down
22 changes: 12 additions & 10 deletions smol_k8s_lab/tui/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@


KUBELET_SUGGESTIONS = SuggestFromList((
"podsPerCore",
"maxPods",
"pods-per-core",
"max-pods",
"node-labels",
"featureGates"
"feature-gates",
"system-reserved",
"kube-reserved"
))


Expand Down Expand Up @@ -115,29 +117,29 @@ class NewOptionModal(ModalScreen):
"./css/new_option_modal.tcss"
]

def __init__(self, trigger: str, in_use_args: list = []) -> None:
def __init__(self, tab: str, in_use_args: list = []) -> None:
self.in_use_args = in_use_args
self.trigger = trigger
self.tab = tab
super().__init__()

def compose(self) -> ComposeResult:
# base screen grid
question = f"[#ffaff9]Add[/] [i]new[/] [#C1FF87]{self.trigger} option[/]."
question = f"[#ffaff9]Add[/] [i]new[/] [#C1FF87]{self.tab} option[/]."
tooltip = (
"Start typing an option to show suggestions. Use the right arrow "
"key to complete the suggestion. Hit enter to submit."
)
if self.trigger.startswith("k3"):
if self.tab.startswith("k3s k3s.yaml"):
tooltip += (
"Note: If [dim][#C1FF87]cilium[/][/] is [i]enabled[/], we "
"add flannel-backend: none and disable-network-policy: true."
)
suggestions = K3S_SUGGESTIONS
elif "network" in self.trigger:
elif "network" in self.tab:
tooltip += ("Note: If [dim][#C1FF87]cilium[/][/] is [i]enabled[/],"
"we pass in disableDefaultCNI=true.")
suggestions = NETWORKING_SUGGESTIONS
elif "kubelet" in self.trigger:
elif "kubelet" in self.tab:
suggestions = KUBELET_SUGGESTIONS

with Grid(id="new-option-modal-screen"):
Expand All @@ -147,7 +149,7 @@ def compose(self) -> ComposeResult:

with Grid(id='new-option-grid'):
input = Input(id='new-option-input',
placeholder=f"new {self.trigger} option",
placeholder=f"new {self.tab} option",
suggester=suggestions,
validators=[
Length(minimum=4),
Expand Down

0 comments on commit 7a5d73c

Please sign in to comment.