mirror of
https://github.com/skoelle/kctl-tui.git
synced 2026-09-18 12:30:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
201168e8cd | ||
|
|
ffbf4341fa |
@@ -75,9 +75,9 @@ Once start navigation is complete, the tool opens a tmux session with
|
|||||||
| -> runs the kctl-tui binary in "panel" mode |
|
| -> runs the kctl-tui binary in "panel" mode |
|
||||||
| -> menu: Redeploy, secrets diff |
|
| -> 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|
|
||||||
+--------------------------------------------------+
|
+--------------------------------------------------+
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -94,8 +94,8 @@ tmux kill-session -t kctl
|
|||||||
tmux new-session -d -s 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 \; \
|
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.0 "k9s --context $CTX_A --namespace $NS --command pods" \; \
|
||||||
split-window -v -t kctl:0.1 "k9s --context $CTX_B -n $NS" \; \
|
split-window -v -t kctl:0.1 "k9s --context $CTX_B --namespace $NS --command pods" \; \
|
||||||
select-layout -t kctl even-vertical \; \
|
select-layout -t kctl even-vertical \; \
|
||||||
select-pane -t kctl:0.0 \; \
|
select-pane -t kctl:0.0 \; \
|
||||||
attach -t kctl
|
attach -t kctl
|
||||||
|
|||||||
@@ -278,10 +278,11 @@ func (m *fullModel) startTmuxSession() tea.Cmd {
|
|||||||
|
|
||||||
envA := m.cfg.Envs[0]
|
envA := m.cfg.Envs[0]
|
||||||
ctxA := m.cfg.ResolveContext(envA, m.selectedContext)
|
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)
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "[debug] selfPath=%s\n", selfPath)
|
kubeexec.VerboseLog("[debug] selfPath=%s\n", selfPath)
|
||||||
fmt.Fprintf(os.Stderr, "[debug] panelCmd=%s\n", panelCmd)
|
kubeexec.VerboseLog("[debug] panelCmd=%s\n", panelCmd)
|
||||||
|
kubeexec.VerboseLog("[debug] k9sCmdA=%s\n", k9sCmdA)
|
||||||
|
|
||||||
// Kill stale session first (ignore error if none exists).
|
// Kill stale session first (ignore error if none exists).
|
||||||
exec.Command("tmux", "kill-session", "-t", "kctl").Run()
|
exec.Command("tmux", "kill-session", "-t", "kctl").Run()
|
||||||
@@ -296,7 +297,8 @@ func (m *fullModel) startTmuxSession() tea.Cmd {
|
|||||||
if len(m.cfg.Envs) > 1 {
|
if len(m.cfg.Envs) > 1 {
|
||||||
envB := m.cfg.Envs[1]
|
envB := m.cfg.Envs[1]
|
||||||
ctxB := m.cfg.ResolveContext(envB, m.selectedContext)
|
ctxB := m.cfg.ResolveContext(envB, m.selectedContext)
|
||||||
k9sCmdB := fmt.Sprintf("k9s --context %s -n %s", ctxB, m.selectedNamespace)
|
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})
|
setup = append(setup, []string{"split-window", "-v", "-t", "kctl:0.1", k9sCmdB})
|
||||||
}
|
}
|
||||||
setup = append(setup,
|
setup = append(setup,
|
||||||
@@ -306,13 +308,12 @@ func (m *fullModel) startTmuxSession() tea.Cmd {
|
|||||||
|
|
||||||
for _, args := range setup {
|
for _, args := range setup {
|
||||||
if out, err := exec.Command("tmux", args...).CombinedOutput(); err != nil {
|
if out, err := exec.Command("tmux", args...).CombinedOutput(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "[debug] tmux %s failed: %v\n%s\n", args[0], err, out)
|
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)} }
|
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.
|
// Only attach uses tea.ExecProcess so it takes over the terminal.
|
||||||
fmt.Fprintf(os.Stderr, "[debug] tmux attach -t kctl\n")
|
|
||||||
c := exec.Command("tmux", "attach", "-t", "kctl")
|
c := exec.Command("tmux", "attach", "-t", "kctl")
|
||||||
return tea.ExecProcess(c, func(err error) tea.Msg {
|
return tea.ExecProcess(c, func(err error) tea.Msg {
|
||||||
return tmuxDoneMsg{err: err}
|
return tmuxDoneMsg{err: err}
|
||||||
|
|||||||
@@ -29,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) {
|
func logCmd(name string, args ...string) {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user