isula-build/patch/0042-fix-some-make-checkall-golangci-lint-flaws.patch
DCCooper 950f2f8ba2 isula-build:Sync upstream patches
Signed-off-by: DCCooper <1866858@gmail.com>
2021-03-03 19:29:30 +08:00

137 lines
5.1 KiB
Diff

From 34fdae49f82410a8bcc9c6f5940af01a24538de6 Mon Sep 17 00:00:00 2001
From: meilier <xingweizheng@huawei.com>
Date: Thu, 4 Feb 2021 18:40:31 +0800
Subject: [PATCH 01/10] fix some make checkall golangci-lint flaws
---
builder/dockerfile/container/container_src.go | 2 +-
builder/dockerfile/container/help.go | 2 +-
daemon/load.go | 4 ++--
daemon/login.go | 4 ++--
daemon/logout.go | 4 ++--
daemon/save.go | 2 --
pkg/manifest/list.go | 2 +-
util/util.go | 2 --
8 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/builder/dockerfile/container/container_src.go b/builder/dockerfile/container/container_src.go
index ff52ee2c..9426ec76 100644
--- a/builder/dockerfile/container/container_src.go
+++ b/builder/dockerfile/container/container_src.go
@@ -98,7 +98,7 @@ func (i *containerImageSource) GetBlob(ctx context.Context, blob types.BlobInfo,
return nil, -1, errors.Wrapf(err, "blob file %q is not exit", blobFile)
}
- layerFile, err := os.OpenFile(blobFile, os.O_RDONLY, constant.DefaultRootFileMode)
+ layerFile, err := os.OpenFile(filepath.Clean(blobFile), os.O_RDONLY, constant.DefaultRootFileMode)
if err != nil {
return nil, -1, errors.Wrapf(err, "open the blob file %q failed", blobFile)
}
diff --git a/builder/dockerfile/container/help.go b/builder/dockerfile/container/help.go
index c5aa381d..475b479d 100644
--- a/builder/dockerfile/container/help.go
+++ b/builder/dockerfile/container/help.go
@@ -170,7 +170,7 @@ func (ref *Reference) saveLayerToStorage(path string, layer *storage.Layer) (dif
}()
filename := filepath.Join(path, "layer")
- layerFile, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, constant.DefaultRootFileMode)
+ layerFile, err := os.OpenFile(filepath.Clean(filename), os.O_CREATE|os.O_WRONLY, constant.DefaultRootFileMode)
if err != nil {
return "", des, errors.Wrapf(err, "error opening file: %s", filename)
}
diff --git a/daemon/load.go b/daemon/load.go
index 08fb5b1f..d756f9ed 100644
--- a/daemon/load.go
+++ b/daemon/load.go
@@ -55,8 +55,8 @@ func (b *Backend) Load(req *pb.LoadRequest, stream pb.Control_LoadServer) error
)
opts := b.getLoadOptions(req)
- if err := util.CheckLoadFile(req.Path); err != nil {
- return err
+ if cErr := util.CheckLoadFile(req.Path); cErr != nil {
+ return cErr
}
repoTags, err = tryToParseImageFormatFromTarball(b.daemon.opts.DataRoot, &opts)
diff --git a/daemon/login.go b/daemon/login.go
index e3399983..6eeda28e 100644
--- a/daemon/login.go
+++ b/daemon/login.go
@@ -60,8 +60,8 @@ func (b *Backend) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginRes
}
if loginWithAuthFile(req) {
- auth, err := config.GetCredentials(sysCtx, req.Server)
- if err != nil || auth.Password == "" {
+ auth, gErr := config.GetCredentials(sysCtx, req.Server)
+ if gErr != nil || auth.Password == "" {
auth = types.DockerAuthConfig{}
return &pb.LoginResponse{Content: errTryToUseAuth}, errors.Errorf("failed to read auth file: %v", errTryToUseAuth)
}
diff --git a/daemon/logout.go b/daemon/logout.go
index 355b1f7a..d1fbebcb 100644
--- a/daemon/logout.go
+++ b/daemon/logout.go
@@ -47,8 +47,8 @@ func (b *Backend) Logout(ctx context.Context, req *pb.LogoutRequest) (*pb.Logout
}
if req.All {
- if err := config.RemoveAllAuthentication(sysCtx); err != nil {
- return &pb.LogoutResponse{Result: "Remove authentications failed"}, err
+ if rErr := config.RemoveAllAuthentication(sysCtx); rErr != nil {
+ return &pb.LogoutResponse{Result: "Remove authentications failed"}, rErr
}
logrus.Info("Success logout from all servers")
diff --git a/daemon/save.go b/daemon/save.go
index 3dce7bdf..c6411e04 100644
--- a/daemon/save.go
+++ b/daemon/save.go
@@ -17,7 +17,6 @@ import (
"context"
"os"
- "github.com/containers/image/v5/docker/archive"
"github.com/containers/image/v5/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -34,7 +33,6 @@ import (
)
type saveOptions struct {
- writer *archive.Writer
sysCtx *types.SystemContext
logger *logger.Logger
localStore *store.Store
diff --git a/pkg/manifest/list.go b/pkg/manifest/list.go
index 3f8b2fed..381746f7 100644
--- a/pkg/manifest/list.go
+++ b/pkg/manifest/list.go
@@ -129,7 +129,7 @@ func (l *List) SaveListToImage(store *store.Store, imageID, name string) (string
return "", errors.Wrapf(err, "save manifest list to image %v error", imageID)
}
- //marshal list instance information
+ // marshal list instance information
instancesBytes, err := json.Marshal(&l.instances)
if err != nil {
return "", errors.Wrap(err, "marshall list instances error")
diff --git a/util/util.go b/util/util.go
index 61458c73..3f46d796 100644
--- a/util/util.go
+++ b/util/util.go
@@ -57,8 +57,6 @@ const (
var (
// DefaultRegistryPathPrefix is the map for registry and path
DefaultRegistryPathPrefix map[string]string
- // clientExporters to map exporter whether will export the image to client
- clientExporters map[string]bool
)
func init() {
--
2.27.0