helper

package
v0.0.0-...-f5614d7 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEVTRON_ENV_VAR_PREFIX = "$devtron_env_"
	BUILD_ARG_FLAG         = "--build-arg"
	ROOT_PATH              = "."
	BUILDX_K8S_DRIVER_NAME = "devtron-buildx-builder"
	BUILDX_NODE_NAME       = "devtron-buildx-node-"
)
View Source
const (
	WEBHOOK_SELECTOR_TARGET_CHECKOUT_NAME        string = "target checkout"
	WEBHOOK_SELECTOR_SOURCE_CHECKOUT_NAME        string = "source checkout"
	WEBHOOK_SELECTOR_TARGET_CHECKOUT_BRANCH_NAME string = "target branch name"

	WEBHOOK_EVENT_MERGED_ACTION_TYPE     string = "merged"
	WEBHOOK_EVENT_NON_MERGED_ACTION_TYPE string = "non-merged"
)
View Source
const (
	TRIGGER = iota
	SKIP
	PASS
	FAIL
)
View Source
const BRANCH_FIXED = "BRANCH_FIXED"
View Source
const CI_JOB string = "CI_JOB"
View Source
const DOCKER_REGISTRY_TYPE_DOCKERHUB = "docker-hub"
View Source
const DOCKER_REGISTRY_TYPE_ECR = "ecr"
View Source
const DOCKER_REGISTRY_TYPE_OTHER = "other"
View Source
const DefaultRemoteName = "origin"
View Source
const GIT_AKS_PASS = "/git-ask-pass.sh"
View Source
const JSON_KEY_USERNAME = "_json_key"
View Source
const REGISTRY_TYPE_ARTIFACT_REGISTRY = "artifact-registry"
View Source
const REGISTRY_TYPE_GCR = "gcr"
View Source
const STEP_TYPE_INLINE = "INLINE"

Variables

This section is empty.

Functions

func BuildArtifact

func BuildArtifact(ciRequest *CommonWorkflowRequest) (string, error)

func BuildDockerImagePath

func BuildDockerImagePath(ciRequest *CommonWorkflowRequest) (string, error)

func CleanBuildxK8sDriver

func CleanBuildxK8sDriver(nodes []map[string]string) error

func DockerLogin

func DockerLogin(dockerCredentials *DockerCredentials) error

func DockerdUpCheck

func DockerdUpCheck() error

func ExtractDigestForBuildx

func ExtractDigestForBuildx(dest string) (string, error)

func ExtractDigestUsingPull

func ExtractDigestUsingPull(dest string) (string, error)

func GetCache

func GetCache(ciRequest *CommonWorkflowRequest) error

func GetSelfManagedDockerfilePath

func GetSelfManagedDockerfilePath(checkoutPath string) string

func IsCIOrJobTypeEvent

func IsCIOrJobTypeEvent(eventType string) bool

func IsDirEmpty

func IsDirEmpty(name string) (bool, error)

func IsEventTypeEligibleToScanImage

func IsEventTypeEligibleToScanImage(eventType string) bool

func IsEventTypeEligibleToUploadLogs

func IsEventTypeEligibleToUploadLogs(eventType string) bool

func PublishCDEvent

func PublishCDEvent(jsonBody []byte, topic string, cdRequest *ExtEnvRequest) error

func PublishEvent

func PublishEvent(jsonBody []byte, topic string, ciRequest *ExtEnvRequest) error

func PublishEventsOnRest

func PublishEventsOnRest(jsonBody []byte, topic string, cdRequest *ExtEnvRequest) error

func PushArtifact

func PushArtifact(dest string) error

func SendCDEvent

func SendCDEvent(cdRequest *CommonWorkflowRequest) error

func SendCdCompleteEvent

func SendCdCompleteEvent(cdRequest *CommonWorkflowRequest, event CdStageCompleteEvent) error

func SendCiCompleteEvent

func SendCiCompleteEvent(ciRequest *CommonWorkflowRequest, event CiCompleteEvent) error

func SendEventToClairUtility

func SendEventToClairUtility(event *ScanEvent) error

func SendEvents

func SendEvents(ciRequest *CommonWorkflowRequest, digest string, image string, metrics CIMetrics, artifactUploaded bool, failureReason string, imageDetailsFromCR *ImageDetailsFromCR) error

func ShouldTriggerStage

func ShouldTriggerStage(conditions []*ConditionObject, variables []*VariableObject) (bool, error)

func StageIsSuccess

func StageIsSuccess(conditions []*ConditionObject, variables []*VariableObject) (bool, error)

func StartDockerDaemon

func StartDockerDaemon(dockerConnection, dockerRegistryUrl, dockerCert, defaultAddressPoolBaseCidr string, defaultAddressPoolSize int, ciRunnerDockerMtuValue int)

func StopDocker

func StopDocker() error

func SyncCache

func SyncCache(ciRequest *CommonWorkflowRequest) error

func TypeConverter

func TypeConverter(value string, format Format) (interface{}, error)

func UpdateCloudHelperBaseConfigFromEnv

func UpdateCloudHelperBaseConfigFromEnv(cloudHelperBaseConfig *util.CloudHelperBaseConfig)

func UploadArtifact

func UploadArtifact(cloudHelperBaseConfig *util.CloudHelperBaseConfig, artifactFiles map[string]string, artifactFileLocation string) error

func UploadFileToCloud

func UploadFileToCloud(cloudHelperBaseConfig *util.CloudHelperBaseConfig, sourceFilePath string, destinationKey string) error

