diceyml

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: AGPL-3.0 Imports: 12 Imported by: 6

Documentation

Overview

该 visitor 处理 diceyml 中一些字段的默认值

原本的parser会把 global env 塞到各个 service 的 env 去

找出依赖却不存在的 service

找出没有被其他service依赖的后端service, 前端service不考虑(也就是有expose的service)

检查 service name 合法性

Index

Constants

View Source
const (
	WS_DEV     WorkspaceStr = "development"
	WS_TEST                 = "test"
	WS_STAGING              = "staging"
	WS_PROD                 = "production"
)

Variables

This section is empty.

Functions

func CompatibleExpose

func CompatibleExpose(obj *Object)

func Compose

func Compose(obj, envObj *Object, env string)

func ComposeIntPortsFromServicePorts

func ComposeIntPortsFromServicePorts(servicePorts []ServicePort) []int

func ExpandGlobalEnv

func ExpandGlobalEnv(obj *Object)

func FindCycle

func FindCycle(obj *Object) (has bool, chain []string)

if 'has' == false, 'chain' is meaningless

func FindOrphan

func FindOrphan(obj *Object) []string

func InsertAddonOptions

func InsertAddonOptions(obj *Object, env EnvType, addonPlan string, options map[string]string)

func InsertImage

func InsertImage(obj *Object, images map[string]string, envs map[string]map[string]string) error

func InsertSideCarImage

func InsertSideCarImage(obj *Object, images map[string]map[string]string) error

images: map[servicename]map[sidecarname]image

func MergeEnv

func MergeEnv(obj *Object, env string)

func SetDefaultValue

func SetDefaultValue(obj *Object)

Types

type AddOn

type AddOn struct {
	Plan    string                 `yaml:"plan,omitempty" json:"plan"`
	As      string                 `yaml:"as,omitempty" json:"as,omitempty"`
	Options map[string]string      `yaml:"options,omitempty" json:"options,omitempty"`
	Actions map[string]interface{} `yaml:"actions,omitempty" json:"actions,omitempty"`
	Image   string                 `yaml:"image,omitempty" json:"image,omitempty"`
}

func (*AddOn) Accept

func (obj *AddOn) Accept(v DiceYmlVisitor)

func (*AddOn) MarshalJSON

func (a *AddOn) MarshalJSON() ([]byte, error)

type AddOns

type AddOns map[string]*AddOn

func (*AddOns) Accept

func (obj *AddOns) Accept(v DiceYmlVisitor)

type BasicValidateVisitor

type BasicValidateVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*BasicValidateVisitor) VisitAddOn

func (o *BasicValidateVisitor) VisitAddOn(v DiceYmlVisitor, obj *AddOn)

func (*BasicValidateVisitor) VisitAddOns

func (o *BasicValidateVisitor) VisitAddOns(v DiceYmlVisitor, obj *AddOns)

func (*BasicValidateVisitor) VisitBinds

func (o *BasicValidateVisitor) VisitBinds(v DiceYmlVisitor, obj *Binds)

func (*BasicValidateVisitor) VisitDeployments

func (o *BasicValidateVisitor) VisitDeployments(v DiceYmlVisitor, obj *Deployments)

func (*BasicValidateVisitor) VisitObject

func (o *BasicValidateVisitor) VisitObject(v DiceYmlVisitor, obj *Object)

func (*BasicValidateVisitor) VisitResources

func (o *BasicValidateVisitor) VisitResources(v DiceYmlVisitor, obj *Resources)

func (*BasicValidateVisitor) VisitService

func (o *BasicValidateVisitor) VisitService(v DiceYmlVisitor, obj *Service)

type Bind

type Bind struct {
	HostPath      string `yaml:"host,omitempty" json:"host"`
	ContainerPath string `yaml:"container" json:"container"`
	Type          string `yaml:"type" json:"type"`
}

func ParseBinds

func ParseBinds(binds []string) ([]Bind, error)

type Binds

type Binds []string

func (*Binds) Accept

func (obj *Binds) Accept(v DiceYmlVisitor)

func (Binds) MarshalJSON

func (bs Binds) MarshalJSON() ([]byte, error)

func (*Binds) UnmarshalJSON

func (bs *Binds) UnmarshalJSON(b []byte) error

type CheckEnvSizeVisitor

type CheckEnvSizeVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*CheckEnvSizeVisitor) VisitObject

