mirror of
https://github.com/containerd/containerd.git
synced 2026-11-06 05:17:02 +00:00
plugins: fix perfsprint linting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
12 files changed
+42
-35
No files matched your search
@@ -709,7 +709,7 @@ func writeTimestampFile(p string, t time.Time) error {
|
||||
}
|
||||
|
||||
func writeToCompletion(path string, data []byte, mode os.FileMode) error {
|
||||
tmp := fmt.Sprintf("%s.tmp", path)
|
||||
tmp := path + ".tmp"
|
||||
f, err := os.OpenFile(tmp, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_SYNC, mode)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create tmp file: %w", err)
|
||||
|
||||
@@ -20,9 +20,9 @@ package erofs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"errors"
|
||||
)
|
||||
|
||||
func (s *erofsDiff) formatDmverityLayer(_ context.Context, _ string) error {
|
||||
return fmt.Errorf("dm-verity formatting is only supported on Linux systems")
|
||||
return errors.New("dm-verity formatting is only supported on Linux systems")
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -112,8 +113,8 @@ func init() {
|
||||
|
||||
ic.Meta.Exports = map[string]string{
|
||||
"PauseThreshold": fmt.Sprint(m.pauseThreshold),
|
||||
"DeletionThreshold": fmt.Sprint(m.deletionThreshold),
|
||||
"MutationThreshold": fmt.Sprint(m.mutationThreshold),
|
||||
"DeletionThreshold": strconv.Itoa(m.deletionThreshold),
|
||||
"MutationThreshold": strconv.Itoa(m.mutationThreshold),
|
||||
"ScheduleDelay": fmt.Sprint(m.scheduleDelay),
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package erofs
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -171,7 +172,7 @@ func (h *erofsMountHandler) Mount(ctx context.Context, m mount.Mount, mp string,
|
||||
// same place, where its root hash still matches.
|
||||
func dmverityDeviceName(source, mountpoint string) string {
|
||||
sum := sha256.Sum256([]byte(source + "\x00" + mountpoint))
|
||||
return fmt.Sprintf("containerd-erofs-%x", sum[:16])
|
||||
return "containerd-erofs-" + hex.EncodeToString(sum[:16])
|
||||
}
|
||||
|
||||
// setupDmVerityDevice creates or reuses a dm-verity device for the given EROFS source.
|
||||
|
||||
@@ -274,7 +274,7 @@ func (s *controllerService) Update(
|
||||
return nil, errgrpc.ToGRPC(err)
|
||||
}
|
||||
if req.Sandbox == nil {
|
||||
return nil, fmt.Errorf("sandbox can not be nil")
|
||||
return nil, errors.New("sandbox must not be nil")
|
||||
}
|
||||
err = ctrl.Update(ctx, req.SandboxID, sandbox.FromProto(req.Sandbox), req.Fields...)
|
||||
if err != nil {
|
||||
|
||||
@@ -101,15 +101,15 @@ func (c *Config) Validate() error {
|
||||
var result []error
|
||||
|
||||
if c.PoolName == "" {
|
||||
result = append(result, fmt.Errorf("pool_name is required"))
|
||||
result = append(result, errors.New("pool_name is required"))
|
||||
}
|
||||
|
||||
if c.RootPath == "" {
|
||||
result = append(result, fmt.Errorf("root_path is required"))
|
||||
result = append(result, errors.New("root_path is required"))
|
||||
}
|
||||
|
||||
if c.BaseImageSize == "" {
|
||||
result = append(result, fmt.Errorf("base_image_size is required"))
|
||||
result = append(result, errors.New("base_image_size is required"))
|
||||
}
|
||||
|
||||
if c.FileSystemType != "" {
|
||||
@@ -119,7 +119,7 @@ func (c *Config) Validate() error {
|
||||
result = append(result, fmt.Errorf("unsupported Filesystem Type: %q", c.FileSystemType))
|
||||
}
|
||||
} else {
|
||||
result = append(result, fmt.Errorf("filesystem type cannot be empty"))
|
||||
result = append(result, errors.New("filesystem type cannot be empty"))
|
||||
}
|
||||
|
||||
return errors.Join(result...)
|
||||
|
||||
@@ -162,7 +162,7 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) {
|
||||
return nil, fmt.Errorf("failed to check dm-verity support: %w", err)
|
||||
}
|
||||
if !supported {
|
||||
return nil, fmt.Errorf("dmverity_mode is 'on' but dm-verity is not supported on this system")
|
||||
return nil, errors.New("dmverity_mode is 'on' but dm-verity is not supported on this system")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,10 +183,10 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) {
|
||||
// mechanism.
|
||||
if len(config.layerContentCaches) > 0 {
|
||||
if config.enableFsverity {
|
||||
return nil, fmt.Errorf("enable_fsverity is incompatible with layer_content_caches; use dm-verity for cache integrity")
|
||||
return nil, errors.New("enable_fsverity is incompatible with layer_content_caches; use dm-verity for cache integrity")
|
||||
}
|
||||
if config.setImmutable {
|
||||
return nil, fmt.Errorf("set_immutable is incompatible with layer_content_caches")
|
||||
return nil, errors.New("set_immutable is incompatible with layer_content_caches")
|
||||
}
|
||||
|
||||
// A cache dir is recorded in a snapshot and mounted later. A relative
|
||||
@@ -216,7 +216,7 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) {
|
||||
}
|
||||
|
||||
if config.setImmutable && runtime.GOOS != "linux" {
|
||||
return nil, fmt.Errorf("setting IMMUTABLE_FL is only supported on Linux")
|
||||
return nil, errors.New("setting IMMUTABLE_FL is only supported on Linux")
|
||||
}
|
||||
|
||||
ms, err := storage.NewMetaStore(filepath.Join(root, "metadata.db"))
|
||||
@@ -391,7 +391,7 @@ func (s *snapshotter) applyDmverityPolicy(layerBlob string) (string, error) {
|
||||
// If metadata exists, return the metadata path to a mount option.
|
||||
// The format is: X-containerd.dmverity=<metadata-path>
|
||||
if metadataExists {
|
||||
return fmt.Sprintf("X-containerd.dmverity=%s", metadataPath), nil
|
||||
return "X-containerd.dmverity=" + metadataPath, nil
|
||||
}
|
||||
|
||||
return "", nil
|
||||
@@ -509,8 +509,8 @@ func (s *snapshotter) overlayMounts(snap storage.Snapshot, info snapshots.Info,
|
||||
)
|
||||
} else {
|
||||
options = append(options,
|
||||
fmt.Sprintf("workdir=%s", s.workPath(snap.ID)),
|
||||
fmt.Sprintf("upperdir=%s", s.upperPath(snap.ID)),
|
||||
"workdir="+s.workPath(snap.ID),
|
||||
"upperdir="+s.upperPath(snap.ID),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -526,10 +526,10 @@ func (s *snapshotter) overlayMounts(snap storage.Snapshot, info snapshots.Info,
|
||||
|
||||
if s.remapIDs {
|
||||
if v, ok := info.Labels[snapshots.LabelSnapshotUIDMapping]; ok {
|
||||
options = append(options, fmt.Sprintf("uidmap=%s", v))
|
||||
options = append(options, "uidmap="+v)
|
||||
}
|
||||
if v, ok := info.Labels[snapshots.LabelSnapshotGIDMapping]; ok {
|
||||
options = append(options, fmt.Sprintf("gidmap=%s", v))
|
||||
options = append(options, "gidmap="+v)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ package overlay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -507,7 +508,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
|
||||
}
|
||||
stat, ok := st.Sys().(*syscall.Stat_t)
|
||||
if !ok {
|
||||
return fmt.Errorf("incompatible types after stat call: *syscall.Stat_t expected")
|
||||
return errors.New("incompatible types after stat call: *syscall.Stat_t expected")
|
||||
}
|
||||
mappedUID = int(stat.Uid)
|
||||
mappedGID = int(stat.Gid)
|
||||
@@ -557,10 +558,10 @@ func (o *snapshotter) mounts(s storage.Snapshot, info snapshots.Info) []mount.Mo
|
||||
|
||||
if o.remapIDs {
|
||||
if v, ok := info.Labels[snapshots.LabelSnapshotUIDMapping]; ok {
|
||||
options = append(options, fmt.Sprintf("uidmap=%s", v))
|
||||
options = append(options, "uidmap="+v)
|
||||
}
|
||||
if v, ok := info.Labels[snapshots.LabelSnapshotGIDMapping]; ok {
|
||||
options = append(options, fmt.Sprintf("gidmap=%s", v))
|
||||
options = append(options, "gidmap="+v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,8 +586,8 @@ func (o *snapshotter) mounts(s storage.Snapshot, info snapshots.Info) []mount.Mo
|
||||
|
||||
if s.Kind == snapshots.KindActive {
|
||||
options = append(options,
|
||||
fmt.Sprintf("workdir=%s", o.workPath(s.ID)),
|
||||
fmt.Sprintf("upperdir=%s", o.upperPath(s.ID)),
|
||||
"workdir="+o.workPath(s.ID),
|
||||
"upperdir="+o.upperPath(s.ID),
|
||||
)
|
||||
} else if len(s.ParentIDs) == 1 {
|
||||
return []mount.Mount{
|
||||
@@ -605,7 +606,7 @@ func (o *snapshotter) mounts(s storage.Snapshot, info snapshots.Info) []mount.Mo
|
||||
for i := range s.ParentIDs {
|
||||
parentPaths[i] = o.upperPath(s.ParentIDs[i])
|
||||
}
|
||||
options = append(options, fmt.Sprintf("lowerdir=%s", strings.Join(parentPaths, ":")))
|
||||
options = append(options, "lowerdir="+strings.Join(parentPaths, ":"))
|
||||
options = append(options, o.options...)
|
||||
|
||||
return []mount.Mount{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package overlayutils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -289,7 +290,7 @@ func SupportsIDMappedMounts() (bool, error) {
|
||||
return false, fmt.Errorf("failed to stat %s: %w", filepath.Join(td, "merged"), err)
|
||||
}
|
||||
if stat, ok := st.Sys().(*syscall.Stat_t); !ok {
|
||||
return false, fmt.Errorf("incompatible types after stat call: *syscall.Stat_t expected")
|
||||
return false, errors.New("incompatible types after stat call: *syscall.Stat_t expected")
|
||||
} else if int(stat.Uid) != uidMap.HostID || int(stat.Gid) != gidMap.HostID {
|
||||
return false, fmt.Errorf("bad mapping: expected {uid: %d, gid: %d}; real {uid: %d, gid: %d}", uidMap.HostID, gidMap.HostID, int(stat.Uid), int(stat.Gid))
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package windows
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -84,7 +85,7 @@ func init() {
|
||||
|
||||
config, ok := ic.Config.(*BlockCIMSnapshotterConfig)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid block CIM snapshotter configuration")
|
||||
return nil, errors.New("invalid block CIM snapshotter configuration")
|
||||
}
|
||||
|
||||
log.G(ic.Context).WithField("config", config).Trace("initializing blockcim snapshotter")
|
||||
@@ -225,7 +226,7 @@ func (s *blockCIMSnapshotter) Mounts(ctx context.Context, key string) (_ []mount
|
||||
|
||||
func (s *blockCIMSnapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
|
||||
if !strings.Contains(key, snapshots.UnpackKeyPrefix) {
|
||||
return fmt.Errorf("committing a scratch snapshot to read-only cim layer isn't supported yet")
|
||||
return errors.New("committing a scratch snapshot to read-only cim layer isn't supported yet")
|
||||
}
|
||||
|
||||
return s.ms.WithTransaction(ctx, true, func(ctx context.Context) error {
|
||||
@@ -295,7 +296,7 @@ func (s *blockCIMSnapshotter) createSnapshot(ctx context.Context, kind snapshots
|
||||
}
|
||||
|
||||
if len(newSnapshot.ParentIDs) == 0 {
|
||||
return fmt.Errorf("scratch snapshot without any parents isn't supported")
|
||||
return errors.New("scratch snapshot without any parents isn't supported")
|
||||
}
|
||||
|
||||
parentLayerPaths := s.parentIDsToParentPaths(newSnapshot.ParentIDs)
|
||||
@@ -472,7 +473,7 @@ const (
|
||||
// index. already exists in the 0th snapshot's directory, nothing is done.
|
||||
func (s *blockCIMSnapshotter) prepareMergedCIM(ctx context.Context, snapshotIDs []string) (rErr error) {
|
||||
if len(snapshotIDs) < 2 {
|
||||
return fmt.Errorf("merging CIM requires at least 2 snapshots")
|
||||
return errors.New("merging CIM requires at least 2 snapshots")
|
||||
}
|
||||
log.G(ctx).WithFields(log.Fields{
|
||||
"source snapshots": snapshotIDs,
|
||||
|
||||
@@ -21,6 +21,7 @@ package windows
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -73,7 +74,7 @@ func WithNTFSFormat() scratchCreationOpt {
|
||||
func WithSize(size uint64) scratchCreationOpt {
|
||||
return func(opts *scratchCreationOptions) error {
|
||||
if size == 0 {
|
||||
return fmt.Errorf("VHD size cannot be zero")
|
||||
return errors.New("VHD size cannot be zero")
|
||||
}
|
||||
opts.sizeInBytes = size
|
||||
return nil
|
||||
@@ -209,7 +210,7 @@ func (s *cimFSSnapshotter) Mounts(ctx context.Context, key string) (_ []mount.Mo
|
||||
|
||||
func (s *cimFSSnapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
|
||||
if !strings.Contains(key, snapshots.UnpackKeyPrefix) {
|
||||
return fmt.Errorf("committing a scratch snapshot to read-only cim layer isn't supported yet")
|
||||
return errors.New("committing a scratch snapshot to read-only cim layer isn't supported yet")
|
||||
}
|
||||
|
||||
return s.ms.WithTransaction(ctx, true, func(ctx context.Context) error {
|
||||
@@ -289,7 +290,7 @@ func (s *cimFSSnapshotter) createSnapshot(ctx context.Context, kind snapshots.Ki
|
||||
}
|
||||
|
||||
if len(newSnapshot.ParentIDs) == 0 {
|
||||
return fmt.Errorf("scratch snapshot without any parents isn't supported")
|
||||
return errors.New("scratch snapshot without any parents isn't supported")
|
||||
}
|
||||
|
||||
parentLayerPaths := s.parentIDsToParentPaths(newSnapshot.ParentIDs)
|
||||
|
||||
@@ -21,6 +21,7 @@ package windows
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -258,7 +259,7 @@ func (s *wcowSnapshotter) Mounts(ctx context.Context, key string) (_ []mount.Mou
|
||||
func (s *wcowSnapshotter) createScratchLayer(ctx context.Context, snDir string, parentLayers []string, sizeInBytes uint64) error {
|
||||
parentLen := len(parentLayers)
|
||||
if parentLen == 0 {
|
||||
return fmt.Errorf("no parent layers present")
|
||||
return errors.New("no parent layers present")
|
||||
}
|
||||
|
||||
baseLayer := parentLayers[parentLen-1]
|
||||
|
||||
Reference in new issue
Block a user