importer

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigurationDependencyKey = "service"

ConfigurationDependencyKey is the reserved key of the service's configuration in the dependencies array.

Variables

This section is empty.

Functions

func IsValid

func IsValid(source string) (bool, error)

IsValid validates a service at a source.

Types

type Dependency added in v0.3.0

type Dependency struct {
	// Image is the Docker image.
	Image string `yaml:"image" json:"image,omitempty" validate:"printascii"`

	// Volumes are the Docker volumes.
	Volumes []string `yaml:"volumes" json:"volumes,omitempty" validate:"unique,dive,printascii"`

	// VolumesFrom are the docker volumes-from from.
	VolumesFrom []string `yaml:"volumesFrom" json:"volumesFrom,omitempty" validate:"unique,dive,printascii"`

	// Ports holds ports configuration for container.
	Ports []string `yaml:"ports" json:"ports,omitempty" validate:"unique,dive,portmap"`

	// Command is the Docker command which will be executed when container started.
	Command string `yaml:"command" json:"command,omitempty" validate:"printascii"`

	// Args hold the args to pass to the Docker container
	Args []string `yaml:"args" json:"args,omitempty" validate:"dive,printascii"`

	// Env is a slice of environment variables in key=value format.
	Env []string `yaml:"env" json:"env,omitempty" validate:"unique,dive,env"`
}

Dependency represents a Docker container and it holds instructions about how it should run.

type Event added in v0.3.0

type Event struct {
	// Name is the name of event.
	Name string `yaml:"name" json:"name,omitempty" validate:"printascii"`

	// Description is the description of event.
	Description string `yaml:"description" json:"description,omitempty" validate:"printascii"`

	// Data holds the input parameters of event.
	Data map[string]*Parameter `yaml:"data" json:"data,omitempty" validate:"required,dive,keys,printascii,endkeys,required"`
}

Event describes a service task.

type Parameter added in v0.3.0

type Parameter struct {
	// Name is the name of parameter.
	Name string `yaml:"name" json:"name,omitempty" validate:"printascii"`

	// Description is the description of parameter.
	Description string `yaml:"description" json:"description,omitempty" validate:"printascii"`

	// Type is the data type of parameter.
	Type string `yaml:"type" json:"type,omitempty" validate:"required,printascii,oneof=String Number Boolean Object Any"`

	// Optional indicates if parameter is optional.
	Optional bool `yaml:"optional" json:"optional,omitempty"`

	// Repeated is to have an array of this parameter
	Repeated bool `yaml:"repeated" json:"repeated,omitempty"`

	// Definition of the structure of the object when the type is object
	Object map[string]*Parameter `yaml:"object" json:"object,omitempty" validate:"dive,keys,printascii,endkeys,required"`
}

Parameter describes task input parameters, output parameters of a task output and input parameters of an event.

type ServiceDefinition added in v0.3.0

type ServiceDefinition struct {
	// Name is the service name.
	Name string `yaml:"name" json:"name,omitempty" validate:"required,printascii,min=1"`

	// Sid is the service id. It must be unique.
	Sid string `yaml:"sid" json:"sid,omitempty" validate:"omitempty,printascii,max=63,domain"`

	// Description is service description.
	Description string `yaml:"description" json:"description,omitempty" validate:"printascii"`

	// Tasks are the list of tasks that service can execute.
	Tasks map[string]*Task `yaml:"tasks" json:"tasks,omitempty" validate:"dive,keys,printascii,endkeys,required"`

	// Events are the list of events that service can emit.
	Events map[string]*Event `yaml:"events" json:"events,omitempty" validate:"dive,keys,printascii,endkeys,required"`

	// Dependencies are the Docker containers that service can depend on.
	Dependencies map[string]*Dependency `yaml:"dependencies" json:"dependencies,omitempty" validate:"dive,keys,printascii,ne=service,endkeys,required"`

	// Configuration is the Docker container that service runs inside.
	Configuration *Dependency `yaml:"configuration" json:"configuration,omitempty"`

	// Repository holds the service's repository url if it's living on a git host.
	Repository string `yaml:"repository" json:"repository,omitempty" validate:"omitempty,uri"`
}

ServiceDefinition represents MESG services configurations.

func From

func From(source string) (*ServiceDefinition, error)

From imports a service from a source.

type Task added in v0.3.0

type Task struct {
	// Name is the name of task.
	Name string `yaml:"name" json:"name,omitempty" validate:"printascii"`

	// Description is the description of task.
	Description string `yaml:"description" json:"description,omitempty" validate:"printascii"`

	// Inputs are the definition of the execution inputs of task.
	Inputs map[string]*Parameter `yaml:"inputs" json:"inputs,omitempty" validate:"dive,keys,printascii,endkeys,required"`

	// Outputs are the definition of the execution results of task.
	Outputs map[string]*Parameter `yaml:"outputs" json:"outputs,omitempty" validate:"dive,keys,printascii,endkeys,required"`
}

Task describes a service task.

type ValidationError

type ValidationError struct{}

ValidationError is the error type for the Validation of service.

func (*ValidationError) Error

func (v *ValidationError) Error() string

type ValidationResult

type ValidationResult struct {
	ServiceFileWarnings []string
	ServiceFileExist    bool
	DockerfileExist     bool
}

ValidationResult contains the result of the validation of a service.

func Validate

func Validate(source string) (*ValidationResult, error)

Validate validates a service at a source.

func (*ValidationResult) IsValid

func (v *ValidationResult) IsValid() bool

IsValid returns true if the validation result is valid.

Jump to

Keyboard shortcuts

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