globalconfig

package
v1.25.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRemoteConfigURL is the default URL for remote config data
	DefaultRemoteConfigURL = "https://raw.githubusercontent.com/ddev/remote-config/main/remote-config.jsonc"
	// DefaultSponsorshipDataURL is the default URL for sponsorship data
	DefaultSponsorshipDataURL = "https://ddev.com/s/sponsorship-data.json"
	// DefaultAddonDataURL is the default URL for add-on registry data
	DefaultAddonDataURL = "https://addons.ddev.com/addons.json"
)
View Source
const (
	DdevSSHAgentContainer      = "ddev-ssh-agent"
	DdevRouterContainer        = "ddev-router"
	XdebugIDELocationContainer = "container"
	XdebugIDELocationWSL2      = "wsl2"
)

Container types used with DDEV (duplicated from ddevapp, avoiding cross-package cycles)

View Source
const DdevGithubOrg = "ddev"
View Source
const DdevGlobalConfigName = "global_config.yaml"

DdevGlobalConfigName is the name of the global config file.

View Source
const DdevProjectListFileName = "project_list.yaml"

DdevProjectListFileName is the name of the global projects file.

Variables

View Source
var (
	FormatOptionsDefault = table.FormatOptions{

		Header: text.FormatUpper,
		Row:    text.FormatDefault,
	}

	DdevDefaultStyle = table.Style{
		Name:    "StyleLight",
		Box:     table.StyleBoxLight,
		Color:   table.ColorOptionsDefault,
		Format:  FormatOptionsDefault,
		HTML:    table.DefaultHTMLOptions,
		Options: OptionsSeparateRows,
		Title:   table.TitleOptionsDefault,
	}
	DdevStyleBold = table.Style{
		Name:    "StyleBold",
		Box:     table.StyleBoxBold,
		Color:   table.ColorOptionsDefault,
		Format:  FormatOptionsDefault,
		HTML:    table.DefaultHTMLOptions,
		Options: table.OptionsDefault,
		Title:   table.TitleOptionsDefault,
	}
	DdevStyleColoredBright = table.Style{
		Name:    "StyleColoredBright",
		Box:     table.StyleBoxDefault,
		Color:   table.ColorOptionsBright,
		Format:  FormatOptionsDefault,
		HTML:    table.DefaultHTMLOptions,
		Options: table.OptionsNoBordersAndSeparators,
		Title:   table.TitleOptionsDark,
	}
)
View Source
var DdevDebug = nodeps.IsEnvTrue("DDEV_DEBUG") || DdevVerbose

DdevDebug is set to true if the env var is set If DdevVerbose is true, DdevDebug is true

View Source
var DdevNoInstrumentation = nodeps.IsEnvTrue("DDEV_NO_INSTRUMENTATION") || os.Getenv("CI") == "true"

DdevNoInstrumentation is set to true if the env var is set

View Source
var DdevVerbose = nodeps.IsEnvTrue("DDEV_VERBOSE")

DdevVerbose is set to true if the env var is set

View Source
var GoroutineCount = 0

GoroutineCount for tests

View Source
var IsInternetActiveAlreadyChecked = false

IsInternetActiveAlreadyChecked flags whether it's been checked

View Source
var IsInternetActiveErr error

IsInternetActiveErr is any error from the check

View Source
var IsInternetActiveNetResolver interface {
	LookupIP(ctx context.Context, network, host string) ([]net.IP, error)
} = net.DefaultResolver

IsInternetActiveNetResolver wraps the standard DNS resolver. In order to override net.DefaultResolver with a stub, we have to define an interface on our own since there is none from the standard library.

View Source
var IsInternetActiveResult = false

IsInternetActiveResult is the result of the check

View Source
var OptionsSeparateRows = table.Options{
	DrawBorder:      true,
	SeparateColumns: true,
	SeparateFooter:  true,
	SeparateHeader:  true,
	SeparateRows:    true,
}
View Source
var StyleMap = map[string]table.Style{
	"default": DdevDefaultStyle,
	"bold":    DdevStyleBold,
	"bright":  DdevStyleColoredBright,
}

StyleMap give the list of available styles

