Skip to content

Commit

Permalink
Fix PATH Order (#1679)
Browse files Browse the repository at this point in the history
* fix path order

Signed-off-by: Richard Li <ricli@linkedin.com>

* whitespace

Signed-off-by: Richard Li <ricli@linkedin.com>

---------

Signed-off-by: Richard Li <ricli@linkedin.com>
Co-authored-by: Richard Li <ricli@linkedin.com>
  • Loading branch information
RichhLi and Richard Li committed Jun 30, 2023
1 parent 1e21826 commit b5f9a49
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/lang/ir/v1/system.go
Expand Up @@ -353,15 +353,20 @@ func (g *generalGraph) compileBaseImage() (llb.State, error) {
// 1. configured paths in the Starlark frontend `runtime.environ(extra_path=[...])`
// 2. paths in the base image
// 3. others added during the image building (Python paths, etc.)
extraPaths := make(map[string]bool)
for _, path := range strings.Split(kv[1], ":") {
extraPaths[path] = true
}

// iterate over the original paths and add them to the map
pathMap := make(map[string]bool)
for _, path := range g.RuntimeEnvPaths {
extraPaths[path] = false
pathMap[path] = true
}
for path, required := range extraPaths {
if required {
// split the PATH into different paths
newPaths := strings.Split(kv[1], ":")
// iterate over the new paths
for _, path := range newPaths {
// check if the path is already in the map
if _, ok := pathMap[path]; !ok {
// if not, add the path to the map and slice
pathMap[path] = true
g.RuntimeEnvPaths = append(g.RuntimeEnvPaths, path)
}
}
Expand Down

0 comments on commit b5f9a49

Please sign in to comment.