Documentation ¶
Index ¶
- Constants
- Variables
- func IsFileEncrypted(filepath string) (isEncrypted bool, err error)
- func LoadFixtureProject(t *testing.T) func()
- func TestChdir(t *testing.T, dir string) func()
- type Config
- type Detector
- type Hosts
- type MockProjectDetector
- type Options
- type ProjectDetector
- type RandomStringGenerator
- type Requirement
- type RequirementResult
- type Site
- type SiteHost
- type StringGenerator
- type Trellis
- func (t *Trellis) ActivateProject() bool
- func (t *Trellis) AutocompleteEnvironment(flags *flag.FlagSet) complete.Predictor
- func (t *Trellis) AutocompleteSite(flags *flag.FlagSet) complete.Predictor
- func (t *Trellis) CheckVirtualenv(ui cli.Ui)
- func (t *Trellis) ConfigPath() string
- func (t *Trellis) CreateConfigDir() error
- func (t *Trellis) Detect(path string) (projectPath string, ok bool)
- func (t *Trellis) EnvironmentNames() []string
- func (t *Trellis) FindSiteNameFromEnvironment(environment string, siteNameArg string) (string, error)
- func (t *Trellis) GenerateSite(site *Site, host string, env string)
- func (t *Trellis) GenerateVaultConfig(name string, env string, randomString StringGenerator) *Vault
- func (t *Trellis) GenerateVaultPassFile(path string) error
- func (t *Trellis) HostsFromDomain(domain string, env string) (canonical *publicsuffix.DomainName, redirect *publicsuffix.DomainName)
- func (t *Trellis) LoadGlobalCliConfig() error
- func (t *Trellis) LoadProject() error
- func (t *Trellis) LoadProjectCliConfig() error
- func (t *Trellis) MainSiteFromEnvironment(environment string) (string, *Site, error)
- func (t *Trellis) ParseConfig(path string) *Config
- func (t *Trellis) PredictEnvironment(flags *flag.FlagSet) complete.PredictFunc
- func (t *Trellis) PredictSite(flags *flag.FlagSet) complete.PredictFunc
- func (t *Trellis) SiteFromEnvironmentAndName(environment string, name string) *Site
- func (t *Trellis) SiteNamesFromEnvironment(environment string) []string
- func (t *Trellis) SshHost(environment string, siteName string, user string) string
- func (t *Trellis) UpdateAnsibleConfig(section string, key string, value string) error
- func (t *Trellis) UpdateDefaultConfig(config *Config, name string, host string, env string)
- func (t *Trellis) UpdateHosts(env string, ip string) (path string, err error)
- func (t *Trellis) ValidateEnvironment(name string) (err error)
- func (t *Trellis) WriteYamlFile(s interface{}, path string, header string) error
- type TrellisOption
- type Vault
- type VaultUser
- type VaultWordPressSite
- type VaultWordPressSiteEnv
- type Virtualenv
- func (v *Virtualenv) Activate()
- func (v *Virtualenv) Active() bool
- func (v *Virtualenv) Create() (err error)
- func (v *Virtualenv) Deactivate()
- func (v *Virtualenv) Delete() error
- func (v *Virtualenv) Initialized() bool
- func (v *Virtualenv) Installed() (ok bool, cmd *exec.Cmd)
- func (v *Virtualenv) UpdateBinShebangs(binGlob string) error
Constants ¶
const ( ConfigDir = ".trellis" GlobPattern = "group_vars/*/wordpress_sites.yml" )
const DefaultSiteName = "example.com"
const OldPathEnvName string = "PRE_TRELLIS_PATH"
const PathEnvName string = "PATH"
const Template = `
[{{ .Environment }}]
{{ .Host }}
[web]
{{ .Host }}
`
const VenvEnvName string = "VIRTUAL_ENV"
const VirtualenvDir string = "virtualenv"
Variables ¶
var DefaultCliConfig = cli_config.Config{ AllowDevelopmentDeploys: false, AskVaultPass: false, CheckForUpdates: true, LoadPlugins: true, Open: make(map[string]string), VirtualenvIntegration: true, Vm: cli_config.VmConfig{ Manager: "auto", HostsResolver: "hosts_file", Ubuntu: "24.04", }, }
Functions ¶
func IsFileEncrypted ¶
func LoadFixtureProject ¶
Types ¶
type MockProjectDetector ¶ added in v1.3.0
type MockProjectDetector struct {
// contains filtered or unexported fields
}
type ProjectDetector ¶ added in v1.3.0
type ProjectDetector struct{}
type RandomStringGenerator ¶
type RandomStringGenerator struct {
Length int
}
func (*RandomStringGenerator) Generate ¶
func (rs *RandomStringGenerator) Generate() string
type Requirement ¶
type Requirement struct { Name string Command string Url string Optional bool VersionConstraint string ExtractVersion func(output string) string }
func (*Requirement) Check ¶
func (r *Requirement) Check() (result RequirementResult, err error)
func (*Requirement) IsInstalled ¶
func (r *Requirement) IsInstalled() (path string, ok bool)
type RequirementResult ¶
type Site ¶
type Site struct { SiteHosts []SiteHost `yaml:"site_hosts"` AbsLocalPath string `yaml:"-"` LocalPath string `yaml:"local_path"` AdminEmail string `yaml:"admin_email,omitempty"` Branch string `yaml:"branch,omitempty"` Repo string `yaml:"repo,omitempty"` RepoSubtreePath string `yaml:"repo_subtree_path,omitempty"` Multisite map[string]interface{} `yaml:"multisite"` Ssl map[string]interface{} `yaml:"ssl"` Cache map[string]interface{} `yaml:"cache"` }
func (*Site) SslEnabled ¶ added in v1.3.0
type StringGenerator ¶
type StringGenerator interface {
Generate() string
}
type Trellis ¶
type Trellis struct { CliConfig cli_config.Config ConfigDir string Detector Detector Environments map[string]*Config Path string Virtualenv *Virtualenv VenvInitialized bool // contains filtered or unexported fields }
func NewMockTrellis ¶ added in v1.3.0
func NewTrellis ¶
func NewTrellis(opts ...TrellisOption) *Trellis
func (*Trellis) ActivateProject ¶
Activates a Trellis project's virtualenv without loading the config files. This is optimized to be a lighter weight version of LoadProject more suitable for the shell hook.
func (*Trellis) AutocompleteEnvironment ¶
func (*Trellis) AutocompleteSite ¶
func (*Trellis) CheckVirtualenv ¶ added in v1.2.0
func (*Trellis) ConfigPath ¶
func (*Trellis) CreateConfigDir ¶
func (*Trellis) Detect ¶
Detect if a path is a Trellis project or not This will traverse up the directory tree until it finds a valid project, or stop at the root and give up.
func (*Trellis) EnvironmentNames ¶
func (*Trellis) FindSiteNameFromEnvironment ¶
func (*Trellis) GenerateVaultConfig ¶
func (t *Trellis) GenerateVaultConfig(name string, env string, randomString StringGenerator) *Vault
func (*Trellis) GenerateVaultPassFile ¶
func (*Trellis) HostsFromDomain ¶
func (t *Trellis) HostsFromDomain(domain string, env string) (canonical *publicsuffix.DomainName, redirect *publicsuffix.DomainName)
func (*Trellis) LoadGlobalCliConfig ¶ added in v1.11.0
func (*Trellis) LoadProject ¶
Loads a Trellis project. If a project is detected, the wordpress_sites config files are parsed and the directory is changed to the project path.
func (*Trellis) LoadProjectCliConfig ¶ added in v1.8.0
func (*Trellis) MainSiteFromEnvironment ¶ added in v1.11.0
func (*Trellis) ParseConfig ¶
func (*Trellis) PredictEnvironment ¶
func (t *Trellis) PredictEnvironment(flags *flag.FlagSet) complete.PredictFunc
func (*Trellis) PredictSite ¶
func (t *Trellis) PredictSite(flags *flag.FlagSet) complete.PredictFunc
func (*Trellis) SiteFromEnvironmentAndName ¶
func (*Trellis) SiteNamesFromEnvironment ¶
func (*Trellis) UpdateAnsibleConfig ¶
func (*Trellis) UpdateDefaultConfig ¶
func (*Trellis) UpdateHosts ¶
func (*Trellis) ValidateEnvironment ¶
type TrellisOption ¶ added in v1.3.0
type TrellisOption func(*Trellis)
func WithOptions ¶ added in v1.3.0
func WithOptions(options *Options) TrellisOption
type Vault ¶
type Vault struct { MysqlRootPassword string `yaml:"vault_mysql_root_password"` Users []VaultUser `yaml:"vault_users,omitempty"` WordPressSites map[string]VaultWordPressSite `yaml:"vault_wordpress_sites"` }
type VaultWordPressSite ¶
type VaultWordPressSite struct { AdminPassword string `yaml:"admin_password"` Env VaultWordPressSiteEnv `yaml:"env"` }
type VaultWordPressSiteEnv ¶
type VaultWordPressSiteEnv struct { DbPassword string `yaml:"db_password"` AuthKey string `yaml:"auth_key,omitempty"` SecureAuthKey string `yaml:"secure_auth_key,omitempty"` LoggedInKey string `yaml:"logged_in_key,omitempty"` NonceKey string `yaml:"nonce_key,omitempty"` AuthSalt string `yaml:"auth_salt,omitempty"` SecureAuthSalt string `yaml:"secure_auth_salt,omitempty"` LoggedInSalt string `yaml:"logged_in_salt,omitempty"` NonceSalt string `yaml:"nonce_salt,omitempty"` }
type Virtualenv ¶
func NewVirtualenv ¶
func NewVirtualenv(path string) *Virtualenv
func (*Virtualenv) Activate ¶
func (v *Virtualenv) Activate()
func (*Virtualenv) Active ¶
func (v *Virtualenv) Active() bool
func (*Virtualenv) Create ¶
func (v *Virtualenv) Create() (err error)
func (*Virtualenv) Deactivate ¶
func (v *Virtualenv) Deactivate()
func (*Virtualenv) Delete ¶ added in v1.4.0
func (v *Virtualenv) Delete() error
func (*Virtualenv) Initialized ¶
func (v *Virtualenv) Initialized() bool
func (*Virtualenv) UpdateBinShebangs ¶ added in v1.6.0
func (v *Virtualenv) UpdateBinShebangs(binGlob string) error
Updates the shebang lines in pip generated bin files to properly handle paths with spaces.
Pip does not properly handle paths with spaces in them when creating the bin scripts:
#!/path with spaces/bin/python
This is an invalid POSIX path so Python can't execute the script.
As a workaround, this function replaces that invalid shebang with the workaround that Virtualenv uses itself for the pip binary:
#!/bin/sh '''exec' "/path with spaces/bin/python" "$0" "$@" ' '''
If this function is called on a BinPath without spaces, it's just a no-op that doesn't modify any files.