v1

package
v2.0.36 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: Apache-2.0 Imports: 10 Imported by: 60

Documentation

Index

Constants

View Source
const (
	SecretLabel = "secret-type"
	// speical secret of the the registry
	SecretRegistry = "registry"
	// speical secret of the the config
	SecretConfig = "config"
	// speical secret of the the certificate
	SecretCertificate = "certificate"
	// speical custom secret of the the certificate
	SecretCustomCertificate = "custom-certificate"
)

Variables

View Source
var ErrJSONLevelExceedsLimit = fmt.Errorf("the level of json exceeds the max limit (%d)", maxJSONLevel)

ErrJSONLevelExceedsLimit the level of json exceeds the max limit

Functions

This section is empty.

Types

type ActiveRequest

type ActiveRequest struct {
	BatchName        string            `yaml:"batchName,omitempty" json:"batchName,omitempty"`
	Namespace        string            `yaml:"namespace,omitempty" json:"namespace,omitempty"`
	FingerprintValue string            `yaml:"fingerprintValue,omitempty" json:"fingerprintValue,omitempty"`
	SecurityType     string            `yaml:"securityType,omitempty" json:"securityType,omitempty"`
	SecurityValue    string            `yaml:"securityValue,omitempty" json:"securityValue,omitempty"`
	PenetrateData    map[string]string `yaml:"penetrateData,omitempty" json:"penetrateData,omitempty"`
}

ActiveRequest body of active request

type ActiveResponse

type ActiveResponse struct {
	NodeName    string            `yaml:"nodeName,omitempty" json:"nodeName,omitempty"`
	Namespace   string            `yaml:"namespace,omitempty" json:"namespace,omitempty"`
	Certificate utils.Certificate `yaml:"certificate,omitempty" json:"certificate,omitempty"`
}

ActiveResponse body of active responce

type AppInfo

type AppInfo struct {
	Name    string `yaml:"name,omitempty" json:"name,omitempty"`
	Version string `yaml:"version,omitempty" json:"version,omitempty"`
}

AppInfo app info

type AppStats

type AppStats struct {
	AppInfo       `yaml:",inline" json:",inline"`
	Status        Status                   `yaml:"status,omitempty" json:"status,omitempty"`
	Cause         string                   `yaml:"cause,omitempty" json:"cause,omitempty"`
	InstanceStats map[string]InstanceStats `yaml:"instances,omitempty" json:"instances,omitempty"`
}

AppStats app statistics

type Application

type Application struct {
	Name              string            `json:"name,omitempty" yaml:"name,omitempty" validate:"resourceName,nonBaetyl"`
	Type              string            `json:"type,omitempty" yaml:"type,omitempty" default:"container"`
	Labels            map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	Namespace         string            `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	CreationTimestamp time.Time         `json:"createTime,omitempty" yaml:"createTime,omitempty"`
	Version           string            `json:"version,omitempty" yaml:"version,omitempty"`
	Selector          string            `json:"selector,omitempty" yaml:"selector,omitempty"`
	Services          []Service         `json:"services,omitempty" yaml:"services,omitempty"`
	Volumes           []Volume          `json:"volumes,omitempty" yaml:"volumes,omitempty"`
	Description       string            `json:"description,omitempty" yaml:"description,omitempty"`
	System            bool              `json:"system,omitempty" yaml:"system,omitempty"`
}

Application application info

type Configuration

type Configuration struct {
	Name              string            `json:"name,omitempty" yaml:"name,omitempty" validate:"resourceName,nonBaetyl"`
	Namespace         string            `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	Labels            map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	Data              map[string]string `json:"data,omitempty" yaml:"data,omitempty" default:"{}" binding:"required"`
	CreationTimestamp time.Time         `json:"createTime,omitempty" yaml:"createTime,omitempty"`
	UpdateTimestamp   time.Time         `json:"updateTime,omitempty" yaml:"updateTime,omitempty"`
	Description       string            `json:"description,omitempty" yaml:"description,omitempty"`
	Version           string            `json:"version,omitempty" yaml:"version,omitempty"`
	System            bool              `json:"system,omitempty" yaml:"system,omitempty"`
}

