mirror of
https://github.com/offen/docker-volume-backup.git
synced 2024-11-10 00:30:29 +01:00
Fix lint warnings and std lib deprecations
This commit is contained in:
parent
3d7677f02a
commit
548d741f03
@ -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)
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -57,13 +57,14 @@ func (s *script) exec(containerRef string, command string, user string) ([]byte,
|
||||
return nil, nil, fmt.Errorf("exec: error demultiplexing output: %w", err)
|
||||
}
|
||||
break
|
||||
default:
|
||||
}
|
||||
|
||||
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 +153,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)
|
||||
|
@ -15,10 +15,12 @@ import (
|
||||
// caller invokes the returned release func. In case the lock is currently blocked
|
||||
// by another execution, it will repeatedly retry until the lock is available
|
||||
// or the given timeout is exceeded.
|
||||
//
|
||||
//lint:ignore U1000 Keep unused function
|
||||
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)
|
||||
|
@ -53,6 +53,7 @@ type script struct {
|
||||
file string
|
||||
stats *Stats
|
||||
|
||||
//lint:ignore U1000 used in lock.go
|
||||
encounteredLock bool
|
||||
|
||||
c *Config
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@ -46,7 +45,7 @@ func NewStorageBackend(opts Config, logFunc storage.Log) (storage.Backend, error
|
||||
}
|
||||
|
||||
if _, err := os.Stat(opts.IdentityFile); err == nil {
|
||||
key, err := ioutil.ReadFile(opts.IdentityFile)
|
||||
key, err := os.ReadFile(opts.IdentityFile)
|
||||
if err != nil {
|
||||
return nil, errors.New("NewStorageBackend: error reading the private key")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user