MCPcopy Index your code
hub / github.com/ddev/ddev / GetProcessedProjectConfigYAML

Method GetProcessedProjectConfigYAML

pkg/ddevapp/config.go:187–224  ·  view source on GitHub ↗

GetProcessedProjectConfigYAML returns the processed project configuration as YAML This is equivalent to what 'ddev utility configyaml' shows - the project configuration after all config.*.yaml files have been merged and processed

(omitKeys ...string)

Source from the content-addressed store, hash-verified

185// This is equivalent to what 'ddev utility configyaml' shows - the project configuration
186// after all config.*.yaml files have been merged and processed
187func (app *DdevApp) GetProcessedProjectConfigYAML(omitKeys ...string) ([]byte, error) {
188 // Ensure we have the latest processed configuration
189 _, err := app.ReadConfig(true)
190 if err != nil {
191 return nil, fmt.Errorf("failed to read project configuration: %v", err)
192 }
193
194 // Marshal the fully processed DdevApp struct to YAML
195 configYAML, err := yaml.Marshal(app)
196 if err != nil {
197 return nil, fmt.Errorf("failed to marshal project configuration to YAML: %v", err)
198 }
199
200 // If no keys to omit, return as-is
201 if len(omitKeys) == 0 {
202 return configYAML, nil
203 }
204
205 // Parse YAML into a map to filter keys
206 var configMap map[string]any
207 err = yaml.Unmarshal(configYAML, &configMap)
208 if err != nil {
209 return nil, fmt.Errorf("failed to parse YAML for filtering: %v", err)
210 }
211
212 // Remove specified keys
213 for _, key := range omitKeys {
214 delete(configMap, strings.TrimSpace(key))
215 }
216
217 // Marshal back to YAML
218 filteredYAML, err := yaml.Marshal(configMap)
219 if err != nil {
220 return nil, fmt.Errorf("failed to marshal filtered YAML: %v", err)
221 }
222
223 return filteredYAML, nil
224}
225
226// WriteConfig writes the app configuration into the .ddev folder.
227func (app *DdevApp) WriteConfig() error {

Callers 2

createConfigurationFilesFunction · 0.80

Calls 3

ReadConfigMethod · 0.95
ErrorfMethod · 0.80
UnmarshalMethod · 0.65

Tested by

no test coverage detected