domain

package
v1.22.38 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CmdExitCodeUnknown default exit code
	CmdExitCodeUnknown = -1

	// CmdExitCodeTimeOut exit code for timeout
	CmdExitCodeTimeOut = -100

	// CmdExitCodeKilled exit code for killed
	CmdExitCodeKilled = -1

	// CmdExitCodeSuccess exit code for command executed successfully
	CmdExitCodeSuccess = 0
)
View Source
const (
	TtyActionOpen  = "OPEN"
	TtyActionClose = "CLOSE"
	TtyActionShell = "SHELL"
)
View Source
const (
	ConfigCategorySmtp = "SMTP"
	ConfigCategoryText = "TEXT"
)
View Source
const (
	SecretCategoryAuth        = "AUTH"
	SecretCategorySshRsa      = "SSH_RSA"
	SecretCategoryToken       = "TOKEN"
	SecretCategoryAndroidSign = "ANDROID_SIGN"
	SecretCategoryKubeConfig  = "KUBE_CONFIG"
)
View Source
const (
	VarServerUrl = "FLOWCI_SERVER_URL"

	VarAgentDebug         = "FLOWCI_AGENT_DEBUG" // boolean
	VarAgentToken         = "FLOWCI_AGENT_TOKEN"
	VarAgentPort          = "FLOWCI_AGENT_PORT"
	VarAgentWorkspace     = "FLOWCI_AGENT_WORKSPACE"
	VarAgentJobDir        = "FLOWCI_AGENT_JOB_DIR"
	VarAgentPluginDir     = "FLOWCI_AGENT_PLUGIN_DIR"
	VarAgentLogDir        = "FLOWCI_AGENT_LOG_DIR"
	VarAgentVolumes       = "FLOWCI_AGENT_VOLUMES"
	VarAgentDockerNetwork = "FLOWCI_AGENT_DOCKER_NETWORK"
	VarAgentDockerAuth    = "FLOWCI_AGENT_DOCKER_AUTH"     // for private docker repo auth
	VarAgentEnableProfile = "FLOWCI_AGENT_PROFILE_ENABLED" // boolean
	VarAgentFromDocker    = "FLOWCI_DOCKER_AGENT"          // boolean

	VarK8sEnabled   = "FLOWCI_AGENT_K8S_ENABLED"    // boolean
	VarK8sInCluster = "FLOWCI_AGENT_K8S_IN_CLUSTER" // boolean

	VarK8sNodeName  = "K8S_NODE_NAME"
	VarK8sPodName   = "K8S_POD_NAME"
	VarK8sPodIp     = "K8S_POD_IP"
	VarK8sNamespace = "K8S_NAMESPACE"

	VarAgentIpPattern           = "FLOWCI_AGENT_IP_%s"        // ip address of agent host
	VarExportContainerIdPattern = "export CONTAINER_ID_%d=%s" // container id , d=index of dockers
	VarExportContainerIpPattern = "export CONTAINER_IP_%d=%s" // container ip , d=index of dockers
)
View Source
const EventOnBusy = AppEvent("EventOnBusy")
View Source
const EventOnIdle = AppEvent("EventOnIdle")

Variables

This section is empty.

Functions

func NilOrEmpty

func NilOrEmpty(v Variables) bool

NilOrEmpty detect variable is nil or empty

Types

type AgentConfig

type AgentConfig struct {
	ExitOnIdle int `json:"exitOnIdle"` // 0 for don't exit agent on idle
}

AgentConfig response body of AgentInit from server

type AgentConfigResponse

type AgentConfigResponse struct {
	Response
	Data *AgentConfig
}

func (*AgentConfigResponse) GetMessage

func (r *AgentConfigResponse) GetMessage() string

func (*AgentConfigResponse) IsOk

func (r *AgentConfigResponse) IsOk() bool

type AgentInit

type AgentInit struct {
	IsK8sCluster bool   `json:"isK8sCluster"`
	IsDocker     bool   `json:"isDocker"`
	Token        string `json:"token"`
	Port         int    `json:"port"`
	Os           string `json:"os"`
	Status       string `json:"status"`
}

