config

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLogLevel         = validator.TextErr{Err: errors.New("invalid log level, must be one of debug, info, warn, error")}
	ErrInvalidDockerAPIVersion = validator.TextErr{Err: errors.New("invalid Docker API version format, must be e.g. v1.40")}
)
View Source
var (
	DefaultDeploymentConfigFileNames    = []string{".doco-cd.yaml", ".doco-cd.yml"}
	DeprecatedDeploymentConfigFileNames = []string{".compose-deploy.yaml", ".compose-deploy.yml"}
	ErrConfigFileNotFound               = errors.New("configuration file not found in repository")
	ErrInvalidConfig                    = errors.New("invalid deploy configuration")
	ErrKeyNotFound                      = errors.New("key not found")
	ErrDeprecatedConfig                 = errors.New("configuration file name is deprecated, please use .doco-cd.y(a)ml instead")
)

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	LogLevel            string `env:"LOG_LEVEL,required" envDefault:"info"`                                       // LogLevel is the log level for the application
	HttpPort            uint16 `env:"HTTP_PORT,required" envDefault:"80" validate:"min=1,max=65535"`              // HttpPort is the port the HTTP server will listen on
	WebhookSecret       string `env:"WEBHOOK_SECRET,required"`                                                    // WebhookSecret is the secret used to authenticate the webhook
	GitAccessToken      string `env:"GIT_ACCESS_TOKEN"`                                                           // GitAccessToken is the access token used to authenticate with the Git server (e.g. GitHub) for private repositories
	AuthType            string `env:"AUTH_TYPE" envDefault:"oauth2"`                                              // AuthType is the type of authentication to use when cloning repositories
	SkipTLSVerification bool   `env:"SKIP_TLS_VERIFICATION" envDefault:"false"`                                   // SkipTLSVerification skips the TLS verification when cloning repositories.
	DockerAPIVersion    string `env:"DOCKER_API_VERSION" envDefault:"v1.40" validate:"regexp=^v[0-9]+\\.[0-9]+$"` // DockerAPIVersion is the version of the Docker API to use
	DockerQuietDeploy   bool   `env:"DOCKER_QUIET_DEPLOY" envDefault:"true"`                                      // DockerQuietDeploy suppresses the status output of dockerCli in deployments (e.g. pull, create, start)
}

AppConfig is used to configure this application

func GetAppConfig

func GetAppConfig() (*AppConfig, error)

GetAppConfig returns the configuration

type DeployConfig

type DeployConfig struct {
	Name             string   `yaml:"name"`                                                                                                         // Name is the name of the docker-compose deployment / stack
	Reference        string   `yaml:"reference" default:"refs/heads/main"`                                                                          // Reference is the Git reference to the deployment, e.g. refs/heads/main or refs/tags/v1.0.0
	WorkingDirectory string   `yaml:"working_dir" default:"."`                                                                                      // WorkingDirectory is the working directory for the deployment
	ComposeFiles     []string `yaml:"compose_files" default:"[\"compose.yaml\", \"compose.yml\", \"docker-compose.yml\", \"docker-compose.yaml\"]"` // ComposeFiles is the list of docker-compose files to use
	RemoveOrphans    bool     `yaml:"remove_orphans" default:"true"`                                                                                // RemoveOrphans removes containers for services not defined in the Compose file
	ForceRecreate    bool     `yaml:"force_recreate" default:"false"`                                                                               // ForceRecreate forces the recreation/redeployment of containers even if the configuration has not changed
	ForceImagePull   bool     `yaml:"force_image_pull" default:"false"`                                                                             // ForceImagePull always pulls the latest version of the image tags you've specified if a newer version is available
	Timeout          int      `yaml:"timeout" default:"180"`                                                                                        // Timeout is the time in seconds to wait for the deployment to finish in seconds before timing out
	BuildOpts        struct {
		ForceImagePull bool              `yaml:"force_image_pull" default:"false"` // ForceImagePull always attempt to pull a newer version of the image
		Quiet          bool              `yaml:"quiet" default:"false"`            // Quiet suppresses the build output
		Args           map[string]string `yaml:"args"`                             // BuildArgs is a map of build-time arguments to pass to the build process
		NoCache        bool              `yaml:"no_cache" default:"false"`         // NoCache disables the use of the cache when building images
	} `yaml:"build_opts"` // BuildOpts is the build options for the deployment
}

DeployConfig is the structure of the deployment configuration file

func DefaultDeployConfig

func DefaultDeployConfig(name string) *DeployConfig

DefaultDeployConfig creates a DeployConfig with default values

func FromYAML

func FromYAML(f string) (*DeployConfig, error)

func GetDeployConfig

func GetDeployConfig(repoDir, name string) (*DeployConfig, error)

GetDeployConfig returns either the deployment configuration from the repository or the default configuration

func (*DeployConfig) UnmarshalYAML

func (c *DeployConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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