More linting errors
This commit is contained in:
		
							parent
							
								
									99ab68e7f4
								
							
						
					
					
						commit
						ccb6259b06
					
				|  | @ -20,7 +20,6 @@ import ( | |||
| 	"github.com/GoogleContainerTools/kaniko/pkg/dockerfile" | ||||
| 	"github.com/google/go-containerregistry/pkg/v1" | ||||
| 	"github.com/moby/buildkit/frontend/dockerfile/instructions" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| ) | ||||
| 
 | ||||
| type ShellCommand struct { | ||||
|  | @ -29,13 +28,7 @@ type ShellCommand struct { | |||
| 
 | ||||
| // ExecuteCommand handles command processing similar to CMD and RUN,
 | ||||
| func (s *ShellCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error { | ||||
| 	logrus.Info("cmd: SHELL") | ||||
| 	var newShell []string | ||||
| 
 | ||||
| 	newShell = s.cmd.Shell | ||||
| 
 | ||||
| 	logrus.Infof("Replacing Shell in config with %v", newShell) | ||||
| 	config.Shell = newShell | ||||
| 	config.Shell = s.cmd.Shell | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -54,8 +54,8 @@ func Stages(opts *config.KanikoOptions) ([]config.KanikoStage, error) { | |||
| 		stage.Name = resolvedBaseName | ||||
| 		kanikoStages = append(kanikoStages, config.KanikoStage{ | ||||
| 			Stage:                  stage, | ||||
| 			BaseImageIndex:         baseImageIndex(opts, index, stages), | ||||
| 			BaseImageStoredLocally: (baseImageIndex(opts, index, stages) != -1), | ||||
| 			BaseImageIndex:         baseImageIndex(index, stages), | ||||
| 			BaseImageStoredLocally: (baseImageIndex(index, stages) != -1), | ||||
| 			SaveStage:              saveStage(index, stages), | ||||
| 			FinalStage:             index == targetStage, | ||||
| 		}) | ||||
|  | @ -68,7 +68,7 @@ func Stages(opts *config.KanikoOptions) ([]config.KanikoStage, error) { | |||
| 
 | ||||
| // baseImageIndex returns the index of the stage the current stage is built off
 | ||||
| // returns -1 if the current stage isn't built off a previous stage
 | ||||
| func baseImageIndex(opts *config.KanikoOptions, currentStage int, stages []instructions.Stage) int { | ||||
| func baseImageIndex(currentStage int, stages []instructions.Stage) int { | ||||
| 	for i, stage := range stages { | ||||
| 		if i > currentStage { | ||||
| 			break | ||||
|  |  | |||
|  | @ -20,7 +20,6 @@ import ( | |||
| 	"strconv" | ||||
| 	"testing" | ||||
| 
 | ||||
| 	"github.com/GoogleContainerTools/kaniko/pkg/config" | ||||
| 	"github.com/GoogleContainerTools/kaniko/testutil" | ||||
| 	"github.com/moby/buildkit/frontend/dockerfile/instructions" | ||||
| ) | ||||
|  | @ -184,7 +183,7 @@ func Test_baseImageIndex(t *testing.T) { | |||
| 	} | ||||
| 	for _, test := range tests { | ||||
| 		t.Run(test.name, func(t *testing.T) { | ||||
| 			actual := baseImageIndex(&config.KanikoOptions{}, test.currentStage, stages) | ||||
| 			actual := baseImageIndex(test.currentStage, stages) | ||||
| 			if actual != test.expected { | ||||
| 				t.Fatalf("unexpected result, expected %d got %d", test.expected, actual) | ||||
| 			} | ||||
|  |  | |||
|  | @ -228,10 +228,7 @@ func IsSrcRemoteFileURL(rawurl string) bool { | |||
| 		return false | ||||
| 	} | ||||
| 	_, err = http.Get(rawurl) | ||||
| 	if err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	return true | ||||
| 	return err == nil | ||||
| } | ||||
| 
 | ||||
| func UpdateConfigEnv(newEnvs []instructions.KeyValuePair, config *v1.Config, replacementEnvs []string) error { | ||||
|  |  | |||
|  | @ -109,7 +109,7 @@ func GetFSFromImage(root string, img v1.Image) error { | |||
| // DeleteFilesystem deletes the extracted image file system
 | ||||
| func DeleteFilesystem() error { | ||||
| 	logrus.Info("Deleting filesystem...") | ||||
| 	err := filepath.Walk(constants.RootDir, func(path string, info os.FileInfo, err error) error { | ||||
| 	return filepath.Walk(constants.RootDir, func(path string, info os.FileInfo, _ error) error { | ||||
| 		whitelisted, err := CheckWhitelist(path) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
|  | @ -123,7 +123,6 @@ func DeleteFilesystem() error { | |||
| 		} | ||||
| 		return os.RemoveAll(path) | ||||
| 	}) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| // ChildDirInWhitelist returns true if there is a child file or directory of the path in the whitelist
 | ||||
|  | @ -310,6 +309,9 @@ func RelativeFiles(fp string, root string) ([]string, error) { | |||
| 	fullPath := filepath.Join(root, fp) | ||||
| 	logrus.Debugf("Getting files and contents at root %s", fullPath) | ||||
| 	err := filepath.Walk(fullPath, func(path string, info os.FileInfo, err error) error { | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		whitelisted, err := CheckWhitelist(path) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
|  |  | |||
|  | @ -195,10 +195,10 @@ func fileIsCompressedTar(src string) (bool, archive.Compression) { | |||
| 
 | ||||
| func fileIsUncompressedTar(src string) bool { | ||||
| 	r, err := os.Open(src) | ||||
| 	defer r.Close() | ||||
| 	if err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	defer r.Close() | ||||
| 	fi, err := os.Lstat(src) | ||||
| 	if err != nil { | ||||
| 		return false | ||||
|  | @ -210,13 +210,8 @@ func fileIsUncompressedTar(src string) bool { | |||
| 	if tr == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	for { | ||||
| 		_, err := tr.Next() | ||||
| 		if err != nil { | ||||
| 			return false | ||||
| 		} | ||||
| 		return true | ||||
| 	} | ||||
| 	_, err = tr.Next() | ||||
| 	return err == nil | ||||
| } | ||||
| 
 | ||||
| // UnpackCompressedTar unpacks the compressed tar at path to dir
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue