Skip to content

Commit

Permalink
More linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya Wadhwa committed Sep 11, 2018
1 parent 99ab68e commit 0312c0e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
8 changes: 1 addition & 7 deletions pkg/commands/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,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
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/dockerfile/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/dockerfile/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,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)
}
Expand Down
5 changes: 1 addition & 4 deletions pkg/util/command_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 7 additions & 2 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ 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, err error) error {
if err != nil {
return err
}
whitelisted, err := CheckWhitelist(path)
if err != nil {
return err
Expand All @@ -123,7 +126,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
Expand Down Expand Up @@ -310,6 +312,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
Expand Down
11 changes: 3 additions & 8 deletions pkg/util/tar_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0312c0e

Please sign in to comment.