Skip to content

Commit 4335082

Browse files
committed
add ready
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
1 parent 730d5e2 commit 4335082

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/app/app_config.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ type Config struct {
124124

125125
LogConfig *logConfig `envPrefix:"LOG_"`
126126
LogLevel log.Level `env:"-"`
127+
128+
Ready bool
127129
}
128130

129131
func NewConfig() *Config {
@@ -140,6 +142,10 @@ func NewConfig() *Config {
140142
}
141143

142144
func (cfg *Config) Parse() error {
145+
if cfg.Ready {
146+
return nil
147+
}
148+
143149
opts := env.Options{
144150
Prefix: "",
145151
}
@@ -151,10 +157,18 @@ func (cfg *Config) Parse() error {
151157

152158
cfg.LogLevel = log.LogLevelFromStr(cfg.LogConfig.Level)
153159

160+
cfg.SetupGlobalVars()
161+
162+
cfg.Ready = true
163+
154164
return nil
155165
}
156166

157167
func (cfg *Config) SetupGlobalVars() {
168+
if cfg.Ready {
169+
return
170+
}
171+
158172
setIfNotEmpty(&HooksDir, cfg.AppConfig.HooksDir)
159173
setIfNotEmpty(&TempDir, cfg.AppConfig.TmpDir)
160174
setIfNotEmpty(&ListenAddress, cfg.AppConfig.ListenAddress)

0 commit comments

Comments
 (0)