Skip to content

Commit a667752

Browse files
committed
Merge branch 'develop' into create-cm-on-cluster-action-oss
# Conflicts: # go.mod # go.sum # vendor/modules.txt
2 parents 85c29e5 + 9f5bdbd commit a667752

File tree

5,667 files changed

+788960
-281391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,667 files changed

+788960
-281391
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21 AS build-env
1+
FROM golang:1.24.0 AS build-env
22

33
RUN echo $GOPATH && \
44
apt update && \

DockerfileEA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21 AS build-env
1+
FROM golang:1.24.0 AS build-env
22

33
RUN echo $GOPATH && \
44
apt update && \

go.mod

Lines changed: 161 additions & 181 deletions
Large diffs are not rendered by default.

go.sum

Lines changed: 426 additions & 1717 deletions
Large diffs are not rendered by default.

internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type CdWorkflowRepository interface {
4040
FindCdWorkflowMetaByEnvironmentId(appId int, environmentId int, offset int, size int) ([]CdWorkflowRunner, error)
4141
FindCdWorkflowMetaByPipelineId(pipelineId int, offset int, size int) ([]CdWorkflowRunner, error)
4242
FindArtifactByPipelineIdAndRunnerType(pipelineId int, runnerType apiBean.WorkflowType, limit int, runnerStatuses []string) ([]CdWorkflowRunner, error)
43-
SaveWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) (*CdWorkflowRunner, error)
43+
SaveWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) error
4444
UpdateWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) error
4545
UpdateIsArtifactUploaded(wfrId int, isArtifactUploaded workflow.ArtifactUploadedType) error
4646
GetPreviousQueuedRunners(cdWfrId, pipelineId int) ([]*CdWorkflowRunner, error)
@@ -435,9 +435,11 @@ func (impl *CdWorkflowRepositoryImpl) FindLastPreOrPostTriggeredByEnvironmentId(
435435
return wfr, err
436436
}
437437

438-
func (impl *CdWorkflowRepositoryImpl) SaveWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) (*CdWorkflowRunner, error) {
439-
err := tx.Insert(wfr)
440-
return wfr, err
438+
func (impl *CdWorkflowRepositoryImpl) SaveWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) error {
439+
if tx == nil {
440+
return impl.dbConnection.Insert(wfr)
441+
}
442+
return tx.Insert(wfr)
441443
}
442444

