Documentation ¶
Index ¶
- Constants
- Variables
- func IsDirectory(path string) bool
- func MakeMux(directory string) *http.ServeMux
- type ConfigError
- type ConfigErrorType
- type DeploymentConfig
- func (c *DeploymentConfig) AllowedSecret(secret string) bool
- func (c *DeploymentConfig) AllowsMethod(method string) bool
- func (c *DeploymentConfig) Check(method string, secret string) *ConfigError
- func (c *DeploymentConfig) DoLock() (*os.File, *ConfigError)
- func (c *DeploymentConfig) PrepareEnv() *([]string)
- func (c *DeploymentConfig) Read(name string) error
- func (c *DeploymentConfig) Run() *ConfigError
- type RequestMethod
- type RuntimeConfig
Constants ¶
const ( // RequestGET get method RequestGET RequestMethod = "GET" // RequestPOST post method RequestPOST RequestMethod = "POST" // MaxSecretSize max size of secret body MaxSecretSize int = 64 )
Variables ¶
var RequestMethods = []RequestMethod{RequestGET, RequestPOST}
RequestMethods contains list of allowed methods
Functions ¶
func IsDirectory ¶
IsDirectory returns true if given path is a directory
Types ¶
type ConfigError ¶
type ConfigError struct { // ErrorType error type ErrorType ConfigErrorType // Message with error Message *string }
ConfigError keeps information on runtime config errors
func (*ConfigError) Error ¶
func (c *ConfigError) Error() *string
func (*ConfigError) IsExecutionError ¶
func (c *ConfigError) IsExecutionError() bool
IsExecutionError returns true if error is about execution problem
func (*ConfigError) IsMissingConfig ¶
func (c *ConfigError) IsMissingConfig() bool
IsMissingConfig returns true if error is about missing config file
func (*ConfigError) IsPreconditionsError ¶
func (c *ConfigError) IsPreconditionsError() bool
IsPreconditionsError returns true if secret is invalid or mehtod is invalid
func (*ConfigError) IsReadError ¶
func (c *ConfigError) IsReadError() bool
IsReadError returns true if error is about unreadable config file
func (*ConfigError) IsSetupError ¶
func (c *ConfigError) IsSetupError() bool
IsSetupError returns true if preparation of execution has failed
type ConfigErrorType ¶
type ConfigErrorType int
ConfigErrorType type of error
const ( // MissingConfig no configuration file MissingConfig ConfigErrorType = iota // ReadError can't read config ReadError // PreconditionsError invalid method or invalid secret PreconditionsError // SetupError cannot prepare execution environment SetupError // ExecutionError execution failed ExecutionError )
type DeploymentConfig ¶
type DeploymentConfig struct { // DirName directory where config file is DirName string // RunDirName name of a directory where the command should be executed, default: DirName RunDirName string // ConfigName of config file ConfigName string // Commands to execute (or one command with cli arguments split into list) Commands []string // LogFile file to write output LogFile string // Env overrides Env []string // Ref conf parser instance RefCfg *(viper.Viper) // RefCmd subcommand reference RefCmd *(exec.Cmd) // PostOnly makrs that this config should be called from POST request only AllowedMethods []RequestMethod // Secret Required secret in body (if SecretHeader is omited) Secret *string // Secret stored in this header instead of body SecretHeader *string }
DeploymentConfig Deployment configuration structure
func NewConfig ¶
func NewConfig(dir string) (*DeploymentConfig, error)
NewConfig Create new Config with dir set to dir
func NewConfigFromEnv ¶
func NewConfigFromEnv() (*DeploymentConfig, error)
NewConfigFromEnv Create new Config from env variable
func (*DeploymentConfig) AllowedSecret ¶
func (c *DeploymentConfig) AllowedSecret(secret string) bool
AllowedSecret checks if provided secret is correct
func (*DeploymentConfig) AllowsMethod ¶
func (c *DeploymentConfig) AllowsMethod(method string) bool
AllowsMethod checks if given http method is allowed
func (*DeploymentConfig) Check ¶
func (c *DeploymentConfig) Check(method string, secret string) *ConfigError
Check runs pre-execution checks: allowed method check and secret check
func (*DeploymentConfig) DoLock ¶
func (c *DeploymentConfig) DoLock() (*os.File, *ConfigError)
DoLock Ensures that only one call will be executed at one time
func (*DeploymentConfig) PrepareEnv ¶
func (c *DeploymentConfig) PrepareEnv() *([]string)
PrepareEnv returns an array of env entries: local env + entries from configuration
func (*DeploymentConfig) Read ¶
func (c *DeploymentConfig) Read(name string) error
Read and parse config file from name
func (*DeploymentConfig) Run ¶
func (c *DeploymentConfig) Run() *ConfigError
Run runs command specified in configuration, returns nil
type RequestMethod ¶
type RequestMethod string
RequestMethod method that can be used for deployment
func RequestMethodsFromStrings ¶
func RequestMethodsFromStrings(sIn []string) []RequestMethod
RequestMethodsFromStrings converts array of strings to array of request methods
type RuntimeConfig ¶
type RuntimeConfig struct { // port to listen on Port int // directory with configuration Dir string }
RuntimeConfig keeps runtime configuration