Skip to content

Commit d02ffa8

Browse files
feat: added the host url in the pre post ci cd steps (#5864)
* added the host url in the pre post ci cd steps * added host url field in wf request during the pre post ci step
1 parent 9746089 commit d02ffa8

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

pkg/deployment/trigger/devtronApps/PreStageTriggerService.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
2828
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/cdWorkflow"
2929
"github.com/devtron-labs/devtron/internal/util"
30+
bean6 "github.com/devtron-labs/devtron/pkg/attributes/bean"
3031
bean4 "github.com/devtron-labs/devtron/pkg/bean"
3132
repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository"
3233
bean5 "github.com/devtron-labs/devtron/pkg/deployment/common/bean"
@@ -564,6 +565,12 @@ func (impl *TriggerServiceImpl) buildWFRequest(runner *pipelineConfig.CdWorkflow
564565
if digestPolicyConfigurations.UseDigestForTrigger() {
565566
image = ReplaceImageTagWithDigest(image, artifact.ImageDigest)
566567
}
568+
569+
host, err := impl.attributeService.GetByKey(bean6.HostUrlKey)
570+
if err != nil {
571+
impl.logger.Errorw("error in getting hostUrl", "err", err)
572+
return nil, err
573+
}
567574
cdStageWorkflowRequest := &types.WorkflowRequest{
568575
EnvironmentId: cdPipeline.EnvironmentId,
569576
AppId: cdPipeline.AppId,
@@ -588,6 +595,7 @@ func (impl *TriggerServiceImpl) buildWFRequest(runner *pipelineConfig.CdWorkflow
588595
WorkflowId: artifact.WorkflowId,
589596
},
590597
OrchestratorHost: impl.config.OrchestratorHost,
598+
HostUrl: host.Value,
591599
OrchestratorToken: impl.config.OrchestratorToken,
592600
CloudProvider: impl.config.CloudProvider,
593601
WorkflowExecutor: workflowExecutor,

pkg/deployment/trigger/devtronApps/TriggerService.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import (
4747
bean4 "github.com/devtron-labs/devtron/pkg/app/bean"
4848
"github.com/devtron-labs/devtron/pkg/app/status"
4949
statusBean "github.com/devtron-labs/devtron/pkg/app/status/bean"
50+
"github.com/devtron-labs/devtron/pkg/attributes"
5051
"github.com/devtron-labs/devtron/pkg/auth/user"
5152
bean2 "github.com/devtron-labs/devtron/pkg/bean"
5253
chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
@@ -163,6 +164,7 @@ type TriggerServiceImpl struct {
163164
deploymentConfigService common.DeploymentConfigService
164165
deploymentServiceTypeConfig *util3.DeploymentServiceTypeConfig
165166
ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator
167+
attributeService attributes.AttributesService
166168
}
167169

168170
func NewTriggerServiceImpl(logger *zap.SugaredLogger,
@@ -217,7 +219,7 @@ func NewTriggerServiceImpl(logger *zap.SugaredLogger,
217219
K8sUtil *util5.K8sServiceImpl,
218220
transactionUtilImpl *sql.TransactionUtilImpl,
219221
deploymentConfigService common.DeploymentConfigService,
220-
ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator,
222+
ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator, attributeService attributes.AttributesService,
221223
) (*TriggerServiceImpl, error) {
222224
impl := &TriggerServiceImpl{
223225
logger: logger,
@@ -274,6 +276,7 @@ func NewTriggerServiceImpl(logger *zap.SugaredLogger,
274276
deploymentConfigService: deploymentConfigService,
275277
deploymentServiceTypeConfig: envVariables.DeploymentServiceTypeConfig,
276278
ciCdPipelineOrchestrator: ciCdPipelineOrchestrator,
279+
attributeService: attributeService,
277280
}
278281
config, err := types.GetCdConfig()
279282
if err != nil {

pkg/pipeline/CiService.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"github.com/devtron-labs/common-lib/utils"
2525
bean3 "github.com/devtron-labs/common-lib/utils/bean"
2626
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/cdWorkflow"
27+
"github.com/devtron-labs/devtron/pkg/attributes"
28+
bean4 "github.com/devtron-labs/devtron/pkg/attributes/bean"
2729
"github.com/devtron-labs/devtron/pkg/infraConfig"
2830
"github.com/devtron-labs/devtron/pkg/pipeline/adapter"
2931
"github.com/devtron-labs/devtron/pkg/pipeline/bean/CiPipeline"
@@ -96,6 +98,7 @@ type CiServiceImpl struct {
9698
infraProvider infraProviders.InfraProvider
9799
ciCdPipelineOrchestrator CiCdPipelineOrchestrator
98100
buildxCacheFlags *BuildxCacheFlags
101+
attributeService attributes.AttributesService
99102
}
100103

101104
func NewCiServiceImpl(Logger *zap.SugaredLogger, workflowService WorkflowService,
@@ -112,7 +115,7 @@ func NewCiServiceImpl(Logger *zap.SugaredLogger, workflowService WorkflowService
112115
pluginInputVariableParser PluginInputVariableParser,
113116
globalPluginService plugin.GlobalPluginService,
114117
infraProvider infraProviders.InfraProvider,
115-
ciCdPipelineOrchestrator CiCdPipelineOrchestrator,
118+
ciCdPipelineOrchestrator CiCdPipelineOrchestrator, attributeService attributes.AttributesService,
116119
) *CiServiceImpl {
117120
buildxCacheFlags := &BuildxCacheFlags{}
118121
err := env.Parse(buildxCacheFlags)
@@ -141,6 +144,7 @@ func NewCiServiceImpl(Logger *zap.SugaredLogger, workflowService WorkflowService
141144
infraProvider: infraProvider,
142145
ciCdPipelineOrchestrator: ciCdPipelineOrchestrator,
143146
buildxCacheFlags: buildxCacheFlags,
147+
attributeService: attributeService,
144148
}
145149
config, err := types.GetCiConfig()
146150
if err != nil {
@@ -595,7 +599,11 @@ func (impl *CiServiceImpl) buildWfRequestForCiPipeline(pipeline *pipelineConfig.
595599
impl.Logger.Errorw("error in getting infra configuration using scope ", "ciPipelineId", pipeline.Id, "scope", infraConfigScope, "err", err)
596600
return nil, err
597601
}
598-
602+
host, err := impl.attributeService.GetByKey(bean4.HostUrlKey)
603+
if err != nil {
604+
impl.Logger.Errorw("error in getting host url", "err", err, "hostUrl", host.Value)
605+
return nil, err
606+
}
599607
if ciWorkflowConfig.CiCacheBucket == "" {
600608
ciWorkflowConfig.CiCacheBucket = impl.config.DefaultCacheBucket
601609
}
@@ -796,6 +804,7 @@ func (impl *CiServiceImpl) buildWfRequestForCiPipeline(pipeline *pipelineConfig.
796804
ExtraEnvironmentVariables: trigger.ExtraEnvironmentVariables,
797805
EnableBuildContext: impl.config.EnableBuildContext,
798806
OrchestratorHost: impl.config.OrchestratorHost,
807+
HostUrl: host.Value,
799808
OrchestratorToken: impl.config.OrchestratorToken,
800809
ImageRetryCount: impl.config.ImageRetryCount,
801810
ImageRetryInterval: impl.config.ImageRetryInterval,

pkg/pipeline/types/Workflow.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ type WorkflowRequest struct {
144144
Env *repository.Environment
145145
AppLabels map[string]string
146146
Scope resourceQualifiers.Scope
147-
BuildxCacheModeMin bool `json:"buildxCacheModeMin"`
148-
AsyncBuildxCacheExport bool `json:"asyncBuildxCacheExport"`
149-
UseDockerApiToGetDigest bool `json:"useDockerApiToGetDigest"`
147+
BuildxCacheModeMin bool `json:"buildxCacheModeMin"`
148+
AsyncBuildxCacheExport bool `json:"asyncBuildxCacheExport"`
149+
UseDockerApiToGetDigest bool `json:"useDockerApiToGetDigest"`
150+
HostUrl string `json:"hostUrl"`
150151
}
151152

152153
func (workflowRequest *WorkflowRequest) updateExternalRunMetadata() {

wire_gen.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)