Skip to content
This repository was archived by the owner on May 4, 2021. It is now read-only.

Commit 0b31a90

Browse files
authored
Plan: Start working on env cleanup (#316)
1 parent 35b9e70 commit 0b31a90

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/builder/build_plan.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package builder
1717
import (
1818
"fmt"
1919
"hash/crc32"
20+
"os"
2021
"strconv"
2122

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

162163
// Execute executes all build stages in order.
163164
func (plan *BuildPlan) Execute() (*image.DistributionManifest, error) {
165+
// We need to backup the original env to restore it between stages
166+
orignalEnv := utils.ConvertStringSliceToMap(os.Environ())
167+
164168
var currStage *buildStage
165169
for k := 0; k < len(plan.stages); k++ {
166170
currStage = plan.stages[k]
@@ -178,6 +182,12 @@ func (plan *BuildPlan) Execute() (*image.DistributionManifest, error) {
178182
if err := plan.executeStage(currStage, lastStage, copiedFrom); err != nil {
179183
return nil, fmt.Errorf("execute stage: %s", err)
180184
}
185+
186+
// Restore env
187+
os.Clearenv()
188+
for k, v := range orignalEnv {
189+
os.Setenv(k, v)
190+
}
181191
}
182192

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

0 commit comments

Comments
 (0)