Configuration config info

type ConfigurationObject

type ConfigurationObject struct {
	// hex format
	MD5      string            `json:"md5,omitempty" yaml:"md5,omitempty"`
	Sha256   string            `json:"sha256,omitempty" yaml:"sha256,omitempty"`
	URL      string            `json:"url,omitempty" yaml:"url,omitempty"`
	Token    string            `json:"token,omitempty" yaml:"token,omitempty"`
	Unpack   string            `json:"unpack,omitempty" yaml:"unpack,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty"`
}

ConfigurationObject extended feature for object configuration

type ContainerPort

type ContainerPort struct {
	HostPort      int32  `json:"hostPort,omitempty" yaml:"hostPort,omitempty"`
	ContainerPort int32  `json:"containerPort,omitempty" yaml:"containerPort,omitempty"`
	Protocol      string `json:"protocol,omitempty" yaml:"protocol,omitempty"`
	HostIP        string `json:"hostIP,omitempty" yaml:"hostIP,omitempty"`
}

ContainerPort port config in container

type CoreInfo

type CoreInfo struct {
	GoVersion   string `yaml:"goVersion,omitempty" json:"goVersion,omitempty"`
	BinVersion  string `yaml:"binVersion,omitempty" json:"binVersion,omitempty"`
	GitRevision string `yaml:"gitRevision,omitempty" json:"gitRevision,omitempty"`
}

type Desire

type Desire map[string]interface{}

Desire desire data

func (Desire) AppInfos

func (d Desire) AppInfos(isSys bool) []AppInfo

func (Desire) AppStats

func (d Desire) AppStats(isSys bool) []AppStats

func (Desire) Diff

func (d Desire) Diff(reported Report) (Desire, error)

Diff diff with reported data, return the delta fo desire

func (Desire) Merge

func (d Desire) Merge(desired Desire) error

Merge merge new reported data

func (Desire) SetAppInfos

func (d Desire) SetAppInfos(isSys bool, apps []AppInfo)

func (Desire) SetAppStats

func (d Desire) SetAppStats(isSys bool, stats []AppStats)

type DesireRequest

type DesireRequest struct {
	Infos []ResourceInfo `yaml:"infos" json:"infos"`
}

DesireRequest body of request to sync desired data

type DesireResponse

type DesireResponse struct {
	Values []ResourceValue `yaml:"values" json:"values"`
}

DesireResponse body of response to sync desired data

type Device

type Device struct {
	DevicePath  string `json:"devicePath,omitempty" yaml:"devicePath,omitempty"`
	Policy      string `json:"policy,omitempty" yaml:"policy,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

VolumeDevice device volume config

type Environment

type Environment struct {
	Name  string `json:"name,omitempty" yaml:"name,omitempty"`
	Value string `json:"value,omitempty" yaml:"value,omitempty"`
}

Environment environment config

type HostPathVolumeSource

type HostPathVolumeSource struct {
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
}

HostPathVolumeSource volume source of host path

type InstanceStats

type InstanceStats struct {
	Name        string            `yaml:"name,omitempty" json:"name,omitempty"`
	ServiceName string            `yaml:"serviceName,omitempty" json:"serviceName"`
	Usage       map[string]string `yaml:"usage,omitempty" json:"usage,omitempty"`
	Status      Status            `yaml:"status,omitempty" json:"status,omitempty"`
	Cause       string            `yaml:"cause,omitempty" json:"cause,omitempty"`
	CreateTime  time.Time         `yaml:"createTime,omitempty" json:"createTime,omitempty"`
}

InstanceStats instance stats

type Kind

type Kind string

Kind app model kind, crd on k8s

const (
	KindNode          Kind = "node"
	KindApp           Kind = "app"
	KindApplication   Kind = "application"
	KindConfig        Kind = "config"
	KindConfiguration Kind = "configuration"
	KindSecret        Kind = "secret"
)

All kinds

type Message added in v2.0.18

type Message struct {
	Kind     MessageKind       `yaml:"kind" json:"kind"`
	Metadata map[string]string `yaml:"meta" json:"meta"`
	Content  VariableValue     `yaml:"content" json:"content"`
}

Message general structure for http and ws sync

type MessageKind added in v2.0.18

type MessageKind string

MessageKind message kind

const (
	// MessageReport report message kind
	MessageReport MessageKind = "report"
	// MessageDesire desire message kind
	MessageDesire MessageKind = "desire"
	// MessageKeep keep alive message kind
	MessageKeep MessageKind = "keepalive"
)

type Node

type Node struct {
	Namespace         string            `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	Name              string            `json:"name,omitempty" yaml:"name,omitempty" validate:"omitempty,resourceName"`
	Version           string            `json:"version,omitempty" yaml:"version,omitempty"`
	CreationTimestamp time.Time         `json:"createTime,omitempty" yaml:"createTime,omitempty"`
	Labels            map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" validate:"omitempty,validLabels"`
	Annotations       map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
	Report            Report            `json:"report,omitempty" yaml:"report,omitempty"`
	Desire            Desire            `json:"desire,omitempty" yaml:"desire,omitempty"`
	Description       string            `json:"description,omitempty" yaml:"description,omitempty"`
}