ValidOmitContainers is the valid omit's that can be done in for a project

View Source
var ValidXdebugIDELocations = []string{XdebugIDELocationContainer, XdebugIDELocationWSL2, ""}

Functions

func CheckForMultipleGlobalDdevDirs added in v1.25.0

func CheckForMultipleGlobalDdevDirs() error

CheckForMultipleGlobalDdevDirs returns an error if a global DDEV config exists in a location other than the one DDEV uses, so the user can remove or relocate it. Leftover config at a no-longer-honored $XDG_CONFIG_HOME/ddev is reported with instructions to set DDEV_XDG_CONFIG_HOME or remove it. A stale ~/.ddev or, on Linux, ~/.config/ddev is also reported; when both Linux standard locations exist, ~/.ddev wins by precedence but either is valid.

func CheckHostPortsAvailable

func CheckHostPortsAvailable(projectName string, ports []string) error

CheckHostPortsAvailable checks GlobalDdev UsedHostPorts to see if requested ports are available.

func EnsureGlobalConfig added in v1.22.0

func EnsureGlobalConfig()

EnsureGlobalConfig Make sure the global configuration has been initialized

func GetCAROOT

func GetCAROOT() string

GetCAROOT is a wrapper on global config

func GetDDEVBinDir

func GetDDEVBinDir() string

GetDDEVBinDir returns the directory of the Mutagen config and binary

func GetDockerBuildxDestination added in v1.25.3

func GetDockerBuildxDestination() (string, error)

GetDockerBuildxDestination gets the full path to the docker-buildx binary which is going to be downloaded in ~/.ddev/bin

func GetFreePort

func GetFreePort(localIPAddr string) (string, error)

GetFreePort gets an ephemeral port currently available, but also not listed in DdevGlobalConfig.UsedHostPorts

func GetGlobalConfigPath

func GetGlobalConfigPath() string

GetGlobalConfigPath gets the path to global config file

func GetGlobalConfigYAML added in v1.24.8

func GetGlobalConfigYAML() ([]byte, error)

GetGlobalConfigYAML returns the global DDEV configuration as YAML This provides access to global settings that affect all DDEV projects

func GetGlobalDdevDir

func GetGlobalDdevDir() string

GetGlobalDdevDir returns the DDEV global config directory, and creates it as needed.

func GetGlobalDdevDirLocation added in v1.23.2

func GetGlobalDdevDirLocation() string

GetGlobalDdevDirLocation returns the global config directory location to be used by DDEV: $DDEV_XDG_CONFIG_HOME/ddev if $DDEV_XDG_CONFIG_HOME is set (all platforms), ~/.config/ddev if this directory exists on Linux/WSL2 only, ~/.ddev otherwise.

func GetGlobalProjectList

func GetGlobalProjectList() map[string]*ProjectInfo

GetGlobalProjectList returns the global project list map

func GetMutagenDataDirectory

func GetMutagenDataDirectory() string

GetMutagenDataDirectory gets the full path to the MUTAGEN_DATA_DIRECTORY As a side-effect, it sets MUTAGEN_DATA_DIRECTORY if it's not set

func GetMutagenPath

func GetMutagenPath() string

GetMutagenPath gets the full path to the Mutagen binary

func GetProjectListPath added in v1.22.7

func GetProjectListPath() string

GetProjectListPath gets the path to global projects file

func GetRequiredDockerBuildxVersion added in v1.25.3

func GetRequiredDockerBuildxVersion() string

GetRequiredDockerBuildxVersion returns the docker-buildx version DDEV should download, or empty string when docker_buildx_version is "system" (the default), meaning no download.

func GetRouterURL

func GetRouterURL() string

GetRouterURL Return the Traefik router URL

func GetTableStyle

func GetTableStyle() string

GetTableStyle returns the configured (string) table style

func GetValidOmitContainers

func GetValidOmitContainers() []string

GetValidOmitContainers is a helper function that returns a list of valid containers for OmitContainers.

func HostPostIsAllocated

func HostPostIsAllocated(port string) string

HostPostIsAllocated returns the project name that has allocated the port, or empty string.

func IsInteractive added in v1.24.9