func (o *CheckEnvSizeVisitor) VisitObject(v DiceYmlVisitor, obj *Object)

func (*CheckEnvSizeVisitor) VisitService

func (o *CheckEnvSizeVisitor) VisitService(v DiceYmlVisitor, obj *Service)

type CompatibleExposeVisitor

type CompatibleExposeVisitor struct {
	DefaultVisitor
}

func (*CompatibleExposeVisitor) VisitServices

func (o *CompatibleExposeVisitor) VisitServices(v DiceYmlVisitor, obj *Services)

type ComposeVisitor

type ComposeVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*ComposeVisitor) VisitEnvObjects

func (o *ComposeVisitor) VisitEnvObjects(v DiceYmlVisitor, obj *EnvObjects)

type DefaultValueVisitor

type DefaultValueVisitor struct {
	DefaultVisitor
}

func (*DefaultValueVisitor) VisitResources

func (o *DefaultValueVisitor) VisitResources(v DiceYmlVisitor, obj *Resources)

type DefaultVisitor

type DefaultVisitor struct {
	// contains filtered or unexported fields
}

func (*DefaultVisitor) VisitAddOn

func (*DefaultVisitor) VisitAddOn(v DiceYmlVisitor, obj *AddOn)

func (*DefaultVisitor) VisitAddOns

func (*DefaultVisitor) VisitAddOns(v DiceYmlVisitor, obj *AddOns)

func (*DefaultVisitor) VisitBinds

func (*DefaultVisitor) VisitBinds(v DiceYmlVisitor, obj *Binds)

func (*DefaultVisitor) VisitDeployments

func (*DefaultVisitor) VisitDeployments(v DiceYmlVisitor, obj *Deployments)

func (*DefaultVisitor) VisitEnvObject

func (*DefaultVisitor) VisitEnvObject(v DiceYmlVisitor, obj *EnvObject)

func (*DefaultVisitor) VisitEnvObjects

func (*DefaultVisitor) VisitEnvObjects(v DiceYmlVisitor, obj *EnvObjects)

func (*DefaultVisitor) VisitExecCheck

func (*DefaultVisitor) VisitExecCheck(v DiceYmlVisitor, obj *ExecCheck)

func (*DefaultVisitor) VisitHTTPCheck

func (*DefaultVisitor) VisitHTTPCheck(v DiceYmlVisitor, obj *HTTPCheck)

func (*DefaultVisitor) VisitHealthCheck

func (*DefaultVisitor) VisitHealthCheck(v DiceYmlVisitor, obj *HealthCheck)

func (*DefaultVisitor) VisitJob

func (o *DefaultVisitor) VisitJob(v DiceYmlVisitor, obj *Job)

func (*DefaultVisitor) VisitJobs

func (o *DefaultVisitor) VisitJobs(v DiceYmlVisitor, obj *Jobs)

func (*DefaultVisitor) VisitObject

func (*DefaultVisitor) VisitObject(v DiceYmlVisitor, obj *Object)

func (*DefaultVisitor) VisitResources

func (*DefaultVisitor) VisitResources(v DiceYmlVisitor, obj *Resources)

func (*DefaultVisitor) VisitService

func (*DefaultVisitor) VisitService(v DiceYmlVisitor, obj *Service)

func (*DefaultVisitor) VisitServices

func (o *DefaultVisitor) VisitServices(v DiceYmlVisitor, obj *Services)

type Deployments

type Deployments struct {
	Replicas int               `yaml:"replicas,omitempty" json:"replicas"`
	Policies string            `yaml:"policies,omitempty" json:"policies"`
	Labels   map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
	// Type indicates the type of Deployments, per-node,stateful and stateless are supported
	Workload string `yaml:"workload,omitempty" json:"workload,omitempty"`
	// Selectors available selectors:
	// [location]
	Selectors Selectors `yaml:"selectors,omitempty" json:"selectors,omitempty"`
}

func (*Deployments) Accept

func (obj *Deployments) Accept(v DiceYmlVisitor)

type DiceYaml

type DiceYaml struct {
	// contains filtered or unexported fields
}

func New

func New(b []byte, validate bool) (*DiceYaml, error)

得到的 DiceYaml 是环境无关的,不能用于获取环境相关的信息

func NewDeployable

func NewDeployable(b []byte, env string, validate bool) (*DiceYaml, error)

得到对应部署环境的 DiceYaml,可用于部署

func (*DiceYaml) Compose

