Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Aug 31, 2023
1 parent cf3712c commit 015c4d3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
"net/http"

"github.com/gorilla/mux"
"github.com/sapcc/go-bits/httpapi"
"github.com/sapcc/go-bits/respondwith"

"github.com/sapcc/backup-tools/internal/backup"
"github.com/sapcc/backup-tools/internal/core"
"github.com/sapcc/backup-tools/internal/restore"
"github.com/sapcc/go-bits/httpapi"
"github.com/sapcc/go-bits/respondwith"
)

// API contains the HTTP request handlers for the backup-server.
Expand Down
7 changes: 4 additions & 3 deletions internal/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import (
"github.com/kballard/go-shellquote"
"github.com/majewsky/schwift"
"github.com/prometheus/client_golang/prometheus"
"github.com/sapcc/backup-tools/internal/core"
"github.com/sapcc/go-bits/logg"

"github.com/sapcc/backup-tools/internal/core"
)

var backupLastSuccessGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Expand Down Expand Up @@ -68,7 +69,7 @@ func Create(cfg *core.Configuration, reason string) (nowTime time.Time, returned

//enumerate databases that need to be backed up
query := `SELECT datname FROM pg_database WHERE datname !~ '^template|^postgres$'`
cmd := exec.Command("psql", cfg.ArgsForPsql("-t", "-c", query)...)
cmd := exec.Command("psql", cfg.ArgsForPsql("-t", "-c", query)...) //nolint:gosec // input is user supplied and self executed
logg.Info(">> " + shellquote.Join(cmd.Args...))
cmd.Stderr = os.Stderr
output, err := cmd.Output()
Expand All @@ -94,7 +95,7 @@ func Create(cfg *core.Configuration, reason string) (nowTime time.Time, returned
errChan := make(chan error, 1) //must be buffered to ensure that `pipewriter.Close()` runs immediately
go func() {
defer pipeWriter.Close()
cmd := exec.CommandContext(ctx, "pg_dump",
cmd := exec.CommandContext(ctx, "pg_dump", //nolint:gosec // input is user supplied and self executed
"-h", cfg.PgHostname, "-U", cfg.PgUsername, //NOTE: PGPASSWORD comes via inherited env variable
"-c", "--if-exist", "-C", "-Z", "5", databaseName)
logg.Info(">> " + shellquote.Join(cmd.Args...))
Expand Down
1 change: 1 addition & 0 deletions internal/backup/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"time"

"github.com/majewsky/schwift"

"github.com/sapcc/backup-tools/internal/core"
)

Expand Down
5 changes: 3 additions & 2 deletions internal/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import (
"os/exec"

"github.com/kballard/go-shellquote"
"github.com/sapcc/backup-tools/internal/core"
"github.com/sapcc/go-bits/logg"

"github.com/sapcc/backup-tools/internal/core"
)

// Restore downloads and restores this backup into the Postgres.
Expand All @@ -44,7 +45,7 @@ func (bkp RestorableBackup) Restore(cfg *core.Configuration) error {

//playback dumps
for _, filePath := range filePaths {
cmd := exec.Command("psql", cfg.ArgsForPsql("-a", "-f", filePath)...)
cmd := exec.Command("psql", cfg.ArgsForPsql("-a", "-f", filePath)...) //nolint:gosec // input is user supplied and self executed
logg.Info(">> " + shellquote.Join(cmd.Args...))
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down
2 changes: 1 addition & 1 deletion internal/restore/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (bkp RestorableBackup) downloadOneFile(dirPath, databaseName string, cfg *c
return "", err
}
defer writer.Close()
_, err = io.Copy(writer, gzipReader)
_, err = io.Copy(writer, gzipReader) //nolint:gosec // the archive is created by us and we must extract it completely
if err != nil {
return "", fmt.Errorf("could not ungzip %s: %w", obj.Name(), err)
}
Expand Down

0 comments on commit 015c4d3

Please sign in to comment.