AgentInit request data to get settings to server

type AgentProfile

type AgentProfile struct {
	CpuNum      int     `json:"cpuNum"`
	CpuUsage    float64 `json:"cpuUsage"`
	TotalMemory uint64  `json:"totalMemory"`
	FreeMemory  uint64  `json:"freeMemory"`
	TotalDisk   uint64  `json:"totalDisk"`
	FreeDisk    uint64  `json:"freeDisk"`
}

AgentProfile token signed at server side

type AgentStatus

type AgentStatus string

AgentStatus string of agent status

const (
	// AgentOffline offline status
	AgentOffline AgentStatus = "OFFLINE"

	// AgentBusy busy status
	AgentBusy AgentStatus = "BUSY"

	// AgentIdle idle status
	AgentIdle AgentStatus = "IDLE"
)

type AppEvent

type AppEvent string

type AuthSecret

type AuthSecret struct {
	SecretBase
	Pair *SimpleAuthPair `json:"pair"`
}

func (*AuthSecret) ToEnvs

func (s *AuthSecret) ToEnvs() map[string]string

type Cache

type Cache struct {
	Key   string   `json:"key"`
	Paths []string `json:"paths"`
}

type CmdIn

type CmdIn struct {
	Type CmdType `json:"type"`
}

type CmdOut

type CmdOut interface {
	ToBytes() []byte
}

type CmdStatus

type CmdStatus string
const (
	CmdStatusPending   CmdStatus = "PENDING"
	CmdStatusRunning   CmdStatus = "RUNNING"
	CmdStatusSuccess   CmdStatus = "SUCCESS"
	CmdStatusSkipped   CmdStatus = "SKIPPED"
	CmdStatusException CmdStatus = "EXCEPTION"
	CmdStatusKilled    CmdStatus = "KILLED"
	CmdStatusTimeout   CmdStatus = "TIMEOUT"
)

type CmdType

type CmdType string
const (
	CmdTypeShell CmdType = "SHELL"
	CmdTypeTty   CmdType = "TTY"
	CmdTypeKill  CmdType = "KILL"
	CmdTypeClose CmdType = "CLOSE"
)

type Config

type Config interface {
	GetName() string
	GetCategory() string
	ToEnvs() map[string]string
	ConfigMarker()
}

type ConfigBase

type ConfigBase struct {
	Name     string
	Category string
}

func (*ConfigBase) ConfigMarker

func (c *ConfigBase) ConfigMarker()

func (*ConfigBase) GetCategory

func (c *ConfigBase) GetCategory() string

func (*ConfigBase) GetName

func (c *ConfigBase) GetName() string

type ConfigResponse

type ConfigResponse struct {
	Response
	Data *ConfigBase `json:"data"`
}

type DockerConfig

type DockerConfig struct {
	Name     string
	Auth     *SimpleAuthPair
	Config   *container.Config
	Host     *container.HostConfig
	IsStop   bool
	IsDelete bool

	ContainerID string // try to resume if container id is existed
}

func (*DockerConfig) HasEntrypoint

func (c *DockerConfig) HasEntrypoint() bool

type DockerOption

type DockerOption struct {
	Image             string    `json:"image"`
	Auth              string    `json:"auth"`
	Name              string    `json:"name"`
	Entrypoint        []string  `json:"entrypoint"` // host:container
	Command           []string  `json:"command"`
	Ports             []string  `json:"ports"`
	Network           string    `json:"network"`
	Environment       Variables `json:"environment"`
	User              string    `json:"user"`
	IsRuntime         bool      `json:"isRuntime"`
	IsStopContainer   bool      `json:"isStopContainer"`
	IsDeleteContainer bool      `json:"isDeleteContainer"`
	ContainerID       string    // try to resume if container id is existed

	AuthContent *SimpleAuthPair // the real auth secret from 'auth' name
}

func (*DockerOption) HasAuth

func (d *DockerOption) HasAuth() bool

func (*DockerOption) SetDefaultNetwork