func (d *DiceYaml) Compose(env string, yml *DiceYaml) error

func (*DiceYaml) InsertAddonOptions

func (d *DiceYaml) InsertAddonOptions(env EnvType, addon string, options map[string]string) error

func (*DiceYaml) InsertImage

func (d *DiceYaml) InsertImage(images map[string]string, envs map[string]map[string]string) error

func (*DiceYaml) InsertSideCarImage

func (d *DiceYaml) InsertSideCarImage(images map[string]map[string]string) error

images: map[servicename]map[sidecarname]image

func (*DiceYaml) JSON

func (d *DiceYaml) JSON() (string, error)

func (*DiceYaml) MergeEnv

func (d *DiceYaml) MergeEnv(env string) error

func (*DiceYaml) Obj

func (d *DiceYaml) Obj() *Object

func (*DiceYaml) Parse

func (d *DiceYaml) Parse(validate bool) error

func (*DiceYaml) Validate

func (d *DiceYaml) Validate() ValidateError

func (*DiceYaml) YAML

func (d *DiceYaml) YAML() (string, error)

type DiceYmlVisitor

type DiceYmlVisitor interface {
	VisitObject(v DiceYmlVisitor, obj *Object)
	VisitEnvObject(v DiceYmlVisitor, obj *EnvObject)
	VisitEnvObjects(v DiceYmlVisitor, obj *EnvObjects)
	VisitService(v DiceYmlVisitor, obj *Service)
	VisitServices(v DiceYmlVisitor, obj *Services)
	VisitJobs(v DiceYmlVisitor, obj *Jobs)
	VisitJob(v DiceYmlVisitor, obj *Job)
	VisitAddOn(v DiceYmlVisitor, obj *AddOn)
	VisitAddOns(v DiceYmlVisitor, obj *AddOns)
	VisitResources(v DiceYmlVisitor, obj *Resources)
	VisitHealthCheck(v DiceYmlVisitor, obj *HealthCheck)
	VisitHTTPCheck(v DiceYmlVisitor, obj *HTTPCheck)
	VisitExecCheck(v DiceYmlVisitor, obj *ExecCheck)
	VisitDeployments(v DiceYmlVisitor, obj *Deployments)
	VisitBinds(v DiceYmlVisitor, obj *Binds)
}

=========================== default visitor =====================================

func NewBasicValidateVisitor

func NewBasicValidateVisitor() DiceYmlVisitor

func NewCheckEnvSizeVisitor

func NewCheckEnvSizeVisitor() DiceYmlVisitor

func NewCompatibleExposeVisitor

func NewCompatibleExposeVisitor() DiceYmlVisitor

func NewComposeVisitor

func NewComposeVisitor(envObj *Object, env string) DiceYmlVisitor

func NewDefaultValueVisitor

func NewDefaultValueVisitor() DiceYmlVisitor

func NewEnvVisitor

func NewEnvVisitor() DiceYmlVisitor

func NewFieldnameValidateVisitor

func NewFieldnameValidateVisitor(raw []byte) (DiceYmlVisitor, error)

func NewFindCycleVisitor

func NewFindCycleVisitor() DiceYmlVisitor

func NewFindLackServiceVisitor

func NewFindLackServiceVisitor() DiceYmlVisitor

func NewFindOrphanVisitor

func NewFindOrphanVisitor() DiceYmlVisitor

func NewInsertAddonOptionsVisitor

func NewInsertAddonOptionsVisitor(env EnvType, addonPlan string, options map[string]string) DiceYmlVisitor

func NewInsertImageVisitor

func NewInsertImageVisitor(images map[string]string, envs map[string]map[string]string) DiceYmlVisitor

func NewInsertSideCarImageVisitor

func NewInsertSideCarImageVisitor(images map[string]map[string]string) DiceYmlVisitor

func NewMergeEnvVisitor

func NewMergeEnvVisitor(envObj *EnvObject) DiceYmlVisitor

func NewServiceNameVisitor

func NewServiceNameVisitor() DiceYmlVisitor

type Endpoint

type Endpoint struct {
	Domain      string           `yaml:"domain,omitempty" json:"domain,omitempty"`
	Path        string           `yaml:"path,omitempty" json:"path,omitempty"`
	BackendPath string           `yaml:"backend_path,omitempty" json:"backend_path,omitempty"`
	Policies    EndpointPolicies `yaml:"policies,omitempty" json:"policies,omitempty"`
}

