MCPcopy Index your code
hub / github.com/devspace-sh/devspace / parseConfig

Method parseConfig

pkg/devspace/config/loader/loader.go:296–365  ·  view source on GitHub ↗
(
	ctx context.Context,
	rawConfig map[string]interface{},
	localCache localcache.Cache,
	remoteCache remotecache.Cache,
	client kubectl.Client,
	parser Parser,
	options *ConfigOptions,
	log log.Logger,
)

Source from the content-addressed store, hash-verified

294}
295
296func (l *configLoader) parseConfig(
297 ctx context.Context,
298 rawConfig map[string]interface{},
299 localCache localcache.Cache,
300 remoteCache remotecache.Cache,
301 client kubectl.Client,
302 parser Parser,
303 options *ConfigOptions,
304 log log.Logger,
305) (*latest.Config, map[string]interface{}, variable.Resolver, error) {
306 // create a new variable resolver
307 resolver, err := variable.NewResolver(localCache, &variable.PredefinedVariableOptions{
308 ConfigPath: l.absConfigPath,
309 KubeClient: client,
310 Profile: options.Profiles,
311 }, options.Vars, log)
312 if err != nil {
313 return nil, nil, nil, err
314 }
315
316 // copy raw config
317 copiedRawConfig, err := ResolveImports(ctx, resolver, filepath.Dir(l.absConfigPath), rawConfig, log)
318 if err != nil {
319 return nil, nil, nil, err
320 }
321
322 // Delete imports from config
323 delete(copiedRawConfig, "imports")
324
325 // prepare profiles
326 copiedRawConfig, err = prepareProfiles(ctx, copiedRawConfig, resolver)
327 if err != nil {
328 return nil, nil, nil, err
329 }
330
331 // apply the profiles
332 copiedRawConfig, err = l.applyProfiles(ctx, copiedRawConfig, options, resolver, log)
333 if err != nil {
334 return nil, nil, nil, err
335 }
336
337 // reload variables to make sure they are loaded correctly
338 err = reloadVariables(resolver, copiedRawConfig, log)
339 if err != nil {
340 return nil, nil, nil, err
341 }
342
343 // Delete vars from config
344 delete(copiedRawConfig, "vars")
345
346 // parse the config
347 latestConfig, rawBeforeConversion, err := parser.Parse(ctx, rawConfig, copiedRawConfig, resolver, log)
348 if err != nil {
349 return nil, nil, nil, err
350 }
351
352 // check if we do not want to change the generated config or
353 // secret vars.

Callers 2

LoadWithParserMethod · 0.95
TestParseConfigFunction · 0.80

Calls 7

applyProfilesMethod · 0.95
NewResolverFunction · 0.92
ResolveImportsFunction · 0.85
prepareProfilesFunction · 0.85
reloadVariablesFunction · 0.85
ParseMethod · 0.65
SaveMethod · 0.65

Tested by 1

TestParseConfigFunction · 0.64