def

package
v2.2.13 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package def provides a parser for Platform.sh YAML files and structures that represent the data.

Index

Constants

View Source
const AppDir = "/app"

AppDir defines the app directory.

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual(actual interface{}, expected interface{}, msg string, t *testing.T)

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

func NewValidateError(key string, msg string) error

NewValidateError creates a new ValidateError.

func RoutesToMap

func RoutesToMap(routes []Route) map[string]Route

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

func (d App) GetEmptyRelationship() map[string]interface{}

GetEmptyRelationship returns an empty relationship.

func (App) GetTypeName

func (d App) GetTypeName() string

GetTypeName gets the type of app.

func (*App) SetDefaults

func (d *App) SetDefaults()

SetDefaults sets the default values.

func (App) Validate

func (d App) Validate() []error

Validate checks for errors.

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.

func (AppBuild) Validate

func (d AppBuild) Validate(root *App) []error

Validate checks for errors.

type AppCron

type AppCron struct {
	Spec    string `yaml:"spec" json:"spec"`
	Command string `yaml:"cmd" json:"cmd"`
}

AppCron defines a cron job.

func (*AppCron) SetDefaults

func (d *AppCron) SetDefaults()

SetDefaults sets the default values.

func (AppCron) Validate

func (d AppCron) Validate(root *App) []error

Validate checks for errors.

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.

func (AppHooks) Validate

func (d AppHooks) Validate(root *App) []error

Validate checks for errors.

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

func (d *AppMount) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements Unmarshaler interface.

func (AppMount) Validate

func (d AppMount) Validate(root *App) []error

Validate checks for errors.

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.

func (*AppWeb) SetDefaults

func (d *AppWeb) SetDefaults()

SetDefaults sets the default values.

func (AppWeb) Validate

func (d AppWeb) Validate(root *App) []error

Validate checks for errors.

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

func (d AppWorker) GetTypeName() string

GetTypeName gets the type of app.

func (*AppWorker) SetDefaults

func (d *AppWorker) SetDefaults()

SetDefaults sets the default values.

func (AppWorker) Validate

func (d AppWorker) Validate(root *App) []error

Validate checks for errors.

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) Get

func (d Bool) Get() bool

Get retrieves the current value.

func (Bool) MarshalJSON

func (d Bool) MarshalJSON() ([]byte, error)

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

func (d *Bool) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json Unm,arshaler interface.

func (*Bool) UnmarshalYAML

func (d *Bool) UnmarshalYAML(unmarshal func(interface{}) error) error

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.

func (GlobalConfig) Validate

func (d GlobalConfig) Validate() []error

Validate checks for errors.

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

func ExpandRoutes(inRoutes []Route, internalDomainSuffix string) ([]Route, error)

ExpandRoutes expands routes to include internal verisons and makes modifications for use with PCC.

func ParseRoutesYaml

func ParseRoutesYaml(d []byte) ([]Route, error)

ParseRoutesYaml parses contents of routes.yaml file.

func ParseRoutesYamlFile

func ParseRoutesYamlFile(f string) ([]Route, error)

ParseRoutesYamlFile opens the routes.yaml file and parses it.

func ParseRoutesYamlFiles

func ParseRoutesYamlFiles(fileList []string) ([]Route, error)

ParseRoutesYamlFiles reads multiple routes yaml files and merges them.

func (*Route) SetDefaults

func (d *Route) SetDefaults()

SetDefaults sets the default values.

func (Route) Validate

func (d Route) Validate() []error

Validate checks for errors.

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.

func (RoutesSsi) Validate

func (d RoutesSsi) Validate(root *Route) []error

Validate checks for errors.

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

func ParseServiceYamlFiles(fileList []string) ([]Service, error)

ParseServiceYamlFiles parses multiple services.yaml files and merges them in to one.

func ParseServiceYamls

func ParseServiceYamls(d [][]byte) ([]Service, error)

ParseServiceYamls parses multiple services.yaml contents and merges them in to one.

func (Service) GetEmptyRelationship

func (d Service) GetEmptyRelationship() map[string]interface{}

GetEmptyRelationship retursn an empty relationship.

func (Service) GetTypeName

func (d Service) GetTypeName() string

GetTypeName gets the service type.

func (*Service) SetDefaults

func (d *Service) SetDefaults()

SetDefaults sets the default values.

func (Service) Validate

func (d Service) Validate() []error

Validate checks for errors.

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) Delete

func (v *Variables) Delete(key string)

Delete unsets a value.

func (Variables) Get

func (v Variables) Get(name string) interface{}

Get returns given value using a colon as a delimiter for sub values.

func (Variables) GetString

func (v Variables) GetString(name string) string

GetString returns value as string.

func (Variables) GetStringSubMap

func (v Variables) GetStringSubMap(name string) map[string]string

GetStringSubMap return sub map with string values.

func (Variables) GetSubMap

func (v Variables) GetSubMap(name string) map[string]interface{}

GetSubMap create sub map from given prefix.

func (Variables) Keys

func (v Variables) Keys() []string

Keys returns list of keys.

func (*Variables) Merge

func (v *Variables) Merge(m Variables)

Merge merges given variables with this one.

func (*Variables) Set

func (v *Variables) Set(key string, value interface{}) error

Set sets a value.

func (*Variables) UnmarshalJSON

func (v *Variables) UnmarshalJSON(data []byte) error

UnmarshalJSON implements Unmarshaler interface.

func (*Variables) UnmarshalYAML

func (v *Variables) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implement Unmarshaler interface.

type YamlMerge

type YamlMerge map[string]interface{}

YamlMerge provides interface for creating yaml that is mergable with support for custom tags.

func (*YamlMerge) UnmarshalYAML

func (m *YamlMerge) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML unmarshals YAML for app def.

Jump to

Keyboard shortcuts

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