conf

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package conf 定义了 pipeline 所需要的配置选项,这些配置选项都是通过环境变量加载.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APITestNetportalAccessK8sNamespaceBlacklist

func APITestNetportalAccessK8sNamespaceBlacklist() []string

APITestNetportalAccessK8sNamespaceBlacklist 返回 api-test 调用 netportal 代理的 k8s namespace 黑名单.

func ActionTypeMapping

func ActionTypeMapping() map[string]string

ActionTypeMapping 返回新老 action type 映射关系.

func AgentAccessibleCacheTTL

func AgentAccessibleCacheTTL() int64

AgentTTL 返回 agent 下载成功后 accessible 状态缓存的有效时间,默认为 12 小时。

func AgentContainerPathWhenExecute

func AgentContainerPathWhenExecute() string

AgentContainerPathWhenExecute 返回 agent 在 action 运行时需要被挂载的路径, 例如: /opt/emptydir/agent .

func AgentPreFetcherDestDir

func AgentPreFetcherDestDir() string

AgentPreFetcherDestDir 返回 agent 在 PreFetcher 中需要被 entrypoint 拷贝到的目录. 注意:不能是 /opt/action(agent 在镜像中的目录为 /opt/action/agent), 这样会导致 k8s initContainer emptyDir 与 mountDir 相同,entrypoint 执行失败。

func AnalyzedPipelineDefaultDatabaseGCTTLSec added in v1.1.0

func AnalyzedPipelineDefaultDatabaseGCTTLSec() uint64

AnalyzedPipelineDefaultDatabaseGCTTLSec return default database gc ttl for analyzed pipeline record

func BuildCacheCleanJobCron

func BuildCacheCleanJobCron() string

BuildCacheCleanJobCron 返回清理 构建缓存镜像 任务的 定时配置.

func BuildCacheExpireIn

func BuildCacheExpireIn() time.Duration

BuildCacheExpireIn 返回 构建缓存镜像 的失效时间.

func ClusterManagerAddr added in v1.1.0

func ClusterManagerAddr() string

ClusterManagerAddr return cluster-manager address

func CmsBase64EncodedRsaPrivateKey

func CmsBase64EncodedRsaPrivateKey() string

CmsBase64EncodedRsaPrivateKey 返回 配置管理 用于解密 value 的 rsa private key.

func CmsBase64EncodedRsaPublicKey

func CmsBase64EncodedRsaPublicKey() string

CmsBase64EncodedRsaPublicKey 返回 配置管理 用于加密 value 的 rsa public key.

func CollectorAddr

func CollectorAddr() string

CollectorAddr 返回 collector 的集群内部地址.

func CollectorPublicURL

func CollectorPublicURL() string

CollectorPublicURL 返回 collector 的公网地址

func CronCompensateConcurrentNumber added in v1.0.1

func CronCompensateConcurrentNumber() int64

func CronCompensateTimeMinute added in v1.0.1

func CronCompensateTimeMinute() int64

func CronFailureCreateIntervalCompensateTimeSecond added in v1.0.1

func CronFailureCreateIntervalCompensateTimeSecond() int64

func Debug

func Debug() bool

Debug 返回 Debug 选项.

func DiceCluster

func DiceCluster() string

DiceCluster 返回 pipeline 服务所在集群,用于判断 task 运行在 中心 or SaaS 集群.

func DiceHubAddr

func DiceHubAddr() string

DiceHubAddr 返回 dicehub 的集群内部地址.

func DisablePipelineVolume

func DisablePipelineVolume() bool

DisablePipelineVolume 返回 是否关闭 pipeline volume,只有值引用.

func EventboxAddr

func EventboxAddr() string

EventboxAddr 返回 eventbox 的集群内部地址.

func ExecutorRefreshIntervalMinute added in v1.1.0

func ExecutorRefreshIntervalMinute() uint64

ExecutorRefreshIntervalMinute return default executor refresh interval

func FailedPipelineDefaultResourceGCTTLSec added in v1.1.0

func FailedPipelineDefaultResourceGCTTLSec() uint64

FailedPipelineDefaultResourceGCTTLSec return default resource gc for failed pipeline

func FinishedPipelineDefaultDatabaseGCTTLSec added in v1.1.0

func FinishedPipelineDefaultDatabaseGCTTLSec() uint64

FinishedPipelineDefaultDatabaseGCTTLSec return default database gc ttl for finished pipeline record

func GittarAddr

func GittarAddr() string

GittarAddr 返回 gittar 的集群内部地址.

func GittarPublicURL

func GittarPublicURL() string

GittarPublicURL 返回 gittar 的公网地址.

func HepaAddr

func HepaAddr() string

HepaAddr 返回 hepa 的集群内部地址.

