Documentation ¶
Index ¶
- func AllowHost(host string)
- func AskForConfirmation(s string) bool
- func CheckPath(cmd string) bool
- func Contains(slice []string, target string) bool
- func DirExists(path string) bool
- func DisallowHost(host string)
- func DistrustOrigin(host string)
- func EvaluateDockerComposeStatus() error
- func FetchLogs(containerName string, lines string) []string
- func FileExists(path string) bool
- func GenerateCertificatePackage() error
- func GenerateRandomPassword(pwLength int, safe bool) string
- func GetCwdFromExe() string
- func GetLocalGhostwriterVersion() (string, error)
- func GetRemoteGhostwriterVersion() (string, error)
- func ParseGhostwriterEnvironmentVariables()
- func PostgresVersionForData(yaml string) int
- func PostgresVersionInstalled(yaml string) int
- func RunBasicCmd(name string, args []string) (string, error)
- func RunCmd(name string, args []string) error
- func RunDockerComposeBackup(yaml string)
- func RunDockerComposeBackups(yaml string)
- func RunDockerComposeDown(yaml string)
- func RunDockerComposeInstall(yaml string)
- func RunDockerComposeRestart(yaml string)
- func RunDockerComposeRestore(yaml string, restore string)
- func RunDockerComposeStart(yaml string)
- func RunDockerComposeStop(yaml string)
- func RunDockerComposeUp(yaml string)
- func RunDockerComposeUpgrade(yaml string, skipseed bool)
- func RunGhostwriterTests()
- func RunRawCmd(name string, args ...string) error
- func SetConfig(key string, value string)
- func SetDevMode()
- func SetProductionMode()
- func TrustOrigin(host string)
- func WriteGhostwriterEnvironmentVariables()
- type Configuration
- type Configurations
- type Container
- type Containers
- type HealthIssue
- type HealthIssues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowHost ¶
func AllowHost(host string)
AllowHost appends a host to the allowed hosts list in the .env file.
func AskForConfirmation ¶ added in v0.2.12
AskForConfirmation asks the user for confirmation. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user. Original source: https://gist.github.com/r0l1/3dcbb0c8f6cfe9c66ab8008f55f8f28b
func CheckPath ¶
CheckPath checks the $PATH environment variable for a given “cmd“ and return a “bool“ indicating if it exists.
func Contains ¶
Contains checks if a slice of strings (“slice“ parameter) contains a given string (“search“ parameter).
func DirExists ¶
DirExists determines if a given string is a valid directory. Reference: https://golangcode.com/check-if-a-file-exists/
func DisallowHost ¶
func DisallowHost(host string)
DisallowHost removes a host to the allowed hosts list in the .env file.
func DistrustOrigin ¶ added in v0.2.2
func DistrustOrigin(host string)
DistrustOrigin removes an origin to the trusted origins list in the .env file.
func EvaluateDockerComposeStatus ¶ added in v0.2.8
func EvaluateDockerComposeStatus() error
EvaluateDockerComposeStatus determines if the host has the “docker compose“ plugin or the “docker compose“ script installed and set the global `dockerCmd` variable.
func FetchLogs ¶
FetchLogs fetches logs from the container with the specified “name“ label (“containerName“ parameter).
func FileExists ¶
FileExists determines if a given string is a valid filepath. Reference: https://golangcode.com/check-if-a-file-exists/
func GenerateCertificatePackage ¶
func GenerateCertificatePackage() error
GenerateCertificatePackage generate TLS certificates and Diffie-Helman parameters file using Go.
func GenerateRandomPassword ¶
GenerateRandomPassword generates a random password of the given length The password will be comprised of a-zA-Z0-9 and !@#$%^&*()_-+=/?<>., Special characters exclude the following: '";:`~\/| Exclusions are to help avoid issues with escaping and breaking quotes in env files
func GetCwdFromExe ¶
func GetCwdFromExe() string
GetCwdFromExe gets the current working directory based on “ghostwriter-cli“ location.
func GetLocalGhostwriterVersion ¶
GetLocalGhostwriterVersion fetches the local Ghostwriter version from the “VERSION“ file.
func GetRemoteGhostwriterVersion ¶
GetRemoteGhostwriterVersion fetches the latest Ghostwriter version from GitHub's API.
func ParseGhostwriterEnvironmentVariables ¶
func ParseGhostwriterEnvironmentVariables()
ParseGhostwriterEnvironmentVariables attempts to find and open an existing .env file or create a new one. If an .env file is found, load it into the Viper configuration. If an .env file is not found, create a new one with default values. Then write the final file with “WriteGhostwriterEnvironmentVariables()“.
func PostgresVersionForData ¶ added in v0.2.21
Gets the major version number of the PostgreSQL data. If different from the installation version, an upgrade is needed.
func PostgresVersionInstalled ¶ added in v0.2.21
Gets the major version number of the PostgreSQL installation
func RunBasicCmd ¶
RunBasicCmd executes a given command (“name“) with a list of arguments (“args“) and return a “string“ with the output.
func RunDockerComposeBackup ¶ added in v0.2.12
func RunDockerComposeBackup(yaml string)
RunDockerComposeBackup executes the “docker compose“ command to back up the PostgreSQL database in the environment from the specified YAML file (“yaml“ parameter).
func RunDockerComposeBackups ¶ added in v0.2.12
func RunDockerComposeBackups(yaml string)
RunDockerComposeBackups executes the “docker compose“ command to list available PostgreSQL database backups in the environment from the specified YAML file (“yaml“ parameter).
func RunDockerComposeDown ¶
func RunDockerComposeDown(yaml string)
RunDockerComposeDown executes the “docker compose“ commands to bring down the environment with the specified YAML file (“yaml“ parameter).
func RunDockerComposeInstall ¶
func RunDockerComposeInstall(yaml string)
RunDockerComposeInstall executes the “docker compose“ commands for a first-time installation with the specified YAML file (“yaml“ parameter).
func RunDockerComposeRestart ¶
func RunDockerComposeRestart(yaml string)
RunDockerComposeRestart executes the “docker compose“ commands to restart the environment with the specified YAML file (“yaml“ parameter).
func RunDockerComposeRestore ¶ added in v0.2.12
RunDockerComposeRestore executes the “docker compose“ command to restore a PostgreSQL database backup in the environment from the specified YAML file (“yaml“ parameter).
func RunDockerComposeStart ¶
func RunDockerComposeStart(yaml string)
RunDockerComposeStart executes the “docker compose“ commands to start the environment with the specified YAML file (“yaml“ parameter).
func RunDockerComposeStop ¶
func RunDockerComposeStop(yaml string)
RunDockerComposeStop executes the “docker compose“ commands to stop all services in the environment with the specified YAML file (“yaml“ parameter).
func RunDockerComposeUp ¶
func RunDockerComposeUp(yaml string)
RunDockerComposeUp executes the “docker compose“ commands to bring up the environment with the specified YAML file (“yaml“ parameter).
func RunDockerComposeUpgrade ¶
RunDockerComposeUpgrade executes the “docker compose“ commands for re-building or upgrading an installation with the specified YAML file (“yaml“ parameter).
func RunGhostwriterTests ¶
func RunGhostwriterTests()
RunGhostwriterTests runs Ghostwriter's unit and integration tests via “docker compose“. The tests are run in the development environment and assume certain values will be set for test conditions, so the .env file is temporarily adjusted during the test run.
func RunRawCmd ¶ added in v0.2.21
RunRawCmd executes a given command (“name“) with a list of arguments (“args“) Does not convert docker to docker compose like `RunCmd` does.
func SetDevMode ¶
func SetDevMode()
SetDevMode updates the environment variables to switch to development mode.
func SetProductionMode ¶
func SetProductionMode()
SetProductionMode updates the environment variables to switch to production mode.
func TrustOrigin ¶ added in v0.2.2
func TrustOrigin(host string)
TrustOrigin appends an origin to the trusted origins list in the .env file.
func WriteGhostwriterEnvironmentVariables ¶
func WriteGhostwriterEnvironmentVariables()
WriteGhostwriterEnvironmentVariables writes the environment variables to the “.env“ file.
Types ¶
type Configuration ¶
Configuration is a custom type for storing configuration values as Key:Val pairs.
type Configurations ¶
type Configurations []Configuration
Configurations is a custom type for storing `Configuration` values
func GetConfig ¶
func GetConfig(args []string) Configurations
GetConfig retrieves the specified values from the .env file.
func GetConfigAll ¶
func GetConfigAll() Configurations
GetConfigAll retrieves all values from the .env configuration file.
func (Configurations) Len ¶
func (c Configurations) Len() int
Len returns the length of a Configurations struct
func (Configurations) Less ¶
func (c Configurations) Less(i, j int) bool
Less determines if one Configuration is less than another Configuration
func (Configurations) Swap ¶
func (c Configurations) Swap(i, j int)
Swap exchanges the position of two Configuration values in a Configurations struct
type Container ¶
Container is a custom type for storing container information similar to output from “docker containers ls“.
type Containers ¶
type Containers []Container
Containers is a collection of Container structs
func GetRunning ¶
func GetRunning() Containers
GetRunning determines if the container with the specified “name“ label (“containerName“ parameter) is running.
func (Containers) Less ¶
func (c Containers) Less(i, j int) bool
Less determines if one Container is less than another Container
func (Containers) Swap ¶
func (c Containers) Swap(i, j int)
Swap exchanges the position of two Container values in a Containers struct
type HealthIssue ¶ added in v0.2.8
HealthIssue is a custom type for storing healthcheck output.
type HealthIssues ¶ added in v0.2.8
type HealthIssues []HealthIssue
func CheckDockerHealth ¶ added in v0.2.8
func CheckDockerHealth(dev bool) (HealthIssues, error)
CheckDockerHealth determines if all containers are running and passing their respective health checks.
func CheckGhostwriterHealth ¶ added in v0.2.8
func CheckGhostwriterHealth(dev bool) (HealthIssues, error)
CheckGhostwriterHealth fetches the latest health reports from Ghostwriter's status API endpoint.
func (HealthIssues) Len ¶ added in v0.2.8
func (c HealthIssues) Len() int
func (HealthIssues) Less ¶ added in v0.2.8
func (c HealthIssues) Less(i, j int) bool
func (HealthIssues) Swap ¶ added in v0.2.8
func (c HealthIssues) Swap(i, j int)