trellis

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigDir   = ".trellis"
	GlobPattern = "group_vars/*/wordpress_sites.yml"
)
View Source
const DefaultSiteName = "example.com"
View Source
const OldPathEnvName string = "PRE_TRELLIS_PATH"
View Source
const PathEnvName string = "PATH"
View Source
const Template = `
[{{ .Environment }}]
{{ .Host }}

[web]
{{ .Host }}
`
View Source
const VenvEnvName string = "VIRTUAL_ENV"
View Source
const VirtualenvDir string = "virtualenv"

Variables

View Source
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:        "22.04",
	},
}

Functions

func IsFileEncrypted

func IsFileEncrypted(filepath string) (isEncrypted bool, err error)

func LoadFixtureProject

func LoadFixtureProject(t *testing.T) func()

func TestChdir

func TestChdir(t *testing.T, dir string) func()

Types

type Config

type Config struct {
	WordPressSites map[string]*Site `yaml:"wordpress_sites"`
}

func (*Config) AllHosts added in v1.9.0

func (c *Config) AllHosts() []string

func (*Config) AllHostsByDomain added in v1.9.0

func (c *Config) AllHostsByDomain() map[string][]dns.Host

type Detector

type Detector interface {
	Detect(path string) (projectPath string, ok bool)
}

type Hosts

type Hosts struct {
	Environment string
	Host        string
}

type MockProjectDetector added in v1.3.0

type MockProjectDetector struct {
	// contains filtered or unexported fields
}

func (*MockProjectDetector) Detect added in v1.3.0

func (p *MockProjectDetector) Detect(path string) (projectPath string, ok bool)

type Options added in v1.3.0

type Options struct {
	Detector  Detector
	ConfigDir string
}

type ProjectDetector added in v1.3.0

type ProjectDetector struct{}

func (*ProjectDetector) Detect added in v1.3.0

func (p *ProjectDetector) Detect(path string) (projectPath string, ok bool)

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.

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 RequirementResult struct {
	Satisfied bool
	Installed bool
	Message   string
	Version   string
}

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) MainHost

func (s *Site) MainHost() string

func (*Site) MainUrl added in v1.3.0

func (s *Site) MainUrl() string

func (*Site) SslEnabled added in v1.3.0

func (s *Site) SslEnabled() bool

type SiteHost

type SiteHost struct {
	Canonical string   `yaml:"canonical"`
	Redirects []string `yaml:"redirects"`
}

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 NewMockTrellis(projectDetected bool) *Trellis

func NewTrellis

func NewTrellis(opts ...TrellisOption) *Trellis

func (*Trellis) ActivateProject

func (t *Trellis) ActivateProject() bool

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 (t *Trellis) AutocompleteEnvironment(flags *flag.FlagSet) complete.Predictor

func (*Trellis) AutocompleteSite

func (t *Trellis) AutocompleteSite(flags *flag.FlagSet) complete.Predictor

func (*Trellis) CheckVirtualenv added in v1.2.0

func (t *Trellis) CheckVirtualenv(ui cli.Ui)

func (*Trellis) ConfigPath

func (t *Trellis) ConfigPath() string

func (*Trellis) CreateConfigDir

func (t *Trellis) CreateConfigDir() error

func (*Trellis) Detect

func (t *Trellis) Detect(path string) (projectPath string, ok bool)

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 (t *Trellis) EnvironmentNames() []string

func (*Trellis) FindSiteNameFromEnvironment

func (t *Trellis) FindSiteNameFromEnvironment(environment string, siteNameArg string) (string, error)

func (*Trellis) GenerateSite

func (t *Trellis) GenerateSite(site *Site, host string, env string)

func (*Trellis) GenerateVaultConfig

func (t *Trellis) GenerateVaultConfig(name string, env string, randomString StringGenerator) *Vault

func (*Trellis) GenerateVaultPassFile

func (t *Trellis) GenerateVaultPassFile(path string) error

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 (t *Trellis) LoadGlobalCliConfig() error

func (*Trellis) LoadProject

func (t *Trellis) LoadProject() error

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 (t *Trellis) LoadProjectCliConfig() error

func (*Trellis) MainSiteFromEnvironment added in v1.11.0

func (t *Trellis) MainSiteFromEnvironment(environment string) (string, *Site, error)

func (*Trellis) ParseConfig

func (t *Trellis) ParseConfig(path string) *Config

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 (t *Trellis) SiteFromEnvironmentAndName(environment string, name string) *Site

func (*Trellis) SiteNamesFromEnvironment

func (t *Trellis) SiteNamesFromEnvironment(environment string) []string

func (*Trellis) SshHost added in v1.9.0

func (t *Trellis) SshHost(environment string, siteName string, user string) string

func (*Trellis) UpdateAnsibleConfig

func (t *Trellis) UpdateAnsibleConfig(section string, key string, value string) error

func (*Trellis) UpdateDefaultConfig

func (t *Trellis) UpdateDefaultConfig(config *Config, name string, host string, env string)

func (*Trellis) UpdateHosts

func (t *Trellis) UpdateHosts(env string, ip string) (path string, err error)

func (*Trellis) ValidateEnvironment

func (t *Trellis) ValidateEnvironment(name string) (err error)

func (*Trellis) WriteYamlFile

func (t *Trellis) WriteYamlFile(s interface{}, path string, header string) error

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 VaultUser

type VaultUser struct {
	Name     string `yaml:"name"`
	Password string `yaml:"password"`
	Salt     string `yaml:"salt"`
}

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

type Virtualenv struct {
	Path    string
	BinPath string
	OldPath string
}

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) Installed

func (v *Virtualenv) Installed() (ok bool, cmd *exec.Cmd)

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.

Jump to

Keyboard shortcuts

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