Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 47 additions & 24 deletions kamal.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

// actionItem describes one action available in the main menu.
type actionItem struct {
key string
title string
desc string
needsVersion bool // rollback needs a version/commit hash typed in
Expand All @@ -29,34 +30,31 @@ func (a actionItem) FilterValue() string { return a.title }
func actions() []actionItem {
return []actionItem{
{
key: "d",
title: "󰚰 Deploy",
desc: "kamal deploy -d <destination>",
buildArgs: func(dest, _ string) []string {
return withDest([]string{"deploy"}, dest)
},
},
{
key: "U",
title: "󰒓 Setup",
desc: "kamal setup -d <destination> (provision servers & deploy)",
buildArgs: func(dest, _ string) []string {
return withDest([]string{"setup"}, dest)
},
},
{
title: "󰈙 Env Push",
desc: "kamal env push -d <destination> (push .env variables to servers)",
buildArgs: func(dest, _ string) []string {
return withDest([]string{"env", "push"}, dest)
},
},
{
key: "R",
title: "󰑙 Redeploy",
desc: "kamal redeploy -d <destination> (skip build cache invalidation steps)",
desc: "kamal redeploy -d <destination>",
buildArgs: func(dest, _ string) []string {
return withDest([]string{"redeploy"}, dest)
},
},
{
key: "r",
title: "󰁯 Rollback",
desc: "kamal rollback <version> -d <destination>",
needsVersion: true,
Expand All @@ -66,54 +64,69 @@ func actions() []actionItem {
},
},
{
title: "󰆼 DB Dump (Backup)",
desc: "kamal app exec -i -- /bin/sh -c 'pg_dump ...'",
buildArgs: func(dest, _ string) []string {
args := []string{"app", "exec", "-i"}
args = withDest(args, dest)
args = append(args, "--", "/bin/sh", "-c", "pg_dump $DATABASE_URL -F c > /tmp/db.dump")
return args
},
},
{
title: "󰗨 DB Restore",
desc: "kamal app exec -i -- /bin/sh -c 'pg_restore ...'",
key: "e",
title: "󰈙 Env Push",
desc: "kamal env push -d <destination> (push .env variables to servers)",
buildArgs: func(dest, _ string) []string {
args := []string{"app", "exec", "-i"}
args = withDest(args, dest)
args = append(args, "--", "/bin/sh", "-c", "pg_restore -d $DATABASE_URL --clean --no-owner /tmp/db.dump")
return args
return withDest([]string{"env", "push"}, dest)
},
},
{
key: "A",
title: "󰋩 App Details",
desc: "kamal app details -d <destination>",
buildArgs: func(dest, _ string) []string {
return withDest([]string{"app", "details"}, dest)
},
},
{
key: "l",
title: "󰅩 App Logs",
desc: "kamal app logs -d <destination> (last lines, no follow)",
buildArgs: func(dest, _ string) []string {
return withDest([]string{"app", "logs"}, dest)
},
},
{
key: "b",
title: "󰀵 App Boot",
desc: "kamal app boot -d <destination>",
buildArgs: func(dest, _ string) []string {
return withDest([]string{"app", "boot"}, dest)
},
},
{
key: "D",
title: "󰆼 DB Dump (Backup)",
desc: "kamal app exec -i -- /bin/sh -c 'pg_dump ...'",
buildArgs: func(dest, _ string) []string {
args := []string{"app", "exec", "-i"}
args = withDest(args, dest)
args = append(args, "--", "/bin/sh", "-c", "pg_dump $DATABASE_URL -F c > /tmp/db.dump")
return args
},
},
{
key: "S",
title: "󰗨 DB Restore",
desc: "kamal app exec -i -- /bin/sh -c 'pg_restore ...'",
buildArgs: func(dest, _ string) []string {
args := []string{"app", "exec", "-i"}
args = withDest(args, dest)
args = append(args, "--", "/bin/sh", "-c", "pg_restore -d $DATABASE_URL --clean --no-owner /tmp/db.dump")
return args
},
},
{
key: "a",
title: "󰚌 Audit",
desc: "kamal audit -d <destination> (recent deploy history)",
buildArgs: func(dest, _ string) []string {
return withDest([]string{"audit"}, dest)
},
},
{
key: "X",
title: "󰆴 Remove",
desc: "kamal remove -d <destination> (remove containers and images from servers)",
buildArgs: func(dest, _ string) []string {
Expand All @@ -123,6 +136,16 @@ func actions() []actionItem {
}
}

// actionByKey finds an action by its shortcut key.
func actionByKey(key string) (actionItem, bool) {
for _, a := range actions() {
if a.key == key {
return a, true
}
}
return actionItem{}, false
}

// withDest appends "-d <dest>" unless dest is the empty/default destination.
func withDest(args []string, dest string) []string {
if dest != "" {
Expand Down
Loading
Loading