Skip to content

Commit 777c1d4

Browse files
fix
1 parent a96f08a commit 777c1d4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

internal/core/context.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,19 @@ func ExtractBuildInfo(ctx context.Context) *BuildInfo {
7777
}
7878

7979
func ExtractEnv(ctx context.Context, envKey string) string {
80+
meta := extractMeta(ctx)
81+
if value, exist := meta.OverrideEnv[envKey]; exist {
82+
return value
83+
}
84+
8085
if envKey == "HOME" {
8186
homeDir, _ := os.UserHomeDir()
8287
return homeDir
8388
}
8489

85-
meta := extractMeta(ctx)
86-
if value, exist := meta.OverrideEnv[envKey]; exist {
87-
return value
88-
}
8990
return os.Getenv(envKey)
9091
}
92+
93+
func ExtractUserHomeDir(ctx context.Context) string {
94+
return ExtractEnv(ctx, "HOME")
95+
}

internal/namespaces/account/custom.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func initCommand() *core.Command {
4949
func InitRun(ctx context.Context, argsI interface{}) (i interface{}, e error) {
5050
// Get default local SSH key
5151
relativePath := path.Join(".ssh", "id_rsa.pub")
52-
filename := path.Join(core.ExtractEnv(ctx, "HOME"), relativePath)
52+
filename := path.Join(core.ExtractUserHomeDir(ctx), relativePath)
5353
shortenedFilename := "~/" + relativePath
5454
localSSHKeyContent, err := ioutil.ReadFile(filename)
5555

0 commit comments

Comments
 (0)