Skip to content

Commit

Permalink
Plan: Start working on env cleanup (uber-archive#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rowern authored Apr 2, 2020
1 parent 35b9e70 commit 0b31a90
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/builder/build_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package builder
import (
"fmt"
"hash/crc32"
"os"
"strconv"

"github.com/uber/makisu/lib/cache"
Expand Down Expand Up @@ -161,6 +162,9 @@ func (plan *BuildPlan) processStagesAndAliases(

// Execute executes all build stages in order.
func (plan *BuildPlan) Execute() (*image.DistributionManifest, error) {
// We need to backup the original env to restore it between stages
orignalEnv := utils.ConvertStringSliceToMap(os.Environ())

var currStage *buildStage
for k := 0; k < len(plan.stages); k++ {
currStage = plan.stages[k]
Expand All @@ -178,6 +182,12 @@ func (plan *BuildPlan) Execute() (*image.DistributionManifest, error) {
if err := plan.executeStage(currStage, lastStage, copiedFrom); err != nil {
return nil, fmt.Errorf("execute stage: %s", err)
}

// Restore env
os.Clearenv()
for k, v := range orignalEnv {
os.Setenv(k, v)
}
}

// Wait for cache layers to be pushed. This will make them available to
Expand Down

0 comments on commit 0b31a90

Please sign in to comment.