utils

package
v2.3.0-alpha3+incompat... Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PipelineNamespace              = "cattle-pipeline"
	PipelineNamespaceSuffix        = "-pipeline"
	JenkinsName                    = "jenkins"
	JenkinsAgentContainerName      = "jnlp"
	PipelineName                   = "pipeline"
	PipelineSecretName             = "pipeline-secret"
	PipelineAPIKeySecretName       = "pipeline-api-key"
	PipelineSecretUserKey          = "admin-user"
	PipelineSecretTokenKey         = "admin-token"
	PipelineSecretRegistryTokenKey = "registry-token"
	PipelineSecretAPITokenKey      = "API_TOKEN"
	PipelineSecretDefaultUser      = "admin"
	PipelineSecretDefaultToken     = "admin123"
	GitCaCertVolumeName            = "git-ca-crt"
	GitCaCertPath                  = "/home/jenkins/certs"
	RegistryName                   = "docker-registry"
	RegistryProxyName              = "registry-proxy"
	RegistryCrt                    = "client.cert"
	RegistryKey                    = "client.key"
	RegistryCACrt                  = "ca.crt"
	RegistryCAKey                  = "ca.key"
	RegistryCACrtSecretName        = "registry-ca-crt"
	RegistryCrtSecretName          = "registry-crt"
	RegistryCrtVolumeName          = "crt"
	RegistryAuthVolumeName         = "auth"
	RegistryAuthPath               = "/opt/auth/"
	RegistryCrtPath                = "/opt/crt/"
	RegistryMappingPath            = "/opt/mapping/"
	RegistryPortMappingKey         = "mappings"
	RegistryPortMappingFile        = "mappings.yaml"
	PublishSecretUserKey           = "username"
	PublishSecretPwKey             = "password"
	DockerCredentialName           = "pipeline-docker-registry"
	ProxyConfigMapName             = "proxy-mappings"
	MinioName                      = "minio"
	MinioBucketLocation            = "local"
	MinioLogBucket                 = "pipeline-logs"
	NetWorkPolicyName              = "pipeline-np"
	LabelKeyApp                    = "app"
	LabelKeyJenkins                = "jenkins"
	JenkinsMaster                  = "master"
	LabelKeyExecution              = "execution"
	DefaultRegistry                = "index.docker.io"
	LocalRegistry                  = "docker-registry"
	DefaultTag                     = "latest"
	JenkinsPort                    = 8080
	JenkinsJNLPPort                = 50000
	RegistryPort                   = 443
	MinioPort                      = 9000

	WebhookEventPush        = "push"
	WebhookEventPullRequest = "pull_request"
	WebhookEventTag         = "tag"

	TriggerTypeUser    = "user"
	TriggerTypeWebhook = "webhook"

	StateWaiting  = "Waiting"
	StateBuilding = "Building"
	StateSuccess  = "Success"
	StateFailed   = "Failed"
	StateSkipped  = "Skipped"
	StateAborted  = "Aborted"
	StateQueueing = "Queueing"
	StatePending  = "Pending"
	StateDenied   = "Denied"

	ConditionChanged = "Changed"

	PipelineFinishLabel    = "pipeline.project.cattle.io/finish"
	LocalRegistryPortLabel = "pipeline.project.cattle.io/local-registry-port"
	PipelineNamespaceLabel = "pipeline.project.cattle.io/pipeline-namespace"

	PipelineFileYml  = ".rancher-pipeline.yml"
	PipelineFileYaml = ".rancher-pipeline.yaml"

	EnvGitRepoName       = "CICD_GIT_REPO_NAME"
	EnvGitURL            = "CICD_GIT_URL"
	EnvGitCommit         = "CICD_GIT_COMMIT"
	EnvGitRef            = "CICD_GIT_REF"
	EnvGitBranch         = "CICD_GIT_BRANCH"
	EnvGitTag            = "CICD_GIT_TAG"
	EnvTriggerType       = "CICD_TRIGGER_TYPE"
	EnvEvent             = "CICD_EVENT"
	EnvExecutionID       = "CICD_EXECUTION_ID"
	EnvExecutionSequence = "CICD_EXECUTION_SEQUENCE"
	EnvPipelineID        = "CICD_PIPELINE_ID"
	EnvProjectID         = "CICD_PROJECT_ID"
	EnvClusterID         = "CICD_CLUSTER_ID"
	EnvRegistry          = "CICD_REGISTRY"
	EnvImageRepo         = "CICD_IMAGE_REPO"
	EnvLocalRegistry     = "CICD_LOCAL_REGISTRY"

	SettingExecutorQuota                = "executor-quota"
	SettingExecutorQuotaDefault         = "2"
	SettingSigningDuration              = "registry-signing-duration"
	SettingSigningDurationDefault       = "2160h"
	SettingGitCaCerts                   = "git-cacerts"
	SettingExecutorMemoryRequest        = "executor-memory-request"
	SettingExecutorMemoryRequestDefault = "10Mi"
	SettingExecutorMemoryLimit          = "executor-memory-limit"
	SettingExecutorMemoryLimitDefault   = "1Gi"
	SettingExecutorCPURequest           = "executor-cpu-request"
	SettingExecutorCPURequestDefault    = "10m"
	SettingExecutorCPULimit             = "executor-cpu-limit"
	SettingExecutorCPULimitDefault      = "1"

	PipelineToolsMemoryRequestDefault = "10Mi"
	PipelineToolsMemoryLimitDefault   = "100Mi"
	PipelineToolsCPURequestDefault    = "10m"
	PipelineToolsCPULimitDefault      = "300m"
	StepMemoryRequestDefault          = "10Mi"
	StepMemoryLimitDefault            = "1Gi"
	StepCPURequestDefault             = "10m"
	StepCPULimitDefault               = "1"

	DefaultTimeout = 60
)
View Source
const (
	PipelineByProjectIndex                    = "pipeline.project.cattle.io/pipeline-by-project"
	PipelineExecutionByClusterIndex           = "pipeline.project.cattle.io/execution-by-cluster"
	PipelineExecutionByProjectIndex           = "pipeline.project.cattle.io/execution-by-project"
	SourceCodeCredentialByProjectAndTypeIndex = "pipeline.project.cattle.io/credential-by-project-and-type"
	SourceCodeRepositoryByCredentialIndex     = "pipeline.project.cattle.io/repository-by-credential"
	SourceCodeRepositoryByProjectAndTypeIndex = "pipeline.project.cattle.io/repository-by-project-and-type"
)

