Documentation
¶
Index ¶
- Variables
- func AppHomeDir() string
- func AppVersion() *version.Version
- func AppendEnvironmentTemplates(t *template.Template, templateList *list.List, partialName string) error
- func AppendMutagenTemplates(t *template.Template, templateList *list.List, partialName string) error
- func AppendTemplatesFromPaths(t *template.Template, templateList *list.List, paths []string) error
- func AppendTemplatesFromPathsStatic(t *template.Template, templateList *list.List, paths []string) error
- func ArgumentRequiredError(op string) error
- func AskForConfirmation(msg string, suppressMessage ...bool) bool
- func BlackfireCommand() string
- func BlackfireContainer() string
- func BlackfireEnabled() bool
- func CACertificateFilePath(caDir string) (string, error)
- func CAPrivKeyFilePath(caDir string) (string, error)
- func CannotFindContainerError(op string) error
- func CheckCaCertificateExistInDir(caDir string, dontAskRecreate ...bool) bool
- func CheckDocker() error
- func CheckExitCodeOfCommand(command string) int
- func CheckFileExists(file string) bool
- func CheckFileExistsAndRecreate(file string) bool
- func CheckRegexInFile(regex, filePath string) (bool, error)
- func CheckRegexInString(regex, str string) bool
- func Cleanup() error
- func CommandAvailable(name string) bool
- func ComposerVersion() (*version.Version, error)
- func ContainerIDByName(containerName string) (string, error)
- func ContainerRunning(container string) (bool, error)
- func ContainerStateByName(containerName string) (string, error)
- func ContainsString(slice []string, val string) bool
- func ConvertTemplateToComposeConfig(t *template.Template, templateList *list.List) (compose.ConfigDetails, error)
- func CreateCaCertificate(caDir string) error
- func CreateDir(dir string, perms ...int) error
- func CreateDirAndWriteBytesToFile(bytes []byte, file string, perms ...int) error
- func CreatePrivKeyAndCertificate(certDir string, certName string, dnsNames []string, ...) error
- func CreateSignedCertificate(c certificateComponents) ([]byte, error)
- func Cwd() string
- func DBCommand() string
- func DBContainer() string
- func DBDumpCommand() string
- func DecompressFileFromArchive(src io.Reader, archive, filename string) (io.Reader, error)
- func DockerComposeCompleter() ...
- func DockerComposeVersionMismatchError(op string) error
- func DockerHost() string
- func DockerNetworkExist(networkName string) (bool, error)
- func DockerNetworksByLabel(label string) ([]string, error)
- func DockerPeeredServices(action, networkName string) error
- func DockerVersionMismatchError(op string) error
- func EncodeRSAPrivateKeyToPEM(privateKey *rsa.PrivateKey) ([]byte, error)
- func EnvName() string
- func EnvNetworkName() string
- func EnvType() string
- func EvalSymlinkPath(file string) (string, error)
- func ExecuteTemplate(t *template.Template, buffer io.Writer) error
- func ExtractUnknownArgs(flags *pflag.FlagSet, args []string) []string
- func FileNotFoundError(op string) error
- func GenerateAndSaveSSHKeys(bitSize int, pathToSave string) error
- func GenerateMutagenTemplateFileIfNotExist() error
- func GenerateRSAPrivateKey(bitSize int) (*rsa.PrivateKey, error)
- func GenerateSSHPublicKey(publicKey *rsa.PublicKey) ([]byte, error)
- func HomeDir() string
- func InsertStringAfterOccurrence(args []string, insertStr, searchStr string) []string
- func InsertStringBeforeOccurrence(args []string, insertStr, searchStr string) []string
- func InstallCaCertificate(caDir string) error
- func InstallDNSResolver()
- func InstallSSHConfig() error
- func IsAdmin() bool
- func IsDBEnabled() bool
- func IsDebug() bool
- func LookupContainerAddressInNetwork(containerName, environmentName, networkName string) (string, error)
- func LookupContainerGatewayInNetwork(containerName, networkName string) (string, error)
- func MagentoBackendFrontname() string
- func MagentoVersion() (*version.Version, error)
- func MagentoVersionFromViper() (*version.Version, error)
- func MutagenSyncEnabled() bool
- func MutagenSyncFile() string
- func MutagenSyncIgnore() string
- func NewDockerClient() (*client.Client, error)
- func OSDistro() string
- func Pipeline(cmds ...*exec.Cmd) (pipeLineOutput, collectedStandardError []byte, pipeLineError error)
- func Quote(s string) string
- func ResolveDomainToTraefik() bool
- func RunDockerComposeCommand(args []string, suppressOsStdOut ...bool) (string, error)
- func RunDockerComposeWithConfig(args []string, details compose.ConfigDetails, suppressOsStdOut ...bool) (string, error)
- func RunMeElevated()
- func RunOsCommand(args []string, suppressOsStdOut ...bool) (string, error)
- func ServiceDomain() string
- func ServiceEnabled(service string) bool
- func SingleWebContainer() bool
- func SuperuserAllowed() bool
- func SvcEnabledPermissive(s string) bool
- func SvcEnabledStrict(name string) bool
- func TooManyContainersFoundError(op string) error
- func TraefikDomain() string
- func TraefikFullDomain() string
- func TraefikSubdomain() string
- func Unzip(src io.Reader, dest string) ([]string, error)
- func WebRoot() string
Constants ¶
This section is empty.
Variables ¶
var ( SslBaseDir = "ssl" CaBaseDir = "rootca" CertBaseDir = "certs" )
var ( // FS is a Memory Map Filesystem. FS = afero.NewOsFs() // AFS is the implementation of Afero Filesystem. AFS = &afero.Afero{Fs: FS} )
var ( // ErrEmptyDirName occurs when directory name is empty. ErrEmptyDirName = errors.New("empty directory name") // ErrFileWithThisDirNameExist occurs when file already exist. ErrFileWithThisDirNameExist = errors.New("file with the same name exists") // ErrFileNotFound occurs when file is not found. ErrFileNotFound = errors.New("file not found") // ErrUnknownEnvType occurs when an unknown environment type is specified. ErrUnknownEnvType = errors.New("unknown env type") // ErrUnknownAction occurs when an unknown actions is called. ErrUnknownAction = errors.New("unknown action error") // ErrDockerAPIIsUnreachable occurs when Docker is not running, Docker version is too old, // or the user who runs the application cannot call Docker API. ErrDockerAPIIsUnreachable = errors.New("docker api is unreachable") // ErrDockerVersionMismatch occurs when Docker version is too old. ErrDockerVersionMismatch = errors.New("docker version is too old") // ErrDockerComposeVersionMismatch occurs when docker-compose version is too old. ErrDockerComposeVersionMismatch = errors.New("docker-compose version is too old") // ErrEnvNameIsInvalid occurs when the environment name is invalid. It should be a valid hostname. ErrEnvNameIsInvalid = errors.New("environment name is invalid, it should match RFC1178") // ErrEnvIsEmpty occurs when environment name is empty. ErrEnvIsEmpty = fmt.Errorf("env name is empty. please run `%v env-init`", AppName) // ErrCaCertDoesNotExist occurs when the Signing CA Certificate is not yet created. ErrCaCertDoesNotExist = fmt.Errorf( "the root CA certificate is missing, please run '%v install' and try again", AppName, ) // ErrCannotFindContainer occurs when the application cannot find the requested container. ErrCannotFindContainer = errors.New("container cannot be found") // ErrTooManyContainersFound occurs when the application found more than 1 container. ErrTooManyContainersFound = errors.New("too many containers found") // ErrArgumentRequired occurs when the function is called without a required argument. ErrArgumentRequired = errors.New("argument required") // ErrInvokedAsRootUser occurs when the Application was called by Root user. ErrInvokedAsRootUser = errors.New( "In most cases, you should not run " + AppName + " as root user except for `self-update`. " + "If you are sure you want to do this, use " + strings.ToUpper(AppName) + "_ALLOW_SUPERUSER=1.", ) )
var ( // AppName is the lowercase Application Name, used globally. AppName = strings.ToLower(appname) )
var (
TmpFilesList = list.New()
)
Functions ¶
func AppVersion ¶
func AppVersion() *version.Version
AppVersion returns a version.Version object contains the application version.
func AppendEnvironmentTemplates ¶
func AppendEnvironmentTemplates(t *template.Template, templateList *list.List, partialName string) error
AppendEnvironmentTemplates tries to look up all the templates dedicated for an environment type.
func AppendMutagenTemplates ¶
func AppendMutagenTemplates(t *template.Template, templateList *list.List, partialName string) error
AppendMutagenTemplates is going to add mutagen configuration templates.
func AppendTemplatesFromPaths ¶
AppendTemplatesFromPaths appends templates to t from templateList list searching them in paths path list. If it cannot find templates it's not going to fail. If a template with the same name already exists, it's going to skip that template.
func AppendTemplatesFromPathsStatic ¶
func AppendTemplatesFromPathsStatic(t *template.Template, templateList *list.List, paths []string) error
AppendTemplatesFromPathsStatic appends templates to t from templateList list searching them in paths path list. This function looks up templates built to the application's binary (static files). If it cannot find templates it's not going to fail. If a template with the same name already exists, it's going to skip that template.
func ArgumentRequiredError ¶
ArgumentRequiredError is a wrapper function for ErrArgumentRequired error.
func AskForConfirmation ¶
AskForConfirmation ask msg from the user and returns the answer.
func BlackfireCommand ¶
func BlackfireCommand() string
BlackfireCommand returns the command which is called when the application manipulates blackfire.
func BlackfireContainer ¶
func BlackfireContainer() string
BlackfireContainer returns the container name of the Blackfire debug container.
func BlackfireEnabled ¶
func BlackfireEnabled() bool
BlackfireEnabled returns true if the blackfire container is enabled.
func CACertificateFilePath ¶
CACertificateFilePath returns the CA certificate path based on caDir.
func CAPrivKeyFilePath ¶
CAPrivKeyFilePath returns the CA privkey path based on caDir.
func CannotFindContainerError ¶
CannotFindContainerError is a wrapper function for ErrCannotFindContainer error.
func CheckCaCertificateExistInDir ¶
CheckCaCertificateExistInDir checks if the CA Certificate PEM file already exists in Dir.
func CheckExitCodeOfCommand ¶
CheckExitCodeOfCommand runs a command and returns its exit code.
func CheckFileExists ¶
CheckFileExists checks if the file already exists and ask the user if he'd like to recreate it.
func CheckFileExistsAndRecreate ¶
CheckFileExistsAndRecreate checks if the file already exists and ask the user if he'd like to recreate it.
If user input is yes - return false (as if the file does not existing).
func CheckRegexInFile ¶
CheckRegexInFile checks if the file contains content.
func CheckRegexInString ¶
CheckRegexInString checks if the string contains content.
func CommandAvailable ¶
CommandAvailable returns if the parameter can be find in $PATH.
func ComposerVersion ¶
func ComposerVersion() (*version.Version, error)
ComposerVersion returns the Composer Version defined in Viper settings.
func ContainerIDByName ¶
ContainerIDByName returns a container ID of the containerName running in
the current environment.
func ContainerRunning ¶
ContainerRunning returns true if container is running.
func ContainerStateByName ¶
ContainerStateByName returns the container state of the containerName running in
the current environment.
func ContainsString ¶
ContainsString checks if a slice of string contains a string.
func ConvertTemplateToComposeConfig ¶
func ConvertTemplateToComposeConfig(t *template.Template, templateList *list.List) (compose.ConfigDetails, error)
ConvertTemplateToComposeConfig iterates through all the templates and converts them to docker-compose configurations.
func CreateCaCertificate ¶
CreateCaCertificate creates a Private Key and a Signed CA Certificate in PEM format and writes to file.
func CreateDirAndWriteBytesToFile ¶
CreateDirAndWriteBytesToFile creates the base directory and writes bytes to a file in it.
func CreatePrivKeyAndCertificate ¶
func CreatePrivKeyAndCertificate( certDir string, certName string, dnsNames []string, caCertFilePath, caPrivKeyFilePath string, ) error
CreatePrivKeyAndCertificate creates a Private Key and a Certificate signed by caCertificate and writes to file in PEM format.
func CreateSignedCertificate ¶
func DBCommand ¶
func DBCommand() string
DBCommand returns the command which is called when the application manipulates the database.
func DBContainer ¶
func DBContainer() string
DBContainer returns the name of the database container.
func DBDumpCommand ¶
func DBDumpCommand() string
DBDumpCommand returns the command which is called when the application dumps a database.
func DockerComposeCompleter ¶
func DockerComposeCompleter() func(cmd *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective, )
DockerComposeCompleter returns a completer function for docker-compose.
func DockerComposeVersionMismatchError ¶
DockerComposeVersionMismatchError is a wrapper function for ErrDockerComposeVersionMismatch error.
func DockerHost ¶
func DockerHost() string
func DockerNetworkExist ¶
DockerNetworkExist returns true if the docker network exists.
func DockerNetworksByLabel ¶
func DockerPeeredServices ¶
DockerPeeredServices attaches/detaches the common services to the current environment's docker network.
func DockerVersionMismatchError ¶
DockerVersionMismatchError is a wrapper function for ErrDockerVersionMismatch error.
func EncodeRSAPrivateKeyToPEM ¶
func EncodeRSAPrivateKeyToPEM(privateKey *rsa.PrivateKey) ([]byte, error)
EncodeRSAPrivateKeyToPEM encodes Private Key from RSA to PEM format.
func EnvNetworkName ¶
func EnvNetworkName() string
EnvNetworkName returns the environments docker network name in lowercase format.
func EvalSymlinkPath ¶
EvalSymlinkPath checks if file exists and returns the resolved path if a symlink if file is a symlink,
else it returns the filepath.
func ExecuteTemplate ¶
ExecuteTemplate executes the templates, appending some specific template functions to the execution.
func ExtractUnknownArgs ¶
ExtractUnknownArgs returns []string arguments which are not used by pflags.
func FileNotFoundError ¶
FileNotFoundError is a wrapper function for ErrFileNotFound error.
func GenerateAndSaveSSHKeys ¶
GenerateAndSaveSSHKeys generates and writes SSH keys with bitSize and saves them to pathToSave.
func GenerateMutagenTemplateFileIfNotExist ¶
func GenerateMutagenTemplateFileIfNotExist() error
GenerateMutagenTemplateFileIfNotExist generates mutagen configuration from template if it doesn't exists.
func GenerateRSAPrivateKey ¶
func GenerateRSAPrivateKey(bitSize int) (*rsa.PrivateKey, error)
GenerateRSAPrivateKey creates a RSA Private Key of specified byte size.
func GenerateSSHPublicKey ¶
GenerateSSHPublicKey takes a rsa.PublicKey and return bytes suitable for writing to .pub file returns in the format "ssh-rsa ...".
func InsertStringAfterOccurrence ¶
InsertStringAfterOccurrence inserts insertStr after the occurrence of searchStr to args and returns args.
If searchStr is not exists it will append to the end of args.
func InsertStringBeforeOccurrence ¶
InsertStringBeforeOccurrence inserts insertStr before occurrence of searchStr (if exist) to args and returns args.
If searchStr is not exists it will append to the end of args.
func InstallCaCertificate ¶
InstallCaCertificate installs the generated CA certificate.
func InstallDNSResolver ¶
func InstallDNSResolver()
InstallDNSResolver configures local DNS resolution based on the operating system.
func InstallSSHConfig ¶
func InstallSSHConfig() error
InstallSSHConfig updates the ssh config file to use our key if the target host is the tunnel.
func IsDBEnabled ¶
func IsDBEnabled() bool
IsDBEnabled returns true if the database service is enabled for the current environment.
func LookupContainerAddressInNetwork ¶
func LookupContainerAddressInNetwork(containerName, environmentName, networkName string) (string, error)
LookupContainerAddressInNetwork returns the container IP address in the specific network.
func LookupContainerGatewayInNetwork ¶
LookupContainerGatewayInNetwork returns the container IP address in the specific network.
func MagentoBackendFrontname ¶
func MagentoBackendFrontname() string
MagentoBackendFrontname returns Magento admin path from Viper settings.
func MagentoVersion ¶
func MagentoVersion() (*version.Version, error)
MagentoVersion returns a *version.Version object which contains the Magento version.
func MagentoVersionFromViper ¶
func MagentoVersionFromViper() (*version.Version, error)
MagentoVersionFromViper returns a *version.Version object from Viper settings. Note: If it's unset, it will return a dedicated latest version.
func MutagenSyncEnabled ¶
func MutagenSyncEnabled() bool
MutagenSyncEnabled returns true for macOS and Windows if it's not disabled explicitly (or if the WSL2 Direct Mount option is not enabled on Windows).
func MutagenSyncFile ¶
func MutagenSyncFile() string
MutagenSyncFile returns the file path of the mutagen sync file.
func MutagenSyncIgnore ¶
func MutagenSyncIgnore() string
MutagenSyncIgnore returns the additional mutagen ignored files from Viper settings.
func NewDockerClient ¶
NewDockerClient creates a docker client and return with it.
func OSDistro ¶
func OSDistro() string
OSDistro returns the linux distro name if GOOS is linux, else "darwin" or "windows".
func Pipeline ¶
func Pipeline(cmds ...*exec.Cmd) (pipeLineOutput, collectedStandardError []byte, pipeLineError error)
Pipeline runs cmds piped after each other.
func Quote ¶
Quote puts a quote around s string in Unix-like systems and returns it, while it just returns s as-is on Windows.
func ResolveDomainToTraefik ¶
func ResolveDomainToTraefik() bool
ResolveDomainToTraefik returns true if an environment's service containers should resolve their "main" domains to the Traefik container's address. If this is enabled, the nginx/php containers will be able to reach themselves through the traefik proxy.
func RunDockerComposeCommand ¶
RunDockerComposeCommand runs the passed parameters with docker-compose and returns the output.
func RunDockerComposeWithConfig ¶
func RunDockerComposeWithConfig( args []string, details compose.ConfigDetails, suppressOsStdOut ...bool, ) (string, error)
RunDockerComposeWithConfig calls docker-compose with the converted configuration settings (from templates).
func RunOsCommand ¶
RunOsCommand is going to run a command depending on the caller's operating system.
func ServiceDomain ¶
func ServiceDomain() string
ServiceDomain returns the application's service domain.
func ServiceEnabled ¶
ServiceEnabled returns true if service is enabled in Viper settings.
func SingleWebContainer ¶
func SingleWebContainer() bool
SingleWebContainer returns true if Single Web Container setting is enabled in Viper settings.
func SuperuserAllowed ¶
func SuperuserAllowed() bool
SuperuserAllowed returns true if the application is allowed to be invoked by root.
func SvcEnabledPermissive ¶
SvcEnabledPermissive returns true if the s service is enabled in Viper settings. This function is also going to return true if the service is not mentioned in Viper settings (defaults to true).
func SvcEnabledStrict ¶
SvcEnabledStrict returns true if the s service is enabled in Viper settings. This function is going to return false if the service is not mentioned in Viper settings (defaults to false).
func TooManyContainersFoundError ¶
TooManyContainersFoundError is a wrapper function for ErrCannotFindContainer error.
func TraefikDomain ¶
func TraefikDomain() string
TraefikDomain returns traefik domain from Viper settings.
func TraefikFullDomain ¶
func TraefikFullDomain() string
TraefikFullDomain returns traefik full domain (subdomain + domain merged).
func TraefikSubdomain ¶
func TraefikSubdomain() string
TraefikSubdomain returns traefik subdomain from Viper settings.
Types ¶
This section is empty.