func IsInteractive() bool

IsInteractive returns true if we are running in an interactive mode

func IsInternetActive

func IsInternetActive() bool

IsInternetActive checks to see if we have a viable internet connection. It tries a quick DNS query. This requires that the named record be query-able. This check will only be made once per command run.

func IsValidOmitContainers

func IsValidOmitContainers(containerList []string) bool

IsValidOmitContainers is a helper function to determine if the OmitContainers array is valid

func IsValidTableStyle

func IsValidTableStyle(style string) bool

IsValidTableStyle checks to see if the table style is valid

func IsValidXdebugIDELocation

func IsValidXdebugIDELocation(loc string) bool

IsValidXdebugIDELocation limits the choices for XdebugIDELocation

func ReadCAROOTDetails added in v1.25.3

func ReadCAROOTDetails() (string, error)

ReadCAROOTDetails verifies that the mkcert command is available and its CA keys readable. 1. Find out CAROOT 2. Look there to see if key/crt are readable 3. If not, see if mkcert is even available, return empty

func ReadGlobalConfig

func ReadGlobalConfig() error

ReadGlobalConfig reads the global config file into DdevGlobalConfig Or creates the file

func ReadProjectList added in v1.22.7

func ReadProjectList() error

ReadProjectList reads the global projects file into DdevProjectList Or creates the file

func RemoveProjectInfo

func RemoveProjectInfo(projectName string) error

RemoveProjectInfo removes the ProjectInfo line for a project

func ReservePorts

func ReservePorts(projectName string, ports []string) error

ReservePorts adds the ProjectInfo if necessary and assigns the reserved ports

func SetProjectAppRoot

func SetProjectAppRoot(projectName string, appRoot string) error

SetProjectAppRoot sets the approot in the ProjectInfo of global config

func ValidTableStyleList

func ValidTableStyleList() []string

ValidTableStyleList returns an array of valid styles

func ValidateGlobalConfig

func ValidateGlobalConfig() error

ValidateGlobalConfig validates global config

func WriteGlobalConfig

func WriteGlobalConfig(config GlobalConfig) error

WriteGlobalConfig writes the global config into ~/.ddev.

func WriteProjectList added in v1.22.7

func WriteProjectList(projects map[string]*ProjectInfo) error

WriteProjectList writes the global projects list into ~/.ddev.

Types

type GlobalConfig

type GlobalConfig struct {
	DeveloperMode                    bool                        `yaml:"developer_mode,omitempty"`
	DockerBuildxVersion              string                      `yaml:"docker_buildx_version,omitempty"`
	FailOnHookFailGlobal             bool                        `yaml:"fail_on_hook_fail"`
	InstrumentationOptIn             bool                        `yaml:"instrumentation_opt_in"`
	InstrumentationQueueSize         int                         `yaml:"instrumentation_queue_size,omitempty"`
	InstrumentationReportingInterval time.Duration               `yaml:"instrumentation_reporting_interval,omitempty"`
	InstrumentationUser              string                      `yaml:"instrumentation_user,omitempty"`
	InternetDetectionTimeout         int64                       `yaml:"internet_detection_timeout_ms"`
	LastStartedVersion               string                      `yaml:"last_started_version"`
	LetsEncryptEmail                 string                      `yaml:"letsencrypt_email"`
	Messages                         MessagesConfig              `yaml:"messages,omitempty"`
	MkcertCARoot                     string                      `yaml:"mkcert_caroot"`
	NoBindMounts                     bool                        `yaml:"no_bind_mounts"`
	NoTUI                            bool                        `yaml:"no_tui,omitempty"`
	OmitContainersGlobal             []string                    `yaml:"omit_containers,flow"`
	OmitProjectNameByDefault         bool                        `yaml:"omit_project_name_by_default,omitempty"`
	OmitSnapshotOnDelete             bool                        `yaml:"omit_snapshot_on_delete,omitempty"`
	PerformanceMode                  configTypes.PerformanceMode `yaml:"performance_mode"`
	ProjectTldGlobal                 string                      `yaml:"project_tld"`
	RemoteConfig                     RemoteConfig                `yaml:"remote_config,omitempty"`
	Router                           string                      `yaml:"router,omitempty"`
	RouterBindAllInterfaces          bool                        `yaml:"router_bind_all_interfaces"`
	RouterHTTPPort                   string                      `yaml:"router_http_port"`
	RouterHTTPSPort                  string                      `yaml:"router_https_port"`
	RouterMailpitHTTPPort            string                      `yaml:"mailpit_http_port,omitempty"`
	RouterMailpitHTTPSPort           string                      `yaml:"mailpit_https_port,omitempty"`
	RouterXHGuiHTTPPort              string                      `yaml:"xhgui_http_port,omitempty"`
	RouterXHGuiHTTPSPort             string                      `yaml:"xhgui_https_port,omitempty"`
	ShareDefaultProvider             string                      `yaml:"share_default_provider,omitempty"`
	SimpleFormatting                 bool                        `yaml:"simple_formatting"`
	TableStyle                       string                      `yaml:"table_style"`
	TraefikMonitorPort               string                      `yaml:"traefik_monitor_port,omitempty"`
	UseHardenedImages                bool                        `yaml:"use_hardened_images"`
	UseLetsEncrypt                   bool                        `yaml:"use_letsencrypt"`
	WSL2NoWindowsHostsMgt            bool                        `yaml:"wsl2_no_windows_hosts_mgt"`
	WebEnvironment                   []string                    `yaml:"web_environment"`
	XdebugIDELocation                string                      `yaml:"xdebug_ide_location"`
	XHProfMode                       configTypes.XHProfMode      `yaml:"xhprof_mode,omitempty"`
	ProjectList                      map[string]*ProjectInfo     `yaml:"project_info,omitempty"`
}