Variables

This section is empty.

Functions

func BCryptHash

func BCryptHash(password string) (string, error)

func EnsureAccessToken

func EnsureAccessToken(credentialInterface v3.SourceCodeCredentialInterface, remote model.Remote, credential *v3.SourceCodeCredential) (string, error)

EnsureAccessToken Checks expiry and do token refresh when needed

func Excludes

func Excludes(c *v3.Constraint, v string) bool

Excludes returns true if the string matches the exclude patterns.

func GenerateExecution

func GenerateExecution(executions v3.PipelineExecutionInterface, pipeline *v3.Pipeline, pipelineConfig *v3.PipelineConfig, info *model.BuildInfo) (*v3.PipelineExecution, error)

func GetEnvVarMap

func GetEnvVarMap(execution *v3.PipelineExecution) map[string]string

func GetNextExecutionName

func GetNextExecutionName(p *v3.Pipeline) string

func GetPipelineCommonName

func GetPipelineCommonName(projectName string) string

func GetRegistryPortMapping

func GetRegistryPortMapping(cm *corev1.ConfigMap) (map[string]string, error)

func Includes

func Includes(c *v3.Constraint, v string) bool

Includes returns true if the string matches the include patterns.

func IsFinishState

func IsFinishState(state string) bool

func IsStageSuccess

func IsStageSuccess(stage v3.StageStatus) bool

func Match

func Match(c *v3.Constraint, v string) bool

func MatchAll

func MatchAll(cs *v3.Constraints, execution *v3.PipelineExecution) bool

func PipelineByProjectName

func PipelineByProjectName(obj interface{}) ([]string, error)

func PipelineConfigFromYaml

func PipelineConfigFromYaml(content []byte) (*v3.PipelineConfig, error)

func PipelineConfigToYaml

func PipelineConfigToYaml(pipelineConfig *v3.PipelineConfig) ([]byte, error)

func PipelineExecutionByClusterName

func PipelineExecutionByClusterName(obj interface{}) ([]string, error)

func PipelineExecutionByProjectName

func PipelineExecutionByProjectName(obj interface{}) ([]string, error)

func ProjectNameAndSourceCodeTypeKey

func ProjectNameAndSourceCodeTypeKey(projectName, souceCodeType string) string

func SetRegistryPortMapping

func SetRegistryPortMapping(configmap *corev1.ConfigMap, portMap map[string]string) error

func SourceCodeCredentialByProjectNameAndType

func SourceCodeCredentialByProjectNameAndType(obj interface{}) ([]string, error)

func SourceCodeRepositoryByCredentialName

func SourceCodeRepositoryByCredentialName(obj interface{}) ([]string, error)

func SourceCodeRepositoryByProjectNameAndType

func SourceCodeRepositoryByProjectNameAndType(obj interface{}) ([]string, error)

func SplitImageTag

func SplitImageTag(image string) (string, string, string)

func ValidPipelineConfig

func ValidPipelineConfig(config v3.PipelineConfig) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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