common

package
v0.0.0-...-930cb11 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BashDetectShell = `` /* 401-byte string literal not displayed */
View Source
const DefaultDockerWorkspace = "/workspace" // docker executor worspace dir
View Source
const DefaultLivessTimeout = 1800 // pod 生产时间
View Source
const DefaultMetricsServerPort = 9252 //prometheus metrics 端口
View Source
const DefaultNetworkClientTimeout = 60 * time.Minute // http 底层 timeout 超时时间
View Source
const KubernetesPollAttempts = 100 // 尝试获得 Pod 详情次数
View Source
const KubernetesPollInterval = 10 * time.Second // 每次查询 pod 详情 间隔时间
View Source
const NAME = "super-runner"
View Source
const SshConnectRetries = 3 // ssh 重试次数
View Source
const SshRetryInterval = 3 //ssh 间隔时间
View Source
const VERSION = "2020-12-08"

Variables

This section is empty.

Functions

func RegisterExecutor

func RegisterExecutor(executor string, provider ExecutorProvider)

Types

type AtomInfo

type AtomInfo struct {
	AtomName string `json:"atom_name"`

	Execution Execution    `json:"execution"`
	Variables JobVariables `json:"variables,omitempty"`
}

type AtomRequest

type AtomRequest struct {
	Pipeline   string `json:"pipeline"`
	StageIndex int    `json:"stage_index"`
	JobIndex   int    `json:"job_index"`
	AtomIndex  int    `json:"atom_index"` // 该job 的 atom 下标
	Token      string `json:"job_token"`  // job 的 token

}

type AtomResponse

type AtomResponse struct {
	ID       int      `json:"id"`
	Token    string   `json:"token"`
	AtomInfo AtomInfo `json:"atom_info"`
}

type Atoms

type Atoms struct {
	Count int `json:"count"`
}

type BuildError

type BuildError struct {
	Inner error
}

func (*BuildError) Error

func (b *BuildError) Error() string

type Docker

type Docker struct {
	DNS             []string       `toml:"dns,omitempty" json:"dns" long:"dns" env:"DOCKER_DNS" description:"A list of DNS servers for the container to use"`
	DockerWorkspace string         `toml:"workspace"`
	Privileged      bool           `` /* 138-byte string literal not displayed */
	Volumes         []DockerVolume `` /* 284-byte string literal not displayed */
}

type DockerVolume

type DockerVolume struct {
	Name     string `toml:"name"`
	Source   string `toml:"source"`
	Target   string `toml:"target"`
	ReadOnly bool   `toml:"read_only"`
}

type Execution

type Execution struct {
	Language    string   `json:"language"`
	PackagePath string   `json:"package_path"`
	InputPath   string   `json:"input_path"`
	OutputPath  string   `json:"output_path"`
	Demands     []string `json:"demands"`
	Artifacts   []string `json:"artifacts,omitempty"`
	Target      string   `json:"target"`
}

type Executor

type Executor interface {
	Prepare(job Job) error
	Run() error
	Wait() error
	SendError(err error)
	Cleanup() error
}

type ExecutorProvider

type ExecutorProvider interface {
	CanCreate() bool
	Create() Executor
}

func GetExecutor

func GetExecutor(executorStr string) ExecutorProvider

type GitConfig

type GitConfig struct {
	Name     string `toml:"name"`
	Password string `toml:"password"`
}

type Image

type Image struct {
	Name       string   `json:"name"`
	Alias      string   `json:"alias,omitempty"`
	Command    []string `json:"command,omitempty"`
	Entrypoint []string `json:"entrypoint,omitempty"`
}

type Job

type Job struct {
	Runner RunnerConfig
	JobResponse
}

func (*Job) Run

func (j *Job) Run() error

type JobInfo

type JobInfo struct {
	Pipeline   string       `json:"pipeline"`
	Stage      string       `json:"stage"`
	StageIndex int          `json:"stage_index"`
	JobName    string       `json:"job_name"`
	JobIndex   int          `json:"job_index"`
	Timestamp  int64        `json:"timestamp"`
	Image      Image        `json:"image"`
	Services   Services     `json:"services,omitempty"`
	Volumes    []Volume     `json:"volumes,omitempty"`
	Variables  JobVariables `json:"variables,omitempty"`
	Atoms      Atoms        `json:"atoms"`
	Timeout    int32        `json:"timeout,omitempty"`
}

