mirror of
https://github.com/skoelle/kctl-tui.git
synced 2026-09-17 20:10:24 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
201168e8cd | ||
|
|
ffbf4341fa | ||
|
|
37be0707ad | ||
|
|
9e6acdedc2 | ||
|
|
07662dc9b7 | ||
|
|
38b28f64fb | ||
|
|
6a749811c7 | ||
|
|
313dffcbbf | ||
|
|
8546ac9bf2 |
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Stefan Koelle
|
||||
Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -227,4 +227,4 @@ and untested, since it has no meaningful behavior without a live cluster.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
Licensed under the [MIT License](LICENSE) - Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
|
||||
@@ -75,9 +75,9 @@ Once start navigation is complete, the tool opens a tmux session with
|
||||
| -> runs the kctl-tui binary in "panel" mode |
|
||||
| -> menu: Redeploy, secrets diff |
|
||||
+--------------------------------------------------+
|
||||
| Pane 1 (middle): k9s --context <context-a> -n <ns>|
|
||||
| Pane 1 (middle): k9s --context <context-a> --namespace <ns> --command pods|
|
||||
+--------------------------------------------------+
|
||||
| Pane 2 (bottom): k9s --context <context-b> -n <ns>|
|
||||
| Pane 2 (bottom): k9s --context <context-b> --namespace <ns> --command pods|
|
||||
+--------------------------------------------------+
|
||||
```
|
||||
|
||||
@@ -89,12 +89,13 @@ not cover: **redeploy** and **secrets diff**.
|
||||
Example startup command (generic placeholders):
|
||||
|
||||
```
|
||||
tmux kill-session -t kctl \; \
|
||||
# Kill stale session first (separate command — tmux aborts on kill-session error).
|
||||
tmux kill-session -t kctl
|
||||
tmux new-session -d -s kctl \
|
||||
-- "kctl-tui panel --context=$CTX_A --ns=$NS --team=$TEAM" \; \
|
||||
"kctl-tui panel --context=$CTX_A --ns=$NS --team=$TEAM" \; \
|
||||
set-option -t kctl remain-on-exit on \; \
|
||||
split-window -v -t kctl:0.0 -- "k9s --context $CTX_A -n $NS" \; \
|
||||
split-window -v -t kctl:0.1 -- "k9s --context $CTX_B -n $NS" \; \
|
||||
split-window -v -t kctl:0.0 "k9s --context $CTX_A --namespace $NS --command pods" \; \
|
||||
split-window -v -t kctl:0.1 "k9s --context $CTX_B --namespace $NS --command pods" \; \
|
||||
select-layout -t kctl even-vertical \; \
|
||||
select-pane -t kctl:0.0 \; \
|
||||
attach -t kctl
|
||||
|
||||
+31
-16
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -275,31 +278,43 @@ func (m *fullModel) startTmuxSession() tea.Cmd {
|
||||
|
||||
envA := m.cfg.Envs[0]
|
||||
ctxA := m.cfg.ResolveContext(envA, m.selectedContext)
|
||||
k9sCmdA := fmt.Sprintf("k9s --context %s -n %s", ctxA, m.selectedNamespace)
|
||||
k9sCmdA := fmt.Sprintf("k9s --context %s --namespace %s --command pods", ctxA, m.selectedNamespace)
|
||||
|
||||
args := []string{
|
||||
"kill-session", "-t", "kctl", ";", // ignore error if no session exists
|
||||
"new-session", "-d", "-s", "kctl",
|
||||
"--", panelCmd, ";",
|
||||
"set-option", "-t", "kctl", "remain-on-exit", "on", ";",
|
||||
"split-window", "-v", "-t", "kctl:0.0", "--", k9sCmdA, ";",
|
||||
kubeexec.VerboseLog("[debug] selfPath=%s\n", selfPath)
|
||||
kubeexec.VerboseLog("[debug] panelCmd=%s\n", panelCmd)
|
||||
kubeexec.VerboseLog("[debug] k9sCmdA=%s\n", k9sCmdA)
|
||||
|
||||
// Kill stale session first (ignore error if none exists).
|
||||
exec.Command("tmux", "kill-session", "-t", "kctl").Run()
|
||||
|
||||
// Run setup commands individually — this avoids the ; separator
|
||||
// issue on Windows where psmux doesn't handle chained args.
|
||||
setup := [][]string{
|
||||
{"new-session", "-d", "-s", "kctl", panelCmd},
|
||||
{"set-option", "-t", "kctl", "remain-on-exit", "on"},
|
||||
{"split-window", "-v", "-t", "kctl:0.0", k9sCmdA},
|
||||
}
|
||||
if len(m.cfg.Envs) > 1 {
|
||||
envB := m.cfg.Envs[1]
|
||||
ctxB := m.cfg.ResolveContext(envB, m.selectedContext)
|
||||
k9sCmdB := fmt.Sprintf("k9s --context %s -n %s", ctxB, m.selectedNamespace)
|
||||
args = append(args,
|
||||
"split-window", "-v", "-t", "kctl:0.1", "--", k9sCmdB, ";",
|
||||
)
|
||||
k9sCmdB := fmt.Sprintf("k9s --context %s --namespace %s --command pods", ctxB, m.selectedNamespace)
|
||||
kubeexec.VerboseLog("[debug] k9sCmdB=%s\n", k9sCmdB)
|
||||
setup = append(setup, []string{"split-window", "-v", "-t", "kctl:0.1", k9sCmdB})
|
||||
}
|
||||
args = append(args,
|
||||
"select-layout", "-t", "kctl", "even-vertical", ";",
|
||||
"select-pane", "-t", "kctl:0.0", ";",
|
||||
"attach", "-t", "kctl",
|
||||
setup = append(setup,
|
||||
[]string{"select-layout", "-t", "kctl", "even-vertical"},
|
||||
[]string{"select-pane", "-t", "kctl:0.0"},
|
||||
)
|
||||
|
||||
c := exec.Command("tmux", args...)
|
||||
for _, args := range setup {
|
||||
if out, err := exec.Command("tmux", args...).CombinedOutput(); err != nil {
|
||||
kubeexec.VerboseLog("[debug] tmux %s failed: %v\n%s\n", args[0], err, out)
|
||||
return func() tea.Msg { return tmuxDoneMsg{err: fmt.Errorf("tmux %s: %w", args[0], err)} }
|
||||
}
|
||||
}
|
||||
|
||||
// Only attach uses tea.ExecProcess so it takes over the terminal.
|
||||
c := exec.Command("tmux", "attach", "-t", "kctl")
|
||||
return tea.ExecProcess(c, func(err error) tea.Msg {
|
||||
return tmuxDoneMsg{err: err}
|
||||
})
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/skoelle/kctl-tui/internal/kctl"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package main
|
||||
|
||||
// simpleItem is a minimal implementation of list.Item used for all
|
||||
|
||||
+12
-4
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -37,11 +40,12 @@ func main() {
|
||||
kubeexec.SetVerbose(true, os.Stderr)
|
||||
}
|
||||
|
||||
if showHelp || len(filtered) == 0 {
|
||||
if showHelp {
|
||||
printUsage()
|
||||
if showHelp && len(filtered) == 0 {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
if len(filtered) == 0 {
|
||||
// No subcommand — start the full TUI.
|
||||
}
|
||||
|
||||
if len(filtered) > 0 {
|
||||
@@ -64,6 +68,10 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
return
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "unknown command: %s\n\n", filtered[0])
|
||||
printUsage()
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
# Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
# Install script for kctl-tui.
|
||||
# Downloads the latest GitHub release binary matching the current OS/arch
|
||||
# and installs it to /usr/local/bin (or $INSTALL_DIR if set).
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
// Package config loads the user-specific, non-versioned kctl-tui
|
||||
// configuration (contexts, envs, templates) from a YAML file.
|
||||
package config
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package kctl
|
||||
|
||||
import "sort"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package kctl
|
||||
|
||||
import "testing"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package kctl
|
||||
|
||||
import "sort"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package kctl
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package kctl
|
||||
|
||||
import "strings"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package kctl
|
||||
|
||||
import "testing"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
// Package kubeexec wraps kubectl/aws-cli invocations used by kctl-tui.
|
||||
// All functions here have side effects (they run external processes) and
|
||||
// are therefore not covered by unit tests; the pure logic they depend on
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
||||
// Licensed under the MIT License. See LICENSE file in project root for details.
|
||||
|
||||
package kubeexec
|
||||
|
||||
import (
|
||||
@@ -26,6 +29,16 @@ func SetVerbose(enabled bool, w io.Writer) {
|
||||
}
|
||||
}
|
||||
|
||||
// VerboseLog writes a message to the verbose log if enabled.
|
||||
func VerboseLog(format string, args ...interface{}) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if !verbose {
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(logOut, format, args...)
|
||||
}
|
||||
|
||||
func logCmd(name string, args ...string) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user