type EndpointPolicies

type EndpointPolicies struct {
	Cors      *map[string]interface{} `yaml:"cors,omitempty" json:"cors,omitempty"`
	RateLimit *map[string]interface{} `yaml:"rate_limit,omitempty" json:"rate_limit,omitempty"`
}

type EnvMap

type EnvMap map[string]string

func (*EnvMap) UnmarshalJSON

func (e *EnvMap) UnmarshalJSON(b []byte) error

type EnvObject

type EnvObject struct {
	Envs     EnvMap   `yaml:"envs,omitempty" json:"-"`
	Services Services `yaml:"services,omitempty" json:"services,omitempty"`
	AddOns   AddOns   `yaml:"addons,omitempty" json:"addons,omitempty"`
}

func (*EnvObject) Accept

func (obj *EnvObject) Accept(v DiceYmlVisitor)

默认不会像 Object 一样默认去遍历 Services, AddOns 比如validate,envobject中的service可能是不全的,但也是正确的 如果需要遍历envobject下的service和addon,需要手动去遍历

type EnvObjects

type EnvObjects map[string]*EnvObject

func (*EnvObjects) Accept

func (obj *EnvObjects) Accept(v DiceYmlVisitor)

type EnvType

type EnvType int
const (
	BaseEnv EnvType = iota
	DevEnv
	TestEnv
	StagingEnv
	ProdEnv
)

func (EnvType) String

func (e EnvType) String() string

type EnvVisitor

type EnvVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*EnvVisitor) VisitObject

func (o *EnvVisitor) VisitObject(v DiceYmlVisitor, obj *Object)

func (*EnvVisitor) VisitService

func (o *EnvVisitor) VisitService(v DiceYmlVisitor, obj *Service)

type ExecCheck

type ExecCheck struct {
	Cmd      string `yaml:"cmd,omitempty" json:"cmd,omitempty"`
	Duration int    `yaml:"duration,omitempty" json:"duration,omitempty"`
}

func (*ExecCheck) Accept

func (obj *ExecCheck) Accept(v DiceYmlVisitor)

type FieldnameValidateVisitor

type FieldnameValidateVisitor struct {
	DefaultVisitor
	RawMap map[interface{}]interface{}
	// contains filtered or unexported fields
}

func (*FieldnameValidateVisitor) VisitAddOns

func (o *FieldnameValidateVisitor) VisitAddOns(v DiceYmlVisitor, obj *AddOns)

func (*FieldnameValidateVisitor) VisitDeployments

func (o *FieldnameValidateVisitor) VisitDeployments(v DiceYmlVisitor, obj *Deployments)

func (*FieldnameValidateVisitor) VisitExecCheck

func (o *FieldnameValidateVisitor) VisitExecCheck(v DiceYmlVisitor, obj *ExecCheck)

func (*FieldnameValidateVisitor) VisitHTTPCheck

func (o *FieldnameValidateVisitor) VisitHTTPCheck(v DiceYmlVisitor, obj *HTTPCheck)

func (*FieldnameValidateVisitor) VisitHealthCheck

func (o *FieldnameValidateVisitor) VisitHealthCheck(v DiceYmlVisitor, obj *HealthCheck)

func (*FieldnameValidateVisitor) VisitObject

func (o *FieldnameValidateVisitor) VisitObject(v DiceYmlVisitor, obj *Object)

func (*FieldnameValidateVisitor) VisitResources

func (o *FieldnameValidateVisitor) VisitResources(v DiceYmlVisitor, obj *Resources)

func (*FieldnameValidateVisitor) VisitService

func (o *FieldnameValidateVisitor) VisitService(v DiceYmlVisitor, obj *Service)

func (*FieldnameValidateVisitor) VisitServices

func (o *FieldnameValidateVisitor) VisitServices(v DiceYmlVisitor, obj *Services)

type FindCycleVisitor

type FindCycleVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*FindCycleVisitor) VisitServices

func (o *FindCycleVisitor) VisitServices(v DiceYmlVisitor, obj *Services)

type FindLackServiceVisitor

type FindLackServiceVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*FindLackServiceVisitor) VisitServices

func (o *FindLackServiceVisitor) VisitServices(v DiceYmlVisitor, obj *Services)

type FindOrphanVisitor

type FindOrphanVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*FindOrphanVisitor) VisitServices