UploadFileToCloud Uploads the source file to the destination key of configured blob storage /**

func UploadLogs

func UploadLogs(cloudHelperBaseConfig *util.CloudHelperBaseConfig)

UploadLogs Checks of blob storage is configured, if yes, uploads the locally created log file to configured storage

func ValidBuildxK8sDriverOptions

func ValidBuildxK8sDriverOptions(ciRequest *CommonWorkflowRequest) (bool, []map[string]string)

func ZipAndUpload

func ZipAndUpload(cloudHelperBaseConfig *util.CloudHelperBaseConfig, artifactFileName string) (bool, error)

Types

type AppliesTo

type AppliesTo struct {
	Type  string   `yaml:"type"`
	Value []string `yaml:"value"`
}

type AuthMode

type AuthMode string
const (
	AUTH_MODE_USERNAME_PASSWORD AuthMode = "USERNAME_PASSWORD"
	AUTH_MODE_SSH               AuthMode = "SSH"
	AUTH_MODE_ACCESS_TOKEN      AuthMode = "ACCESS_TOKEN"
	AUTH_MODE_ANONYMOUS         AuthMode = "ANONYMOUS"
)

type BasicAuth

type BasicAuth struct {
	Username, Password string
}

type BuildPackConfig

type BuildPackConfig struct {
	BuilderId       string            `json:"builderId"`
	Language        string            `json:"language"`
	LanguageVersion string            `json:"languageVersion"`
	BuildPacks      []string          `json:"buildPacks"`
	Args            map[string]string `json:"args"`
	ProjectPath     string            `json:"projectPath"`
}

type BuildpackVersionConfig

type BuildpackVersionConfig struct {
	BuilderPrefix string `json:"builderPrefix"`
	Language      string `json:"language"`
	FileName      string `json:"fileName"`
	FileOverride  bool   `json:"fileOverride"`
	EntryRegex    string `json:"entryRegex"`
}

type CIMetrics

type CIMetrics struct {
	CacheDownDuration  float64   `json:"cacheDownDuration"`
	PreCiDuration      float64   `json:"preCiDuration"`
	BuildDuration      float64   `json:"buildDuration"`
	PostCiDuration     float64   `json:"postCiDuration"`
	CacheUpDuration    float64   `json:"cacheUpDuration"`
	TotalDuration      float64   `json:"totalDuration"`
	CacheDownStartTime time.Time `json:"cacheDownStartTime"`
	PreCiStartTime     time.Time `json:"preCiStart"`
	BuildStartTime     time.Time `json:"buildStartTime"`
	PostCiStartTime    time.Time `json:"postCiStartTime"`
	CacheUpStartTime   time.Time `json:"cacheUpStartTime"`
	TotalStartTime     time.Time `json:"totalStartTime"`
}

type CdPipelineConfig

type CdPipelineConfig struct {
	BeforeTasks []*Task `yaml:"beforeStages"`
	AfterTasks  []*Task `yaml:"afterStages"`
}

type CdRequest

type CdRequest struct {
	WorkflowId                 int                               `json:"workflowId"`
	WorkflowRunnerId           int                               `json:"workflowRunnerId"`
	CdPipelineId               int                               `json:"cdPipelineId"`
	TriggeredBy                int32                             `json:"triggeredBy"`
	StageYaml                  string                            `json:"stageYaml"`
	ArtifactLocation           string                            `json:"artifactLocation"`
	ArtifactBucket             string                            `json:"ciArtifactBucket"`
	ArtifactFileName           string                            `json:"ciArtifactFileName"`
	ArtifactRegion             string                            `json:"ciArtifactRegion"`
	BlobStorageS3Config        *blob_storage.BlobStorageS3Config `json:"blobStorageS3Config"`
	TaskYaml                   *TaskYaml                         `json:"-"`
	CiProjectDetails           []CiProjectDetails                `json:"ciProjectDetails"`
	CiArtifactDTO              CiArtifactDTO                     `json:"ciArtifactDTO"`
	DockerUsername             string                            `json:"dockerUsername"`
	DockerPassword             string                            `json:"dockerPassword"`
	AwsRegion                  string                            `json:"awsRegion"`
	AccessKey                  string                            `json:"accessKey"`
	SecretKey                  string                            `json:"secretKey"`
	DockerRegistryURL          string                            `json:"dockerRegistryUrl"`
	DockerRegistryType         string                            `json:"dockerRegistryType"`
	DockerConnection           string                            `json:"dockerConnection"`
	DockerCert                 string                            `json:"dockerCert"`
	OrchestratorHost           string                            `json:"orchestratorHost"`
	OrchestratorToken          string                            `json:"orchestratorToken"`
	IsExtRun                   bool                              `json:"isExtRun"`
	ExtraEnvironmentVariables  map[string]string                 `json:"extraEnvironmentVariables"`
	CloudProvider              blob_storage.BlobStorageType      `json:"cloudProvider"`
	BlobStorageConfigured      bool                              `json:"blobStorageConfigured"`
	AzureBlobConfig            *blob_storage.AzureBlobConfig     `json:"azureBlobConfig"`
	GcpBlobConfig              *blob_storage.GcpBlobConfig       `json:"gcpBlobConfig"`
	BlobStorageLogsKey         string                            `json:"blobStorageLogsKey"`
	InAppLoggingEnabled        bool                              `json:"inAppLoggingEnabled"`
	MinioEndpoint              string                            `json:"minioEndpoint"`
	DefaultAddressPoolBaseCidr string                            `json:"defaultAddressPoolBaseCidr"`
	DefaultAddressPoolSize     int                               `json:"defaultAddressPoolSize"`
	DeploymentTriggeredBy      string                            `json:"deploymentTriggeredBy"`
	DeploymentTriggerTime      time.Time                         `json:"deploymentTriggerTime"`
	CiRunnerDockerMtuValue     int                               `json:"ciRunnerDockerMtuValue"`
	DeploymentReleaseCounter   int                               `json:"deploymentReleaseCounter,omitempty"`
	IsDryRun                   bool                              `json:"isDryRun"`
	PrePostDeploySteps         []*StepObject                     `json:"prePostDeploySteps"`
	RefPlugins                 []*RefPluginObject                `json:"refPlugins"`
	StageType                  string                            `json:"stageType"`
}

type CdStageCompleteEvent

type CdStageCompleteEvent struct {
	CiProjectDetails              []CiProjectDetails  `json:"ciProjectDetails"`
	WorkflowId                    int                 `json:"workflowId"`
	WorkflowRunnerId              int                 `json:"workflowRunnerId"`
	CdPipelineId                  int                 `json:"cdPipelineId"`
	TriggeredBy                   int                 `json:"triggeredBy"`
	StageYaml                     string              `json:"stageYaml"`
	ArtifactLocation              string              `json:"artifactLocation"`
	TaskYaml                      *TaskYaml           `json:"-"`
	PipelineName                  string              `json:"pipelineName"`
	CiArtifactDTO                 CiArtifactDTO       `json:"ciArtifactDTO"`
	PluginRegistryArtifactDetails map[string][]string `json:"PluginRegistryArtifactDetails"`
	PluginArtifactStage           string              `json:"pluginArtifactStage"`
}

type CiArtifactDTO

type CiArtifactDTO struct {
	Id           int    `json:"id"`
	PipelineId   int    `json:"pipelineId"` //id of the ci pipeline from which this webhook was triggered
	Image        string `json:"image"`
	ImageDigest  string `json:"imageDigest"`
	MaterialInfo string `json:"materialInfo"` //git material metadata json array string
	DataSource   string `json:"dataSource"`
	WorkflowId   *int   `json:"workflowId"`
}

type CiBuildConfigBean

type CiBuildConfigBean struct {
	CiBuildType       CiBuildType        `json:"ciBuildType"`
	DockerBuildConfig *DockerBuildConfig `json:"dockerBuildConfig,omitempty"`
	BuildPackConfig   *BuildPackConfig   `json:"buildPackConfig"`
	PipelineType      string             `json:"pipelineType"`
}

type CiBuildType

type CiBuildType string
const (
	SELF_DOCKERFILE_BUILD_TYPE    CiBuildType = "self-dockerfile-build"
	MANAGED_DOCKERFILE_BUILD_TYPE CiBuildType = "managed-dockerfile-build"
	BUILD_SKIP_BUILD_TYPE         CiBuildType = "skip-build"
	BUILDPACK_BUILD_TYPE          CiBuildType = "buildpack-build"
)

type CiCdTriggerEvent

type CiCdTriggerEvent struct {
	Type                  string                 `json:"type"`
	CommonWorkflowRequest *CommonWorkflowRequest `json:"commonWorkflowRequest"`
}

type CiCompleteEvent

type CiCompleteEvent struct {
	CiProjectDetails              []CiProjectDetails  `json:"ciProjectDetails"`
	DockerImage                   string              `json:"dockerImage"`
	Digest                        string              `json:"digest"`
	PipelineId                    int                 `json:"pipelineId"`
	DataSource                    string              `json:"dataSource"`
	PipelineName                  string              `json:"pipelineName"`
	WorkflowId                    int                 `json:"workflowId"`
	TriggeredBy                   int                 `json:"triggeredBy"`
	MaterialType                  string              `json:"materialType"`
	Metrics                       CIMetrics           `json:"metrics"`
	AppName                       string              `json:"appName"`
	IsArtifactUploaded            bool                `json:"isArtifactUploaded"`
	FailureReason                 string              `json:"failureReason"`
	ImageDetailsFromCR            *ImageDetailsFromCR `json:"imageDetailsFromCR"`
	PluginRegistryArtifactDetails map[string][]string `json:"PluginRegistryArtifactDetails"`
	PluginArtifactStage           string              `json:"pluginArtifactStage"`
	IsScanEnabled                 bool                `json:"isScanEnabled"`
}

type CiProjectDetails

type CiProjectDetails struct {
	GitRepository   string      `json:"gitRepository"`
	FetchSubmodules bool        `json:"fetchSubmodules"`
	MaterialName    string      `json:"materialName"`
	CheckoutPath    string      `json:"checkoutPath"`
	CommitHash      string      `json:"commitHash"`
	GitTag          string      `json:"gitTag"`
	CommitTime      time.Time   `json:"commitTime"`
	SourceType      SourceType  `json:"sourceType"`
	SourceValue     string      `json:"sourceValue"`
	Type            string      `json:"type"`
	Message         string      `json:"message"`
	Author          string      `json:"author"`
	GitOptions      GitOptions  `json:"gitOptions"`
	WebhookData     WebhookData `json:"webhookData"`
	CloningMode     string      `json:"cloningMode"`
}

func (*CiProjectDetails) GetCheckoutBranchName

func (prj *CiProjectDetails) GetCheckoutBranchName() string

type CiRequest

type CiRequest struct {
	CiProjectDetails            []CiProjectDetails                `json:"ciProjectDetails"`
	DockerImageTag              string                            `json:"dockerImageTag"`
	DockerRegistryId            string                            `json:"dockerRegistryId"`
	DockerRegistryType          string                            `json:"dockerRegistryType"`
	DockerRegistryURL           string                            `json:"dockerRegistryURL"`
	DockerConnection            string                            `json:"dockerConnection"`
	DockerCert                  string                            `json:"dockerCert"`
	DockerRepository            string                            `json:"dockerRepository"`
	CheckoutPath                string                            `json:"checkoutPath"`
	DockerUsername              string                            `json:"dockerUsername"`
	DockerPassword              string                            `json:"dockerPassword"`
	AwsRegion                   string                            `json:"awsRegion"`
	AccessKey                   string                            `json:"accessKey"`
	SecretKey                   string                            `json:"secretKey"`
	CiCacheLocation             string                            `json:"ciCacheLocation"`
	CiArtifactLocation          string                            `json:"ciArtifactLocation"` // s3 bucket+ path
	CiArtifactBucket            string                            `json:"ciArtifactBucket"`
	CiArtifactFileName          string                            `json:"ciArtifactFileName"`
	CiArtifactRegion            string                            `json:"ciArtifactRegion"`
	BlobStorageS3Config         *blob_storage.BlobStorageS3Config `json:"blobStorageS3Config"`
	CiCacheRegion               string                            `json:"ciCacheRegion"`
	CiCacheFileName             string                            `json:"ciCacheFileName"`
	PipelineId                  int                               `json:"pipelineId"`
	PipelineName                string                            `json:"pipelineName"`
	WorkflowId                  int                               `json:"workflowId"`
	TriggeredBy                 int                               `json:"triggeredBy"`
	CacheLimit                  int64                             `json:"cacheLimit"`
	BeforeDockerBuild           []*Task                           `json:"beforeDockerBuildScripts"`
	AfterDockerBuild            []*Task                           `json:"afterDockerBuildScripts"`
	CiYamlLocation              string                            `json:"CiYamlLocations"`
	TaskYaml                    *TaskYaml                         `json:"-"`
	TestExecutorImageProperties *TestExecutorImageProperties      `json:"testExecutorImageProperties"`
	BlobStorageConfigured       bool                              `json:"blobStorageConfigured"`
	IgnoreDockerCachePull       bool                              `json:"ignoreDockerCachePull"`
	IgnoreDockerCachePush       bool                              `json:"ignoreDockerCachePush"`
	ScanEnabled                 bool                              `json:"scanEnabled"`
	CloudProvider               blob_storage.BlobStorageType      `json:"cloudProvider"`
	AzureBlobConfig             *blob_storage.AzureBlobConfig     `json:"azureBlobConfig"`
	GcpBlobConfig               *blob_storage.GcpBlobConfig       `json:"gcpBlobConfig"`
	BlobStorageLogsKey          string                            `json:"blobStorageLogsKey"`
	InAppLoggingEnabled         bool                              `json:"inAppLoggingEnabled"`
	MinioEndpoint               string                            `json:"minioEndpoint"`
	DefaultAddressPoolBaseCidr  string                            `json:"defaultAddressPoolBaseCidr"`
	DefaultAddressPoolSize      int                               `json:"defaultAddressPoolSize"`
	PreCiSteps                  []*StepObject                     `json:"preCiSteps"`
	PostCiSteps                 []*StepObject                     `json:"postCiSteps"`
	RefPlugins                  []*RefPluginObject                `json:"refPlugins"`
	AppName                     string                            `json:"appName"`
	TriggerByAuthor             string                            `json:"triggerByAuthor"`
	CiBuildConfig               *CiBuildConfigBean                `json:"ciBuildConfig"`
	CiBuildDockerMtuValue       int                               `json:"ciBuildDockerMtuValue"`
	CacheInvalidate             bool                              `json:"cacheInvalidate"`
	IsPvcMounted                bool                              `json:"IsPvcMounted"`
	ExtraEnvironmentVariables   map[string]string                 `json:"extraEnvironmentVariables"`
	EnableBuildContext          bool                              `json:"enableBuildContext"`
	IsExtRun                    bool                              `json:"isExtRun"`
	OrchestratorHost            string                            `json:"orchestratorHost"`
	OrchestratorToken           string                            `json:"orchestratorToken"`
	ImageRetryCount             int                               `json:"imageRetryCount"`
	ImageRetryInterval          int                               `json:"imageRetryInterval"`
}

type CiStageError

type CiStageError struct {
	Err error
}

func (CiStageError) Error

func (err CiStageError) Error() string

func (*CiStageError) Unwrap

func (err *CiStageError) Unwrap() error

type CommonWorkflowRequest

type CommonWorkflowRequest struct {
	WorkflowNamePrefix         string                            `json:"workflowNamePrefix"`
	PipelineName               string                            `json:"pipelineName"`
	PipelineId                 int                               `json:"pipelineId"`
	DockerImageTag             string                            `json:"dockerImageTag"`
	DockerRegistryId           string                            `json:"dockerRegistryId"`
	DockerRegistryType         string                            `json:"dockerRegistryType"`
	DockerRegistryURL          string                            `json:"dockerRegistryURL"`
	DockerConnection           string                            `json:"dockerConnection"`
	DockerCert                 string                            `json:"dockerCert"`
	DockerRepository           string                            `json:"dockerRepository"`
	CheckoutPath               string                            `json:"checkoutPath"`
	DockerUsername             string                            `json:"dockerUsername"`
	DockerPassword             string                            `json:"dockerPassword"`
	AwsRegion                  string                            `json:"awsRegion"`
	AccessKey                  string                            `json:"accessKey"`
	SecretKey                  string                            `json:"secretKey"`
	CiCacheLocation            string                            `json:"ciCacheLocation"`
	CiCacheRegion              string                            `json:"ciCacheRegion"`
	CiCacheFileName            string                            `json:"ciCacheFileName"`
	CiProjectDetails           []CiProjectDetails                `json:"ciProjectDetails"`
	ActiveDeadlineSeconds      int64                             `json:"activeDeadlineSeconds"`
	CiImage                    string                            `json:"ciImage"`
	Namespace                  string                            `json:"namespace"`
	WorkflowId                 int                               `json:"workflowId"`
	TriggeredBy                int                               `json:"triggeredBy"`
	CacheLimit                 int64                             `json:"cacheLimit"`
	BeforeDockerBuildScripts   []*Task                           `json:"beforeDockerBuildScripts"`
	AfterDockerBuildScripts    []*Task                           `json:"afterDockerBuildScripts"`
	CiArtifactLocation         string                            `json:"ciArtifactLocation"`
	CiArtifactBucket           string                            `json:"ciArtifactBucket"`
	CiArtifactFileName         string                            `json:"ciArtifactFileName"`
	CiArtifactRegion           string                            `json:"ciArtifactRegion"`
	ScanEnabled                bool                              `json:"scanEnabled"`
	CloudProvider              blob_storage.BlobStorageType      `json:"cloudProvider"`
	BlobStorageConfigured      bool                              `json:"blobStorageConfigured"`
	BlobStorageS3Config        *blob_storage.BlobStorageS3Config `json:"blobStorageS3Config"`
	AzureBlobConfig            *blob_storage.AzureBlobConfig     `json:"azureBlobConfig"`
	GcpBlobConfig              *blob_storage.GcpBlobConfig       `json:"gcpBlobConfig"`
	BlobStorageLogsKey         string                            `json:"blobStorageLogsKey"`
	InAppLoggingEnabled        bool                              `json:"inAppLoggingEnabled"`
	DefaultAddressPoolBaseCidr string                            `json:"defaultAddressPoolBaseCidr"`
	DefaultAddressPoolSize     int                               `json:"defaultAddressPoolSize"`
	PreCiSteps                 []*StepObject                     `json:"preCiSteps"`
	PostCiSteps                []*StepObject                     `json:"postCiSteps"`
	RefPlugins                 []*RefPluginObject                `json:"refPlugins"`
	AppName                    string                            `json:"appName"`
	TriggerByAuthor            string                            `json:"triggerByAuthor"`
	CiBuildConfig              *CiBuildConfigBean                `json:"ciBuildConfig"`
	CiBuildDockerMtuValue      int                               `json:"ciBuildDockerMtuValue"`
	IgnoreDockerCachePush      bool                              `json:"ignoreDockerCachePush"`
	IgnoreDockerCachePull      bool                              `json:"ignoreDockerCachePull"`
	CacheInvalidate            bool                              `json:"cacheInvalidate"`
	IsPvcMounted               bool                              `json:"IsPvcMounted"`
	ExtraEnvironmentVariables  map[string]string                 `json:"extraEnvironmentVariables"`
	EnableBuildContext         bool                              `json:"enableBuildContext"`
	AppId                      int                               `json:"appId"`
	EnvironmentId              int                               `json:"environmentId"`
	OrchestratorHost           string                            `json:"orchestratorHost"`
	OrchestratorToken          string                            `json:"orchestratorToken"`
	IsExtRun                   bool                              `json:"isExtRun"`
	ImageRetryCount            int                               `json:"imageRetryCount"`
	ImageRetryInterval         int                               `json:"imageRetryInterval"`
	ExtBlobStorageCmName       string                            `json:"extBlobStorageCmName"`
	ExtBlobStorageSecretName   string                            `json:"extBlobStorageSecretName"`
	UseExternalClusterBlob     bool                              `json:"useExternalClusterBlob"`
	ImageScanMaxRetries        int                               `json:"imageScanMaxRetries,omitempty"`
	ImageScanRetryDelay        int                               `json:"imageScanRetryDelay,omitempty"`
	// Data from CD Workflow service
	WorkflowRunnerId            int                            `json:"workflowRunnerId"`
	CdPipelineId                int                            `json:"cdPipelineId"`
	StageYaml                   string                         `json:"stageYaml"`
	ArtifactLocation            string                         `json:"artifactLocation"`
	CiArtifactDTO               CiArtifactDTO                  `json:"ciArtifactDTO"`
	CdImage                     string                         `json:"cdImage"`
	StageType                   string                         `json:"stageType"`
	CdCacheLocation             string                         `json:"cdCacheLocation"`
	CdCacheRegion               string                         `json:"cdCacheRegion"`
	WorkflowPrefixForLog        string                         `json:"workflowPrefixForLog"`
	DeploymentTriggeredBy       string                         `json:"deploymentTriggeredBy,omitempty"`
	DeploymentTriggerTime       time.Time                      `json:"deploymentTriggerTime,omitempty"`
	DeploymentReleaseCounter    int                            `json:"deploymentReleaseCounter,omitempty"`
	PrePostDeploySteps          []*StepObject                  `json:"prePostDeploySteps"`
	TaskYaml                    *TaskYaml                      `json:"-"`
	IsDryRun                    bool                           `json:"isDryRun"`
	CiArtifactLastFetch         time.Time                      `json:"ciArtifactLastFetch"`
	CiPipelineType              string                         `json:"CiPipelineType"`
	RegistryDestinationImageMap map[string][]string            `json:"registryDestinationImageMap"`
	RegistryCredentialMap       map[string]RegistryCredentials `json:"registryCredentialMap"`
	PluginArtifactStage         string                         `json:"pluginArtifactStage"`
	PushImageBeforePostCI       bool                           `json:"pushImageBeforePostCI"`
}

func (*CommonWorkflowRequest) GetCloudHelperBaseConfig

func (c *CommonWorkflowRequest) GetCloudHelperBaseConfig(blobStorageObjectType string) *util.CloudHelperBaseConfig

type ConditionObject

type ConditionObject struct {
	ConditionType       ConditionType `json:"conditionType"`       //TRIGGER, SKIP, PASS, FAIL
	ConditionOnVariable string        `json:"conditionOnVariable"` //name of variable
	ConditionalOperator string        `json:"conditionalOperator"`
	ConditionalValue    string        `json:"conditionalValue"`
	// contains filtered or unexported fields
}

type ConditionType

type ConditionType int

----------

func (ConditionType) MarshalJSON

func (t ConditionType) MarshalJSON() ([]byte, error)

func (ConditionType) String

func (d ConditionType) String() string

func (*ConditionType) UnmarshalJSON

func (t *ConditionType) UnmarshalJSON(b []byte) error

func (ConditionType) ValueOf

func (d ConditionType) ValueOf(conditionType string) (ConditionType, error)

type DockerBuildConfig

type DockerBuildConfig struct {
	DockerfilePath         string              `json:"dockerfileRelativePath,omitempty" validate:"required"`
	DockerfileContent      string              `json:"DockerfileContent"`
	Args                   map[string]string   `json:"args,omitempty"`
	DockerBuildOptions     map[string]string   `json:"dockerBuildOptions"`
	TargetPlatform         string              `json:"targetPlatform,omitempty"`
	BuildContext           string              `json:"buildContext,omitempty"`
	UseBuildx              bool                `json:"useBuildx"`
	BuildxProvenanceMode   string              `json:"buildxProvenanceMode"`
	BuildxK8sDriverOptions []map[string]string `json:"buildxK8SDriverOptions"`
}

func (*DockerBuildConfig) CheckForBuildX

func (dockerBuildConfig *DockerBuildConfig) CheckForBuildX() bool

func (*DockerBuildConfig) CheckForBuildXK8sDriver

func (dockerBuildConfig *DockerBuildConfig) CheckForBuildXK8sDriver() (bool, []map[string]string)

func (*DockerBuildConfig) GetEligibleK8sDriverNodes

func (dockerBuildConfig *DockerBuildConfig) GetEligibleK8sDriverNodes() []map[string]string

func (*DockerBuildConfig) GetProvenanceFlag

func (dockerBuildConfig *DockerBuildConfig) GetProvenanceFlag() string

type DockerCredentials

type DockerCredentials struct {
	DockerUsername, DockerPassword, AwsRegion, AccessKey, SecretKey, DockerRegistryURL, DockerRegistryType string
}

type EnvironmentVariables

type EnvironmentVariables struct {
	ShowDockerBuildCmdInLogs bool `env:"SHOW_DOCKER_BUILD_ARGS" envDefault:"true"`
}

type ExecutorType

type ExecutorType int

---------------

const (
	CONTAINER_IMAGE ExecutorType = iota
	SHELL
	PLUGIN // Added to avoid un-marshaling error in REF_PLUGIN type steps, otherwise this value won't be used
)

func (ExecutorType) MarshalJSON

func (t ExecutorType) MarshalJSON() ([]byte, error)

func (ExecutorType) String

func (d ExecutorType) String() string

func (*ExecutorType) UnmarshalJSON

func (t *ExecutorType) UnmarshalJSON(b []byte) error

func (ExecutorType) ValueOf

func (d ExecutorType) ValueOf(executorType string) (ExecutorType, error)

type ExtEnvRequest

type ExtEnvRequest struct {
	OrchestratorHost  string `json:"orchestratorHost"`
	OrchestratorToken string `json:"orchestratorToken"`
	IsExtRun          bool   `json:"isExtRun"`
}

func GetExternalEnvRequest

func GetExternalEnvRequest(ciCdRequest CommonWorkflowRequest) ExtEnvRequest

type Format

type Format int

------------

const (
	STRING Format = iota
	NUMBER
	BOOL
	DATE
)

func (Format) MarshalJSON

func (t Format) MarshalJSON() ([]byte, error)

func (Format) String

func (d Format) String() string

func (*Format) UnmarshalJSON

func (t *Format) UnmarshalJSON(b []byte) error

func (Format) ValuesOf

func (d Format) ValuesOf(format string) (Format, error)

type GitCliManager

type GitCliManager interface {
	Fetch(gitContext GitContext, rootDir string) (response, errMsg string, err error)
	Checkout(gitContext GitContext, rootDir string, checkout string) (response, errMsg string, err error)
	RunCommandWithCred(cmd *exec.Cmd, userName, password string) (response, errMsg string, err error)
	RunCommand(cmd *exec.Cmd) (response, errMsg string, err error)

	Init(rootDir string, remoteUrl string, isBare bool) error
	Clone(gitContext GitContext, prj CiProjectDetails) (response, errMsg string, err error)
	Merge(rootDir string, commit string) (response, errMsg string, err error)
	RecursiveFetchSubmodules(rootDir string) (response, errMsg string, error error)
	UpdateCredentialHelper(rootDir string) (response, errMsg string, error error)
	UnsetCredentialHelper(rootDir string) (response, errMsg string, error error)
	GitCheckout(gitContext GitContext, checkoutPath string, targetCheckout string, authMode AuthMode, fetchSubmodules bool, gitRepository string) (errMsg string, error error)
	// contains filtered or unexported methods
}

type GitCliManagerImpl

type GitCliManagerImpl struct {
}

func NewGitCliManager

func NewGitCliManager() *GitCliManagerImpl

func (*GitCliManagerImpl) AddRepo

func (impl *GitCliManagerImpl) AddRepo(rootDir string, remoteUrl string) error

func (*GitCliManagerImpl) Checkout

func (impl *GitCliManagerImpl) Checkout(gitContext GitContext, rootDir string, checkout string) (response, errMsg string, err error)

func (*GitCliManagerImpl) Clone

func (impl *GitCliManagerImpl) Clone(gitContext GitContext, prj CiProjectDetails) (response, errMsg string, err error)

func (*GitCliManagerImpl) Fetch

func (impl *GitCliManagerImpl) Fetch(gitContext GitContext, rootDir string) (response, errMsg string, err error)

func (*GitCliManagerImpl) GitCheckout

func (impl *GitCliManagerImpl) GitCheckout(gitContext GitContext, checkoutPath string, targetCheckout string, authMode AuthMode, fetchSubmodules bool, gitRepository string) (errMsg string, error error)

func (*GitCliManagerImpl) Init

func (impl *GitCliManagerImpl) Init(rootDir string, remoteUrl string, isBare bool) error

func (*GitCliManagerImpl) Merge

func (impl *GitCliManagerImpl) Merge(rootDir string, commit string) (response, errMsg string, err error)

setting user.name and user.email as for non-fast-forward merge, git ask for user.name and email

func (*GitCliManagerImpl) RecursiveFetchSubmodules

func (impl *GitCliManagerImpl) RecursiveFetchSubmodules(rootDir string) (response, errMsg string, error error)

func (*GitCliManagerImpl) RunCommand

func (impl *GitCliManagerImpl) RunCommand(cmd *exec.Cmd) (response, errMsg string, err error)

func (*GitCliManagerImpl) RunCommandWithCred

func (impl *GitCliManagerImpl) RunCommandWithCred(cmd *exec.Cmd, userName, password string) (response, errMsg string, err error)

func (*GitCliManagerImpl) UnsetCredentialHelper

func (impl *GitCliManagerImpl) UnsetCredentialHelper(rootDir string) (response, errMsg string, error error)

func (*GitCliManagerImpl) UpdateCredentialHelper

func (impl *GitCliManagerImpl) UpdateCredentialHelper(rootDir string) (response, errMsg string, error error)

type GitContext

type GitContext struct {
	context.Context // Embedding original Go context
	Auth            *BasicAuth
}

type GitManager

type GitManager struct {
	// contains filtered or unexported fields
}

func NewGitManagerImpl

func NewGitManagerImpl(gitCliManager GitCliManager) *GitManager

func (*GitManager) CloneAndCheckout

func (impl *GitManager) CloneAndCheckout(ciProjectDetails []CiProjectDetails) error

type GitOptions

type GitOptions struct {
	UserName      string   `json:"userName"`
	Password      string   `json:"password"`
	SshPrivateKey string   `json:"sshPrivateKey"`
	AccessToken   string   `json:"accessToken"`
	AuthMode      AuthMode `json:"authMode"`
}

type ImageDetailsFromCR

type ImageDetailsFromCR struct {
	ImageDetails []types.ImageDetail `json:"imageDetails"`
	Region       string              `json:"region"`
}

type ImageScanningEvent

type ImageScanningEvent struct {
	CiPipelineId int                `json:"ciPipelineId"`
	CdPipelineId int                `json:"cdPipelineId"`
	TriggerBy    int                `json:"triggeredBy"`
	Image        string             `json:"image"`
	Digest       string             `json:"digest"`
	PipelineType NotifyPipelineType `json:"PipelineType"`
}

func GetImageScanningEvent

func GetImageScanningEvent(ciCdRequest CommonWorkflowRequest) ImageScanningEvent

type MountPath

type MountPath struct {
	SrcPath string `json:"sourcePath"`
	DstPath string `json:"destinationPath"`
}

type NotifyPipelineType

type NotifyPipelineType string
const (
	PRE_CD  NotifyPipelineType = "PRE-CD"
	POST_CD NotifyPipelineType = "POST-CD"
)

type PipelineConfig

type PipelineConfig struct {
	AppliesTo   []AppliesTo `yaml:"appliesTo"`
	BeforeTasks []*Task     `yaml:"beforeDockerBuildStages"`
	AfterTasks  []*Task     `yaml:"afterDockerBuildStages"`
}

type PublishRequest

type PublishRequest struct {
	Topic   string          `json:"topic"`
	Payload json.RawMessage `json:"payload"`
}

type RefPluginObject

type RefPluginObject struct {
	Id    int           `json:"id"`
	Steps []*StepObject `json:"steps"`
}

type RegistryCredentials

type RegistryCredentials struct {
	RegistryType       string `json:"registryType"`
	RegistryURL        string `json:"registryURL"`
	Username           string `json:"username"`
	Password           string `json:"password"`
	AWSAccessKeyId     string `json:"awsAccessKeyId,omitempty"`
	AWSSecretAccessKey string `json:"awsSecretAccessKey,omitempty"`
	AWSRegion          string `json:"awsRegion,omitempty"`
}

type ScanEvent

type ScanEvent struct {
	Image               string `json:"image"`
	ImageDigest         string `json:"imageDigest"`
	AppId               int    `json:"appId"`
	EnvId               int    `json:"envId"`
	PipelineId          int    `json:"pipelineId"`
	CiArtifactId        int    `json:"ciArtifactId"`
	UserId              int    `json:"userId"`
	AccessKey           string `json:"accessKey"`
	SecretKey           string `json:"secretKey"`
	Token               string `json:"token"`
	AwsRegion           string `json:"awsRegion"`
	DockerRegistryId    string `json:"dockerRegistryId"`
	ImageScanMaxRetries int    `json:"imageScanMaxRetries,omitempty"`
	ImageScanRetryDelay int    `json:"imageScanRetryDelay,omitempty"`
}

type SourceType

type SourceType string
const (
	SOURCE_TYPE_BRANCH_FIXED SourceType = "SOURCE_TYPE_BRANCH_FIXED"
	SOURCE_TYPE_WEBHOOK      SourceType = "WEBHOOK"
)

type StepObject

type StepObject struct {
	Name                     string             `json:"name"`
	Index                    int                `json:"index"`
	StepType                 string             `json:"stepType"`     // REF_PLUGIN or INLINE
	ExecutorType             ExecutorType       `json:"executorType"` //continer_image/ shell
	RefPluginId              int                `json:"refPluginId"`
	Script                   string             `json:"script"`
	InputVars                []*VariableObject  `json:"inputVars"`
	ExposedPorts             map[int]int        `json:"exposedPorts"` //map of host:container
	OutputVars               []*VariableObject  `json:"outputVars"`
	TriggerSkipConditions    []*ConditionObject `json:"triggerSkipConditions"`
	SuccessFailureConditions []*ConditionObject `json:"successFailureConditions"`
	DockerImage              string             `json:"dockerImage"`
	Command                  string             `json:"command"`
	Args                     []string           `json:"args"`
	CustomScriptMount        *MountPath         `json:"customScriptMount"` // destination path - storeScriptAt
	SourceCodeMount          *MountPath         `json:"sourceCodeMount"`   // destination path - mountCodeToContainerPath
	ExtraVolumeMounts        []*MountPath       `json:"extraVolumeMounts"` // filePathMapping
	ArtifactPaths            []string           `json:"artifactPaths"`
	TriggerIfParentStageFail bool               `json:"triggerIfParentStageFail"`
}

type StepType

type StepType string
const (
	STEP_TYPE_PRE        StepType = "PRE"
	STEP_TYPE_POST       StepType = "POST"
	STEP_TYPE_REF_PLUGIN StepType = "REF_PLUGIN"
)

type Task

type Task struct {
	Id             int    `json:"id"`
	Index          int    `json:"index"`
	Name           string `json:"name" yaml:"name"`
	Script         string `json:"script" yaml:"script"`
	OutputLocation string `json:"outputLocation" yaml:"outputLocation"` // file/dir
	RunStatus      bool   `json:"-"`                                    // task run was attempted or not
}

func GetAfterDockerBuildTasks

func GetAfterDockerBuildTasks(ciRequest *CommonWorkflowRequest, taskYaml *TaskYaml) ([]*Task, error)

func GetBeforeDockerBuildTasks

func GetBeforeDockerBuildTasks(ciRequest *CommonWorkflowRequest, taskYaml *TaskYaml) ([]*Task, error)

type TaskYaml

type TaskYaml struct {
	Version          string             `yaml:"version"`
	PipelineConf     []PipelineConfig   `yaml:"pipelineConf"`
	CdPipelineConfig []CdPipelineConfig `yaml:"cdPipelineConf"`
}

func GetTaskYaml

func GetTaskYaml(yamlLocation string) (*TaskYaml, error)

func ToTaskYaml

func ToTaskYaml(yamlFile []byte) (*TaskYaml, error)

type TestExecutorImageProperties

type TestExecutorImageProperties struct {
	ImageName string `json:"imageName,omitempty"`
	Arg       string `json:"arg,omitempty"`
}

type VariableObject

type VariableObject struct {
	Name   string `json:"name"`
	Format Format `json:"format"`
	//only for input type
	Value string `json:"value"`
	//	GlobalVarName              string       `json:"globalVarName"`
	ReferenceVariableName      string       `json:"referenceVariableName"`
	VariableType               VariableType `json:"variableType"`
	ReferenceVariableStepIndex int          `json:"referenceVariableStepIndex"`
	VariableStepIndexInPlugin  int          `json:"variableStepIndexInPlugin"`
	TypedValue                 interface{}  `json:"-"` //typeCased and deduced
}

---------------

func (*VariableObject) TypeCheck

func (v *VariableObject) TypeCheck() error

type VariableType

type VariableType int

-----

const (
	VALUE VariableType = iota
	REF_PRE_CI
	REF_POST_CI
	REF_GLOBAL
	REF_PLUGIN
)

func (VariableType) MarshalJSON

func (t VariableType) MarshalJSON() ([]byte, error)

func (VariableType) String

func (d VariableType) String() string

func (*VariableType) UnmarshalJSON

func (t *VariableType) UnmarshalJSON(b []byte) error

func (VariableType) ValueOf

func (d VariableType) ValueOf(variableType string) (VariableType, error)

type WebhookData

type WebhookData struct {
	Id              int               `json:"id"`
	EventActionType string            `json:"eventActionType"`
	Data            map[string]string `json:"data"`
}

Jump to

Keyboard shortcuts

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