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

Method WriteConfig

pkg/ddevapp/config.go:227–321  ·  view source on GitHub ↗

WriteConfig writes the app configuration into the .ddev folder.

()

Source from the content-addressed store, hash-verified

225
226// WriteConfig writes the app configuration into the .ddev folder.
227func (app *DdevApp) WriteConfig() error {
228 // Work against a copy of the DdevApp, since we don't want to actually change it.
229 appcopy := *app
230
231 // If the app name has been changed by `config.*.yaml`,
232 // remove it from the main config.yaml file.
233 if hasConfigNameOverride, _ := app.HasConfigNameOverride(); hasConfigNameOverride {
234 appcopy.Name = ""
235 }
236
237 // Only set the images on write if non-default values have been specified.
238 if appcopy.WebImage == docker.GetWebImage() {
239 appcopy.WebImage = ""
240 }
241 if appcopy.RouterHTTPPort == nodeps.DdevDefaultRouterHTTPPort {
242 appcopy.RouterHTTPPort = ""
243 }
244 if appcopy.RouterHTTPSPort == nodeps.DdevDefaultRouterHTTPSPort {
245 appcopy.RouterHTTPSPort = ""
246 }
247 if appcopy.MailpitHTTPPort == nodeps.DdevDefaultMailpitHTTPPort {
248 appcopy.MailpitHTTPPort = ""
249 }
250 if appcopy.MailpitHTTPSPort == nodeps.DdevDefaultMailpitHTTPSPort {
251 appcopy.MailpitHTTPSPort = ""
252 }
253 if appcopy.ProjectTLD == globalconfig.DdevGlobalConfig.ProjectTldGlobal {
254 appcopy.ProjectTLD = ""
255 }
256 if appcopy.DefaultContainerTimeout == nodeps.DefaultDefaultContainerTimeout {
257 appcopy.DefaultContainerTimeout = ""
258 }
259
260 if appcopy.NodeJSVersion == nodeps.NodeJSDefault {
261 appcopy.NodeJSVersion = ""
262 }
263
264 // Ensure valid type
265 if appcopy.Type == nodeps.AppTypeNone {
266 appcopy.Type = nodeps.AppTypePHP
267 }
268
269 if composerV1Regex.MatchString(appcopy.ComposerVersion) {
270 appcopy.ComposerVersion = "2.2"
271 util.WarningOnce(`Project '%s' now uses Composer v2.2 LTS. Composer v1 is no longer supported by Packagist, see https://blog.packagist.com/shutting-down-packagist-org-support-for-composer-1-x/`, app.Name)
272 }
273
274 // We now want to reserve the port we're writing for HostDBPort and HostWebserverPort and so they don't
275 // accidentally get used for other projects.
276 err := app.UpdateGlobalProjectList()
277 if err != nil {
278 return err
279 }
280
281 // Don't write default working dir values to config
282 defaults := appcopy.DefaultWorkingDirMap()
283 for service, defaultWorkingDir := range defaults {
284 if app.WorkingDir[service] == defaultWorkingDir {

Callers 15

TestExtraPackagesFunction · 0.95
TestMainFunction · 0.95
TestDdevNoProjectMountFunction · 0.95
TestDdevImportDBFunction · 0.95
TestDdevAllDatabasesFunction · 0.95
TestDdevExportDBFunction · 0.95
TestDdevFullSiteSetupFunction · 0.95

Calls 9

HasConfigNameOverrideMethod · 0.95
GetWebImageFunction · 0.92
WarningOnceFunction · 0.92
PrepDdevDirectoryFunction · 0.85
DefaultWorkingDirMapMethod · 0.80
PostConfigActionMethod · 0.80

Tested by 15

TestExtraPackagesFunction · 0.76
TestMainFunction · 0.76
TestDdevNoProjectMountFunction · 0.76
TestDdevImportDBFunction · 0.76
TestDdevAllDatabasesFunction · 0.76
TestDdevExportDBFunction · 0.76
TestDdevFullSiteSetupFunction · 0.76