Skip to content

Commit c88eca8

Browse files
committed
UseAppDockerConfigForPrivateRegistries in workflow request
1 parent c216904 commit c88eca8

File tree

3 files changed

+49
-36
lines changed

3 files changed

+49
-36
lines changed

pkg/pipeline/CiService.go

+15-4
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,31 @@ func (impl *CiServiceImpl) GetCiMaterials(pipelineId int, ciMaterials []*pipelin
158158
}
159159
}
160160

161-
func (impl *CiServiceImpl) handleRuntimeParamsValidations(trigger types.Trigger, ciMaterials []*pipelineConfig.CiPipelineMaterial) error {
161+
func (impl *CiServiceImpl) handleRuntimeParamsValidations(trigger types.Trigger, ciMaterials []*pipelineConfig.CiPipelineMaterial) (bool, error) {
162+
var useAppDockerConfigForPrivateRegistries bool
163+
var err error
162164
// checking if user has given run time parameters for externalCiArtifact, if given then sending git material to Ci-Runner
163165
externalCiArtifact, exists := trigger.ExtraEnvironmentVariables[CiPipeline.ExtraEnvVarExternalCiArtifactKey]
164166
// validate externalCiArtifact as docker image
165167
if exists {
166168
if !strings.Contains(externalCiArtifact, ":") {
167169
impl.Logger.Errorw("validation error", "externalCiArtifact", externalCiArtifact)
168-
return fmt.Errorf("invalid image name given in externalCiArtifact")
170+
return useAppDockerConfigForPrivateRegistries, fmt.Errorf("invalid image name given in externalCiArtifact")
171+
}
172+
useAppBuildConfig, ok := trigger.ExtraEnvironmentVariables[CiPipeline.ExtraEnvVarUseAppDockerConfig]
173+
if ok && len(useAppBuildConfig) > 0 {
174+
useAppDockerConfigForPrivateRegistries, err = strconv.ParseBool(useAppBuildConfig)
175+
if err != nil {
176+
impl.Logger.Errorw("error in parsing useAppBuildConfig string data to bool", "err", err)
177+
return useAppDockerConfigForPrivateRegistries, fmt.Errorf("error in parsing useAppBuildConfig string data to bool, err:- %v", err)
178+
}
169179
}
170180
}
171181
if trigger.PipelineType == string(CiPipeline.CI_JOB) && len(ciMaterials) != 0 && !exists && externalCiArtifact == "" {
172182
ciMaterials[0].GitMaterial = nil
173183
ciMaterials[0].GitMaterialId = 0
174184
}
175-
return nil
185+
return useAppDockerConfigForPrivateRegistries, nil
176186
}
177187

178188
func (impl *CiServiceImpl) TriggerCiPipeline(trigger types.Trigger) (int, error) {
@@ -181,7 +191,7 @@ func (impl *CiServiceImpl) TriggerCiPipeline(trigger types.Trigger) (int, error)
181191
if err != nil {
182192
return 0, err
183193
}
184-
err = impl.handleRuntimeParamsValidations(trigger, ciMaterials)
194+
useAppDockerConfigForPrivateRegistries, err := impl.handleRuntimeParamsValidations(trigger, ciMaterials)
185195
if err != nil {
186196
return 0, err
187197
}
@@ -265,6 +275,7 @@ func (impl *CiServiceImpl) TriggerCiPipeline(trigger types.Trigger) (int, error)
265275
impl.Logger.Errorw("make workflow req", "err", err)
266276
return 0, err
267277
}
278+
workflowRequest.UseAppDockerConfigForPrivateRegistries = useAppDockerConfigForPrivateRegistries
268279
workflowRequest.Scope = scope
269280
workflowRequest.BuildxCacheModeMin = impl.buildxCacheFlags.BuildxCacheModeMin
270281
workflowRequest.AsyncBuildxCacheExport = impl.buildxCacheFlags.AsyncBuildxCacheExport

pkg/pipeline/bean/CiPipeline/CiBuildConfig.go

+1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,5 @@ func (pType PipelineType) IsValidPipelineType() bool {
8989
const (
9090
ExtraEnvVarExternalCiArtifactKey = "externalCiArtifact"
9191
ExtraEnvVarImageDigestKey = "imageDigest"
92+
ExtraEnvVarUseAppDockerConfig = "useAppDockerConfig"
9293
)

pkg/pipeline/types/Workflow.go

+33-32
Original file line numberDiff line numberDiff line change
@@ -113,38 +113,39 @@ type WorkflowRequest struct {
113113
ImageRetryCount int `json:"imageRetryCount"`
114114
ImageRetryInterval int `json:"imageRetryInterval"`
115115
// Data from CD Workflow service
116-
WorkflowRunnerId int `json:"workflowRunnerId"`
117-
CdPipelineId int `json:"cdPipelineId"`
118-
StageYaml string `json:"stageYaml"`
119-
ArtifactLocation string `json:"artifactLocation"`
120-
CiArtifactDTO CiArtifactDTO `json:"ciArtifactDTO"`
121-
CdImage string `json:"cdImage"`
122-
StageType string `json:"stageType"`
123-
CdCacheLocation string `json:"cdCacheLocation"`
124-
CdCacheRegion string `json:"cdCacheRegion"`
125-
WorkflowPrefixForLog string `json:"workflowPrefixForLog"`
126-
DeploymentTriggeredBy string `json:"deploymentTriggeredBy,omitempty"`
127-
DeploymentTriggerTime time.Time `json:"deploymentTriggerTime,omitempty"`
128-
DeploymentReleaseCounter int `json:"deploymentReleaseCounter,omitempty"`
129-
WorkflowExecutor pipelineConfig.WorkflowExecutorType `json:"workflowExecutor"`
130-
PrePostDeploySteps []*bean.StepObject `json:"prePostDeploySteps"`
131-
CiArtifactLastFetch time.Time `json:"ciArtifactLastFetch"`
132-
CiPipelineType string `json:"ciPipelineType"`
133-
UseExternalClusterBlob bool `json:"useExternalClusterBlob"`
134-
RegistryDestinationImageMap map[string][]string `json:"registryDestinationImageMap"`
135-
RegistryCredentialMap map[string]bean4.RegistryCredentials `json:"registryCredentialMap"`
136-
PluginArtifactStage string `json:"pluginArtifactStage"`
137-
PushImageBeforePostCI bool `json:"pushImageBeforePostCI"`
138-
ImageScanMaxRetries int `json:"imageScanMaxRetries,omitempty"`
139-
ImageScanRetryDelay int `json:"imageScanRetryDelay,omitempty"`
140-
Type bean.WorkflowPipelineType
141-
Pipeline *pipelineConfig.Pipeline
142-
Env *repository.Environment
143-
AppLabels map[string]string
144-
Scope resourceQualifiers.Scope
145-
BuildxCacheModeMin bool `json:"buildxCacheModeMin"`
146-
AsyncBuildxCacheExport bool `json:"asyncBuildxCacheExport"`
147-
UseDockerApiToGetDigest bool `json:"useDockerApiToGetDigest"`
116+
WorkflowRunnerId int `json:"workflowRunnerId"`
117+
CdPipelineId int `json:"cdPipelineId"`
118+
StageYaml string `json:"stageYaml"`
119+
ArtifactLocation string `json:"artifactLocation"`
120+
CiArtifactDTO CiArtifactDTO `json:"ciArtifactDTO"`
121+
CdImage string `json:"cdImage"`
122+
StageType string `json:"stageType"`
123+
CdCacheLocation string `json:"cdCacheLocation"`
124+
CdCacheRegion string `json:"cdCacheRegion"`
125+
WorkflowPrefixForLog string `json:"workflowPrefixForLog"`
126+
DeploymentTriggeredBy string `json:"deploymentTriggeredBy,omitempty"`
127+
DeploymentTriggerTime time.Time `json:"deploymentTriggerTime,omitempty"`
128+
DeploymentReleaseCounter int `json:"deploymentReleaseCounter,omitempty"`
129+
WorkflowExecutor pipelineConfig.WorkflowExecutorType `json:"workflowExecutor"`
130+
PrePostDeploySteps []*bean.StepObject `json:"prePostDeploySteps"`
131+
CiArtifactLastFetch time.Time `json:"ciArtifactLastFetch"`
132+
CiPipelineType string `json:"ciPipelineType"`
133+
UseExternalClusterBlob bool `json:"useExternalClusterBlob"`
134+
RegistryDestinationImageMap map[string][]string `json:"registryDestinationImageMap"`
135+
RegistryCredentialMap map[string]bean4.RegistryCredentials `json:"registryCredentialMap"`
136+
PluginArtifactStage string `json:"pluginArtifactStage"`
137+
PushImageBeforePostCI bool `json:"pushImageBeforePostCI"`
138+
ImageScanMaxRetries int `json:"imageScanMaxRetries,omitempty"`
139+
ImageScanRetryDelay int `json:"imageScanRetryDelay,omitempty"`
140+
Type bean.WorkflowPipelineType
141+
Pipeline *pipelineConfig.Pipeline
142+
Env *repository.Environment
143+
AppLabels map[string]string
144+
Scope resourceQualifiers.Scope
145+
BuildxCacheModeMin bool `json:"buildxCacheModeMin"`
146+
AsyncBuildxCacheExport bool `json:"asyncBuildxCacheExport"`
147+
UseDockerApiToGetDigest bool `json:"useDockerApiToGetDigest"`
148+
UseAppDockerConfigForPrivateRegistries bool `json:"useAppDockerConfigForPrivateRegistries"`
148149
}
149150

150151
func (workflowRequest *WorkflowRequest) updateExternalRunMetadata() {

0 commit comments

Comments
 (0)