1
0
mirror of https://github.com/offen/docker-volume-backup.git synced 2025-11-23 21:44:40 +02:00

Cleanup: Lint warnings and deprecated packages (#263)

* Fix lint warnings and std lib deprecations

* Replace deprecated std lib with maintained drop-in replacement fork

Backwartds compatible with original package and suggested by std lib due to security and stability issues.

* OAuth2 is now a direct dependency due to Dropbox

* Undo change

* Revert "Replace deprecated std lib with maintained drop-in replacement fork"

This reverts commit 2887bd409f.

* Update channel handling

* Add linter for PRs

* Rename CI, fetch all issues, add govet
This commit is contained in:
MaxJa4
2023-08-27 18:14:55 +02:00
committed by GitHub
parent 3d7677f02a
commit 5fcc96edf9
10 changed files with 97 additions and 20 deletions

View File

@@ -7,7 +7,6 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"os"
"regexp"
"strconv"
@@ -115,7 +114,7 @@ func (c *CertDecoder) Decode(v string) error {
if v == "" {
return nil
}
content, err := ioutil.ReadFile(v)
content, err := os.ReadFile(v)
if err != nil {
content = []byte(v)
}

View File

@@ -10,7 +10,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"os"
"strings"
@@ -51,19 +51,15 @@ func (s *script) exec(containerRef string, command string, user string) ([]byte,
outputDone <- err
}()
select {
case err := <-outputDone:
if err != nil {
return nil, nil, fmt.Errorf("exec: error demultiplexing output: %w", err)
}
break
if <-outputDone != nil {
return nil, nil, fmt.Errorf("exec: error demultiplexing output: %w", err)
}
stdout, err := ioutil.ReadAll(&outBuf)
stdout, err := io.ReadAll(&outBuf)
if err != nil {
return nil, nil, fmt.Errorf("exec: error reading stdout: %w", err)
}
stderr, err := ioutil.ReadAll(&errBuf)
stderr, err := io.ReadAll(&errBuf)
if err != nil {
return nil, nil, fmt.Errorf("exec: error reading stderr: %w", err)
}
@@ -152,9 +148,9 @@ func (s *script) runLabeledCommands(label string) error {
g.Go(func() error {
cmd, ok := c.Labels[label]
if !ok && label == "docker-volume-backup.archive-pre" {
cmd, _ = c.Labels["docker-volume-backup.exec-pre"]
cmd = c.Labels["docker-volume-backup.exec-pre"]
} else if !ok && label == "docker-volume-backup.archive-post" {
cmd, _ = c.Labels["docker-volume-backup.exec-post"]
cmd = c.Labels["docker-volume-backup.exec-post"]
}
userLabelName := fmt.Sprintf("%s.user", label)

View File

@@ -18,7 +18,7 @@ import (
func (s *script) lock(lockfile string) (func() error, error) {
start := time.Now()
defer func() {
s.stats.LockedTime = time.Now().Sub(start)
s.stats.LockedTime = time.Since(start)
}()
retry := time.NewTicker(5 * time.Second)

View File

@@ -15,7 +15,7 @@ func main() {
}
unlock, err := s.lock("/var/lock/dockervolumebackup.lock")
defer unlock()
defer s.must(unlock())
s.must(err)
defer func() {
@@ -34,7 +34,6 @@ func main() {
if err := s.runHooks(nil); err != nil {
s.logger.Error(
fmt.Sprintf(
"Backup procedure ran successfully, but an error ocurred calling the registered hooks: %v",
err,
),

View File

@@ -25,6 +25,7 @@ import (
"github.com/offen/docker-volume-backup/internal/storage/ssh"
"github.com/offen/docker-volume-backup/internal/storage/webdav"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/containrrr/shoutrrr"
"github.com/containrrr/shoutrrr/pkg/router"
"github.com/docker/docker/api/types"
@@ -35,7 +36,6 @@ import (
"github.com/kelseyhightower/envconfig"
"github.com/leekchan/timeutil"
"github.com/otiai10/copy"
"golang.org/x/crypto/openpgp"
"golang.org/x/sync/errgroup"
)