Documentation
¶
Index ¶
- Variables
- func ApplicationJsonSchema() *jsonschema.Schema
- func ApplicationJsonSchemaString() string
- func ExpandActions(actions []string, resourceType ResourceType) []string
- func FormatValidationErrors(errs []ValidationError) string
- func GenerateYamlContext(err gojsonschema.ResultError, updatedDescription string) string
- func GetValidActions(resourceType ResourceType) []string
- func PrettyPrintPattern(pattern *regexp.Regexp) string
- func SaveToYaml(fs afero.Fs, path string, appSpec *Application) error
- func ValidateActions(actions []string, resourceType ResourceType) ([]string, bool)
- type Application
- type BucketIntent
- type Container
- type DatabaseIntent
- type Dev
- type Docker
- type DockerImage
- type EntrypointIntent
- type IResource
- type Resource
- type ResourceType
- type Route
- type Schedule
- type ServiceIntent
- type ServiceTrigger
- type SugaErrorTemplate
- type TargetType
- type ValidationError
- type YamlContextBuilder
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorTemplateFunc = map[string]interface{}{ "error_prefix": func(field string) string { formatter := newErrorFormatter(field) return formatter.FormatErrorPrefix() }, "invalid_property_name": func(field string) string { formatter := newErrorFormatter(field) return formatter.FormatInvalidProperty() }, "one_of": func(field string) string { formatter := newErrorFormatter(field) return formatter.FormatNumberOneOf() }, "pretty_print_pattern": func(pattern *regexp.Regexp) string { return PrettyPrintPattern(pattern) }, }
Used as function map that can be used when templating the error messages
Functions ¶
func ApplicationJsonSchema ¶
func ApplicationJsonSchema() *jsonschema.Schema
func ApplicationJsonSchemaString ¶
func ApplicationJsonSchemaString() string
func ExpandActions ¶
func ExpandActions(actions []string, resourceType ResourceType) []string
ExpandActions expands 'all' in an actions array whilst maintaining deduplication
func FormatValidationErrors ¶
func FormatValidationErrors(errs []ValidationError) string
Formats the error messages like this:
---> Error Message
| | YAML Context |
func GenerateYamlContext ¶
func GenerateYamlContext(err gojsonschema.ResultError, updatedDescription string) string
GenerateYamlContext generates the YAML context for validation errors
func GetValidActions ¶
func GetValidActions(resourceType ResourceType) []string
func PrettyPrintPattern ¶
func SaveToYaml ¶
func SaveToYaml(fs afero.Fs, path string, appSpec *Application) error
func ValidateActions ¶
func ValidateActions(actions []string, resourceType ResourceType) ([]string, bool)
ValidateActions ensures that all the actions are valid
Types ¶
type Application ¶
type Application struct { // Targets sets platforms this application should be expected to work on // This gives us room to move away from LCD expectations around how platforms are built Targets []string `json:"targets" yaml:"targets" jsonschema:"required,pattern=^(([a-z][a-z0-9-]*)/([a-z][a-z0-9-]*)@(\\d+)|file:([^\\s]+))$"` Name string `json:"name" yaml:"name" jsonschema:"required"` Description string `json:"description" yaml:"description"` ServiceIntents map[string]*ServiceIntent `json:"services,omitempty" yaml:"services,omitempty"` BucketIntents map[string]*BucketIntent `json:"buckets,omitempty" yaml:"buckets,omitempty"` EntrypointIntents map[string]*EntrypointIntent `json:"entrypoints,omitempty" yaml:"entrypoints,omitempty"` DatabaseIntents map[string]*DatabaseIntent `json:"databases,omitempty" yaml:"databases,omitempty"` }
func ApplicationFromJson ¶
func ApplicationFromJson(jsonString string) (*Application, *gojsonschema.Result, error)
func ApplicationFromYaml ¶
func ApplicationFromYaml(yamlString string) (*Application, *gojsonschema.Result, error)
func LoadFromFile ¶
func (*Application) GetResourceIntent ¶
func (a *Application) GetResourceIntent(name string) (interface{}, bool)
func (*Application) GetResourceIntents ¶
func (a *Application) GetResourceIntents() map[string]IResource
func (*Application) GetTypeForIntent ¶
func (a *Application) GetTypeForIntent(intent interface{}) (string, error)
func (*Application) IsValid ¶
func (a *Application) IsValid() []gojsonschema.ResultError
Perform additional validation checks on the application
type BucketIntent ¶
type BucketIntent struct { Resource `json:",inline" yaml:",inline"` ContentPath string `json:"content_path,omitempty" yaml:"content_path,omitempty"` Access map[string][]string `json:"access,omitempty" yaml:"access,omitempty"` }
func (*BucketIntent) GetType ¶
func (b *BucketIntent) GetType() string
type Container ¶
type Container struct { Docker *Docker `json:"docker,omitempty" yaml:"docker,omitempty" jsonschema:"oneof_required=docker"` Image *DockerImage `json:"image,omitempty" yaml:"image,omitempty" jsonschema:"oneof_required=image"` }
Runtime represents a union of all possible runtime types
type DatabaseIntent ¶
type DatabaseIntent struct { Resource `json:",inline" yaml:",inline"` Access map[string][]string `json:"access,omitempty" yaml:"access,omitempty"` // The key that this database will export to services that depend on it. EnvVarKey string `json:"env_var_key" yaml:"env_var_key"` }
func (*DatabaseIntent) GetType ¶
func (d *DatabaseIntent) GetType() string
type Dev ¶
type Dev struct { // The script the start the service (because running it locally is orders of magnitude faster than building the containers) Script string `json:"script" yaml:"script"` }
type Docker ¶
type Docker struct { Dockerfile string `json:"dockerfile,omitempty" yaml:"dockerfile,omitempty"` Context string `json:"context,omitempty" yaml:"context,omitempty"` Args map[string]string `json:"args,omitempty" yaml:"args,omitempty"` }
DockerFileRuntime represents a runtime that uses a Dockerfile
type DockerImage ¶
type DockerImage struct {
ID string `json:"id,omitempty" yaml:"id,omitempty" jsonschema:"required"`
}
type EntrypointIntent ¶
type EntrypointIntent struct { Resource `json:",inline" yaml:",inline"` Routes map[string]Route `json:"routes" yaml:"routes"` }
func (*EntrypointIntent) GetType ¶
func (e *EntrypointIntent) GetType() string
func (EntrypointIntent) JSONSchemaExtend ¶
func (e EntrypointIntent) JSONSchemaExtend(schema *jsonschema.Schema)
type Resource ¶
type Resource struct {
SubType string `json:"subtype,omitempty" yaml:"subtype,omitempty"`
}
func (*Resource) GetSubType ¶
type ResourceType ¶
type ResourceType string
const ( Database ResourceType = "database" Bucket ResourceType = "bucket" )
type Schedule ¶
type Schedule struct {
CronExpression string `json:"cron_expression,omitempty" yaml:"cron_expression,omitempty" jsonschema:"oneof_required=cron_expression"`
}
type ServiceIntent ¶
type ServiceIntent struct { Resource `json:",inline" yaml:",inline"` Env map[string]string `json:"env,omitempty" yaml:"env,omitempty"` Container Container `json:"container" yaml:"container" jsonschema:"oneof_required=container"` Dev *Dev `json:"dev,omitempty" yaml:"dev,omitempty"` Triggers map[string]*ServiceTrigger `json:"triggers,omitempty" yaml:"triggers,omitempty"` }
func (*ServiceIntent) GetType ¶
func (s *ServiceIntent) GetType() string
type ServiceTrigger ¶
type SugaErrorTemplate ¶
type SugaErrorTemplate struct {
gojsonschema.DefaultLocale
}
func (*SugaErrorTemplate) DoesNotMatchPattern ¶
func (t *SugaErrorTemplate) DoesNotMatchPattern() string
func (*SugaErrorTemplate) ErrorFormat ¶
func (t *SugaErrorTemplate) ErrorFormat() string
These are used to format the error messages in the gojsonschema Locale Unused here, but used when gojsonschema validates the schema
func (*SugaErrorTemplate) InvalidPropertyName ¶
func (t *SugaErrorTemplate) InvalidPropertyName() string
func (*SugaErrorTemplate) NumberOneOf ¶
func (t *SugaErrorTemplate) NumberOneOf() string
func (*SugaErrorTemplate) Required ¶
func (t *SugaErrorTemplate) Required() string
type TargetType ¶
type TargetType string
const ( TargetType_Service TargetType = "service" TargetType_Website TargetType = "website" )
type ValidationError ¶
type ValidationError struct { Path string `json:"path"` Message string `json:"message"` ErrorType string `json:"errorType"` YamlContext string `json:"yamlContext"` }
func GetSchemaValidationErrors ¶
func GetSchemaValidationErrors(errs []gojsonschema.ResultError) []ValidationError
type YamlContextBuilder ¶
func (*YamlContextBuilder) String ¶
func (b *YamlContextBuilder) String() string
func (*YamlContextBuilder) WriteError ¶
func (b *YamlContextBuilder) WriteError(s string)
func (*YamlContextBuilder) WriteYamlKey ¶
func (b *YamlContextBuilder) WriteYamlKey(s interface{}, indent int)
Click to show internal directories.
Click to hide internal directories.