type JobRequest

type JobRequest struct {
	Info  VersionInfo `json:"info,omitempty"`
	Token string      `json:"token,omitempty"`
}

type JobResponse

type JobResponse struct {
	ID      int     `json:"id"`
	Token   string  `json:"token"`
	JobInfo JobInfo `json:"job_info"`
}

JobResponse 为解析 json 的结构体

type JobVariable

type JobVariable struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

func ParseVariable

func ParseVariable(text string) (variable JobVariable, err error)

func (JobVariable) String

func (b JobVariable) String() string

type JobVariables

type JobVariables []JobVariable

func (JobVariables) Expand

func (b JobVariables) Expand() (variables JobVariables)

func (JobVariables) ExpandValue

func (b JobVariables) ExpandValue(value string) string

func (JobVariables) Get

func (b JobVariables) Get(key string) string

func (JobVariables) StringList

func (b JobVariables) StringList() (variables []string)

type KafkaConfig

type KafkaConfig struct {
	Read   Read   `toml:"read"`
	Writer Writer `toml:"writer"`
}

type Kubernetes

type Kubernetes struct {
	Config      string   `toml:"config,omitempty"`
	Namespace   string   `toml:"namespace,omitempty"`
	DNS         []string `toml:"dns,omitempty"`
	HelperImage string   `toml:"helper_image,omitempty"`
}

type MinioConfig

type MinioConfig struct {
	Url        string `toml:"url"`
	Bucket     string `toml:"bucket"`
	Access_key string `toml:"access_key"`
	Secret_key string `toml:"secret_key"`
}

type Read

type Read struct {
	BrokerList string `toml:"brokerList"`
	Topic      string `toml:"topic"`
	GroupID    string `toml:"groupID"`
}

type RunnerConfig

type RunnerConfig struct {
	Name          string      `toml:"name"`
	Executor      string      `toml:"executor"`
	Concurrent    int         `toml:"concurrent"`
	Log_level     string      `toml:"log_level"`
	ListenAddress string      `toml:"listen_address,omitempty" json:"listen_address"`
	KafkaConfig   KafkaConfig `toml:"kafka"`
	Kubernetes    Kubernetes  `toml:"kubernetes"`
	MinioConfig   MinioConfig `toml:"minio"`
	Docker        Docker      `toml:"docker"`
	GitConfig     GitConfig   `toml:"git"`
	RunnerCredentials
}

func (*RunnerConfig) GetListenAddress

func (config *RunnerConfig) GetListenAddress() (string, error)

获取 ListenAddress 配置地址

func (*RunnerConfig) LoadConfig

func (config *RunnerConfig) LoadConfig(config_file string) error

解析配置文件

type RunnerCredentials

type RunnerCredentials struct {
	URL   string `toml:"url" json:"url" short:"u" long:"url" env:"CI_SERVER_URL" required:"true" description:"Runner URL"`
	Token string `toml:"token" json:"token" short:"t" long:"token" env:"CI_SERVER_TOKEN" required:"true" description:"Runner token"`
}

func (*RunnerCredentials) GetToken

func (c *RunnerCredentials) GetToken() string

func (*RunnerCredentials) GetURL

func (c *RunnerCredentials) GetURL() string

type Services

type Services []Image

type VersionInfo

type VersionInfo struct {
	Name         string `json:"name,omitempty"`
	Version      string `json:"version,omitempty"`
	Revision     string `json:"revision,omitempty"`
	Platform     string `json:"platform,omitempty"`
	Architecture string `json:"architecture,omitempty"`
	Executor     string `json:"executor,omitempty"`
}

type Volume

type Volume struct {
	Name       string `json:"name"`
	Mount_path string `json:"mount_path"`
	Read_only  bool   `json:"read_only"`
	Host_path  string `json:"host_path"`
}

type Writer

type Writer struct {
	BrokerList string `toml:"brokerList"`
	Topic      string `toml:"topic"`
}

Jump to

Keyboard shortcuts

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