mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-21 09:11:07 +02:00
Fix Integration tests (#2425)
* fix(ci): Bump golangci-lint to 1.51.1 * chore(lint): fix gofmt and goimport issues * chore(lint): fix linter issues - Adapted error comparison according to linter recommendation - Disabled noctx linting for http request where canceling makes no sense - Disabled nilerror linting where nil error is returned on purpose - Disabled makezero linter where slice is explicitly deepcopied * chore(ci): Update go version in tests workflows * fix(ci): Allow boilerplate years from 2000-2099 Previously the regex only allowed the copyright notice to contain the years 2018,2019,2020,2021, or 2022. This commit widens to regex to 20\d\d allowing any year in the range [2000-2099] * feat(ci): Replace minikube with k3s for intregration tests The existing setup for minikube is very complicated, replicating most of the setup steps for a full kubernetes cluster in an only partially supported minikube configuration (driver=none). Furthermore the existing setup has been broken for sometime, likely, at least in part due to the changes to CNI and CRI in recent kubernetes versions. Since what we actually need is only a running Kubernetes cluster on the node and access to a registry on localhost:5000, we can switch the extremely complicated minikube setup for a lightweight cluster using k3s. Minikube came with a default addon for running a registry on every node, but the same is not the case for k3s, instead we make use of the package helm controller and its HelmChart CR to deploy twuni/docker-registry.helm and expose it on localhost using the integrated LoadBalancer controller. * fix(test-684): pin base container version The dockerfile for the regression test connected to issue 684 used a rolling tag as base image, making it flaky and fail since it was introduced. This commit pins the base image to the digest of bionic-20200219, which, based on the date of the commit that introduced to the dockerfile would be the most newest ubuntu build and likely what the "rolling" tag resolved to back then. Since this also an image from the pre-oci days of ubuntu, this circumvents a bug in container-diff as well (https://github.com/GoogleContainerTools/container-diff/issues/389)
This commit is contained in:
@@ -173,10 +173,14 @@ func IsDestDir(path string) bool {
|
||||
|
||||
// DestinationFilepath returns the destination filepath from the build context to the image filesystem
|
||||
// If source is a file:
|
||||
//
|
||||
// If dest is a dir, copy it to /dest/relpath
|
||||
// If dest is a file, copy directly to dest
|
||||
// If dest is a file, copy directly to dest
|
||||
//
|
||||
// If source is a dir:
|
||||
//
|
||||
// Assume dest is also a dir, and copy to dest/
|
||||
//
|
||||
// If dest is not an absolute filepath, add /cwd to the beginning
|
||||
func DestinationFilepath(src, dest, cwd string) (string, error) {
|
||||
_, srcFileName := filepath.Split(src)
|
||||
@@ -287,7 +291,7 @@ func IsSrcRemoteFileURL(rawurl string) bool {
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
_, err = http.Get(rawurl)
|
||||
_, err = http.Get(rawurl) //nolint:noctx
|
||||
return err == nil
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -167,7 +167,7 @@ func GetFSFromLayers(root string, layers []v1.Layer, opts ...FSOpt) ([]string, e
|
||||
tr := tar.NewReader(r)
|
||||
for {
|
||||
hdr, err := tr.Next()
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ func DeleteFilesystem() error {
|
||||
return filepath.Walk(config.RootDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
// ignore errors when deleting.
|
||||
return nil
|
||||
return nil //nolint:nilerr
|
||||
}
|
||||
|
||||
if CheckIgnoreList(path) {
|
||||
@@ -270,7 +270,7 @@ func UnTar(r io.Reader, dest string) ([]string, error) {
|
||||
tr := tar.NewReader(r)
|
||||
for {
|
||||
hdr, err := tr.Next()
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
@@ -450,7 +450,7 @@ func DetectFilesystemIgnoreList(path string) error {
|
||||
for {
|
||||
line, err := reader.ReadString('\n')
|
||||
logrus.Tracef("Read the following line from %s: %s", path, line)
|
||||
if err != nil && err != io.EOF {
|
||||
if err != nil && !errors.Is(err, io.EOF) {
|
||||
return err
|
||||
}
|
||||
lineArr := strings.Split(line, " ")
|
||||
@@ -600,11 +600,11 @@ func AddVolumePathToIgnoreList(path string) {
|
||||
|
||||
// DownloadFileToDest downloads the file at rawurl to the given dest for the ADD command
|
||||
// From add command docs:
|
||||
// 1. If <src> is a remote file URL:
|
||||
// - destination will have permissions of 0600
|
||||
// - If remote file has HTTP Last-Modified header, we set the mtime of the file to that timestamp
|
||||
// 1. If <src> is a remote file URL:
|
||||
// - destination will have permissions of 0600
|
||||
// - If remote file has HTTP Last-Modified header, we set the mtime of the file to that timestamp
|
||||
func DownloadFileToDest(rawurl, dest string, uid, gid int64) error {
|
||||
resp, err := http.Get(rawurl)
|
||||
resp, err := http.Get(rawurl) //nolint:noctx
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (t *Tar) Close() {
|
||||
func (t *Tar) AddFileToTar(p string) error {
|
||||
i, err := os.Lstat(p)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to get file info for %s: %s", p, err)
|
||||
return fmt.Errorf("Failed to get file info for %s: %w", p, err)
|
||||
}
|
||||
linkDst := ""
|
||||
if i.Mode()&os.ModeSymlink != 0 {
|
||||
@@ -156,7 +156,7 @@ func writeSecurityXattrToToFile(path string, hdr *tar.Header) error {
|
||||
}
|
||||
if capability, ok := hdr.Xattrs[securityCapabilityXattr]; ok {
|
||||
err := system.Lsetxattr(path, securityCapabilityXattr, []byte(capability), 0)
|
||||
if err != nil && !errors.Is(err, syscall.EOPNOTSUPP) && err != system.ErrNotSupportedPlatform {
|
||||
if err != nil && !errors.Is(err, syscall.EOPNOTSUPP) && !errors.Is(err, system.ErrNotSupportedPlatform) {
|
||||
return errors.Wrapf(err, "failed to write %q attribute to %q", securityCapabilityXattr, path)
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ func readSecurityXattrToTarHeader(path string, hdr *tar.Header) error {
|
||||
hdr.Xattrs = make(map[string]string)
|
||||
}
|
||||
capability, err := system.Lgetxattr(path, securityCapabilityXattr)
|
||||
if err != nil && !errors.Is(err, syscall.EOPNOTSUPP) && err != system.ErrNotSupportedPlatform {
|
||||
if err != nil && !errors.Is(err, syscall.EOPNOTSUPP) && !errors.Is(err, system.ErrNotSupportedPlatform) {
|
||||
return errors.Wrapf(err, "failed to read %q attribute from %q", securityCapabilityXattr, path)
|
||||
}
|
||||
if capability != nil {
|
||||
|
||||
+3
-2
@@ -30,6 +30,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/minio/highwayhash"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
@@ -195,7 +196,7 @@ func Lgetxattr(path string, attr string) ([]byte, error) {
|
||||
dest := make([]byte, 128)
|
||||
sz, errno := unix.Lgetxattr(path, attr, dest)
|
||||
|
||||
for errno == unix.ERANGE {
|
||||
for errors.Is(errno, unix.ERANGE) {
|
||||
// Buffer too small, use zero-sized buffer to get the actual size
|
||||
sz, errno = unix.Lgetxattr(path, attr, []byte{})
|
||||
if errno != nil {
|
||||
@@ -206,7 +207,7 @@ func Lgetxattr(path string, attr string) ([]byte, error) {
|
||||
}
|
||||
|
||||
switch {
|
||||
case errno == unix.ENODATA:
|
||||
case errors.Is(errno, unix.ENODATA):
|
||||
return nil, nil
|
||||
case errno != nil:
|
||||
return nil, errno
|
||||
|
||||
Reference in New Issue
Block a user