actionagent

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 33 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	CONTEXTDIR = "CONTEXTDIR"
	WORKDIR    = "WORKDIR"
	METAFILE   = "METAFILE"
	UPLOADDIR  = "UPLOADDIR"
)
View Source
const (
	EnvDiceOpenapiPublicUrl = "DICE_OPENAPI_PUBLIC_URL"
	EnvDiceOpenapiAddr      = "DICE_OPENAPI_ADDR"
	EnvDiceIsEdge           = "DICE_IS_EDGE"
)
View Source
const (
	EnvStdErrRegexpList            = "ACTIONAGENT_STDERR_REGEXP_LIST"
	EnvMaxWaitingPathUnlockSec     = "ACTIONAGENT_MAX_WAITING_PATH_UNLOCK_SEC"
	DefaultMaxWaitingPathUnlockSec = 10
)
View Source
const (
	EnvSuffixPublicURL = "_PUBLIC_URL"
	EnvSuffixAddr      = "_ADDR"
)
View Source
const (
	EnvEnablePushLog2Collector = "ACTIONAGENT_ENABLE_PUSH_LOG_TO_COLLECTOR"
	EnvCollectorAddr           = "COLLECTOR_ADDR"
	EnvTaskLogID               = "TERMINUS_DEFINE_TAG"
)
View Source
const EncryptedValueMinLen = "ACTIONAGENT_ENCRYPTED_VAlUE_MIN_LEN"

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Arg *AgentArg

	EasyUse EasyUse

	// errs collect occurred errors
	Errs []error

	FileWatcher *filewatch.Watcher
	FWLock      sync.Mutex

	// PushedMetaFileMap store key value already pushed
	// first-level key: meta name; second-level key: meta value
	// for situation that one key has multiple values
	PushedMetaFileMap     map[string]map[string]struct{}
	LockPushedMetaFileMap sync.RWMutex

	Ctx      context.Context
	Cancel   context.CancelFunc // cancel when logic done
	ExitCode int

	StdErrRegexpList        []*regexp.Regexp
	MaxWaitingPathUnlockSec int

	TextBlackList []string // enciphered data will Replaced by '******' when log output
}

func (*Agent) AppendError

func (agent *Agent) AppendError(err error)

func (*Agent) Callback

func (agent *Agent) Callback()

func (*Agent) Execute

func (agent *Agent) Execute(r io.Reader)

func (*Agent) Exit

func (agent *Agent) Exit()

Exit exit agent.

func (*Agent) ListenSignal

func (agent *Agent) ListenSignal()

func (*Agent) MergeErrors

func (agent *Agent) MergeErrors() []apistructs.ErrorResponse

func (*Agent) PreStop

func (agent *Agent) PreStop()

func (*Agent) Teardown

func (agent *Agent) Teardown(exitCode ...int)

Teardown teardown agent, including prestop, callback.

type AgentArg

type AgentArg struct {
	PullBootstrapInfo bool `json:"pullBootstrapInfo"`

	Commands []string                 `json:"commands,omitempty"` // custom action commands -> script -> run
	Context  spec.PipelineTaskContext `json:"context,omitempty"`  // 上下文

	PrivateEnvs map[string]string `json:"privateEnvs,omitempty"`

	PipelineID     uint64 `json:"pipelineID"`
	PipelineTaskID uint64 `json:"pipelineTaskID"`

	EncryptSecretKeys []string `json:"encryptSecretKeys"` // Encrypt envs, it will Replaced by '******' when log output
}

func NewAgentArgForPull

func NewAgentArgForPull(pipelineID, pipelineTaskID uint64) *AgentArg

type Callback

type Callback apistructs.ActionCallback

func (*Callback) AppendMetadataFields

func (c *Callback) AppendMetadataFields(fields []*apistructs.MetadataField)

append fields to metadata and limit metadataField

func (*Callback) HandleMetaFile

func (c *Callback) HandleMetaFile(b []byte) error

1) decode as: apistructs.Metadata 2) decode as: line(k=v)

type EasyUse

type EasyUse struct {
	ContainerContext  string // 容器内程序运行时上下文目录
	ContainerWd       string // 执行 run 程序时所在目录
	ContainerMetaFile string // metadata 文件

	ContainerUploadDir        string // uploadDir,该目录下的文件在执行结束后会自动上传,并提供下载
	ContainerTempTarUploadDir string // temp tar dir,需要 prepare 时预先创建,用于存放 upload 生成的 tar

	IsEdgeCluster bool // 是否是边缘集群

	RunScript              string // run 文件
	RunProcess             *os.Process
	RunMultiStdoutFilePath string   // multiWriter(os.Stdout) 的文件路径
	RunMultiStdout         *os.File // multiWriter(os.Stdout) 的文件
	RunMultiStderrFilePath string   // multiWriter(os.Stderr) 的文件路径
	RunMultiStderr         *os.File // multiWriter(os.Stderr) 的文件
	FlagEndLineForTail     string   // flag end line for tail to stop

	OpenAPIAddr       string
	OpenAPIToken      string
	TokenForBootstrap string

	EnablePushLog2Collector bool   // 是否推送日志到 collector
	CollectorAddr           string // collector 地址
	TaskLogID               string // 日志 ID,推送和查询时需要一致

	// Machine stat
	MachineStat apistructs.PipelineTaskMachineStat
}

type RunningEnvironment

type RunningEnvironment struct {
	HostIP string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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