Documentation ¶
Index ¶
- Variables
- 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 CannotFindContainerError(op string) error
- func CheckCaCertificateExistInDir(caDir string, dontAskRecreate ...bool) bool
- func CheckDocker() error
- func CheckDockerNetworkExist(networkName string) (bool, 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 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 DecompressFileFromArchive(src io.Reader, archive, filename string) (io.Reader, error)
- func DockerComposeCompleter() ...
- func DockerComposeVersionMismatchError(op string) error
- func DockerPeeredServices(action, networkName string) error
- func DockerVersionMismatchError(op string) error
- func EncodeRSAPrivateKeyToPEM(privateKey *rsa.PrivateKey) ([]byte, error)
- 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 GetAppHomeDir() string
- func GetAppVersion() *version.Version
- func GetBlackfireCommand() string
- func GetBlackfireContainer() string
- func GetCaCertificateFilePath(caDir string) (string, error)
- func GetCaPrivKeyFilePath(caDir string) (string, error)
- func GetComposerVersion() (*version.Version, error)
- func GetContainerIDByName(containerName string) (string, error)
- func GetContainerStateByName(containerName string) (string, error)
- func GetCwd() string
- func GetDBCommand() string
- func GetDBContainer() string
- func GetDBDumpCommand() string
- func GetDockerNetworksWithLabel(label string) ([]string, error)
- func GetEnvName() string
- func GetEnvNetworkName() string
- func GetEnvType() string
- func GetHomeDir() string
- func GetMagentoBackendFrontname() string
- func GetMagentoVersion() (*version.Version, error)
- func GetMagentoVersionFromViper() (*version.Version, error)
- func GetMutagenSyncFile() string
- func GetMutagenSyncIgnore() string
- func GetOSDistro() string
- func GetServiceDomain() string
- func GetTraefikDomain() string
- func GetTraefikFullDomain() string
- func GetTraefikSubdomain() string
- func GetWebRoot() 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 IsAllowedSuperuser() bool
- func IsBlackfireEnabled() bool
- func IsCommandAvailable(name string) bool
- func IsContainerRunning(container string) (bool, error)
- func IsDBEnabled() bool
- func IsDebug() bool
- func IsMutagenSyncEnabled() bool
- func IsServiceEnabled(service string) bool
- func IsSingleWebContainer() bool
- func LookupContainerAddressInNetwork(containerName, environmentName, networkName string) (string, error)
- func LookupContainerGatewayInNetwork(containerName, networkName string) (string, error)
- func NewDockerClient() (*client.Client, error)
- 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 SvcEnabledPermissive(s string) bool
- func SvcEnabledStrict(name string) bool
- func TooManyContainersFoundError(op string) error
- func Unzip(src io.Reader, dest string) ([]string, error)
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 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 CannotFindContainerError ¶
CannotFindContainerError is a wrapper function for ErrCannotFindContainer error.
func CheckCaCertificateExistInDir ¶
CheckCaCertificateExistInDir checks if the CA Certificate PEM file already exists in Dir.
func CheckDockerNetworkExist ¶
CheckDockerNetworkExist returns true if the docker network exists.
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 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 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 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 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 GetAppHomeDir ¶
func GetAppHomeDir() string
GetAppHomeDir returns the application's home directory.
func GetAppVersion ¶
func GetAppVersion() *version.Version
GetAppVersion returns a version.Version object contains the application version.
func GetBlackfireCommand ¶
func GetBlackfireCommand() string
GetBlackfireCommand returns the command which is called when the application manipulates blackfire.
func GetBlackfireContainer ¶
func GetBlackfireContainer() string
GetBlackfireContainer returns the container name of the Blackfire debug container.
func GetCaCertificateFilePath ¶
GetCaCertificateFilePath returns the CA certificate path based on caDir.
func GetCaPrivKeyFilePath ¶
GetCaPrivKeyFilePath returns the CA privkey path based on caDir.
func GetComposerVersion ¶
func GetComposerVersion() (*version.Version, error)
GetComposerVersion returns the Composer Version defined in Viper settings.
func GetContainerIDByName ¶
GetContainerIDByName returns a container ID of the containerName running in
the current environment.
func GetContainerStateByName ¶
GetContainerStateByName returns the container state of the containerName running in
the current environment.
func GetDBCommand ¶
func GetDBCommand() string
GetDBCommand returns the command which is called when the application manipulates the database.
func GetDBContainer ¶
func GetDBContainer() string
GetDBContainer returns the name of the database container.
func GetDBDumpCommand ¶
func GetDBDumpCommand() string
GetDBDumpCommand returns the command which is called when the application dumps a database.
func GetEnvName ¶
func GetEnvName() string
GetEnvName returns the environment name in lowercase format.
func GetEnvNetworkName ¶
func GetEnvNetworkName() string
GetEnvNetworkName returns the environments docker network name in lowercase format.
func GetEnvType ¶
func GetEnvType() string
GetEnvType returns the environment type in lowercase format.
func GetMagentoBackendFrontname ¶
func GetMagentoBackendFrontname() string
GetMagentoBackendFrontname returns Magento admin path from Viper settings.
func GetMagentoVersion ¶
func GetMagentoVersion() (*version.Version, error)
GetMagentoVersion returns a *version.Version object which contains the Magento version.
func GetMagentoVersionFromViper ¶
func GetMagentoVersionFromViper() (*version.Version, error)
GetMagentoVersionFromViper returns a *version.Version object from Viper settings. Note: If it's unset, it will return a dedicated latest version.
func GetMutagenSyncFile ¶
func GetMutagenSyncFile() string
GetMutagenSyncFile returns the file path of the mutagen sync file.
func GetMutagenSyncIgnore ¶
func GetMutagenSyncIgnore() string
GetMutagenSyncIgnore returns the additional mutagen ignored files from Viper settings.
func GetOSDistro ¶
func GetOSDistro() string
GetOSDistro returns the linux distro name if GOOS is linux, else "darwin" or "windows".
func GetServiceDomain ¶
func GetServiceDomain() string
GetServiceDomain returns the application's service domain.
func GetTraefikDomain ¶
func GetTraefikDomain() string
GetTraefikDomain returns traefik domain from Viper settings.
func GetTraefikFullDomain ¶
func GetTraefikFullDomain() string
GetTraefikFullDomain returns traefik full domain (subdomain + domain merged).
func GetTraefikSubdomain ¶
func GetTraefikSubdomain() string
GetTraefikSubdomain returns traefik subdomain from Viper settings.
func GetWebRoot ¶
func GetWebRoot() string
GetWebRoot returns the content of the WEB_ROOT variable from Viper settings.
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 IsAllowedSuperuser ¶
func IsAllowedSuperuser() bool
IsAllowedSuperuser returns true if the application is allowed to be invoked by root.
func IsBlackfireEnabled ¶
func IsBlackfireEnabled() bool
IsBlackfireEnabled returns true if the blackfire container is enabled.
func IsCommandAvailable ¶
IsCommandAvailable returns if the parameter can be find in $PATH.
func IsContainerRunning ¶
IsContainerRunning returns true if container is running.
func IsDBEnabled ¶
func IsDBEnabled() bool
IsDBEnabled returns true if the database service is enabled for the current environment.
func IsMutagenSyncEnabled ¶
func IsMutagenSyncEnabled() bool
IsMutagenSyncEnabled 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 IsServiceEnabled ¶
IsServiceEnabled returns true if service is enabled in Viper settings.
func IsSingleWebContainer ¶
func IsSingleWebContainer() bool
IsSingleWebContainer returns true if Single Web Container setting is enabled in Viper settings.
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 NewDockerClient ¶
NewDockerClient creates a docker client and return with it.
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 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.
Types ¶
This section is empty.