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

Function Parse

pkg/devspace/config/versions/versions.go:122–178  ·  view source on GitHub ↗

Parse parses the data into the latest config

(data map[string]interface{}, log log.Logger)

Source from the content-addressed store, hash-verified

120
121// Parse parses the data into the latest config
122func Parse(data map[string]interface{}, log log.Logger) (*latest.Config, error) {
123 version, ok := data["version"].(string)
124 if !ok {
125 return nil, errors.Errorf("Version is missing in devspace.yaml")
126 }
127
128 loader, ok := VersionLoader[version]
129 if !ok {
130 return nil, errors.Errorf("Unrecognized config version %s. Please upgrade devspace with `devspace upgrade`", version)
131 }
132
133 versionLoadFunc := loader.New
134
135 // Load config strict
136 latestConfig := versionLoadFunc()
137 out, err := yaml.Marshal(data)
138 if err != nil {
139 return nil, err
140 }
141 err = yamlutil.UnmarshalStrict(out, latestConfig)
142 if err != nil {
143 return nil, errors.Errorf("error loading config: %v", err)
144 }
145
146 // Upgrade config to latest
147 for latestConfig.GetVersion() != latest.Version {
148 upgradedConfig, err := latestConfig.Upgrade(log)
149 if err != nil {
150 return nil, errors.Errorf("Error upgrading config from version %s: %v", latestConfig.GetVersion(), err)
151 }
152
153 latestConfig = upgradedConfig
154 }
155
156 // Convert
157 latestConfigConverted, ok := latestConfig.(*latest.Config)
158 if !ok {
159 return nil, errors.Errorf("Error converting config, latest config is not the latest version")
160 }
161
162 // Update version to latest
163 latestConfigConverted.Version = latest.Version
164
165 // Filter out empty images, deployments etc.
166 err = adjustConfig(latestConfigConverted)
167 if err != nil {
168 return nil, err
169 }
170
171 // validate config
172 err = Validate(latestConfigConverted)
173 if err != nil {
174 return nil, err
175 }
176
177 return latestConfigConverted, nil
178}
179

Callers 8

applyPipelineSetValueFunction · 0.92
applySetValuesFunction · 0.92
fillVariablesAndParseFunction · 0.92
ResolveImportsFunction · 0.92
ParseVariablesFunction · 0.70
getProfilesFunction · 0.70
getActivatedProfilesFunction · 0.70
TestParseFunction · 0.70

Calls 6

UnmarshalStrictFunction · 0.92
adjustConfigFunction · 0.85
ValidateFunction · 0.85
GetVersionMethod · 0.65
UpgradeMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

TestParseFunction · 0.56