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

Method LoadWithParser

pkg/devspace/config/loader/loader.go:114–198  ·  view source on GitHub ↗

LoadWithParser loads the config with the given parser

(ctx context.Context, localCache localcache.Cache, client kubectl.Client, parser Parser, options *ConfigOptions, log log.Logger)

Source from the content-addressed store, hash-verified

112
113// LoadWithParser loads the config with the given parser
114func (l *configLoader) LoadWithParser(ctx context.Context, localCache localcache.Cache, client kubectl.Client, parser Parser, options *ConfigOptions, log log.Logger) (_ config.Config, err error) {
115 if localCache == nil {
116 localCache, err = l.LoadLocalCache()
117 if err != nil {
118 return nil, err
119 }
120 }
121 if options == nil {
122 options = &ConfigOptions{}
123 }
124
125 defer func() {
126 if err != nil {
127 pluginErr := plugin.ExecutePluginHookWithContext(map[string]interface{}{"ERROR": err, "LOAD_PATH": l.absConfigPath}, "config.errorLoad", "error:loadConfig")
128 if pluginErr != nil {
129 log.Warnf("Error executing plugin hook: %v", pluginErr)
130 return
131 }
132 }
133 }()
134
135 // call plugin hook
136 pluginErr := plugin.ExecutePluginHookWithContext(map[string]interface{}{"LOAD_PATH": l.absConfigPath}, "config.beforeLoad", "before:loadConfig")
137 if pluginErr != nil {
138 return nil, pluginErr
139 }
140
141 // load the raw data
142 data, err := l.LoadRaw()
143 if err != nil {
144 return nil, err
145 }
146
147 // make sure name is in config
148 name := options.OverrideName
149 if name == "" {
150 var ok bool
151 name, ok = data["name"].(string)
152 if !ok {
153 return nil, fmt.Errorf("name is missing in %s", filepath.Base(l.absConfigPath))
154 }
155 } else {
156 data["name"] = options.OverrideName
157 }
158
159 // validate name
160 if encoding.IsUnsafeName(name) {
161 return nil, fmt.Errorf("DevSpace config has an invalid name '%s', must match regex %s", name, encoding.UnsafeNameRegEx.String())
162 }
163
164 // set name to context
165 ctx = values.WithName(ctx, name)
166
167 // create remote cache
168 var remoteCache remotecache.Cache
169 if client != nil {
170 remoteCache, err = remotecache.NewCacheLoader(name).Load(ctx, client)
171 if err != nil {

Callers 3

testGetProfilesFunction · 0.95
TestParseCommandsFunction · 0.95
LoadWithCacheMethod · 0.95

Calls 15

LoadLocalCacheMethod · 0.95
LoadRawMethod · 0.95
parseConfigMethod · 0.95
ensureRequiresMethod · 0.95
ConfigMethod · 0.95
VariablesMethod · 0.95
RawMethod · 0.95
IsUnsafeNameFunction · 0.92
WithNameFunction · 0.92
NewCacheLoaderFunction · 0.92
NewConfigFunction · 0.92

Tested by 2

testGetProfilesFunction · 0.76
TestParseCommandsFunction · 0.76