Documentation ¶
Overview ¶
Package def provides a parser for Platform.sh YAML files and structures that represent the data.
Index ¶
- Constants
- func AssertEqual(actual interface{}, expected interface{}, msg string, t *testing.T)
- func InterfaceToString(v interface{}) string
- func NewValidateError(key string, msg string) error
- func RoutesToMap(routes []Route) map[string]Route
- type App
- type AppBuild
- type AppCron
- type AppDependencies
- type AppDependenciesPhp
- type AppDependenciesPhpRepository
- type AppHooks
- type AppMount
- type AppRuntime
- type AppRuntimeExtension
- type AppRuntimeXdebug
- type AppWeb
- type AppWebCommands
- type AppWebLocation
- type AppWebLocationRequestBuffering
- type AppWebUpstream
- type AppWorker
- type AppWorkersCommands
- type Bool
- type BoolString
- func (d BoolString) GetBool() bool
- func (d BoolString) GetString() string
- func (d BoolString) IsSet() bool
- func (d BoolString) IsString() bool
- func (d *BoolString) MarshalJSON() ([]byte, error)
- func (d *BoolString) SetDefaults()
- func (d *BoolString) UnmarshalYAML(unmarshal func(interface{}) error) error
- type GlobalConfig
- type Route
- type RouteCache
- type RouteRedirects
- type RouteRedirectsPath
- type RoutesSsi
- type Service
- type ServiceConfiguration
- type ValidateError
- type Variables
- func (v *Variables) Delete(key string)
- func (v Variables) Get(name string) interface{}
- func (v Variables) GetString(name string) string
- func (v Variables) GetStringSubMap(name string) map[string]string
- func (v Variables) GetSubMap(name string) map[string]interface{}
- func (v Variables) Keys() []string
- func (v *Variables) Merge(m Variables)
- func (v *Variables) Set(key string, value interface{}) error
- func (v *Variables) UnmarshalJSON(data []byte) error
- func (v *Variables) UnmarshalYAML(unmarshal func(interface{}) error) error
- type YamlMerge
Constants ¶
const AppDir = "/app"
AppDir defines the app directory.
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
AssertEqual checks for equality between two interfaces and triggers an error if not.
func InterfaceToString ¶
func InterfaceToString(v interface{}) string
InterfaceToString returns conversion of given interface to string.
func NewValidateError ¶
NewValidateError creates a new ValidateError.
func RoutesToMap ¶
RoutesToMap converts route array in to map.
Types ¶
type App ¶
type App struct { Path string Name string `yaml:"name"` Type string `yaml:"type"` Size string `yaml:"size"` Disk int `yaml:"disk"` Build AppBuild `yaml:"build" json:"build"` Variables Variables `yaml:"variables"` Relationships map[string]string `yaml:"relationships"` Web AppWeb `yaml:"web"` Mounts map[string]*AppMount `yaml:"mounts" json:"mounts"` Hooks AppHooks `yaml:"hooks" json:"hooks"` Crons map[string]*AppCron `yaml:"crons" json:"crons"` Dependencies AppDependencies `yaml:"dependencies"` Runtime AppRuntime `yaml:"runtime"` Workers map[string]*AppWorker `yaml:"workers" json:"workers"` }
App defines an application.
func ParseAppYamlFiles ¶
func ParseAppYamlFiles(fileList []string, global *GlobalConfig) (*App, error)
ParseAppYamlFiles parses multiple .platform.app.yaml files and merges them in to one.
func ParseAppYamls ¶
func ParseAppYamls(d [][]byte, global *GlobalConfig) (*App, error)
ParseAppYamls parses multiple .platform.app.yaml contents and merges them in to one.
func (App) GetEmptyRelationship ¶
GetEmptyRelationship returns an empty relationship.
type AppBuild ¶
type AppBuild struct {
Flavor string `yaml:"flavor" json:"flavor,omitempty"`
}
AppBuild defines what happens when building the app.
func (*AppBuild) SetDefaults ¶
func (d *AppBuild) SetDefaults()
SetDefaults sets the default values.
type AppCron ¶
type AppCron struct { Spec string `yaml:"spec" json:"spec"` Command string `yaml:"cmd" json:"cmd"` }
AppCron defines a cron job.
type AppDependencies ¶
type AppDependencies struct { PHP AppDependenciesPhp `yaml:"php" json:"php"` NodeJS map[string]string `yaml:"nodejs" json:"nodejs"` Python2 map[string]string `yaml:"python2" json:"python2"` Python3 map[string]string `yaml:"python3" json:"python3"` }
AppDependencies defines dependencies of the application.
func (*AppDependencies) SetDefaults ¶
func (d *AppDependencies) SetDefaults()
SetDefaults sets the default values.
func (AppDependencies) Validate ¶
func (d AppDependencies) Validate(root *App) []error
Validate checks for errors.
type AppDependenciesPhp ¶
type AppDependenciesPhp struct { Require map[string]string `yaml:"require" json:"require,omitempty"` Repositories []*AppDependenciesPhpRepository `yaml:"repositories" json:"repositories,omitempty"` }
AppDependenciesPhp defines php app dependencies.
func (*AppDependenciesPhp) SetDefaults ¶
func (d *AppDependenciesPhp) SetDefaults()
SetDefaults sets the default values.
func (*AppDependenciesPhp) UnmarshalYAML ¶
func (d *AppDependenciesPhp) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements Unmarshaler interface.
func (AppDependenciesPhp) Validate ¶
func (d AppDependenciesPhp) Validate(root *App) []error
Validate checks for errors.
type AppDependenciesPhpRepository ¶
type AppDependenciesPhpRepository struct { Type string `yaml:"type" json:"type"` URL string `yaml:"url" json:"url"` }
AppDependenciesPhpRepository defines php app dependency repository.
func (*AppDependenciesPhpRepository) SetDefaults ¶
func (d *AppDependenciesPhpRepository) SetDefaults()
SetDefaults sets the default values.
func (AppDependenciesPhpRepository) Validate ¶
func (d AppDependenciesPhpRepository) Validate(root *App) []error
Validate checks for errors.
type AppHooks ¶
type AppHooks struct { Build string `yaml:"build" json:"build"` Deploy string `yaml:"deploy" json:"deploy"` PostDeploy string `yaml:"post_deploy" json:"post_deploy"` }
AppHooks defines hook commands.
func (*AppHooks) SetDefaults ¶
func (d *AppHooks) SetDefaults()
SetDefaults sets the default values.
type AppMount ¶
type AppMount struct { Source string `yaml:"source" json:"source"` Service string `yaml:"service" json:"service,omitempty"` SourcePath string `yaml:"source_path" json:"souce_path"` }
AppMount defines persistent mount volumes
func (*AppMount) SetDefaults ¶
func (d *AppMount) SetDefaults()
SetDefaults sets the default values.
func (*AppMount) UnmarshalYAML ¶
UnmarshalYAML implements Unmarshaler interface.
type AppRuntime ¶
type AppRuntime struct { RequestTerminateTimeout int `yaml:"request_terminate_timeout" json:"-"` Extensions []*AppRuntimeExtension `yaml:"extensions" json:"extensions"` DisabledExtensions []string `yaml:"disabled_extensions" json:"disabled_extensions,omitempty"` Xdebug AppRuntimeXdebug `yaml:"xdebug" json:"xdebug"` }
AppRuntime defines runtime configuration.
func (*AppRuntime) SetDefaults ¶
func (d *AppRuntime) SetDefaults()
SetDefaults sets the default values.
func (AppRuntime) Validate ¶
func (d AppRuntime) Validate(root *App) []error
Validate checks for errors.
type AppRuntimeExtension ¶
type AppRuntimeExtension struct { Name string `yaml:"name" json:"name"` Configuration map[string]string `yaml:"configuration" json:"configuration,omitempty"` }
AppRuntimeExtension defines an extension (PHP).
func (*AppRuntimeExtension) SetDefaults ¶
func (d *AppRuntimeExtension) SetDefaults()
SetDefaults sets the default values.
func (*AppRuntimeExtension) UnmarshalYAML ¶
func (d *AppRuntimeExtension) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements Unmarshaler interface.
func (AppRuntimeExtension) Validate ¶
func (d AppRuntimeExtension) Validate(root *App) []error
Validate checks for errors.
type AppRuntimeXdebug ¶ added in v2.2.11
type AppRuntimeXdebug struct {
IdeKey string `yaml:"idekey" json:"idekey"`
}
AppRuntimeXdebug defines xdebug config.
func (*AppRuntimeXdebug) SetDefaults ¶ added in v2.2.11
func (d *AppRuntimeXdebug) SetDefaults()
SetDefaults sets the default values.
func (AppRuntimeXdebug) Validate ¶ added in v2.2.11
func (d AppRuntimeXdebug) Validate(root *App) []error
Validate checks for errors.
type AppWeb ¶
type AppWeb struct { Commands AppWebCommands `yaml:"commands" json:"commands"` Upstream AppWebUpstream `yaml:"upstream" json:"upstream"` Locations map[string]*AppWebLocation `yaml:"locations" json:"locations"` MoveToRoot bool `json:"move_to_root"` }
AppWeb defines how app is exposed to the web.
type AppWebCommands ¶
type AppWebCommands struct {
Start string `yaml:"start" json:"start,omitempty"`
}
AppWebCommands defines command(s) to launch the app.
func (*AppWebCommands) SetDefaults ¶
func (d *AppWebCommands) SetDefaults()
SetDefaults sets the default values.
func (AppWebCommands) Validate ¶
func (d AppWebCommands) Validate(root *App) []error
Validate checks for errors.
type AppWebLocation ¶
type AppWebLocation struct { Root string `yaml:"root" json:"root"` Passthru BoolString `yaml:"passthru" json:"passthru"` Index []string `yaml:"index" json:"index,omitempty"` Expires string `yaml:"expires" json:"expires"` Scripts Bool `yaml:"scripts" json:"scripts"` Allow Bool `yaml:"allow" json:"allow"` Headers map[string]string `yaml:"headers" json:"headers,omitempty"` Rules map[string]*AppWebLocation `yaml:"rules" json:"rules,omitempty"` RequestBuffering AppWebLocationRequestBuffering `yaml:"request_buffering" json:"request_buffering"` }
AppWebLocation defines how the app should respond to a web request.
func (*AppWebLocation) SetDefaults ¶
func (d *AppWebLocation) SetDefaults()
SetDefaults sets the default values.
func (AppWebLocation) Validate ¶
func (d AppWebLocation) Validate(root *App) []error
Validate checks for errors.
type AppWebLocationRequestBuffering ¶
type AppWebLocationRequestBuffering struct { Enabled Bool `yaml:"enabled" json:"enabled"` MaxRequestSize string `yaml:"max_request_size" json:"max_request_size"` }
AppWebLocationRequestBuffering defines request buffering config.
func (*AppWebLocationRequestBuffering) SetDefaults ¶
func (d *AppWebLocationRequestBuffering) SetDefaults()
SetDefaults sets the default values.
func (AppWebLocationRequestBuffering) Validate ¶
func (d AppWebLocationRequestBuffering) Validate(root *App) []error
Validate checks for errors.
type AppWebUpstream ¶
type AppWebUpstream struct { SocketFamily string `yaml:"socket_family" json:"socket_family,omitempty"` Protocol string `yaml:"protocol" json:"protocol,omitempty"` }
AppWebUpstream defines how the front server will connect to the app.
func (*AppWebUpstream) SetDefaults ¶
func (d *AppWebUpstream) SetDefaults()
SetDefaults sets the default values.
func (AppWebUpstream) Validate ¶
func (d AppWebUpstream) Validate(root *App) []error
Validate checks for errors.
type AppWorker ¶
type AppWorker struct { Name string `json:"-"` ParentApp string `json:"-"` Path string `json:"-"` Type string `json:"-"` Runtime AppRuntime `json:"-"` Dependencies AppDependencies `json:"-"` Size string `yaml:"size" json:"size"` Disk int `yaml:"disk" json:"disk"` Mounts map[string]*AppMount `yaml:"mounts" json:"mounts"` Relationships map[string]string `yaml:"relationships" json:"relationship"` Variables Variables `yaml:"variables" json:"variables"` Commands AppWorkersCommands `yaml:"commands" json:"commands"` }
AppWorker defines a worker.
func (AppWorker) GetTypeName ¶
GetTypeName gets the type of app.
func (*AppWorker) SetDefaults ¶
func (d *AppWorker) SetDefaults()
SetDefaults sets the default values.
type AppWorkersCommands ¶
type AppWorkersCommands struct {
Start string `yaml:"start" json:"start"`
}
AppWorkersCommands defines command(s) to launch the app worker.
func (*AppWorkersCommands) SetDefaults ¶
func (d *AppWorkersCommands) SetDefaults()
SetDefaults sets the default values.
func (AppWorkersCommands) Validate ¶
func (d AppWorkersCommands) Validate(root *App) []error
Validate checks for errors.
type Bool ¶
type Bool struct { DefaultValue bool // contains filtered or unexported fields }
Bool defines a boolean that can contain a default value.
func (Bool) MarshalJSON ¶
MarshalJSON implements json Marshaler interface.
func (*Bool) SetDefaults ¶
func (d *Bool) SetDefaults()
SetDefaults sets the default value if not set via yaml.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON implements json Unm,arshaler interface.
func (*Bool) UnmarshalYAML ¶
UnmarshalYAML implements Unmarshaler interface.
type BoolString ¶
type BoolString struct {
// contains filtered or unexported fields
}
BoolString defines a type that can either be a boolean or a string.
func (BoolString) GetBool ¶
func (d BoolString) GetBool() bool
GetBool retrieves the current bool value.
func (BoolString) GetString ¶
func (d BoolString) GetString() string
GetString retrieves the current string value.
func (BoolString) IsSet ¶ added in v2.2.8
func (d BoolString) IsSet() bool
IsSet returns true if the value is set.
func (BoolString) IsString ¶
func (d BoolString) IsString() bool
IsString returns true if current value is string.
func (*BoolString) MarshalJSON ¶
func (d *BoolString) MarshalJSON() ([]byte, error)
MarshalJSON implements json Marshaler interface.
func (*BoolString) SetDefaults ¶
func (d *BoolString) SetDefaults()
SetDefaults sets the default value if not set via yaml.
func (*BoolString) UnmarshalYAML ¶
func (d *BoolString) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements Unmarshaler interface.
type GlobalConfig ¶
type GlobalConfig struct { Variables Variables `yaml:"variables" json:"variables"` Flags []string `yaml:"flags" json:"flags"` Options map[string]string `yaml:"options" json:"options"` Router struct { PortHTTP uint16 `yaml:"port_http" json:"port_http"` PortHTTPS uint16 `yaml:"port_https" json:"port_https"` } `yaml:"router" json:"router"` }
GlobalConfig defines global PCC configuration.
func (*GlobalConfig) SetDefaults ¶
func (d *GlobalConfig) SetDefaults()
SetDefaults sets the default values.
type Route ¶
type Route struct { Path string `json:"-"` Type string `yaml:"type" json:"type"` Upstream string `yaml:"upstream" json:"upstream"` To string `yaml:"to" json:"to"` ID string `yaml:"id" json:"id"` Attributes map[string]string `yaml:"attributes" json:"attributes"` Cache RouteCache `yaml:"cache" json:"-"` Redirects RouteRedirects `yaml:"redirects" json:"-"` SSI RoutesSsi `yaml:"ssi" json:"-"` Primary Bool `json:"primary"` OriginalURL string `json:"original_url"` Disable bool `json:"_disable"` }
Route defines a route.
func ExpandRoutes ¶
ExpandRoutes expands routes to include internal verisons and makes modifications for use with PCC.
func ParseRoutesYaml ¶
ParseRoutesYaml parses contents of routes.yaml file.
func ParseRoutesYamlFile ¶
ParseRoutesYamlFile opens the routes.yaml file and parses it.
func ParseRoutesYamlFiles ¶
ParseRoutesYamlFiles reads multiple routes yaml files and merges them.
type RouteCache ¶
type RouteCache struct { Enabled Bool `yaml:"enabled" json:"enabled"` Headers []string `yaml:"headers" json:"headers"` Cookies []string `yaml:"cookies" json:"cookies"` DefaultTTL int `yaml:"default_ttl" json:"default_ttl"` }
RouteCache defines caching for a route.
func (*RouteCache) SetDefaults ¶
func (d *RouteCache) SetDefaults()
SetDefaults sets the default values.
func (RouteCache) Validate ¶
func (d RouteCache) Validate(root *Route) []error
Validate checks for errors.
type RouteRedirects ¶
type RouteRedirects struct { Expires string `yaml:"expires" json:"expires"` Paths map[string]*RouteRedirectsPath `yaml:"paths" json:"paths"` }
RouteRedirects define route redirects.
func (*RouteRedirects) SetDefaults ¶
func (d *RouteRedirects) SetDefaults()
SetDefaults sets the default values.
func (RouteRedirects) Validate ¶
func (d RouteRedirects) Validate(root *Route) []error
Validate checks for errors.
type RouteRedirectsPath ¶
type RouteRedirectsPath struct { To string `yaml:"to" json:"to"` Regexp Bool `yaml:"regexp" json:"regexp"` Prefix Bool `yaml:"prefix" json:"prefix"` AppendSuffix Bool `yaml:"append_suffix" json:"append_suffix"` Code int `yaml:"code" json:"code"` Expires string `yaml:"expires" json:"expires"` }
RouteRedirectsPath defines a route redirect path.
func (*RouteRedirectsPath) SetDefaults ¶
func (d *RouteRedirectsPath) SetDefaults()
SetDefaults sets the default values.
func (RouteRedirectsPath) Validate ¶
func (d RouteRedirectsPath) Validate(root *Route) []error
Validate checks for errors.
type RoutesSsi ¶
type RoutesSsi struct {
Enabled Bool `yaml:"enabled" json:"enabled"`
}
RoutesSsi define route server side include.
func (*RoutesSsi) SetDefaults ¶
func (d *RoutesSsi) SetDefaults()
SetDefaults sets the default values.
type Service ¶
type Service struct { Name string Type string `yaml:"type" json:"type"` Disk int `yaml:"disk" json:"disk"` Configuration ServiceConfiguration `yaml:"configuration" json:"configuration,omitempty"` Relationships map[string]string `yaml:"relationships" json:"relationships,omitempty"` Disable bool `yaml:"_disable"` }
Service defines a service.
func ParseServiceYamlFiles ¶
ParseServiceYamlFiles parses multiple services.yaml files and merges them in to one.
func ParseServiceYamls ¶
ParseServiceYamls parses multiple services.yaml contents and merges them in to one.
func (Service) GetEmptyRelationship ¶
GetEmptyRelationship retursn an empty relationship.
func (Service) GetTypeName ¶
GetTypeName gets the service type.
type ServiceConfiguration ¶
type ServiceConfiguration map[string]interface{}
ServiceConfiguration define service configuration.
func (ServiceConfiguration) IsAuthenticationEnabled ¶
func (d ServiceConfiguration) IsAuthenticationEnabled() bool
IsAuthenticationEnabled returns true if 'authentication.enabled' is true.
func (*ServiceConfiguration) UnmarshalYAML ¶
func (d *ServiceConfiguration) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML - parse yaml
type ValidateError ¶
type ValidateError struct {
// contains filtered or unexported fields
}
ValidateError extends error by providing specific details about a def validation error.
func (*ValidateError) Error ¶
func (d *ValidateError) Error() string
type Variables ¶
type Variables map[string]interface{}
Variables defines project variables which can be defined in multiple places.
func (Variables) GetStringSubMap ¶
GetStringSubMap return sub map with string values.
func (*Variables) UnmarshalJSON ¶
UnmarshalJSON implements Unmarshaler interface.
func (*Variables) UnmarshalYAML ¶
UnmarshalYAML implement Unmarshaler interface.
Source Files ¶
- app.go
- app_build.go
- app_cron.go
- app_dependencies.go
- app_dependencies_php.go
- app_dependencies_php_repository.go
- app_hooks.go
- app_mounts.go
- app_runtime.go
- app_runtime_extensions.go
- app_runtime_xdebug.go
- app_web.go
- app_web_commands.go
- app_web_locations.go
- app_web_locations_request_buffering.go
- app_web_upstream.go
- app_workers.go
- app_workers_commands.go
- bool.go
- bool_string.go
- error_validate.go
- global.go
- helper_convert.go
- helper_merge.go
- helper_route.go
- helper_testing.go
- helper_validate.go
- helper_yaml.go
- main.go
- route.go
- route_cache.go
- route_redirects.go
- route_redirects_paths.go
- route_ssi.go
- service.go
- service_configuration.go
- variables.go