globalconfig

package
v1.19.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DdevSSHAgentContainer = "ddev-ssh-agent"
	DBAContainer          = "dba"
	DdevRouterContainer   = "ddev-router"
)

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

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

DdevGlobalConfigName is the name of the global config 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 = (os.Getenv("DDEV_DEBUG") == "true")

DdevDebug is set to true if the env var is set

View Source
var DdevNoInstrumentation = os.Getenv("DDEV_NO_INSTRUMENTATION") == "true"

DdevNoInstrumentation is set to true if the env var is set

View Source
var DdevVerbose = (os.Getenv("DDEV_VERBOSE") == "true")

DdevVerbose is set to true if the env var is set

View Source
var IsInternetActiveAlreadyChecked = false

IsInternetActiveAlreadyChecked just flags whether it's been checked

View Source
var IsInternetActiveNetResolver interface {
	LookupHost(ctx context.Context, host string) (addrs []string, err 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 = 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

Functions

func CheckHostPortsAvailable added in v1.7.0

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

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

func GetCAROOT added in v1.13.0

func GetCAROOT() string

GetCAROOT is just a wrapper on global config

func GetDDEVBinDir added in v1.18.2

func GetDDEVBinDir() string

GetDDEVBinDir returns the directory of the mutagen config and binary

func GetDockerComposePath added in v1.18.2

func GetDockerComposePath() (string, error)

GetDockerComposePath gets the full path to the docker-compose binary Normally this is the one that has been downloaded to ~/.ddev/bin, but if UseDockerComposeFromPath, then it will be whatever if found in $PATH

func GetFreePort added in v1.7.0

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 GetGlobalDdevDir

func GetGlobalDdevDir() string

GetGlobalDdevDir returns ~/.ddev, the global caching directory

func GetGlobalProjectList added in v1.9.0

func GetGlobalProjectList() map[string]*ProjectInfo

GetGlobalProjectList returns the global project list map

func GetMutagenPath added in v1.18.0

func GetMutagenPath() string

GetMutagenPath gets the full path to the mutagen binary

func GetTableStyle added in v1.18.0

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 added in v1.7.0

func HostPostIsAllocated(port string) string

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

func IsInternetActive added in v1.15.0

func IsInternetActive() bool

IsInternetActive checks to see if we have a viable internet connection. It just 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 added in v1.18.0

func IsValidTableStyle(style string) bool

IsValidTableStyle checks to see if the table style is valid

func ReadGlobalConfig

func ReadGlobalConfig() error

ReadGlobalConfig reads the global config file into DdevGlobalConfig

func RemoveProjectInfo added in v1.8.0

func RemoveProjectInfo(projectName string) error

RemoveProjectInfo removes the ProjectInfo line for a project

func ReservePorts added in v1.7.0

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

ReservePorts adds the ProjectInfo if necessary and assigns the reserved ports

func SetProjectAppRoot added in v1.9.0

func SetProjectAppRoot(projectName string, appRoot string) error

SetProjectAppRoot sets the approot in the ProjectInfo of global config

func ValidTableStyleList added in v1.18.0

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.

Types

type GlobalConfig

type GlobalConfig struct {
	OmitContainersGlobal         []string                `yaml:"omit_containers,flow"`
	NFSMountEnabledGlobal        bool                    `yaml:"nfs_mount_enabled"`
	MutagenEnabledGlobal         bool                    `yaml:"mutagen_enabled"`
	InstrumentationOptIn         bool                    `yaml:"instrumentation_opt_in"`
	RouterBindAllInterfaces      bool                    `yaml:"router_bind_all_interfaces"`
	InternetDetectionTimeout     int64                   `yaml:"internet_detection_timeout_ms"`
	DeveloperMode                bool                    `yaml:"developer_mode,omitempty"`
	InstrumentationUser          string                  `yaml:"instrumentation_user,omitempty"`
	LastStartedVersion           string                  `yaml:"last_started_version"`
	UseHardenedImages            bool                    `yaml:"use_hardened_images"`
	UseLetsEncrypt               bool                    `yaml:"use_letsencrypt"`
	LetsEncryptEmail             string                  `yaml:"letsencrypt_email"`
	AutoRestartContainers        bool                    `yaml:"auto_restart_containers"`
	FailOnHookFailGlobal         bool                    `yaml:"fail_on_hook_fail"`
	WebEnvironment               []string                `yaml:"web_environment"`
	DisableHTTP2                 bool                    `yaml:"disable_http2"`
	TableStyle                   string                  `yaml:"table_style"`
	SimpleFormatting             bool                    `yaml:"simple_formatting"`
	RequiredDockerComposeVersion string                  `yaml:"required_docker_compose_version,omitempty"`
	UseDockerComposeFromPath     bool                    `yaml:"use_docker_compose_from_path,omitempty"`
	NoBindMounts                 bool                    `yaml:"no_bind_mounts"`
	MkcertCARoot                 string                  `yaml:"mkcert_caroot"`
	ProjectList                  map[string]*ProjectInfo `yaml:"project_info"`
}

GlobalConfig is the struct defining ddev's global config

var (
	// DdevGlobalConfig is the currently active global configuration struct
	DdevGlobalConfig GlobalConfig
)

type InvalidOmitContainers

type InvalidOmitContainers error

type ProjectInfo added in v1.7.0

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

func GetProject added in v1.9.0

func GetProject(projectName string) *ProjectInfo

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

Jump to

Keyboard shortcuts

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