Skip to content

Commit

Permalink
fix path generation in llb
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup committed Jan 30, 2025
1 parent c36ab92 commit f795601
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions buildkit/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,12 @@ func getStartState(buildState llb.State, plan *p.BuildPlan, platform specs.Platf
}

func getImageEnv(graphOutput *build_llb.BuildGraphOutput, plan *p.BuildPlan) []string {
paths := graphOutput.GraphEnv.PathList
paths := []string{system.DefaultPathEnvUnix}
paths = append(paths, graphOutput.GraphEnv.PathList...)
paths = append(paths, plan.Start.Paths...)

pathString := strings.Join(paths, ":")

var pathEnv string
if pathString == "" {
pathEnv = "PATH=" + system.DefaultPathEnvUnix
} else {
pathEnv = "PATH=" + pathString + ":" + system.DefaultPathEnvUnix
}

envMap := make(map[string]string)
envMap["PATH"] = pathEnv

for k, v := range graphOutput.GraphEnv.EnvVars {
envMap[k] = v
Expand All @@ -129,6 +121,8 @@ func getImageEnv(graphOutput *build_llb.BuildGraphOutput, plan *p.BuildPlan) []s
envMap[k] = v
}

envMap["PATH"] = pathString

envVars := make([]string, 0, len(envMap))
for k, v := range envMap {
envVars = append(envVars, fmt.Sprintf("%s=%s", k, v))
Expand Down

0 comments on commit f795601

Please sign in to comment.