Node the spec of node

func (*Node) View

func (n *Node) View(timeout time.Duration) (*NodeView, error)

type NodeInfo

type NodeInfo struct {
	Hostname         string `yaml:"hostname,omitempty" json:"hostname,omitempty"`
	Address          string `yaml:"address,omitempty" json:"address,omitempty"`
	Arch             string `yaml:"arch,omitempty" json:"arch,omitempty"`
	KernelVersion    string `yaml:"kernelVer,omitempty" json:"kernelVer,omitempty"`
	OS               string `yaml:"os,omitempty" json:"os,omitempty"`
	ContainerRuntime string `yaml:"containerRuntime,omitempty" json:"containerRuntime"`
	MachineID        string `yaml:"machineID,omitempty" json:"machineID"`
	BootID           string `yaml:"bootID,omitempty" json:"bootID"`
	SystemUUID       string `yaml:"systemUUID,omitempty" json:"systemUUID"`
	OSImage          string `yaml:"osImage,omitempty" json:"osImage"`
}

NodeInfo node info

type NodeStats

type NodeStats struct {
	DiskPressure       bool              `yaml:"diskPressure,omitempty" json:"diskPressure,omitempty"`
	MemoryPressure     bool              `yaml:"memoryPressure,omitempty" json:"memoryPressure,omitempty"`
	PIDPressure        bool              `yaml:"pidPressure,omitempty" json:"pidPressure,omitempty"`
	NetworkUnavailable bool              `yaml:"networkUnavailable,omitempty" json:"NetworkUnavailable,omitempty"`
	Ready              bool              `yaml:"ready,omitempty" json:"ready,omitempty"`
	Usage              map[string]string `yaml:"usage,omitempty" json:"usage,omitempty"`
	Capacity           map[string]string `yaml:"capacity,omitempty" json:"capacity,omitempty"`
	Percent            map[string]string `yaml:"percent,omitempty" json:"percent,omitempty"`
}

NodeStats node statistics

type NodeView