GlobalConfig is the struct defining ddev's global config

var (
	// DdevGlobalConfig is the currently active global configuration struct
	DdevGlobalConfig GlobalConfig
	// DdevProjectList is the list of all existing DDEV projects
	DdevProjectList map[string]*ProjectInfo
)

func New added in v1.22.0

func New() GlobalConfig

New returns a default GlobalConfig

func (*GlobalConfig) GetPerformanceMode added in v1.22.0

func (c *GlobalConfig) GetPerformanceMode() types.PerformanceMode

GetPerformanceMode returns the performance mode config respecting defaults.

func (*GlobalConfig) GetXHProfMode added in v1.24.4

func (c *GlobalConfig) GetXHProfMode() types.XHProfMode

GetXHProfMode returns the xhprof mode config respecting defaults.

func (*GlobalConfig) IsMutagenEnabled added in v1.22.0

func (c *GlobalConfig) IsMutagenEnabled() bool

IsMutagenEnabled returns true if Mutagen is enabled.

func (*GlobalConfig) SetPerformanceMode added in v1.22.0

func (c *GlobalConfig) SetPerformanceMode(performanceMode string) *GlobalConfig

SetPerformanceMode sets the performance mode config.

func (*GlobalConfig) SetXHProfMode added in v1.24.4

func (c *GlobalConfig) SetXHProfMode(xhprofMode string) *GlobalConfig

SetXHProfMode sets the xhprof mode config.

type InvalidOmitContainers

type InvalidOmitContainers error

type MessagesConfig added in v1.22.0

type MessagesConfig struct {
	TickerInterval int `yaml:"ticker_interval,omitempty"`
}

MessagesConfig is the struct defining the messages config.

type ProjectInfo

type ProjectInfo struct {
	AppRoot       string   `yaml:"approot"`
	UsedHostPorts []string `yaml:"used_host_ports,omitempty,flow"`
}

func GetProject

func GetProject(projectName string) *ProjectInfo

GetProject returns a project given name provided, or nil if not found.

type RemoteConfig added in v1.22.0

type RemoteConfig struct {
	UpdateInterval     int    `yaml:"update_interval,omitempty"`
	RemoteConfigURL    string `yaml:"remote_config_url,omitempty"`
	SponsorshipDataURL string `yaml:"sponsorship_data_url,omitempty"`
	AddonDataURL       string `yaml:"addon_data_url,omitempty"`
}

RemoteConfig is the struct defining the remote-config config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL