Merge "Freeze environment reading after saving deps"
diff --git a/common/config.go b/common/config.go
index 348d0db..f8231f0 100644
--- a/common/config.go
+++ b/common/config.go
@@ -48,8 +48,9 @@
srcDir string // the path of the root source directory
- envLock sync.Mutex
- envDeps map[string]string
+ envLock sync.Mutex
+ envDeps map[string]string
+ envFrozen bool
}
type jsonConfigurable interface {
@@ -178,6 +179,9 @@
var exists bool
c.envLock.Lock()
if val, exists = c.envDeps[key]; !exists {
+ if c.envFrozen {
+ panic("Cannot access new environment variables after envdeps are frozen")
+ }
val = os.Getenv(key)
c.envDeps[key] = val
}
@@ -186,6 +190,9 @@
}
func (c *config) EnvDeps() map[string]string {
+ c.envLock.Lock()
+ c.envFrozen = true
+ c.envLock.Unlock()
return c.envDeps
}