type NodeView struct {
	Namespace         string            `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	Name              string            `json:"name,omitempty" yaml:"name,omitempty"`
	Version           string            `json:"version,omitempty" yaml:"version,omitempty"`
	CreationTimestamp time.Time         `json:"createTime,omitempty" yaml:"createTime,omitempty"`
	Labels            map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	Annotations       map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
	Report            *ReportView       `json:"report,omitempty" yaml:"report,omitempty"`
	Desire            Desire            `json:"desire,omitempty" yaml:"desire,omitempty"`
	Description       string            `json:"description,omitempty" yaml:"description,omitempty"`
	Ready             bool              `json:"ready"`
}

type ObjectReference

type ObjectReference struct {
	Name    string `json:"name,omitempty" yaml:"name,omitempty"`
	Version string `json:"version,omitempty" yaml:"version,omitempty"`
}

ObjectReference object reference to config or secret

type Report

type Report map[string]interface{}

Report report data

func (Report) AppInfos

func (r Report) AppInfos(isSys bool) []AppInfo

func (Report) AppStats

func (r Report) AppStats(isSys bool) []AppStats

func (Report) Merge

func (r Report) Merge(reported Report) error

Merge merge new reported data

func (Report) SetAppInfos

func (r Report) SetAppInfos(isSys bool, apps []AppInfo)

func (Report) SetAppStats

func (r Report) SetAppStats(isSys bool, stats []AppStats)

type ReportView

type ReportView struct {
	Time        *time.Time `json:"time,omitempty" yaml:"time,omitempty"`
	Apps        []AppInfo  `json:"apps,omitempty" yaml:"apps,omitempty"`
	SysApps     []AppInfo  `json:"sysapps,omitempty" yaml:"sysapps,omitempty"`
	Core        *CoreInfo  `json:"core,omitempty" yaml:"core,omitempty"`
	AppStats    []AppStats `json:"appstats,omitempty" yaml:"appstats,omitempty"`
	SysAppStats []AppStats `json:"sysappstats,omitempty" yaml:"sysappstats,omitempty"`
	Node        *NodeInfo  `json:"node,omitempty" yaml:"node,omitempty"`
	NodeStats   *NodeStats `json:"nodestats,omitempty" yaml:"nodestats,omitempty"`
}

type ResourceInfo

type ResourceInfo struct {
	Kind    Kind   `yaml:"kind,omitempty" json:"kind,omitempty"`
	Name    string `yaml:"name,omitempty" json:"name,omitempty"`
	Version string `yaml:"version,omitempty" json:"version,omitempty"`
}

ResourceInfo desired info

type ResourceValue

type ResourceValue struct {
	ResourceInfo `yaml:",inline" json:",inline"`
	Value        VariableValue `yaml:"value,omitempty" json:"value,omitempty"`
}

ResourceValue desired value

func (*ResourceValue) App

func (v *ResourceValue) App() *Application

App return app data if its kind is app

func (*ResourceValue) Config

func (v *ResourceValue) Config() *Configuration

Config return config data if its kind is config

func (*ResourceValue) Secret

func (v *ResourceValue) Secret() *Secret

Secret return secret data if its kind is secret

type Resources

type Resources struct {
	Limits   map[string]string `json:"limits,omitempty" yaml:"limits,omitempty"`
	Requests map[string]string `json:"requests,omitempty" yaml:"requests,omitempty"`
}

Resources resources config

type Retry

type Retry struct {
	Max int `json:"max,omitempty" yaml:"max,omitempty"`
}

Retry retry config

type Secret

type Secret struct {
	Name              string            `json:"name,omitempty" yaml:"name,omitempty" validate:"resourceName,nonBaetyl"`
	Namespace         string            `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	Labels            map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	Annotations       map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
	Data              map[string][]byte `json:"data,omitempty" yaml:"data,omitempty"`
	CreationTimestamp time.Time         `json:"createTime,omitempty" yaml:"createTime,omitempty"`
	UpdateTimestamp   time.Time         `json:"updateTime,omitempty" yaml:"updateTime,omitempty"`
	Description       string            `json:"description,omitempty" yaml:"description,omitempty"`
	Version           string            `json:"version,omitempty" yaml:"version,omitempty"`
	System            bool              `json:"system,omitempty" yaml:"system,omitempty"`
}

Secret secret info

type SecurityContext

type SecurityContext struct {
	Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
}

type Service

