mirror of
https://github.com/skoelle/kctl-tui.git
synced 2026-09-18 04:20:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26b5754f60 | ||
|
|
76a389f52d | ||
|
|
73b38ef52c | ||
|
|
c10b553b48 |
+10
-3
@@ -230,6 +230,11 @@ func (m *fullModel) loadNamespacesFor(teamValue string) tea.Cmd {
|
|||||||
// startTmuxSession builds the 3-pane tmux command (control pane running
|
// startTmuxSession builds the 3-pane tmux command (control pane running
|
||||||
// this binary in "panel" mode, plus two k9s status panes) and runs it via
|
// this binary in "panel" mode, plus two k9s status panes) and runs it via
|
||||||
// tea.ExecProcess so the Bubble Tea UI cleanly hands over the terminal.
|
// tea.ExecProcess so the Bubble Tea UI cleanly hands over the terminal.
|
||||||
|
//
|
||||||
|
// Layout: even-vertical stacks all three panes evenly from top to bottom
|
||||||
|
// (control pane, then the two k9s status panes). remain-on-exit keeps a
|
||||||
|
// pane visible (showing its exit status/output) instead of tmux silently
|
||||||
|
// closing it if the control pane's process crashes on startup.
|
||||||
func (m *fullModel) startTmuxSession() tea.Cmd {
|
func (m *fullModel) startTmuxSession() tea.Cmd {
|
||||||
selfPath := "kctl-tui" // resolved via PATH; see README for install instructions
|
selfPath := "kctl-tui" // resolved via PATH; see README for install instructions
|
||||||
panelCmd := fmt.Sprintf("%s panel --ctx=%s --ns=%s --team=%s",
|
panelCmd := fmt.Sprintf("%s panel --ctx=%s --ns=%s --team=%s",
|
||||||
@@ -244,9 +249,11 @@ func (m *fullModel) startTmuxSession() tea.Cmd {
|
|||||||
|
|
||||||
c := exec.Command("tmux", "new-session", "-d", "-s", "kctl",
|
c := exec.Command("tmux", "new-session", "-d", "-s", "kctl",
|
||||||
panelCmd, ";",
|
panelCmd, ";",
|
||||||
"split-window", "-v", k9sCmdA, ";",
|
"set-option", "-t", "kctl", "remain-on-exit", "on", ";",
|
||||||
"split-window", "-v", k9sCmdB, ";",
|
"split-window", "-v", "-t", "kctl:0.0", k9sCmdA, ";",
|
||||||
"select-layout", "main-horizontal", ";",
|
"split-window", "-v", "-t", "kctl:0.1", k9sCmdB, ";",
|
||||||
|
"select-layout", "-t", "kctl", "even-vertical", ";",
|
||||||
|
"select-pane", "-t", "kctl:0.0", ";",
|
||||||
"attach", "-t", "kctl",
|
"attach", "-t", "kctl",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+40
-3
@@ -37,13 +37,50 @@ case "$os" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
echo "Detecting latest release for $REPO ..."
|
echo "Detecting latest release for $REPO ..."
|
||||||
latest_tag="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep -m1 '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')"
|
|
||||||
|
|
||||||
if [ -z "$latest_tag" ]; then
|
release_json="$(curl -sSL "https://api.github.com/repos/${REPO}/releases/latest")" || {
|
||||||
echo "Could not determine latest release tag. Is there at least one published release?" >&2
|
echo "Failed to reach the GitHub API (network error). Check your internet connection and try again." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Received ${#release_json} bytes from the GitHub API."
|
||||||
|
|
||||||
|
if echo "$release_json" | grep -q '"message"[[:space:]]*:[[:space:]]*"Not Found"'; then
|
||||||
|
echo "" >&2
|
||||||
|
echo "Could not find a published release for ${REPO}." >&2
|
||||||
|
echo "This usually means no release has been tagged yet." >&2
|
||||||
|
echo "" >&2
|
||||||
|
echo "Options:" >&2
|
||||||
|
echo " 1) Ask the maintainer to push a version tag (e.g. 'git tag v0.1.0 && git push origin v0.1.0')," >&2
|
||||||
|
echo " which triggers the release build via GitHub Actions." >&2
|
||||||
|
echo " 2) Build from source instead:" >&2
|
||||||
|
echo " git clone https://github.com/${REPO}.git" >&2
|
||||||
|
echo " cd $(basename "$REPO")" >&2
|
||||||
|
echo " go build -o ${BIN_NAME} ./cmd/${BIN_NAME}" >&2
|
||||||
|
echo " sudo mv ${BIN_NAME} ${INSTALL_DIR}/" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if echo "$release_json" | grep -qi 'rate limit exceeded'; then
|
||||||
|
echo "GitHub API rate limit exceeded. Wait a bit and try again, or authenticate with a GitHub token." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Note: '|| true' below prevents 'set -o pipefail' + 'set -e' from aborting the
|
||||||
|
# script silently if grep finds no match; the emptiness check right after
|
||||||
|
# gives a proper diagnostic instead.
|
||||||
|
latest_tag="$(echo "$release_json" | grep -m1 '"tag_name"' | sed -E 's/.*"tag_name"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')" || true
|
||||||
|
|
||||||
|
if [ -z "$latest_tag" ]; then
|
||||||
|
echo "Could not parse the latest release tag from the GitHub API response." >&2
|
||||||
|
echo "Raw response (truncated):" >&2
|
||||||
|
echo "$release_json" | head -c 800 >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Latest release tag: ${latest_tag}"
|
||||||
|
|
||||||
asset="kctl-tui-${os}-${arch}"
|
asset="kctl-tui-${os}-${arch}"
|
||||||
url="https://github.com/${REPO}/releases/download/${latest_tag}/${asset}"
|
url="https://github.com/${REPO}/releases/download/${latest_tag}/${asset}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user