diff --git a/job_test.go b/job_test.go index 44d5620..9ea06fe 100644 --- a/job_test.go +++ b/job_test.go @@ -27,12 +27,12 @@ func TestResticConfigValidate(t *testing.T) { { name: "missing passphrase", expectedErr: main.ErrMutuallyExclusive, - config: main.ResticConfig{}, // nolint:exhaustivestruct + config: main.ResticConfig{}, //nolint:exhaustivestruct }, { name: "passphrase no file", expectedErr: nil, - // nolint:exhaustivestruct + //nolint:exhaustivestruct config: main.ResticConfig{ Passphrase: "shh", }, @@ -40,7 +40,7 @@ func TestResticConfigValidate(t *testing.T) { { name: "file no passphrase", expectedErr: nil, - // nolint:exhaustivestruct + //nolint:exhaustivestruct config: main.ResticConfig{ GlobalOpts: &main.ResticGlobalOpts{ PasswordFile: "file", @@ -50,7 +50,7 @@ func TestResticConfigValidate(t *testing.T) { { name: "file and passphrase", expectedErr: main.ErrMutuallyExclusive, - // nolint:exhaustivestruct + //nolint:exhaustivestruct config: main.ResticConfig{ Passphrase: "shh", GlobalOpts: &main.ResticGlobalOpts{ @@ -89,7 +89,7 @@ func TestJobValidation(t *testing.T) { Schedule: "@daily", Config: ValidResticConfig(), Tasks: []main.JobTask{}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct Forget: nil, MySQL: []main.JobTaskMySQL{}, Sqlite: []main.JobTaskSqlite{}, @@ -103,7 +103,7 @@ func TestJobValidation(t *testing.T) { Schedule: "@daily", Config: ValidResticConfig(), Tasks: []main.JobTask{}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct Forget: nil, MySQL: []main.JobTaskMySQL{}, Sqlite: []main.JobTaskSqlite{}, @@ -117,7 +117,7 @@ func TestJobValidation(t *testing.T) { Schedule: "shrug", Config: ValidResticConfig(), Tasks: []main.JobTask{}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct Forget: nil, MySQL: []main.JobTaskMySQL{}, Sqlite: []main.JobTaskSqlite{}, @@ -129,9 +129,9 @@ func TestJobValidation(t *testing.T) { job: main.Job{ Name: "Test job", Schedule: "@daily", - Config: main.ResticConfig{}, // nolint:exhaustivestruct + Config: main.ResticConfig{}, //nolint:exhaustivestruct Tasks: []main.JobTask{}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct Forget: nil, MySQL: []main.JobTaskMySQL{}, Sqlite: []main.JobTaskSqlite{}, @@ -145,7 +145,7 @@ func TestJobValidation(t *testing.T) { Schedule: "@daily", Config: ValidResticConfig(), Tasks: []main.JobTask{{}}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct Forget: nil, MySQL: []main.JobTaskMySQL{}, Sqlite: []main.JobTaskSqlite{}, @@ -159,7 +159,7 @@ func TestJobValidation(t *testing.T) { Schedule: "@daily", Config: ValidResticConfig(), Tasks: []main.JobTask{}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct Forget: nil, MySQL: []main.JobTaskMySQL{{}}, Sqlite: []main.JobTaskSqlite{}, @@ -173,7 +173,7 @@ func TestJobValidation(t *testing.T) { Schedule: "@daily", Config: ValidResticConfig(), Tasks: []main.JobTask{}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct Forget: nil, MySQL: []main.JobTaskMySQL{}, Sqlite: []main.JobTaskSqlite{{}}, @@ -212,7 +212,7 @@ func TestConfigValidation(t *testing.T) { Schedule: "@daily", Config: ValidResticConfig(), Tasks: []main.JobTask{}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct MySQL: []main.JobTaskMySQL{}, Sqlite: []main.JobTaskSqlite{}, }}}, @@ -230,7 +230,7 @@ func TestConfigValidation(t *testing.T) { Schedule: "@daily", Config: ValidResticConfig(), Tasks: []main.JobTask{}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct Forget: nil, MySQL: []main.JobTaskMySQL{}, Sqlite: []main.JobTaskSqlite{}, diff --git a/main.go b/main.go index e25cbdd..b7cb4a8 100644 --- a/main.go +++ b/main.go @@ -110,7 +110,7 @@ func NewSetFrom(l []string) Set { return s } -/// FilterJobs filters a list of jobs by a list of names +// FilterJobs filters a list of jobs by a list of names. func FilterJobs(jobs []Job, names []string) ([]Job, error) { nameSet := NewSetFrom(names) if nameSet.Contains("all") { diff --git a/main_test.go b/main_test.go index 17bdedc..343a281 100644 --- a/main_test.go +++ b/main_test.go @@ -49,7 +49,7 @@ func TestRunJobs(t *testing.T) { Schedule: "@daily", Config: ValidResticConfig(), Tasks: []main.JobTask{}, - Backup: main.BackupFilesTask{Paths: []string{"/test"}}, // nolint:exhaustivestruct + Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct Forget: nil, MySQL: []main.JobTaskMySQL{}, Sqlite: []main.JobTaskSqlite{}, diff --git a/restic.go b/restic.go index 04fd434..0d401d8 100644 --- a/restic.go +++ b/restic.go @@ -335,7 +335,7 @@ type Snapshot struct { Hostname string `json:"hostname"` Username string `json:"username"` ID string `json:"id"` - ShortID string `json:"short_id"` // nolint:tagliatelle + ShortID string `json:"short_id"` //nolint:tagliatelle Paths []string `json:"paths"` Tags []string `json:"tags,omitempty"` } diff --git a/restic_test.go b/restic_test.go index 2adeb42..7430ae0 100644 --- a/restic_test.go +++ b/restic_test.go @@ -160,19 +160,19 @@ func TestBuildEnv(t *testing.T) { }{ { name: "No Env", - cmd: main.Restic{}, // nolint:exhaustivestruct + cmd: main.Restic{}, //nolint:exhaustivestruct expected: os.Environ(), }, { name: "SetEnv", - cmd: main.Restic{ // nolint:exhaustivestruct + cmd: main.Restic{ //nolint:exhaustivestruct Env: map[string]string{"TestKey": "Value"}, }, expected: append(os.Environ(), "TestKey=Value"), }, { name: "SetEnv", - cmd: main.Restic{ // nolint:exhaustivestruct + cmd: main.Restic{ //nolint:exhaustivestruct Passphrase: "Shhhhhhhh!!", }, expected: append(os.Environ(), "RESTIC_PASSWORD=Shhhhhhhh!!"), @@ -210,7 +210,7 @@ func TestResticInterface(t *testing.T) { Repo: repoDir, Env: map[string]string{}, Passphrase: "Correct.Horse.Battery.Staple", - // nolint:exhaustivestruct + //nolint:exhaustivestruct GlobalOpts: &main.ResticGlobalOpts{ CacheDir: cacheDir, Options: map[string]string{ @@ -231,7 +231,7 @@ func TestResticInterface(t *testing.T) { } // Try to backup when repo is not initialized - err = restic.Backup([]string{dataDir}, main.BackupOpts{}) // nolint:exhaustivestruct + err = restic.Backup([]string{dataDir}, main.BackupOpts{}) //nolint:exhaustivestruct if !errors.Is(err, main.ErrRepoNotFound) { AssertEqualFail(t, "unexpected error creating making backup", nil, err) } @@ -245,7 +245,7 @@ func TestResticInterface(t *testing.T) { AssertEqualFail(t, "unexpected error reinitializing repo", nil, err) // Backup for real this time - err = restic.Backup([]string{dataDir}, main.BackupOpts{Tags: []string{"test"}}) // nolint:exhaustivestruct + err = restic.Backup([]string{dataDir}, main.BackupOpts{Tags: []string{"test"}}) //nolint:exhaustivestruct AssertEqualFail(t, "unexpected error creating making backup", nil, err) // Check snapshots @@ -259,7 +259,7 @@ func TestResticInterface(t *testing.T) { AssertEqual(t, "unexpected snapshot value: tags", []string{"test"}, snapshots[0].Tags) // Backup again - err = restic.Backup([]string{dataDir}, main.BackupOpts{}) // nolint:exhaustivestruct + err = restic.Backup([]string{dataDir}, main.BackupOpts{}) //nolint:exhaustivestruct AssertEqualFail(t, "unexpected error creating making second backup", nil, err) // Check for second backup @@ -268,7 +268,7 @@ func TestResticInterface(t *testing.T) { AssertEqual(t, "unexpected number of snapshots", 2, len(snapshots)) // Forget one backup - err = restic.Forget(main.ForgetOpts{KeepLast: 1, Prune: true}) // nolint:exhaustivestruct + err = restic.Forget(main.ForgetOpts{KeepLast: 1, Prune: true}) //nolint:exhaustivestruct AssertEqualFail(t, "unexpected error forgetting snapshot", nil, err) // Check forgotten snapshot @@ -290,7 +290,7 @@ func TestResticInterface(t *testing.T) { AssertEqualFail(t, "incorrect value in test file (we expect the unexpected!)", "unexpected", string(value)) // Restore files - err = restic.Restore("latest", main.RestoreOpts{Target: restoreTarget}) // nolint:exhaustivestruct + err = restic.Restore("latest", main.RestoreOpts{Target: restoreTarget}) //nolint:exhaustivestruct AssertEqualFail(t, "unexpected error restoring latest snapshot", nil, err) // Check restored values diff --git a/scheduler.go b/scheduler.go index 774c37a..f89e266 100644 --- a/scheduler.go +++ b/scheduler.go @@ -69,7 +69,7 @@ func RunHTTPHandlers(addr string) error { http.HandleFunc("/health", healthHandleFunc) http.Handle("/metrics", promhttp.Handler()) - return fmt.Errorf("error on healthcheck: %w", http.ListenAndServe(addr, nil)) + return fmt.Errorf("error on healthcheck: %w", http.ListenAndServe(addr, nil)) //#nosec: g114 } func ScheduleAndRunJobs(jobs []Job) error { diff --git a/shell.go b/shell.go index 7fc1c0b..b0576e5 100644 --- a/shell.go +++ b/shell.go @@ -50,7 +50,7 @@ func (w *CapturedLogWriter) Write(content []byte) (n int, err error) { } func RunShell(script string, cwd string, env map[string]string, logger *log.Logger) error { - cmd := exec.Command("sh", "-c", strings.TrimSpace(script)) // nolint:gosec + cmd := exec.Command("sh", "-c", strings.TrimSpace(script)) //nolint:gosec // Make both stderr and stdout go to logger cmd.Stdout = NewCapturedLogWriter(logger) diff --git a/tasks.go b/tasks.go index ba428a5..5d8e0bf 100644 --- a/tasks.go +++ b/tasks.go @@ -230,7 +230,7 @@ type BackupFilesTask struct { func (t BackupFilesTask) RunBackup(cfg TaskConfig) error { if t.BackupOpts == nil { - t.BackupOpts = &BackupOpts{} // nolint:exhaustivestruct + t.BackupOpts = &BackupOpts{} //nolint:exhaustivestruct } if err := cfg.Restic.Backup(cfg.BackupPaths, *t.BackupOpts); err != nil { @@ -245,7 +245,7 @@ func (t BackupFilesTask) RunBackup(cfg TaskConfig) error { func (t BackupFilesTask) RunRestore(cfg TaskConfig) error { if t.RestoreOpts == nil { - t.RestoreOpts = &RestoreOpts{} // nolint:exhaustivestruct + t.RestoreOpts = &RestoreOpts{} //nolint:exhaustivestruct } // TODO: Make the snapshot configurable diff --git a/tasks_test.go b/tasks_test.go index 8e2a1e1..a79dfff 100644 --- a/tasks_test.go +++ b/tasks_test.go @@ -120,7 +120,7 @@ func TestJobTaskSql(t *testing.T) { }{ { name: "mysql simple", - // nolint:exhaustivestruct + //nolint:exhaustivestruct task: main.JobTaskMySQL{ Name: "simple", DumpToPath: "./simple.sql", @@ -133,7 +133,7 @@ func TestJobTaskSql(t *testing.T) { }, { name: "mysql tables no database", - // nolint:exhaustivestruct + //nolint:exhaustivestruct task: main.JobTaskMySQL{ Name: "name", Tables: []string{"table1", "table2"},