type Service struct {
	// specifies the unique name of the service
	Name string `json:"name,omitempty" yaml:"name,omitempty" binding:"required" validate:"omitempty,resourceName"`
	// specifies the hostname of the service
	Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
	// specifies the image of the service, usually using the Docker image name
	Image string `json:"image,omitempty" yaml:"image,omitempty" binding:"required"`
	// specifies the number of instances started
	Replica int `json:"replica,omitempty" yaml:"replica,omitempty" binding:"required" default:"1"`
	// specifies the storage volumes that the service needs, map the storage volume to the directory in the container
	VolumeMounts []VolumeMount `json:"volumeMounts,omitempty" yaml:"volumeMounts,omitempty"`
	// specifies the port bindings which exposed by the service, only for Docker container mode
	Ports []ContainerPort `json:"ports,omitempty" yaml:"ports,omitempty"`
	// specifies the device bindings which used by the service, only for Docker container mode
	Devices []Device `json:"devices,omitempty" yaml:"devices,omitempty"`
	// specifies the startup arguments of the service program, but does not include `arg[0]`
	Args []string `json:"args,omitempty" yaml:"args,omitempty"`
	// specifies the environment variable of the service program
	Env []Environment `json:"env,omitempty" yaml:"env,omitempty"`
	// specifies resource limits for a single instance of the service,  only for Docker container mode
	Resources *Resources `json:"resources,omitempty" yaml:"resources,omitempty"`
	// specifies runtime to use, only for Docker container mode
	Runtime string `json:"runtime,omitempty" yaml:"runtime,omitempty"`
	// labels
	Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	// specifies the security context of service
	SecurityContext *SecurityContext `json:"security,omitempty" yaml:"security,omitempty"`
	// specifies host network mode of service
	HostNetwork bool `json:"hostNetwork,omitempty" yaml:"hostNetwork,omitempty"`
	// specifies function config of service
	FunctionConfig *ServiceFunctionConfig `json:"functionConfig,omitempty" yaml:"functionConfig,omitempty"`
	// specifies functions of service
	Functions []ServiceFunction `json:"functions,omitempty" yaml:"functions,omitempty"`
}

Service service config1ma1

type ServiceFunction

type ServiceFunction struct {
	Name    string `json:"name,omitempty" yaml:"name,omitempty"`
	Handler string `json:"handler,omitempty" yaml:"handler,omitempty"`
	CodeDir string `json:"codedir,omitempty" yaml:"codedir,omitempty"`
}

type ServiceFunctionConfig

type ServiceFunctionConfig struct {
	Name    string `json:"name,omitempty" yaml:"name,omitempty" validate:"resourceName"`
	Runtime string `json:"runtime,omitempty" yaml:"runtime,omitempty"`
}

type Status

type Status string
const (
	Pending Status = "Pending"
	Failed  Status = "Failed"
	Running Status = "Running"
	Unknown Status = "Unknown"
)

type VariableValue

type VariableValue struct {
	Value interface{}
	// contains filtered or unexported fields
}

VariableValue variable value which can be app, config or secret

func (VariableValue) MarshalJSON

func (v VariableValue) MarshalJSON() ([]byte, error)

MarshalJSON marshal to json data

func (VariableValue) Unmarshal added in v2.0.33

func (v VariableValue) Unmarshal(obj interface{}) error

Unmarshal unmarshal from json data to obj

func (*VariableValue) UnmarshalJSON

func (v *VariableValue) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal from json data

type Volume

type Volume struct {
	// specified name of the volume
	Name string `json:"name,omitempty" yaml:"name,omitempty" binding:"required" validate:"omitempty,resourceName"`
	// specified driver for the storage volume
	VolumeSource `json:",inline" yaml:",inline"`
}

Volume volume config

type VolumeMount

type VolumeMount struct {
	// specifies name of volume
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// specifies mount path of volume
	MountPath string `json:"mountPath,omitempty" yaml:"mountPath,omitempty"`
	// specifies if the volume is read-only
	ReadOnly bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"`
	// specifies if the volumeMount is immutable
	Immutable bool `json:"immutable,omitempty" yaml:"immutable,omitempty"`
}

VolumeMount volume mount config

type VolumeSource

type VolumeSource struct {
	HostPath *HostPathVolumeSource `json:"hostPath,omitempty" yaml:"hostPath,omitempty"`
	Config   *ObjectReference      `json:"config,omitempty" yaml:"config,omitempty"`
	Secret   *ObjectReference      `json:"secret,omitempty" yaml:"secret,omitempty"`
}

VolumeSource volume source, include empty directory, host path, config and secret

Jump to

Keyboard shortcuts

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