func (o *FindOrphanVisitor) VisitServices(v DiceYmlVisitor, obj *Services)

type HTTPCheck

type HTTPCheck struct {
	Port     int    `yaml:"port,omitempty" json:"port,omitempty"`
	Path     string `yaml:"path,omitempty" json:"path,omitempty"`
	Duration int    `yaml:"duration,omitempty" json:"duration,omitempty"`
}

func (*HTTPCheck) Accept

func (obj *HTTPCheck) Accept(v DiceYmlVisitor)

type HealthCheck

type HealthCheck struct {
	HTTP *HTTPCheck `yaml:"http,omitempty" json:"http,omitempty"`
	Exec *ExecCheck `yaml:"exec,omitempty" json:"exec,omitempty"`
}

func (*HealthCheck) Accept

func (obj *HealthCheck) Accept(v DiceYmlVisitor)

type InitContainer

type InitContainer struct {
	Image      string      `yaml:"image,omitempty" json:"image"`
	SharedDirs []SharedDir `yaml:"shared_dir,omitempty" json:"shared_dir,omitempty"`
	Cmd        string      `yaml:"cmd,omitempty" json:"cmd"`
	Resources  Resources   `yaml:"resources,omitempty" json:"resources"`
}

type InsertAddonOptionsVisitor

type InsertAddonOptionsVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*InsertAddonOptionsVisitor) VisitAddOn

func (o *InsertAddonOptionsVisitor) VisitAddOn(v DiceYmlVisitor, obj *AddOn)

func (*InsertAddonOptionsVisitor) VisitAddOns

func (o *InsertAddonOptionsVisitor) VisitAddOns(v DiceYmlVisitor, obj *AddOns)

func (*InsertAddonOptionsVisitor) VisitEnvObject

func (o *InsertAddonOptionsVisitor) VisitEnvObject(v DiceYmlVisitor, obj *EnvObject)

func (*InsertAddonOptionsVisitor) VisitEnvObjects

func (o *InsertAddonOptionsVisitor) VisitEnvObjects(v DiceYmlVisitor, obj *EnvObjects)

type InsertImageVisitor

type InsertImageVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*InsertImageVisitor) VisitJob

func (o *InsertImageVisitor) VisitJob(v DiceYmlVisitor, obj *Job)

func (*InsertImageVisitor) VisitJobs

func (o *InsertImageVisitor) VisitJobs(v DiceYmlVisitor, obj *Jobs)

func (*InsertImageVisitor) VisitService

func (o *InsertImageVisitor) VisitService(v DiceYmlVisitor, obj *Service)

func (*InsertImageVisitor) VisitServices

func (o *InsertImageVisitor) VisitServices(v DiceYmlVisitor, obj *Services)

type InsertSideCarImageVisitor

type InsertSideCarImageVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*InsertSideCarImageVisitor) VisitService

func (o *InsertSideCarImageVisitor) VisitService(v DiceYmlVisitor, obj *Service)

func (*InsertSideCarImageVisitor) VisitServices

func (o *InsertSideCarImageVisitor) VisitServices(v DiceYmlVisitor, obj *Services)

type Job

type Job struct {
	Image     string            `yaml:"image,omitempty" json:"image"`
	Cmd       string            `yaml:"cmd,omitempty" json:"cmd"`
	Envs      EnvMap            `yaml:"envs,omitempty" json:"envs,omitempty"`
	Resources Resources         `yaml:"resources,omitempty" json:"resources"`
	Labels    map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
	Binds     Binds             `yaml:"binds,omitempty" json:"binds,omitempty"`
	Volumes   Volumes           `yaml:"volumes,omitempty" json:"volumes,omitempty"`
	Hosts     []string          `yaml:"hosts,omitempty" json:"hosts,omitempty"`
}

func (*Job) Accept

func (obj *Job) Accept(v DiceYmlVisitor)

type Jobs

type Jobs map[string]*Job

func (*Jobs) Accept

func (obj *Jobs) Accept(v DiceYmlVisitor)

type MergeEnvVisitor

type MergeEnvVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*MergeEnvVisitor) VisitAddOns

func (o *MergeEnvVisitor) VisitAddOns(v DiceYmlVisitor, obj *AddOns)

func (*MergeEnvVisitor) VisitDeployments

func (o *MergeEnvVisitor) VisitDeployments(v DiceYmlVisitor, obj *Deployments)

func (*MergeEnvVisitor) VisitExecCheck

