Run linters and fixers
continuous-integration/drone/push Build is failing Details

This commit is contained in:
IamTheFij 2022-11-04 15:18:50 -07:00
parent dd23da80ee
commit 6a28cf96a8
9 changed files with 32 additions and 32 deletions

View File

@ -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{},

View File

@ -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") {

View File

@ -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{},

View File

@ -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"`
}

View File

@ -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

View File

@ -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 {

View File

@ -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)

View File

@ -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

View File

@ -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"},