func (d *DockerOption) SetDefaultNetwork(network string)

func (*DockerOption) ToConfig

func (d *DockerOption) ToConfig() *DockerConfig

func (*DockerOption) ToRuntimeConfig

func (d *DockerOption) ToRuntimeConfig(vars Variables, workingDir string, binds []string) *DockerConfig

type DockerVolume

type DockerVolume struct {
	Name   string // volume name
	Dest   string // dest path
	Script string // script file name to execute
	Image  string // image contain volume
	Init   string // init script /ws/{init} in image that will copy required data to /target
}

DockerVolume volume will mount to step docker

func NewVolumesFromString

func NewVolumesFromString(val string) []*DockerVolume

NewFromString parse string name=xxx,dest=xxx,script=xxx;name=xxx,dest=xxx,script=xxx;...

func (*DockerVolume) DefaultTargetInImage

func (v *DockerVolume) DefaultTargetInImage() string

func (*DockerVolume) HasImage

func (v *DockerVolume) HasImage() bool

func (*DockerVolume) InitScriptInImage

func (v *DockerVolume) InitScriptInImage() string

func (*DockerVolume) ScriptPath

func (v *DockerVolume) ScriptPath() string

func (*DockerVolume) ToBindStr

func (v *DockerVolume) ToBindStr() string

type JobCache

type JobCache struct {
	Id     string   `json:"id"`
	FlowId string   `json:"flowId"`
	JobId  string   `json:"jobId"`
	Key    string   `json:"key"`
	Os     string   `json:"os"`
	Files  []string `json:"files"`
}

type JobCacheResponse

type JobCacheResponse struct {
	Response
	Data *JobCache
}

func (*JobCacheResponse) GetMessage

func (r *JobCacheResponse) GetMessage() string

func (*JobCacheResponse) IsOk

func (r *JobCacheResponse) IsOk() bool

type K8sConfig

type K8sConfig struct {
	Enabled   bool
	InCluster bool
	Namespace string
	PodName   string
	PodIp     string
}

type RSASecret

type RSASecret struct {
	SecretBase
	Pair           *SimpleKeyPair `json:"pair"`
	MD5FingerPrint string         `json:"md5Fingerprint"`
}

func (*RSASecret) ToEnvs

func (s *RSASecret) ToEnvs() map[string]string

type Response

type Response struct {
	Code    int
	Message string
}

Response the base response message struct

func (*Response) GetMessage

func (r *Response) GetMessage() string

func (*Response) IsOk

func (r *Response) IsOk() bool

type ResponseMessage

type ResponseMessage interface {
	IsOk() bool
	GetMessage() string
}

type ResponseRaw

type ResponseRaw struct {
	Raw json.RawMessage `json:"data"`
}

type Secret

type Secret interface {
	GetName() string
	GetCategory() string
	ToEnvs() map[string]string
	SecretMarker()
}

type SecretBase

type SecretBase struct {
	Name     string `json:"name"`
	Category string `json:"category"`
}

func (*SecretBase) GetCategory

func (s *SecretBase) GetCategory() string

func (*SecretBase) GetName

func (s *SecretBase) GetName() string

func (*SecretBase) SecretMarker

func (s *SecretBase) SecretMarker()

type SecretField

type SecretField struct {
	Data string `json:"data"`
}

type SecretResponse

type SecretResponse struct {
	Response
	Data *SecretBase `json:"data"`
}

type ShellIn

type ShellIn struct {
	CmdIn
	ID           string          `json:"id"`
	FlowId       string          `json:"flowId"`
	JobId        string          `json:"jobId"`
	AllowFailure bool            `json:"allowFailure"`
	Plugin       string          `json:"plugin"`
	Cache        *Cache          `json:"cache"`
	Dockers      []*DockerOption `json:"dockers"`
	Bash         []string        `json:"bash"`
	Pwsh         []string        `json:"pwsh"`
	Retry        int             `json:"retry"`
	Timeout      int             `json:"timeout"`
	Inputs       Variables       `json:"inputs"`
	EnvFilters   []string        `json:"envFilters"`
	Secrets      []string        `json:"secrets"` // secret name list
	Configs      []string        `json:"configs"` // config name list
}

