Skip to content

Commit beceb53

Browse files
committed
Merge branch 'main' into argo-cd-corrupt-data-fix-from-main
2 parents ece740f + ea98cd9 commit beceb53

File tree

54 files changed

+1688
-419
lines changed

Some content is hidden

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

54 files changed

+1688
-419
lines changed

Wire.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ import (
155155
repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository"
156156
repository5 "github.com/devtron-labs/devtron/pkg/pipeline/repository"
157157
"github.com/devtron-labs/devtron/pkg/pipeline/types"
158+
"github.com/devtron-labs/devtron/pkg/pipeline/workflowStatus"
159+
repository6 "github.com/devtron-labs/devtron/pkg/pipeline/workflowStatus/repository"
158160
"github.com/devtron-labs/devtron/pkg/plugin"
159161
"github.com/devtron-labs/devtron/pkg/policyGovernance"
160162
resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup"
@@ -471,6 +473,11 @@ func InitializeApp() (*App, error) {
471473
pipeline.NewCiServiceImpl,
472474
wire.Bind(new(pipeline.CiService), new(*pipeline.CiServiceImpl)),
473475

476+
workflowStatus.NewWorkflowStageFlowStatusServiceImpl,
477+
wire.Bind(new(workflowStatus.WorkFlowStageStatusService), new(*workflowStatus.WorkFlowStageStatusServiceImpl)),
478+
repository6.NewWorkflowStageRepositoryImpl,
479+
wire.Bind(new(repository6.WorkflowStageRepository), new(*repository6.WorkflowStageRepositoryImpl)),
480+
474481
pipelineConfig.NewCiWorkflowRepositoryImpl,
475482
wire.Bind(new(pipelineConfig.CiWorkflowRepository), new(*pipelineConfig.CiWorkflowRepositoryImpl)),
476483

api/bean/UserRequest.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package bean
1919
import (
2020
"encoding/json"
2121
"github.com/devtron-labs/devtron/pkg/auth/user/bean"
22+
"github.com/devtron-labs/devtron/pkg/sql"
2223
"time"
2324
)
2425

@@ -168,3 +169,40 @@ type BulkDeleteRequest struct {
168169
type UserRoleGroup struct {
169170
RoleGroup *RoleGroup `json:"roleGroup"`
170171
}
172+
173+
type GroupPermissionsAuditDto struct {
174+
RoleGroupInfo *RoleGroup `json:"roleGroupInfo,omitempty"`
175+
EntityAudit sql.AuditLog `json:"entityAudit,omitempty"`
176+
}
177+
178+
func NewGroupPermissionsAuditDto() *GroupPermissionsAuditDto {
179+
return &GroupPermissionsAuditDto{}
180+
}
181+
182+
func (pa *GroupPermissionsAuditDto) WithRoleGroupInfo(roleGroupInfo *RoleGroup) *GroupPermissionsAuditDto {
183+
pa.RoleGroupInfo = roleGroupInfo
184+
return pa
185+
}
186+
func (pa *GroupPermissionsAuditDto) WithEntityAudit(entityAudit sql.AuditLog) *GroupPermissionsAuditDto {
187+
pa.EntityAudit = entityAudit
188+
return pa
189+
}
190+
191+
type UserPermissionsAuditDto struct {
192+
UserInfo *UserInfo `json:"userInfo,omitempty"`
193+
EntityAudit sql.AuditLog `json:"entityAudit,omitempty"`
194+
}
195+
196+
func NewUserPermissionsAuditDto() *UserPermissionsAuditDto {
197+
return &UserPermissionsAuditDto{}
198+
}
199+
200+
func (pa *UserPermissionsAuditDto) WithUserInfo(userInfo *UserInfo) *UserPermissionsAuditDto {
201+
pa.UserInfo = userInfo
202+
return pa
203+
}
204+
205+
func (pa *UserPermissionsAuditDto) WithEntityAudit(entityAudit sql.AuditLog) *UserPermissionsAuditDto {
206+
pa.EntityAudit = entityAudit
207+
return pa
208+
}

api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/devtron-labs/devtron/internal/sql/constants"
2626
"github.com/devtron-labs/devtron/pkg/build/artifacts/imageTagging"
2727
bean2 "github.com/devtron-labs/devtron/pkg/build/pipeline/bean"
28+
constants2 "github.com/devtron-labs/devtron/pkg/pipeline/constants"
2829
"github.com/devtron-labs/devtron/util/stringsUtil"
2930
"golang.org/x/exp/maps"
3031
"io"
@@ -45,7 +46,6 @@ import (
4546
"github.com/devtron-labs/devtron/internal/util"
4647
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
4748
"github.com/devtron-labs/devtron/pkg/bean"
48-
"github.com/devtron-labs/devtron/pkg/pipeline"
4949
bean1 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
5050
"github.com/devtron-labs/devtron/pkg/pipeline/types"
5151
resourceGroup "github.com/devtron-labs/devtron/pkg/resourceGroup"
@@ -663,7 +663,7 @@ func (handler *PipelineConfigRestHandlerImpl) validateCiTriggerRBAC(token string
663663
// This is being done for jobs, jobs execute in default-env (devtron-ci) namespace by default. so considering DefaultCiNamespace as env for rbac enforcement
664664
envName := ""
665665
if triggerEnvironmentId == 0 {
666-
envName = pipeline.DefaultCiWorkflowNamespace
666+
envName = constants2.DefaultCiWorkflowNamespace
667667
}
668668
appObject := handler.enforcerUtil.GetAppRBACNameByAppId(ciPipeline.AppId)
669669
workflowObject := handler.enforcerUtil.GetWorkflowRBACByCiPipelineId(ciPipelineId, workflowName)

env_gen.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

env_gen.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
| DEFAULT_TARGET_PLATFORM | string | | | | false |
7777
| DOCKER_BUILD_CACHE_PATH | string |/var/lib/docker | | | false |
7878
| ENABLE_BUILD_CONTEXT | bool |false | | | false |
79+
| ENABLE_WORKFLOW_EXECUTION_STAGE | bool |true | if enabled then we will display build stages separately for CI/Job/Pre-Post CD | true | false |
7980
| EXTERNAL_BLOB_STORAGE_CM_NAME | string |blob-storage-cm | | | false |
8081
| EXTERNAL_BLOB_STORAGE_SECRET_NAME | string |blob-storage-secret | | | false |
8182
| EXTERNAL_CD_NODE_LABEL_SELECTOR | | | | | false |

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ require gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
288288

289289
replace (
290290
github.com/argoproj/argo-workflows/v3 v3.5.10 => github.com/devtron-labs/argo-workflows/v3 v3.5.13
291-
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250130075053-69cdda98e3e2
292-
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250130075053-69cdda98e3e2
291+
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250213085216-b49895a5c8c4
292+
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250213085216-b49895a5c8c4
293293
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
294294
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5
295295
k8s.io/api => k8s.io/api v0.29.7

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,10 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzq
792792
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
793793
github.com/devtron-labs/argo-workflows/v3 v3.5.13 h1:3pINq0gXOSeTw2z/vYe+j80lRpSN5Rp/8mfQORh8SmU=
794794
github.com/devtron-labs/argo-workflows/v3 v3.5.13/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA=
795-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250130075053-69cdda98e3e2 h1:8QjRav7pCDb32Pz8HwbS1P8QQJ1QSDb3wJgAmNYkNeU=
796-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250130075053-69cdda98e3e2/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo=
797-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250130075053-69cdda98e3e2 h1:8VByFEk14t2z2DDaD/7pTgwSM7zFYEMqfthLWpt2M3w=
798-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250130075053-69cdda98e3e2/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA=
795+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250213085216-b49895a5c8c4 h1:JMD2Vokncnz4dUjOm3/FfajaW7OgPc6W2zo+XbDFBvQ=
796+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250213085216-b49895a5c8c4/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo=
797+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250213085216-b49895a5c8c4 h1:+24669YDx1BSew0KXQnf5UVpjHnL1QHCZPH0UQsM/6o=
798+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250213085216-b49895a5c8c4/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA=
799799
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
800800
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
801801
github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80 h1:xwbTeijNTf4/j1v+tSfwVqwLVnReas/NqEKeQHvSTys=

internal/sql/repository/AppListingRepository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ func (impl AppListingRepositoryImpl) FetchAppsByEnvironmentV2(appListingFilter h
308308

309309
// if any pipeline found get the latest deployment time
310310
if len(pipelineIds) > 0 {
311-
query := impl.appListingRepositoryQueryBuilder.BuildAppListingQueryLastDeploymentTimeV2(pipelineIds)
311+
query, queryParams := impl.appListingRepositoryQueryBuilder.BuildAppListingQueryLastDeploymentTimeV2(pipelineIds)
312312
impl.Logger.Debugw("basic app detail query: ", query)
313313
start := time.Now()
314-
_, err := impl.dbConnection.Query(&lastDeployedTimeDTO, query)
314+
_, err := impl.dbConnection.Query(&lastDeployedTimeDTO, query, queryParams...)
315315
middleware.AppListingDuration.WithLabelValues("buildAppListingQueryLastDeploymentTime", "devtron").Observe(time.Since(start).Seconds())
316316
if err != nil {
317317
impl.Logger.Errorw("error in getting latest deployment time for given pipelines", "err", err, "pipelines", pipelineIds, "query", query)

internal/sql/repository/CiArtifactRepository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ func (impl CiArtifactRepositoryImpl) GetArtifactsByCDPipelineV3(listingFilterOpt
362362
artifactsResp := make([]*CiArtifactWithExtraData, 0, listingFilterOpts.Limit)
363363
var artifacts []*CiArtifact
364364
totalCount := 0
365-
finalQuery := BuildQueryForParentTypeCIOrWebhook(*listingFilterOpts)
366-
_, err := impl.dbConnection.Query(&artifactsResp, finalQuery)
365+
finalQuery, finalQueryParams := BuildQueryForParentTypeCIOrWebhook(*listingFilterOpts)
366+
_, err := impl.dbConnection.Query(&artifactsResp, finalQuery, finalQueryParams...)
367367
if err != nil {
368368
return nil, totalCount, err
369369
}

internal/sql/repository/CiArtifactsListingQueryBuilder.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,28 @@ import (
2020
"fmt"
2121
"github.com/devtron-labs/devtron/api/bean"
2222
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
23+
"github.com/go-pg/pg"
2324
)
2425

2526
const EmptyLikeRegex = "%%"
2627

27-
func BuildQueryForParentTypeCIOrWebhook(listingFilterOpts bean.ArtifactsListFilterOptions) string {
28-
commonPaginatedQueryPart := fmt.Sprintf(" cia.image LIKE '%v'", listingFilterOpts.SearchString)
28+
func BuildQueryForParentTypeCIOrWebhook(listingFilterOpts bean.ArtifactsListFilterOptions) (string, []interface{}) {
29+
commonPaginatedQueryPart, commonPaginatedQueryParams := " cia.image LIKE ?", []interface{}{listingFilterOpts.SearchString}
2930
orderByClause := " ORDER BY cia.id DESC"
30-
limitOffsetQueryPart := fmt.Sprintf(" LIMIT %v OFFSET %v", listingFilterOpts.Limit, listingFilterOpts.Offset)
31+
limitOffsetQueryPart, limitOffsetQueryParams := fmt.Sprintf(" LIMIT ? OFFSET ?"), []interface{}{listingFilterOpts.Limit, listingFilterOpts.Offset}
3132
finalQuery := ""
33+
var finalQueryParams []interface{}
34+
var remainingQueryParams []interface{}
3235
if listingFilterOpts.ParentStageType == bean.CI_WORKFLOW_TYPE {
3336
selectQuery := " SELECT cia.* "
3437
remainingQuery := " FROM ci_artifact cia" +
3538
" INNER JOIN ci_pipeline cp ON (cp.id=cia.pipeline_id or (cp.id=cia.component_id and cia.data_source='post_ci' ) )" +
36-
" INNER JOIN pipeline p ON (p.ci_pipeline_id = cp.id and p.id=%v )" +
39+
" INNER JOIN pipeline p ON (p.ci_pipeline_id = cp.id and p.id=? )" +
3740
" WHERE "
38-
remainingQuery = fmt.Sprintf(remainingQuery, listingFilterOpts.PipelineId)
41+
remainingQueryParams = []interface{}{listingFilterOpts.PipelineId}
3942
if len(listingFilterOpts.ExcludeArtifactIds) > 0 {
40-
remainingQuery += fmt.Sprintf("cia.id NOT IN (%s) AND ", helper.GetCommaSepratedString(listingFilterOpts.ExcludeArtifactIds))
43+
remainingQuery += "cia.id NOT IN (?) AND "
44+
remainingQueryParams = append(remainingQueryParams, pg.In(listingFilterOpts.ExcludeArtifactIds))
4145
}
4246

4347
countQuery := " SELECT count(cia.id) as total_count"
@@ -47,19 +51,24 @@ func BuildQueryForParentTypeCIOrWebhook(listingFilterOpts bean.ArtifactsListFilt
4751
} else if listingFilterOpts.ParentStageType == bean.WEBHOOK_WORKFLOW_TYPE {
4852
selectQuery := " SELECT cia.* "
4953
remainingQuery := " FROM ci_artifact cia " +
50-
" WHERE cia.external_ci_pipeline_id = %v AND "
51-
remainingQuery = fmt.Sprintf(remainingQuery, listingFilterOpts.ParentId)
54+
" WHERE cia.external_ci_pipeline_id = ? AND "
55+
remainingQueryParams = []interface{}{listingFilterOpts.ParentId}
5256
if len(listingFilterOpts.ExcludeArtifactIds) > 0 {
53-
remainingQuery += fmt.Sprintf("cia.id NOT IN (%s) AND ", helper.GetCommaSepratedString(listingFilterOpts.ExcludeArtifactIds))
57+
remainingQuery += "cia.id NOT IN (?) AND "
58+
remainingQueryParams = append(remainingQueryParams, pg.In(listingFilterOpts.ExcludeArtifactIds))
5459
}
5560

5661
countQuery := " SELECT count(cia.id) as total_count"
5762
totalCountQuery := countQuery + remainingQuery + commonPaginatedQueryPart
5863
selectQuery = fmt.Sprintf("%s,(%s) ", selectQuery, totalCountQuery)
5964
finalQuery = selectQuery + remainingQuery + commonPaginatedQueryPart + orderByClause + limitOffsetQueryPart
60-
6165
}
62-
return finalQuery
66+
finalQueryParams = append(finalQueryParams, remainingQueryParams...)
67+
finalQueryParams = append(finalQueryParams, commonPaginatedQueryParams...)
68+
finalQueryParams = append(finalQueryParams, remainingQueryParams...)
69+
finalQueryParams = append(finalQueryParams, commonPaginatedQueryParams...)
70+
finalQueryParams = append(finalQueryParams, limitOffsetQueryParams...)
71+
return finalQuery, finalQueryParams
6372
}
6473

6574
func BuildQueryForArtifactsForCdStage(listingFilterOptions bean.ArtifactsListFilterOptions) string {

0 commit comments

Comments
 (0)