443445
func (impl *CdWorkflowRepositoryImpl) UpdateWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) error {

pkg/deployment/gitOps/git/GitServiceBitbucket.go

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,43 @@ func (impl GitBitbucketClient) CommitValues(ctx context.Context, config *ChartCo
347347
}
348348

349349
//extracting the latest commit hash from the paginated api response of above method, reference of api & response - https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commits
350-
commitHash = commits.(map[string]interface{})["values"].([]interface{})[0].(map[string]interface{})["hash"].(string)
351-
commitTimeString := commits.(map[string]interface{})["values"].([]interface{})[0].(map[string]interface{})["date"].(string)
352-
commitTime, err = time.Parse(time.RFC3339, commitTimeString)
350+
commitsMap, ok := commits.(map[string]interface{})
351+
if !ok {
352+
impl.logger.Errorw("unexpected response format from bitbucket", "commits", commits)
353+
return "", time.Time{}, fmt.Errorf("unexpected response format from bitbucket")
354+
}
355+
356+
values, ok := commitsMap["values"]
357+
if !ok || values == nil {
358+
impl.logger.Errorw("no values found in bitbucket response", "commits", commits, "commitsMap", commitsMap)
359+
return "", time.Time{}, fmt.Errorf("no commits found in bitbucket response")
360+
}
361+
362+
valuesArray, ok := values.([]interface{})
363+
if !ok || len(valuesArray) == 0 {
364+
impl.logger.Errorw("empty values array in bitbucket response", "commits", commits, "values", values)
365+
return "", time.Time{}, fmt.Errorf("empty commits array in bitbucket response")
366+
}
367+
368+
firstCommit, ok := valuesArray[0].(map[string]interface{})
369+
if !ok {
370+
impl.logger.Errorw("invalid commit format in bitbucket response", "commits", commits, "firstCommit", valuesArray[0])
371+
return "", time.Time{}, fmt.Errorf("invalid commit format in bitbucket response")
372+
}
373+
374+
commitHash, ok = firstCommit["hash"].(string)
375+
if !ok || commitHash == "" {
376+
impl.logger.Errorw("no hash found in commit", "commits", commits, "firstCommit", firstCommit)
377+
return "", time.Time{}, fmt.Errorf("no hash found in commit")
378+
}
379+
380+
dateStr, ok := firstCommit["date"].(string)
381+
if !ok || dateStr == "" {
382+
impl.logger.Errorw("no date found in commit", "firstCommit", firstCommit)
383+
return "", time.Time{}, fmt.Errorf("no date found in commit response")
384+
}
385+
386+
commitTime, err = time.Parse(time.RFC3339, dateStr)
353387
if err != nil {
354388
util.TriggerGitOpsMetrics("CommitValues", "GitBitbucketClient", start, err)
355389
impl.logger.Errorw("error in getting commitTime", "err", err)

pkg/deployment/gitOps/git/GitServiceGitlab.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (impl GitLabClient) DeleteProject(projectName string) (err error) {
213213
}()
214214

215215
impl.logger.Infow("deleting project ", "gitlab project name", projectName)
216-
_, err = impl.client.Projects.DeleteProject(fmt.Sprintf("%s/%s", impl.config.GitlabGroupPath, projectName))
216+
_, err = impl.client.Projects.DeleteProject(fmt.Sprintf("%s/%s", impl.config.GitlabGroupPath, projectName), nil)
217217
return err
218218
}
219219
func (impl GitLabClient) createProject(name, description string) (url string, err error) {

pkg/deployment/trigger/devtronApps/deployStageHandlerCode.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,15 @@ func (impl *HandlerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerConte
282282
AuditLog: sql.AuditLog{CreatedOn: triggeredAt, CreatedBy: overrideRequest.UserId, UpdatedOn: triggeredAt, UpdatedBy: overrideRequest.UserId},
283283
ReferenceId: triggerContext.ReferenceId,
284284
}
285-
savedWfr, err := impl.cdWorkflowRunnerService.SaveCDWorkflowRunnerWithStage(runner)
285+
err = impl.cdWorkflowRunnerService.SaveWfr(nil, runner)
286286
if err != nil {
287287
impl.logger.Errorw("err in creating cdWorkflowRunner, ManualCdTrigger", "cdWorkflowId", cdWorkflowId, "err", err)
288288
return 0, "", nil, err
289289
}
290290
runner.CdWorkflow = &pipelineConfig.CdWorkflow{
291291
Pipeline: cdPipeline,
292292
}
293-
overrideRequest.WfrId = savedWfr.Id
293+
overrideRequest.WfrId = runner.Id
294294
overrideRequest.CdWorkflowId = cdWorkflowId
295295
// creating cd pipeline status timeline for deployment initialisation
296296
timeline := impl.pipelineStatusTimelineService.NewDevtronAppPipelineStatusTimelineDbObject(runner.Id, timelineStatus.TIMELINE_STATUS_DEPLOYMENT_INITIATED, timelineStatus.TIMELINE_DESCRIPTION_DEPLOYMENT_INITIATED, overrideRequest.UserId)
@@ -419,7 +419,7 @@ func (impl *HandlerServiceImpl) TriggerAutomaticDeployment(request bean.TriggerR
419419
AuditLog: sql.AuditLog{CreatedOn: triggeredAt, CreatedBy: triggeredBy, UpdatedOn: triggeredAt, UpdatedBy: triggeredBy},
420420
ReferenceId: request.TriggerContext.ReferenceId,
421421
}
422-
savedWfr, err := impl.cdWorkflowRunnerService.SaveCDWorkflowRunnerWithStage(runner)
422+
err := impl.cdWorkflowRunnerService.SaveWfr(nil, runner)
423423
if err != nil {
424424
return err
425425
}
@@ -448,7 +448,7 @@ func (impl *HandlerServiceImpl) TriggerAutomaticDeployment(request bean.TriggerR
448448
impl.logger.Errorw("validation error deployment request", "cdWfr", runner.Id, "err", validationErr)
449449
return validationErr
450450
}
451-
releaseErr := impl.TriggerCD(ctx, artifact, cdWf.Id, savedWfr.Id, pipeline, envDeploymentConfig, triggeredAt, triggeredBy)
451+
releaseErr := impl.TriggerCD(ctx, artifact, cdWf.Id, runner.Id, pipeline, envDeploymentConfig, triggeredAt, triggeredBy)
452452
// if releaseErr found, then the mark current deployment Failed and return
453453
if releaseErr != nil {
454454
err := impl.cdWorkflowCommonService.MarkCurrentDeploymentFailed(runner, releaseErr, triggeredBy)

pkg/pipeline/CiHandler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,11 +766,11 @@ func (impl *CiHandlerImpl) FetchMaterialInfoByArtifactId(ciArtifactId int, envId
766766
res := buildBean.CiPipelineMaterialResponse{
767767
Id: m.Id,
768768
GitMaterialId: m.GitMaterialId,
769-
GitMaterialName: m.GitMaterial.Name[strings.Index(m.GitMaterial.Name, "-")+1:],
769+
GitMaterialName: _gitTrigger.GitRepoName,
770770
Type: string(m.Type),
771-
Value: m.Value,
771+
Value: _gitTrigger.CiConfigureSourceValue,
772772
Active: m.Active,
773-
Url: m.GitMaterial.Url,
773+
Url: _gitTrigger.GitRepoUrl,
774774
History: history,
775775
}
776776
ciMaterialsArr = append(ciMaterialsArr, res)

pkg/workflow/cd/CdWorkflowRunnerService.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ import (
2929
"github.com/devtron-labs/devtron/pkg/workflow/cd/adapter"
3030
"github.com/devtron-labs/devtron/pkg/workflow/cd/bean"
3131
"github.com/devtron-labs/devtron/util"
32+
"github.com/go-pg/pg"
3233
"go.uber.org/zap"
3334
)
3435

3536
type CdWorkflowRunnerService interface {
3637
UpdateWfr(dto *bean.CdWorkflowRunnerDto, updatedBy int) error
38+
SaveWfr(tx *pg.Tx, wfr *pipelineConfig.CdWorkflowRunner) error
3739
UpdateIsArtifactUploaded(wfrId int, isArtifactUploaded bool) error
3840
SaveCDWorkflowRunnerWithStage(wfr *pipelineConfig.CdWorkflowRunner) (*pipelineConfig.CdWorkflowRunner, error)
3941
UpdateCdWorkflowRunnerWithStage(wfr *pipelineConfig.CdWorkflowRunner) error
@@ -103,7 +105,7 @@ func (impl *CdWorkflowRunnerServiceImpl) SaveCDWorkflowRunnerWithStage(wfr *pipe
103105
if impl.config.EnableWorkflowExecutionStage {
104106
wfr.Status = cdWorkflow.WorkflowWaitingToStart
105107
}
106-
wfr, err = impl.cdWorkflowRepository.SaveWorkFlowRunnerWithTx(wfr, tx)
108+
err = impl.cdWorkflowRepository.SaveWorkFlowRunnerWithTx(wfr, tx)
107109
if err != nil {
108110
impl.logger.Errorw("error in saving workflow", "payload", wfr, "error", err)
109111
return wfr, err
@@ -198,3 +200,7 @@ func (impl *CdWorkflowRunnerServiceImpl) GetPrePostWorkflowStagesByWorkflowRunne
198200
}
199201
return resp, nil
200202
}
203+
204+
func (impl *CdWorkflowRunnerServiceImpl) SaveWfr(tx *pg.Tx, wfr *pipelineConfig.CdWorkflowRunner) error {
205+
return impl.cdWorkflowRepository.SaveWorkFlowRunnerWithTx(wfr, tx)
206+
}

0 commit comments

Comments
 (0)