Replace gometalinter with GolangCI-Lint

gometalinter is broken @ HEAD, and I looked into why that was. During
that process, I remembered that we took the linting scripts from
skaffold, and found that in skaffold gometalinter was replaced with
GolangCI-Lint:

https://github.com/GoogleContainerTools/skaffold/pull/619

The change made linting in skaffold faster, so I figured instead of
fixing gometalinter it made more sense to remove it and replace it with
GolangCI-Lint for kaniko as well.
This commit is contained in:
Priya Wadhwa
2018-09-11 13:30:42 -07:00
parent 06defa6552
commit 99ab68e7f4
19 changed files with 466 additions and 100 deletions
+2 -1
View File
@@ -18,8 +18,9 @@ package buildcontext
import (
"errors"
"github.com/GoogleContainerTools/kaniko/pkg/constants"
"strings"
"github.com/GoogleContainerTools/kaniko/pkg/constants"
)
// BuildContext unifies calls to download and unpack the build context.
+3 -2
View File
@@ -17,14 +17,15 @@ limitations under the License.
package buildcontext
import (
"os"
"path/filepath"
"github.com/GoogleContainerTools/kaniko/pkg/constants"
"github.com/GoogleContainerTools/kaniko/pkg/util"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"os"
"path/filepath"
)
// S3 unifies calls to download and unpack the build context.
+12 -12
View File
@@ -27,57 +27,57 @@ import (
var userTests = []struct {
user string
expectedUid string
expectedUID string
shouldError bool
}{
{
user: "root",
expectedUid: "root",
expectedUID: "root",
shouldError: false,
},
{
user: "0",
expectedUid: "0",
expectedUID: "0",
shouldError: false,
},
{
user: "fakeUser",
expectedUid: "",
expectedUID: "",
shouldError: true,
},
{
user: "root:root",
expectedUid: "root:root",
expectedUID: "root:root",
shouldError: false,
},
{
user: "0:root",
expectedUid: "0:root",
expectedUID: "0:root",
shouldError: false,
},
{
user: "root:0",
expectedUid: "root:0",
expectedUID: "root:0",
shouldError: false,
},
{
user: "0:0",
expectedUid: "0:0",
expectedUID: "0:0",
shouldError: false,
},
{
user: "root:fakeGroup",
expectedUid: "",
expectedUID: "",
shouldError: true,
},
{
user: "$envuser",
expectedUid: "root",
expectedUID: "root",
shouldError: false,
},
{
user: "root:$envgroup",
expectedUid: "root:root",
expectedUID: "root:root",
shouldError: false,
},
}
@@ -97,6 +97,6 @@ func TestUpdateUser(t *testing.T) {
}
buildArgs := dockerfile.NewBuildArgs([]string{})
err := cmd.ExecuteCommand(cfg, buildArgs)
testutil.CheckErrorAndDeepEqual(t, test.shouldError, err, test.expectedUid, cfg.User)
testutil.CheckErrorAndDeepEqual(t, test.shouldError, err, test.expectedUID, cfg.User)
}
}
+5 -5
View File
@@ -19,16 +19,16 @@ package config
// KanikoOptions are options that are set by command line arguments
type KanikoOptions struct {
DockerfilePath string
Destinations multiArg
SrcContext string
SnapshotMode string
Bucket string
InsecurePush bool
SkipTlsVerify bool
BuildArgs multiArg
TarPath string
Target string
Destinations multiArg
BuildArgs multiArg
InsecurePush bool
SkipTLSVerify bool
SingleSnapshot bool
Reproducible bool
Target string
NoPush bool
}
+1 -1
View File
@@ -21,8 +21,8 @@ import "github.com/moby/buildkit/frontend/dockerfile/instructions"
// KanikoStage wraps a stage of the Dockerfile and provides extra information
type KanikoStage struct {
instructions.Stage
BaseImageIndex int
FinalStage bool
BaseImageStoredLocally bool
BaseImageIndex int
SaveStage bool
}
+4 -3
View File
@@ -17,8 +17,9 @@ limitations under the License.
package dockerfile
import (
d "github.com/docker/docker/builder/dockerfile"
"strings"
d "github.com/docker/docker/builder/dockerfile"
)
type BuildArgs struct {
@@ -36,14 +37,14 @@ func NewBuildArgs(args []string) *BuildArgs {
}
}
return &BuildArgs{
*d.NewBuildArgs(argsFromOptions),
BuildArgs: *d.NewBuildArgs(argsFromOptions),
}
}
func (b *BuildArgs) Clone() *BuildArgs {
clone := b.BuildArgs.Clone()
return &BuildArgs{
*clone,
BuildArgs: *clone,
}
}
+1 -1
View File
@@ -87,7 +87,7 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error {
// Create a transport to set our user-agent.
tr := http.DefaultTransport
if opts.SkipTlsVerify {
if opts.SkipTLSVerify {
tr.(*http.Transport).TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
}
+2 -1
View File
@@ -17,8 +17,9 @@ limitations under the License.
package util
import (
"github.com/GoogleContainerTools/kaniko/pkg/constants"
"strings"
"github.com/GoogleContainerTools/kaniko/pkg/constants"
)
func GetBucketAndItem(context string) (string, string) {
+7 -7
View File
@@ -23,7 +23,7 @@ import (
"github.com/GoogleContainerTools/kaniko/testutil"
)
var testUrl = "https://github.com/GoogleContainerTools/runtimes-common/blob/master/LICENSE"
var testURL = "https://github.com/GoogleContainerTools/runtimes-common/blob/master/LICENSE"
var testEnvReplacement = []struct {
path string
@@ -220,7 +220,7 @@ var matchSourcesTests = []struct {
srcs: []string{
"pkg/*",
"/root/dir?",
testUrl,
testURL,
},
files: []string{
"pkg/a",
@@ -234,7 +234,7 @@ var matchSourcesTests = []struct {
"/root/dir1",
"pkg/a",
"pkg/b",
testUrl,
testURL,
},
},
}
@@ -344,11 +344,11 @@ var isSrcValidTests = []struct {
},
{
srcsAndDest: []string{
testUrl,
testURL,
"dest",
},
resolvedSources: []string{
testUrl,
testURL,
},
shouldErr: false,
},
@@ -369,13 +369,13 @@ var testResolveSources = []struct {
srcsAndDest: []string{
"context/foo",
"context/b*",
testUrl,
testURL,
"dest/",
},
expectedList: []string{
"context/foo",
"context/bar",
testUrl,
testURL,
},
},
}
+2 -2
View File
@@ -343,8 +343,8 @@ func filesAreHardlinks(first, second string) checker {
if err != nil {
t.Fatalf("error getting file %s", second)
}
stat1 := getSyscallStat_t(fi1)
stat2 := getSyscallStat_t(fi2)
stat1 := getSyscallStatT(fi1)
stat2 := getSyscallStatT(fi2)
if stat1.Ino != stat2.Ino {
t.Errorf("%s and %s aren't hardlinks as they dont' have the same inode", first, second)
}
+2 -1
View File
@@ -25,6 +25,7 @@ import (
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/partial"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"github.com/sirupsen/logrus"
@@ -61,7 +62,7 @@ func RetrieveSourceImage(stage config.KanikoStage, buildArgs []string) (v1.Image
}
// RetrieveConfigFile returns the config file for an image
func RetrieveConfigFile(sourceImage v1.Image) (*v1.ConfigFile, error) {
func RetrieveConfigFile(sourceImage partial.WithConfigFile) (*v1.ConfigFile, error) {
imageConfig, err := sourceImage.ConfigFile()
if err != nil {
return nil, err
+2 -2
View File
@@ -118,7 +118,7 @@ func (t *Tar) Whiteout(p string) error {
func (t *Tar) checkHardlink(p string, i os.FileInfo) (bool, string) {
hardlink := false
linkDst := ""
stat := getSyscallStat_t(i)
stat := getSyscallStatT(i)
if stat != nil {
nlinks := stat.Nlink
if nlinks > 1 {
@@ -135,7 +135,7 @@ func (t *Tar) checkHardlink(p string, i os.FileInfo) (bool, string) {
return hardlink, linkDst
}
func getSyscallStat_t(i os.FileInfo) *syscall.Stat_t {
func getSyscallStatT(i os.FileInfo) *syscall.Stat_t {
if sys := i.Sys(); sys != nil {
if stat, ok := sys.(*syscall.Stat_t); ok {
return stat