Skip to content

Commit 26392d6

Browse files
committed
wip: pull image using digest support
1 parent 4abad59 commit 26392d6

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

client/argocdServer/k8sClient.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ func (impl ArgoK8sClientImpl) CreateAcdApp(appRequest *AppTemplate, cluster *rep
7070
return "", err
7171
}
7272

73-
config, err := rest.InClusterConfig()
74-
if err != nil {
75-
impl.logger.Errorw("error in config", "err", err)
76-
return "", err
77-
}
73+
//config, err := rest.InClusterConfig()
74+
//if err != nil {
75+
// impl.logger.Errorw("error in config", "err", err)
76+
// return "", err
77+
//}
78+
config := &rest.Config{Host: "https://172.191.203.220:16443", BearerToken: "cGVlZE4xWlZzVTFyQVpXZ2J2d2RQcGplQTI5NUJRYjdabEdMeXEyY1pWbz0K", TLSClientConfig: rest.TLSClientConfig{Insecure: true}}
79+
7880
config.GroupVersion = &schema.GroupVersion{Group: "argoproj.io", Version: "v1alpha1"}
7981
config.NegotiatedSerializer = serializer.NewCodecFactory(runtime.NewScheme())
8082
config.APIPath = "/apis"

pkg/pipeline/CiService.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ func (impl *CiServiceImpl) buildWfRequestForCiPipeline(pipeline *pipelineConfig.
658658
RegistryDestinationImageMap: registryDestinationImageMap,
659659
RegistryCredentialMap: registryCredentialMap,
660660
PluginArtifactStage: pluginArtifactStage,
661+
PullImageUsingDigest: impl.config.PullImageUsingDigest,
661662
}
662663

663664
if dockerRegistry != nil {

pkg/pipeline/WorkflowDagExecutor.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ type WorkflowDagExecutorImpl struct {
197197
argoClientWrapperService argocdServer.ArgoClientWrapperService
198198
pipelineConfigListenerService PipelineConfigListenerService
199199
customTagService CustomTagService
200+
CiCdConfig *types.CiCdConfig
200201
}
201202

202203
const kedaAutoscaling = "kedaAutoscaling"
@@ -302,6 +303,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi
302303
argoClientWrapperService argocdServer.ArgoClientWrapperService,
303304
pipelineConfigListenerService PipelineConfigListenerService,
304305
customTagService CustomTagService,
306+
CiCdConfig *types.CiCdConfig,
305307
) *WorkflowDagExecutorImpl {
306308
wde := &WorkflowDagExecutorImpl{logger: Logger,
307309
pipelineRepository: pipelineRepository,
@@ -378,6 +380,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi
378380
argoClientWrapperService: argoClientWrapperService,
379381
pipelineConfigListenerService: pipelineConfigListenerService,
380382
customTagService: customTagService,
383+
CiCdConfig: CiCdConfig,
381384
}
382385
config, err := types.GetCdConfig()
383386
if err != nil {
@@ -1637,12 +1640,13 @@ func (impl *WorkflowDagExecutorImpl) buildWFRequest(runner *pipelineConfig.CdWor
16371640
DataSource: artifact.DataSource,
16381641
WorkflowId: artifact.WorkflowId,
16391642
},
1640-
OrchestratorHost: impl.config.OrchestratorHost,
1641-
OrchestratorToken: impl.config.OrchestratorToken,
1642-
CloudProvider: impl.config.CloudProvider,
1643-
WorkflowExecutor: workflowExecutor,
1644-
RefPlugins: refPluginsData,
1645-
Scope: scope,
1643+
OrchestratorHost: impl.config.OrchestratorHost,
1644+
OrchestratorToken: impl.config.OrchestratorToken,
1645+
CloudProvider: impl.config.CloudProvider,
1646+
WorkflowExecutor: workflowExecutor,
1647+
RefPlugins: refPluginsData,
1648+
Scope: scope,
1649+
PullImageUsingDigest: impl.config.PullImageUsingDigest,
16461650
}
16471651

16481652
extraEnvVariables := make(map[string]string)
@@ -2958,7 +2962,7 @@ func (impl *WorkflowDagExecutorImpl) TriggerPipeline(overrideRequest *bean.Value
29582962
manifestPushResponse := manifestPushService.PushChart(manifestPushTemplate, ctx)
29592963
if manifestPushResponse.Error != nil {
29602964
impl.logger.Errorw("Error in pushing manifest to git", "err", err, "git_repo_url", manifestPushTemplate.RepoUrl)
2961-
return releaseNo, manifest, err
2965+
return releaseNo, manifest, manifestPushResponse.Error
29622966
}
29632967
pipelineOverrideUpdateRequest := &chartConfig.PipelineOverride{
29642968
Id: valuesOverrideResponse.PipelineOverride.Id,
@@ -4072,6 +4076,11 @@ func (impl *WorkflowDagExecutorImpl) getReleaseOverride(envOverride *chartConfig
40724076
if strategy != nil {
40734077
deploymentStrategy = string(strategy.Strategy)
40744078
}
4079+
4080+
if impl.CiCdConfig.PullImageUsingDigest {
4081+
imageTag[imageTagLen-1] = fmt.Sprintf("%s@%s", imageTag[imageTagLen-1], artifact.ImageDigest)
4082+
}
4083+
40754084
releaseAttribute := app.ReleaseAttributes{
40764085
Name: imageName,
40774086
Tag: imageTag[imageTagLen-1],

pkg/pipeline/types/CiCdConfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ type CiCdConfig struct {
123123
ExtBlobStorageSecretName string `env:"EXTERNAL_BLOB_STORAGE_SECRET_NAME" envDefault:"blob-storage-secret"`
124124
UseArtifactListingQueryV2 bool `env:"USE_ARTIFACT_LISTING_QUERY_V2" envDefault:"true"`
125125
UseImageTagFromGitProviderForTagBasedBuild bool `env:"USE_IMAGE_TAG_FROM_GIT_PROVIDER_FOR_TAG_BASED_BUILD" envDefault:"false"` // this is being done for https://github.com/devtron-labs/devtron/issues/4263
126+
PullImageUsingDigest bool `env:"PULL_IMAGE_USING_DIGEST" envDefault:"false"`
126127
}
127128

128129
type CiConfig struct {

pkg/pipeline/types/Workflow.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ type WorkflowRequest struct {
126126
RegistryCredentialMap map[string]plugin.RegistryCredentials `json:"registryCredentialMap"`
127127
PluginArtifactStage string `json:"pluginArtifactStage"`
128128
PushImageBeforePostCI bool `json:"pushImageBeforePostCI"`
129+
PullImageUsingDigest bool `json:"pullImageUsingDigest"`
129130
Type bean.WorkflowPipelineType
130131
Pipeline *pipelineConfig.Pipeline
131132
Env *repository.Environment

wire_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)