Documentation
¶
Index ¶
- Constants
- Variables
- func IsDetailedErr(err error) error
- func NewDetailedErr(err error, details interface{}) error
- type AuthConfig
- type Bind
- type Build
- type BuildImageMessage
- type BuildOptions
- type Builds
- type CPUAndMem
- type CPUMap
- type Config
- type Container
- type CopyMessage
- type CopyOptions
- type CreateContainerMessage
- type DeployOptions
- type DeployStatus
- type DockerConfig
- type Entrypoint
- type EtcdConfig
- type GitConfig
- type HealthCheck
- type Hook
- type LogConfig
- type Network
- type Node
- type NodeInfo
- type Pod
- type PullImageMessage
- type ReallocResourceMessage
- type RemoveContainerMessage
- type RemoveImageMessage
- type ReplaceContainerMessage
- type RunAndWaitMessage
- type RunAndWaitOptions
- type SchedConfig
Constants ¶
const ( Byte int64 = 1 KByte = Byte << 10 MByte = KByte << 10 GByte = MByte << 10 )
size units
Variables ¶
var ( ErrInsufficientCPU = errors.New("cannot alloc a plan, not enough cpu") ErrInsufficientMEM = errors.New("cannot alloc a plan, not enough memory") ErrInsufficientCap = errors.New("cannot alloc a each node plan, not enough capacity") ErrInsufficientRes = errors.New("not enough resource") ErrInsufficientNodes = errors.New("not enough nodes") ErrNegativeMemory = errors.New("memory must be positive") ErrNegativeQuota = errors.New("quota must be positive") ErrZeroNodes = errors.New("no nodes provide to choose some") ErrNodeFormat = errors.New("bad endpoint name") ErrNodeExist = errors.New("node already exists") ErrKeyIsDir = errors.New("key is a directory") ErrKeyIsNotDir = errors.New("key is not a directory") ErrKeyIsEmpty = errors.New("key is empty") ErrBadContainerID = errors.New("container ID must be length of 64") ErrBadDeployMethod = errors.New("deploy method not support yet") ErrBadFaver = errors.New("favor should be either CPU or MEM") ErrBadIPAddress = errors.New("bad IP address") ErrBadPodType = errors.New("pod type not support yet") ErrBadSCMType = errors.New("unkonwn SCM type") ErrBadMemory = errors.New("bad `Memory` value") ErrBadCPU = errors.New("bad `CPU` value") ErrBadCount = errors.New("bad `Count` value") ErrPodHasNodes = errors.New("pod has nodes") ErrPodNoNodes = errors.New("pod has no nodes") ErrCannotGetEngine = errors.New("cannot get engine") ErrNilEngine = errors.New("engine is nil") ErrBadMeta = errors.New("bad meta") ErrInvaildPassword = errors.New("invaild password") ErrInvaildUsername = errors.New("invaild username") )
errors
Functions ¶
func IsDetailedErr ¶
IsDetailedErr returns the error's type if the error is a detailedErr, otherwise return it back
func NewDetailedErr ¶
NewDetailedErr returns an error with details
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Username string `yaml:"username,omitempty" json:"username,omitempty"`
Password string `yaml:"password,omitempty" json:"password,omitempty"`
}
AuthConfig contains authorization information for connecting to a Registry Basically copied from https://github.com/moby/moby/blob/16a1736b9b93e44c898f95d670bbaf20a558103d/api/types/auth.go#L4 But use yaml instead of json And we use it as grpc simple auth
type Bind ¶
type Bind struct {
InContainerPath string `yaml:"bind,omitempty"`
ReadOnly bool `yaml:"ro,omitempty"`
}
Bind define a single bind
type Build ¶
type Build struct {
Base string `yaml:"base,omitempty"`
Repo string `yaml:"repo,omitempty"`
Version string `yaml:"version,omitempty"`
Dir string `yaml:"dir,omitempty"`
Submodule bool `yaml:"submodule,omitempty"`
Commands []string `yaml:"commands,omitempty,flow"`
Envs map[string]string `yaml:"envs,omitempty,flow"`
Args map[string]string `yaml:"args,omitempty,flow"`
Labels map[string]string `yaml:"labels,omitempty,flow"`
Artifacts map[string]string `yaml:"artifacts,omitempty,flow"`
Cache map[string]string `yaml:"cache,omitempty,flow"`
}
Build define build
type BuildImageMessage ¶
type BuildImageMessage struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Progress string `json:"progress,omitempty"`
Error string `json:"error,omitempty"`
Stream string `json:"stream,omitempty"`
ErrorDetail errorDetail `json:"errorDetail,omitempty"`
}
BuildImageMessage for build image message
type BuildOptions ¶
BuildOptions is options for building image
type Builds ¶
type Builds struct {
Stages []string `yaml:"stages,omitempty,flow"`
Builds map[string]*Build `yaml:"builds,omitempty,flow"`
}
Builds define builds
type Config ¶
type Config struct {
LogLevel string `yaml:"log_level"`
Bind string `yaml:"bind"` // HTTP API address
Statsd string `yaml:"statsd"` // statsd host and port
Profile string `yaml:"profile"` // profile ip:port
ImageCache int `yaml:"image_cache"` // cache image count
LockTimeout int `yaml:"lock_timeout"` // timeout for lock (ttl)
GlobalTimeout time.Duration `yaml:"global_timeout"` // timeout for remove, run_and_wait and build, in second
Auth AuthConfig `yaml:"auth"` // grpc auth
Git GitConfig `yaml:"git"`
Etcd EtcdConfig `yaml:"etcd"`
Docker DockerConfig `yaml:"docker"`
Scheduler SchedConfig `yaml:"scheduler"`
}
Config holds eru-core config
type Container ¶
type Container struct {
ID string `json:"id"`
Podname string `json:"podname"`
Nodename string `json:"nodename"`
Name string `json:"name"`
CPU CPUMap `json:"cpu"`
Quota float64 `json:"quota"`
Memory int64 `json:"memory"`
Hook *Hook `json:"hook"`
Privileged bool `json:"privileged"`
SoftLimit bool `json:"softlimit"`
Engine *engineapi.Client `json:"-"`
Node *Node `json:"-"`
}
Container store container info only relationship with pod and node is stored if you wanna get realtime information, use Inspect method
func (*Container) Inspect ¶
func (c *Container) Inspect(ctx context.Context) (enginetypes.ContainerJSON, error)
Inspect a container
type CopyMessage ¶
type CopyMessage struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
Error error `json:"error,omitempty"`
Data io.ReadCloser `json:"-"`
}
CopyMessage for copy message
type CopyOptions ¶
CopyOptions for multiple container files copy
type CreateContainerMessage ¶
type CreateContainerMessage struct {
Podname string
Nodename string
ContainerID string
ContainerName string
Error error
Success bool
CPU CPUMap
Quota float64
Memory int64
Publish map[string]string
Hook []byte
}
CreateContainerMessage for create message
type DeployOptions ¶
type DeployOptions struct {
Name string // Name of application
Entrypoint *Entrypoint // entrypoint
Podname string // Name of pod to deploy
Nodename string // Specific nodes to deploy, if given, must belong to pod
Image string // Name of image to deploy
ExtraArgs string // Extra arguments to append to command
CPUQuota float64 // How many cores needed, e.g. 1.5
Memory int64 // Memory for container, in bytes
Count int // How many containers needed, e.g. 4
Env []string // Env for container
DNS []string // DNS for container
ExtraHosts []string // Extra hosts for container
Volumes []string // Volumes for container
Networks map[string]string // Network names and specified IPs
NetworkMode string // Network mode
User string // User for container
Debug bool // debug mode, use syslog as log driver
OpenStdin bool // OpenStdin for container
Meta map[string]string // Meta for containers
NodeLabels map[string]string // NodeLabels for filter node
DeployMethod string // Deploy method
Data map[string][]byte // For additional file data
SoftLimit bool // softlimit memory
}
DeployOptions is options for deploying
type DeployStatus ¶
type DeployStatus struct {
Data string
Err error
Action string
Appname string
Entrypoint string
Nodename string
ID string
}
DeployStatus store deploy status
type DockerConfig ¶
type DockerConfig struct {
APIVersion string `yaml:"version"` // docker API version
NetworkMode string `yaml:"network_mode"` // docker network mode
CertPath string `yaml:"cert_path"` // docker cert files path
Hub string `yaml:"hub"` // docker hub address
Namespace string `yaml:"namespace"` // docker hub prefix, will be set to $Hub/$HubPrefix/$appname
BuildPod string `yaml:"build_pod"` // podname used to build
UseLocalDNS bool `yaml:"local_dns"` // use node IP as dns
Log LogConfig `yaml:"log"` // docker log driver
AuthConfigs map[string]AuthConfig `yaml:"auths"` // docker registry credentials
}
DockerConfig holds eru-core docker config
type Entrypoint ¶
type Entrypoint struct {
Name string `yaml:"name,omitempty"`
Command string `yaml:"cmd,omitempty"`
Privileged bool `yaml:"privileged,omitempty"`
Dir string `yaml:"dir,omitempty"`
Log *LogConfig `yaml:"log,omitempty"`
Publish []string `yaml:"publish,omitempty,flow"`
HealthCheck *HealthCheck `yaml:"healthcheck,omitempty,flow"`
Hook *Hook `yaml:"hook,omitempty,flow"`
RestartPolicy string `yaml:"restart,omitempty"`
}
Entrypoint is a single entrypoint
type EtcdConfig ¶
type EtcdConfig struct {
Machines []string `yaml:"machines"` // etcd cluster addresses
Prefix string `yaml:"prefix"` // etcd lock prefix, all locks will be created under this dir
LockPrefix string `yaml:"lock_prefix"` // etcd lock prefix, all locks will be created under this dir
}
EtcdConfig holds eru-core etcd config
type GitConfig ¶
type GitConfig struct {
SCMType string `yaml:"scm_type"` // source code manager type [gitlab/github]
PublicKey string `yaml:"public_key"` // public key to clone code
PrivateKey string `yaml:"private_key"` // private key to clone code
Token string `yaml:"token"` // Token to call SCM API
}
GitConfig holds eru-core git config
type HealthCheck ¶
type HealthCheck struct {
TCPPorts []string `yaml:"tcp_ports,omitempty,flow"`
HTTPPort string `yaml:"http_port"`
HTTPURL string `yaml:"url,omitempty"`
HTTPCode int `yaml:"code,omitempty"`
}
HealthCheck define healthcheck
type Hook ¶
type Hook struct {
AfterStart []string `yaml:"after_start,omitempty"`
BeforeStop []string `yaml:"before_stop,omitempty"`
Force bool `yaml:"force,omitempty"`
}
Hook define hooks
type LogConfig ¶
type LogConfig struct {
Type string `yaml:"type"` // Log type, can be "journald", "json-file", "none"
Config map[string]string `yaml:"config"` // Log configs
}
LogConfig define log type
type Node ¶
type Node struct {
sync.Mutex
Name string `json:"name"`
Endpoint string `json:"endpoint"`
Podname string `json:"podname"`
Available bool `json:"available"`
CPU CPUMap `json:"cpu"`
MemCap int64 `json:"memcap"`
Labels map[string]string `json:"labels"`
Engine *engineapi.Client `json:"-"`
}
Node store node info
type NodeInfo ¶
type NodeInfo struct {
CPUAndMem
Name string
CPUs int
CPUPlan []CPUMap
Capacity int // 可以部署几个
Count int // 上面有几个了
Deploy int // 最终部署几个
}
NodeInfo for deploy
type Pod ¶
type Pod struct {
Name string `json:"name"`
Desc string `json:"desc"`
// scheduler favor, should be CPU or MEM
Favor string `json:"favor"`
}
Pod define pod
type PullImageMessage ¶
type PullImageMessage struct {
BuildImageMessage
}
PullImageMessage for cache image
type ReallocResourceMessage ¶
ReallocResourceMessage for realloc resource
type RemoveContainerMessage ¶
RemoveContainerMessage for remove message
type RemoveImageMessage ¶
RemoveImageMessage for remove image message
type ReplaceContainerMessage ¶
type ReplaceContainerMessage struct {
Create *CreateContainerMessage
Remove *RemoveContainerMessage
Error error
}
ReplaceContainerMessage for replace method
type RunAndWaitMessage ¶
RunAndWaitMessage for run and wait
type RunAndWaitOptions ¶
type RunAndWaitOptions struct {
DeployOptions
Timeout int
Cmd string
}
RunAndWaitOptions is options for running and waiting