Skip to content

Commit

Permalink
rename default home function
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya Wadhwa committed Aug 10, 2018
1 parent 16139c2 commit 8ba0648
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (r *RunCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.Bui
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
replacementEnvs := buildArgs.ReplacementEnvs(config.Env)
cmd.Env = addDefaultEnvs(config.User, replacementEnvs)
cmd.Env = addDefaultHOME(config.User, replacementEnvs)
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}

// If specified, run the command as a specific user
Expand Down Expand Up @@ -115,8 +115,8 @@ func (r *RunCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.Bui
return nil
}

// addDefaultEnvs adds default values of variables (like $HOME) if they aren't already set
func addDefaultEnvs(user string, envs []string) []string {
// addDefaultHOME adds the default value for HOME if it isn't already set
func addDefaultHOME(user string, envs []string) []string {
for _, env := range envs {
split := strings.SplitN(env, "=", 2)
if split[0] == constants.HOME {
Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/GoogleContainerTools/kaniko/testutil"
)

func Test_addDefaultEnvs(t *testing.T) {
func Test_addDefaultHOME(t *testing.T) {
tests := []struct {
name string
user string
Expand Down Expand Up @@ -65,7 +65,7 @@ func Test_addDefaultEnvs(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actual := addDefaultEnvs(test.user, test.initial)
actual := addDefaultHOME(test.user, test.initial)
testutil.CheckErrorAndDeepEqual(t, false, nil, test.expected, actual)
})
}
Expand Down

0 comments on commit 8ba0648

Please sign in to comment.