func (*ShellIn) HasCache

func (in *ShellIn) HasCache() bool

func (*ShellIn) HasConfigs

func (in *ShellIn) HasConfigs() bool

func (*ShellIn) HasDockerOption

func (in *ShellIn) HasDockerOption() bool

func (*ShellIn) HasEnvFilters

func (in *ShellIn) HasEnvFilters() bool

func (*ShellIn) HasPlugin

func (in *ShellIn) HasPlugin() bool

func (*ShellIn) HasSecrets

func (in *ShellIn) HasSecrets() bool

func (*ShellIn) VarsToStringArray

func (in *ShellIn) VarsToStringArray() []string

type ShellLog

type ShellLog struct {
	JobId  string `json:"jobId"`
	StepId string `json:"stepId"`
	Log    string `json:"log"` // b64
}

type ShellOut

type ShellOut struct {
	ID         string    `json:"id"`
	ProcessId  int       `json:"processId"`
	Containers []string  `json:"containers"` // container ids applied for shell
	Status     CmdStatus `json:"status"`
	Code       int       `json:"code"`
	Output     Variables `json:"output"`
	StartAt    time.Time `json:"startAt"`
	FinishAt   time.Time `json:"finishAt"`
	Error      string    `json:"error"`
	LogSize    int64     `json:"logSize"`
}

func NewShellOutput

func NewShellOutput(in *ShellIn) *ShellOut

func (*ShellOut) IsFinishStatus

func (e *ShellOut) IsFinishStatus() bool

func (*ShellOut) ToBytes

func (e *ShellOut) ToBytes() []byte

type SimpleAuthPair

type SimpleAuthPair struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type SimpleKeyPair

type SimpleKeyPair struct {
	PublicKey  string `json:"publicKey"`
	PrivateKey string `json:"privateKey"`
}

type SmtpConfig

type SmtpConfig struct {
	ConfigBase
	Server     string
	Port       int
	SecureType string `json:"secure"`
	Auth       *SimpleAuthPair
}

func (*SmtpConfig) ToEnvs

func (c *SmtpConfig) ToEnvs() map[string]string

type TextConfig

type TextConfig struct {
	ConfigBase
	Text string
}

func (*TextConfig) ToEnvs

func (c *TextConfig) ToEnvs() map[string]string

type TokenSecret

type TokenSecret struct {
	SecretBase
	Token *SecretField `json:"token"`
}

func (*TokenSecret) ToEnvs

func (s *TokenSecret) ToEnvs() map[string]string

type TtyIn

type TtyIn struct {
	CmdIn
	ID     string `json:"id"`
	Action string `json:"action"`
	Input  string `json:"input"`
}

type TtyLog

type TtyLog struct {
	ID  string `json:"id"`
	Log string `json:"log"`
}

type TtyOut

type TtyOut struct {
	ID        string `json:"id"`
	Action    string `json:"action"`
	IsSuccess bool   `json:"success"`
	Error     string `json:"error"`
}

Open, Close control action response

func (*TtyOut) ToBytes

func (obj *TtyOut) ToBytes() []byte

type Variables

type Variables map[string]string

Variables applied for environment variable as key, value

func ConnectVars

func ConnectVars(a Variables, b Variables) Variables

func NewVariables

func NewVariables() Variables

func (Variables) AddMapVars

func (v Variables) AddMapVars(vars map[string]string)

func (Variables) Copy

func (v Variables) Copy() Variables

func (Variables) IsEmpty

func (v Variables) IsEmpty() bool

IsEmpty to check is empty variables

func (Variables) Resolve

func (v Variables) Resolve() Variables

Resolve to gain actual value from env variables

func (Variables) Size

func (v Variables) Size() int

func (Variables) ToStringArray

func (v Variables) ToStringArray() []string

ToStringArray convert variables map to key=value string array

Jump to

Keyboard shortcuts

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