|
5 | 5 | "flag" |
6 | 6 | "fmt" |
7 | 7 | "github.com/loft-sh/devspace/pkg/devspace/config/loader" |
| 8 | + "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/expression" |
8 | 9 | "github.com/loft-sh/devspace/pkg/devspace/config/versions/latest" |
9 | 10 | "github.com/loft-sh/devspace/pkg/devspace/env" |
10 | 11 | "github.com/loft-sh/devspace/pkg/util/log" |
@@ -185,11 +186,18 @@ func BuildRoot(f factory.Factory, excludePlugins bool) *cobra.Command { |
185 | 186 | } |
186 | 187 |
|
187 | 188 | // try to parse the raw config |
188 | | - rawConfig, err := parseConfig(f) |
189 | | - if err != nil { |
190 | | - f.GetLog().Debugf("error parsing raw config: %v", err) |
191 | | - } else { |
192 | | - env.GlobalGetEnv = rawConfig.GetEnv |
| 189 | + var rawConfig *RawConfig |
| 190 | + |
| 191 | + // This check is necessary to avoid process loops where a variable inside |
| 192 | + // the devspace.yaml would execute another devspace command which would again |
| 193 | + // load the config and execute DevSpace config parsing etc. |
| 194 | + if os.Getenv(expression.DEVSPACE_SKIP_PRELOAD_ENV) == "" { |
| 195 | + rawConfig, err = parseConfig(f) |
| 196 | + if err != nil { |
| 197 | + f.GetLog().Debugf("error parsing raw config: %v", err) |
| 198 | + } else { |
| 199 | + env.GlobalGetEnv = rawConfig.GetEnv |
| 200 | + } |
193 | 201 | } |
194 | 202 |
|
195 | 203 | // build the root cmd |
@@ -323,7 +331,9 @@ func parseConfig(f factory.Factory) (*RawConfig, error) { |
323 | 331 | r := &RawConfig{ |
324 | 332 | resolved: map[string]string{}, |
325 | 333 | } |
326 | | - _, err = configLoader.LoadWithParser(timeoutCtx, nil, nil, r, &loader.ConfigOptions{Dry: true}, log.Discard) |
| 334 | + _, err = configLoader.LoadWithParser(timeoutCtx, nil, nil, r, &loader.ConfigOptions{ |
| 335 | + Dry: true, |
| 336 | + }, log.Discard) |
327 | 337 | if r.Resolver != nil { |
328 | 338 | return r, nil |
329 | 339 | } |
|
0 commit comments