Skip to content

Commit

Permalink
use a meaningful description for each bash command
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Hurst committed Sep 12, 2024
1 parent 1451bc3 commit 3bc9295
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions internal/cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,22 +1108,28 @@ func gatherPostgresLogsAndConfigs(ctx context.Context,
}

// We will execute several bash commands in the DB container
commands := []string{
"pg_controldata",
"df -h /pgdata",
"du -h /pgdata | expand",
"df -h /pgwal",
"du -h /pgwal | expand",
"df -h /tablespaces",
"du -h /tablespaces | expand",
"ls /pg*/pg*_wal/archive_status/* | grep -E '*.ready' | wc",
"ls /pg*/pg*_wal/archive_status/* | grep -E '*.done' | wc",
// text is command to execute and desc is a short description
type Command struct {
text string
desc string
}

commands := []Command{
{text: "pg_controldata", desc: "pg_controldata"},
{text: "df -h /pgdata", desc: "df /pgdata"},
{text: "du -h /pgdata | expand", desc: "du /pgdata"},
{text: "df -h /pgwal", desc: "df /pgwal"},
{text: "du -h /pgwal | expand", desc: "du /pgwal"},
{text: "df -h /tablespaces", desc: "df /tablespaces"},
{text: "du -h /tablespaces | expand", desc: "du /tablespaces"},
{text: "ls /pg*/pg*_wal/archive_status/* | grep -E '*.ready' | wc", desc: "archive_status/*.ready files"},
{text: "ls /pg*/pg*_wal/archive_status/* | grep -E '*.done' | wc", desc: "archive_status/*.done files"},
}

var buf bytes.Buffer

for _, command := range commands {
stdout, stderr, err := Executor(exec).bashCommand(command)
stdout, stderr, err := Executor(exec).bashCommand(command.text)
if err != nil {
if apierrors.IsForbidden(err) {
writeInfo(cmd, err.Error())
Expand All @@ -1134,7 +1140,7 @@ func gatherPostgresLogsAndConfigs(ctx context.Context,
writeDebug(cmd, "This is acceptable in some configurations.\n")
continue
}
buf.Write([]byte(fmt.Sprintf("%s\n", command)))
buf.Write([]byte(fmt.Sprintf("%s\n", command.desc)))
buf.Write([]byte(stdout))
if stderr != "" {
buf.Write([]byte(stderr))
Expand Down

0 comments on commit 3bc9295

Please sign in to comment.