func InitializeSendRunningIntervalNum added in v1.1.0

func InitializeSendRunningIntervalNum() uint64

InitializeSendIntervalNum return initialize send running pipeline id interval num

func InitializeSendRunningIntervalSec added in v1.1.0

func InitializeSendRunningIntervalSec() uint64

InitializeSendIntervalTime return initialize send running pipeline id interval second

func InternalUserID

func InternalUserID() string

InternalUserID 返回 pipeline 组件在内部调用时默认分配的 用户 ID

func ListenAddr

func ListenAddr() string

ListenAddr 返回 pipeline 服务监听地址.

func Load

func Load()

Load 从环境变量加载配置选项.

func OpenAPIAddr

func OpenAPIAddr() string

OpenAPIAddr 返回 openapi 的集群内部地址.

func OpenAPIPublicURL

func OpenAPIPublicURL() string

OpenAPIPublicURL 返回 openapi 的公网地址,用于 SaaS 集群 task 回调中心集群 openapi.

func OpenapiOAuth2TokenClientID

func OpenapiOAuth2TokenClientID() string

OpenapiOAuth2TokenClientID 返回 用于申请 openapi oauth2 token 的客户端 id.

func OpenapiOAuth2TokenClientSecret

func OpenapiOAuth2TokenClientSecret() string

OpenapiOAuth2TokenClientID 返回 用于申请 openapi oauth2 token 的客户端 secret.

func QueueLoopHandleIntervalSec

func QueueLoopHandleIntervalSec() uint64

QueueLoopHandleIntervalSec return reconciler queueManager loop handle interval second.

func SchedulerAddr

func SchedulerAddr() string

SchedulerAddr 返回 scheduler 的集群内部地址.

func SpecifyImagePullPolicy added in v1.2.0

func SpecifyImagePullPolicy() string

SpecifyImagePullPolicy return default image pull policy

func StorageURL

func StorageURL() string

StorageURL 返回 storage url.

func SuccessPipelineDefaultResourceGCTTLSec added in v1.1.0

func SuccessPipelineDefaultResourceGCTTLSec() uint64

SuccessPipelineDefaultResourceGCTTLSec return default resource gc for success pipeline

func TaskDefaultCPU

func TaskDefaultCPU() float64

TaskDefaultCPU 返回 task 默认的 cpu 限制.

func TaskDefaultMEM

func TaskDefaultMEM() float64

TaskDefaultMEM 返回 task 默认的 memory 限制.

func TaskDefaultTimeout

func TaskDefaultTimeout() time.Duration

TaskDefaultTimeout 返回 task 默认超时时间.

func TaskQueueAlertTime

func TaskQueueAlertTime() time.Duration

TaskQueueAlertTime 返回 task 排队超过多少时间告警.

func TaskRunWaitInterval

func TaskRunWaitInterval() time.Duration

TaskRunWaitInterval 返回 task run 在 wait 过程中的时间间隔. 时间越短越精确,但对 scheduler 压力会变大,建议使用默认值 5s.

Types

type Conf