func (o *MergeEnvVisitor) VisitExecCheck(v DiceYmlVisitor, obj *ExecCheck)

func (*MergeEnvVisitor) VisitHTTPCheck

func (o *MergeEnvVisitor) VisitHTTPCheck(v DiceYmlVisitor, obj *HTTPCheck)

func (*MergeEnvVisitor) VisitObject

func (o *MergeEnvVisitor) VisitObject(v DiceYmlVisitor, obj *Object)

func (*MergeEnvVisitor) VisitResources

func (o *MergeEnvVisitor) VisitResources(v DiceYmlVisitor, obj *Resources)

func (*MergeEnvVisitor) VisitService

func (o *MergeEnvVisitor) VisitService(v DiceYmlVisitor, obj *Service)

func (*MergeEnvVisitor) VisitServices

func (o *MergeEnvVisitor) VisitServices(v DiceYmlVisitor, obj *Services)

type Object

type Object struct {
	Version      string            `yaml:"version" json:"version"`
	Meta         map[string]string `yaml:"meta" json:"meta"`
	Envs         EnvMap            `yaml:"envs" json:"envs,omitempty"`
	Services     Services          `yaml:"services" json:"services,omitempty"`
	Jobs         Jobs              `yaml:"jobs,omitempty" json:"jobs,omitempty"`
	AddOns       AddOns            `yaml:"addons" json:"addons,omitempty"`
	Environments EnvObjects        `yaml:"environments,omitempty" json:"-"`
	Values       ValueObjects      `yaml:"values" json:"values,omitempty"`
}

func CopyObj

func CopyObj(src *Object) *Object

func (*Object) Accept

func (obj *Object) Accept(v DiceYmlVisitor)

type Resources

type Resources struct {
	CPU     float64           `yaml:"cpu,omitempty" json:"cpu"`
	Mem     int               `yaml:"mem,omitempty" json:"mem"`
	MaxCPU  float64           `yaml:"max_cpu,omitempty" json:"max_cpu"`
	MaxMem  int               `yaml:"max_mem,omitempty" json:"max_mem"`
	Disk    int               `yaml:"disk,omitempty" json:"disk"`
	Network map[string]string `yaml:"network,omitempty" json:"network"`
}

func (*Resources) Accept

func (obj *Resources) Accept(v DiceYmlVisitor)

type Selector

type Selector struct {
	Not bool `json:"not"`

	// 由上面的定义可见,Not=true时,len(Values) = 1
	Values []string `json:"values"`
}

Selector value struct of Selectors Selectors: map[key]value key: [a-zA-Z0-9-]* value: NOT_VALUE

| NORMAL_VALUE { "|" NORMAL_VALUE }

NOT_VALUE: "!" NORMAL_VALUE NORMAL_VALUE: [a-zA-Z0-9-]*

func (Selector) MarshalYAML

func (sl Selector) MarshalYAML() (interface{}, error)

func (*Selector) UnmarshalYAML

func (sl *Selector) UnmarshalYAML(unmarshal func(interface{}) error) error

type Selectors

type Selectors map[string]Selector

type Service

type Service struct {
	Image           string                   `yaml:"image,omitempty" json:"image"`
	ImageUsername   string                   `yaml:"image_username,omitempty" json:"image_username"`
	ImagePassword   string                   `yaml:"image_password,omitempty" json:"image_password"`
	Cmd             string                   `yaml:"cmd,omitempty" json:"cmd"`
	Ports           []ServicePort            `yaml:"ports,omitempty" json:"ports,omitempty"`
	Envs            EnvMap                   `yaml:"envs,omitempty" json:"envs,omitempty"`
	Hosts           []string                 `yaml:"hosts,omitempty" json:"hosts,omitempty"`
	Resources       Resources                `yaml:"resources,omitempty" json:"resources"`
	Labels          map[string]string        `yaml:"labels,omitempty" json:"labels,omitempty"`
	Annotations     map[string]string        `yaml:"annotations,omitempty" json:"annotations,omitempty"`
	Binds           Binds                    `yaml:"binds,omitempty" json:"binds,omitempty"`
	Volumes         Volumes                  `yaml:"volumes,omitempty" json:"volumes,omitempty"`
	Deployments     Deployments              `yaml:"deployments,omitempty" json:"deployments"`
	DependsOn       []string                 `yaml:"depends_on,omitempty" json:"depends_on,omitempty"`
	Expose          []int                    `yaml:"expose,omitempty" json:"expose,omitempty"`
	HealthCheck     HealthCheck              `yaml:"health_check,omitempty" json:"health_check"`
	SideCars        map[string]*SideCar      `yaml:"sidecars,omitempty" json:"sidecars,omitempty"`
	Init            map[string]InitContainer `yaml:"init,omitempty" json:"init,omitempty"`
	MeshEnable      *bool                    `yaml:"mesh_enable,omitempty" json:"mesh_enable,omitempty"`
	TrafficSecurity TrafficSecurity          `yaml:"traffic_security,omitempty" json:"traffic_security,omitempty"`
	Endpoints       []Endpoint               `yaml:"endpoints,omitempty" json:"endpoints,omitempty"`
}

