github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/pkg/ddevapp/assets.go (about) 1 package ddevapp 2 3 import ( 4 "embed" 5 "github.com/drud/ddev/pkg/fileutil" 6 "github.com/drud/ddev/pkg/globalconfig" 7 ) 8 9 // The bundled assets for the project .ddev directory are in directory dotddev_assets 10 // And the global .ddev assets are in directory global_dotddev_assets 11 // 12 //go:embed dotddev_assets/* dotddev_assets/commands/.gitattributes global_dotddev_assets/* global_dotddev_assets/.gitignore global_dotddev_assets/commands/.gitattributes app_compose_template.yaml router_compose_template.yaml ssh_auth_compose_template.yaml traefik_config_template.yaml traefik_static_config_template.yaml traefik_global_config_template.yaml router_Dockerfile_template drupal/* magento/* wordpress/* typo3/* postgres/* healthcheck/* 13 var bundledAssets embed.FS 14 15 // PopulateExamplesCommandsHomeadditions grabs embedded assets and 16 // installs them into the named directory 17 // Note that running this with no appName (very common) can result in updating 18 // a *different* projects assets. So `ddev start something` will first update the current 19 // directory's assets (if it's a project) and then later (when called with appName) update 20 // the actual project's assets. 21 func PopulateExamplesCommandsHomeadditions(appName string) error { 22 app, err := GetActiveApp(appName) 23 // If we have an error from GetActiveApp, it means we're not in a project directory 24 // That's not an error, just means we can't do this work, so return nil. 25 if err != nil { 26 return nil 27 } 28 29 err = fileutil.CopyEmbedAssets(bundledAssets, "dotddev_assets", app.GetConfigPath("")) 30 if err != nil { 31 return err 32 } 33 err = fileutil.CopyEmbedAssets(bundledAssets, "global_dotddev_assets", globalconfig.GetGlobalDdevDir()) 34 if err != nil { 35 return err 36 } 37 38 return nil 39 }