type Conf struct {
	ListenAddr  string `env:"LISTEN_ADDR" default:":3081"`
	Debug       bool   `env:"DEBUG" default:"false"`
	DiceCluster string `env:"DICE_CLUSTER" default:"local"` // 服务所在集群

	// task level
	TaskDefaultCPU      float64       `env:"TASK_DEFAULT_CPU" default:"0.5"`
	TaskDefaultMEM      float64       `env:"TASK_DEFAULT_MEM" default:"2048"`
	TaskDefaultTimeout  time.Duration `env:"TASK_DEFAULT_TIMEOUT" default:"1h"`
	TaskRunWaitInterval time.Duration `env:"TASK_RUN_WAIT_INTERVAL" default:"5s"`
	TaskQueueAlertTime  time.Duration `env:"TASK_QUEUE_ALERT_TIME" default:"10m"`

	// agent
	AgentAccessibleCacheTTL int64  `env:"AGENT_ACCESSIBLE_CACHE_TTL" default:"43200"` // 默认 12 小时
	AgentPreFetcherDestDir  string `env:"AGENT_PRE_FETCHER_DEST_DIR" default:"/opt/emptydir"`

	// build cache
	BuildCacheCleanJobCron string        `env:"BUILD_CACHE_CLEAN_JOB_CRON" default:"0 0 0 * * ?"`
	BuildCacheExpireIn     time.Duration `env:"BUILD_CACHE_EXPIRE_IN" default:"168h"`

	// bundle
	GittarAddr         string `env:"GITTAR_ADDR" required:"false"`
	OpenAPIAddr        string `env:"OPENAPI_ADDR" required:"false"`
	EventboxAddr       string `env:"EVENTBOX_ADDR" required:"false"`
	DiceHubAddr        string `env:"DICEHUB_ADDR" required:"false"`
	SchedulerAddr      string `env:"SCHEDULER_ADDR" required:"false"`
	HepaAddr           string `env:"HEPA_ADDR" required:"false"`
	CollectorAddr      string `env:"COLLECTOR_ADDR" required:"false"`
	ClusterManagerAddr string `env:"CLUSTER_MANAGER_ADDR" required:"false"`

	// public url
	GittarPublicURL    string `env:"GITTAR_PUBLIC_URL" required:"true"`
	OpenAPIPublicURL   string `env:"OPENAPI_PUBLIC_URL" required:"true"`
	CollectorPublicURL string `env:"COLLECTOR_PUBLIC_URL" required:"false"`

	// oss/nfs storage
	PipelineStorageURL string `env:"PIPELINE_STORAGE_URL" required:"true"`

	// action type mapping
	ActionTypeMappingStr string `env:"ACTION_TYPE_MAPPING"` // git:git-checkout,dicehub:release
	ActionTypeMapping    map[string]string

	// 默认用户 ID,用于鉴权
	InternalUserID string `env:"INTERNAL_USER_ID" default:"1103"`

	// cms
	CmsBase64EncodedRsaPublicKey  string `` /* 1118-byte string literal not displayed */
	CmsBase64EncodedRsaPrivateKey string `` /* 4367-byte string literal not displayed */

	// openapi oauth2 token client
	OpenapiOAuth2TokenClientID     string `env:"OPENAPI_OAUTH2_TOKEN_CLIENT_ID" default:"pipeline"`
	OpenapiOAuth2TokenClientSecret string `env:"OPENAPI_OAUTH2_TOKEN_CLIENT_SECRET" default:"devops/pipeline"`

	// DisablePipelineVolume default is false, means enable context volumes
	DisablePipelineVolume bool `env:"DISABLE_PIPELINE_VOLUME" default:"false"`

	// queue handle loop interval
	QueueLoopHandleIntervalSec uint64 `env:"QUEUE_LOOP_HANDLE_INTERVAL_SEC" default:"10"`

	// API-Test
	APITestNetportalAccessK8sNamespaceBlacklist string `env:"APITEST_NETPORTAL_ACCESS_K8S_NAMESPACE_BLACKLIST" default:"default,kube-system"`

	// initialize send running pipeline interval
	InitializeSendRunningIntervalSec uint64 `env:"INITIALIZE_SEND_RUNNING_INTERVAL_SEC" default:"10"`
	InitializeSendRunningIntervalNum uint64 `env:"INITIALIZE_SEND_RUNNING_INTERVAL_NUM" default:"20"`

	// cron compensate time
	CronCompensateTimeMinute       int64 `env:"CRON_COMPENSATE_TIME_MINUTE" default:"5"`
	CronCompensateConcurrentNumber int64 `env:"CRON_COMPENSATE_CONCURRENT_NUMBER" default:"10"`

	// cron interrupt compensate identification failure time second
	CronFailureCreateIntervalCompensateTimeSecond int64 `env:"CRON_FAILURE_CREATE_INTERVAL_COMPENSATE_TIME_SECOND" default:"300"`

	// database gc
	AnalyzedPipelineDefaultDatabaseGCTTLSec uint64 `env:"ANALYZED_PIPELINE_DEFAULT_DATABASE_GC_TTL_SEC" default:"86400"`   // 60 * 60 * 24 analyzed pipeline db record default retains 1 day
	FinishedPipelineDefaultDatabaseGCTTLSec uint64 `env:"FINISHED_PIPELINE_DEFAULT_DATABASE_GC_TTL_SEC" default:"5184000"` // 60 * 60 * 24 * 30 * 2 finished pipeline db record default retains 2 month
	// resource gc
	SuccessPipelineDefaultResourceGCTTLSec uint64 `env:"SUCCESS_PIPELINE_DEFAULT_RESOURCE_GC_TTL_SEC" default:"1800"` // 60 * 30 success pipeline resources default retains 30 min
	FailedPipelineDefaultResourceGCTTLSec  uint64 `env:"FAILED_PIPELINE_DEFAULT_RESOURCE_GC_TTL_SEC" default:"1800"`  // 60 * 30 failed pipeline resources default retains 30 min

	// scheduler executor refresh interval
	ExecutorRefreshIntervalMinute uint64 `env:"EXECUTOR_REFRESH_INTERVAL_MINUTE" default:"20"`
	SpecifyImagePullPolicy        string `env:"SPECIFY_IMAGE_PULL_POLICY" default:"IfNotPresent"`
}

Conf 定义配置对象.

Jump to

Keyboard shortcuts

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