func (*Service) Accept

func (obj *Service) Accept(v DiceYmlVisitor)

type ServiceNameVisitor

type ServiceNameVisitor struct {
	DefaultVisitor
	// contains filtered or unexported fields
}

func (*ServiceNameVisitor) VisitObject

func (o *ServiceNameVisitor) VisitObject(v DiceYmlVisitor, obj *Object)

func (*ServiceNameVisitor) VisitService

func (o *ServiceNameVisitor) VisitService(v DiceYmlVisitor, obj *Service)

type ServicePort

type ServicePort struct {
	Port       int            `yaml:"port" json:"port"`
	Protocol   string         `yaml:"protocol" json:"protocol"`
	L4Protocol apiv1.Protocol `yaml:"l4_protocol" json:"l4_protocol"`
	Expose     bool           `yaml:"expose" json:"expose"`
	Default    bool           `yaml:"default" json:"default"`
}

func (*ServicePort) UnmarshalJSON

func (sp *ServicePort) UnmarshalJSON(b []byte) error

The ServicePort UnmarshalJSON unmarshal custom json definition which support more protocol and adapted previous version

func (*ServicePort) UnmarshalYAML

func (sp *ServicePort) UnmarshalYAML(unmarshal func(interface{}) error) error

The ServicePort UnmarshalYAML unmarshal custom yaml definition which support more protocol and adapted previous version

type Services

type Services map[string]*Service

func (*Services) Accept

func (obj *Services) Accept(v DiceYmlVisitor)

type SharedDir

type SharedDir struct {
	Main    string `yaml:"main" json:"main"`
	SideCar string `yaml:"sidecar" json:"sidecar"`
}

type SideCar

type SideCar struct {
	Image      string      `yaml:"image,omitempty" json:"image"`
	Cmd        string      `yaml:"cmd,omitempty" json:"cmd"`
	Envs       EnvMap      `yaml:"envs,omitempty" json:"envs,omitempty"`
	SharedDirs []SharedDir `yaml:"shared_dir,omitempty" json:"shared_dir,omitempty"`
	Resources  Resources   `yaml:"resources,omitempty" json:"resources"`
}

type TrafficSecurity

type TrafficSecurity struct {
	Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
}

type ValidateError

type ValidateError map[*regexp.Regexp]error

validate result is a map , key: regexp of problem-position-element, value: error info NOTE: why use regex to mark the position of problem-elements ?

because the yaml package not expose the line information

func BasicValidate

func BasicValidate(obj *Object) ValidateError

func CheckEnvSize

func CheckEnvSize(obj *Object) ValidateError

func FieldnameValidate

func FieldnameValidate(obj *Object, raw []byte) ValidateError

func FindLackService

func FindLackService(obj *Object) ValidateError

func ServiceNameCheck

func ServiceNameCheck(obj *Object) ValidateError

type ValueMap

type ValueMap map[string]string

type ValueObjects

type ValueObjects map[WorkspaceStr]*ValueMap

type Volume

type Volume struct {
	ID *string `json:"id"`
	// nfs, local
	Storage string `json:"storage"`
	Path    string `json:"path"`
}

func (*Volume) UnmarshalYAML

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

volumes:

  • name~storage:/container/path
  • name:/container/path # 没有 ~storage 表示使用默认本地默认存储,就是本地磁盘
  • /container/path # 没有指定 volume name,默认生成 uuid
  • log-volume~nas:/var/logs # ~nas 表示使用 nas 存储
  • data-volume~nas:/home/admin/data

type Volumes

type Volumes []Volume

type WorkspaceStr

type WorkspaceStr string

Jump to

Keyboard shortcuts

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