Skip to content

Commit e677fbd

Browse files
kartik-579ayu-devtronvikramdevtrongireesh-naiduShivam-nagar23
authored
misc: Main sync rc - branch update (#5753)
* added config sql script (#5681) * feat: CVE severity categorisation and scan result listing API enhancements (#5617) * feat: add support for app and env sorting in scan list api and add medium, high and unknown severity support * fix: query fix for appName sort or envName sort * fix: sql script number change * fix: minor changes * fix: review fix * fix: remove dml on cve_store and handle it in code handling this versioning * fix: review comments * fix: update script numbers * fix: minor fix * feat: casbin deny policy sql scripts (#5677) * system controller scripts * script additions * sql cript update * sql script number chnage * feat: Config diff phase 2 oss (#5488) * story(configDiffView) : open api spec * story(configDiffView) : open api spec updated * story(configDiffView) : open api spec updated for error state * story(configDiffView) : WIP * story(configDiffView) : WIP "some code changed" * story(configDiffView) : support for names added * story(configDiffView) : iota removed * story(configDiffView) : pg no rows handled * story(configDiffView) : spelling check * story(configDiffView) : code review comment resolved * story(configDiffView) : env id added * story(configDiffView) : intersection added * story(configDiffView) : comments removed * story(configDiffView) : code review comment resolved * story(configDiffView) : comment removed * story(configDiffView) : CMCSNames DTO moved * story(configDiffView) : null case handled * story(configDiffView) : logger added * story(configDiffView) : code refactored * story(configDiffView) : code refactored v2 * story(configDiffView) : spec updated * story(configDiffView) : code refactored * story(configDiffView) : config names * main sync * overridden and global flag introduced in config diff autocomplete api * ent sync * get config data in resthandler * new api for showing all config data in config/data :- Service func -> GetAllConfigData * using a single key instead of global and overridden key in config/autocomplete api * ConfigState made string instead of int * not sending inheriting in case base config * code review comment incorporation * ent sync * code review comment incorp -1 * code review comment incorp -2 * code review comment incorp -3 * small fix in plugin * migration number changes (#5692) * main sync * minor fix * refrain from checkin autoscalingCheckBeforeTrigger for virt clus (#5696) * fix: Decode secret fix on add update oss (#5695) * ValidateEncodedDataByDecoding in case add or update secret * wire fix from main * minor refactor * comment * saving pco concurrency case handled (#5688) * fix: script for pipelineStageStepVariable, making input value and default_value text from varchar255 (#5701) * script for pipelineStageStepVariable, making input value and default_value text from varchar255 * erro log fix * scipt number change --------- Co-authored-by: adi6859 <[email protected]> Co-authored-by: Vikram Singh <[email protected]> * fix: Helm apps entries in Ea mode (#5652) * added the ea apps entry app table * resolved the ea mode multiple rows error during configuration of app * modified the ea dockerfile in ca-certificates cmd * uncommented the code and left the ea helm app making way untouched * remodified the dockerfile as previous state * modified the docker file ea mode * dockerfile exit code 100 due to ap install alternative in ea mode dockerfile * execute make after main merge * modified changes in dockerfile ea mode * resolved comments after first level review * executed make after merging with develop branch * feat: refactoring deployment app name usage (#5702) * removing hard coded deployment app name * removing %s-%s usage * wip: query change for enterprise * wip * wip * wip * adding release mode in deployment config * wip: release changes * left join on pco and artifact * handling empty release mode - backward compatibility * fixing panic * migration number changes (#5692) * refrain from checkin autoscalingCheckBeforeTrigger for virt clus (#5696) * fix: Decode secret fix on add update oss (#5695) * ValidateEncodedDataByDecoding in case add or update secret * wire fix from main * minor refactor * comment * saving pco concurrency case handled (#5688) * migration updated * main merge and migration script updated * wip * review changes * fix sql no --------- Co-authored-by: Prakash <[email protected]> * migration syn with ent (#5719) * fix: group image vulnerabilities by base/os image (#5680) * feat: add support for app and env sorting in scan list api and add medium, high and unknown severity support * fix: query fix for appName sort or envName sort * fix: sql script number change * fix: minor changes * fix: review fix * fix: remove dml on cve_store and handle it in code handling this versioning * fix: review comments * feat: storing target,class and type values in imageScanExecutionResults * feat: add sql script * feat: add sql script * fix: add new columns * fix: update script numbers * fix: correct down script * fix: minor fix * chore: script number update * fix: remove sql script (#5727) * Revert "fix: Helm apps entries in Ea mode (#5652)" (#5733) This reverts commit f1aa1fc. * chore: custom argo-workflow dependency (#5731) * bumped github.com/argoproj/argo-workflows/v3 v3.5.10 => github.com/devtron-labs/argo-workflows/v3 v3.5.10 * migration number changes (#5692) * refrain from checkin autoscalingCheckBeforeTrigger for virt clus (#5696) * fix: Decode secret fix on add update oss (#5695) * ValidateEncodedDataByDecoding in case add or update secret * wire fix from main * minor refactor * comment * saving pco concurrency case handled (#5688) * fix: script for pipelineStageStepVariable, making input value and default_value text from varchar255 (#5701) * script for pipelineStageStepVariable, making input value and default_value text from varchar255 * erro log fix * fix: ea fixes for helm app (#5708) * added the ea apps entry app table * resolved the ea mode multiple rows error during configuration of app * modified the ea dockerfile in ca-certificates cmd * uncommented the code and left the ea helm app making way untouched * remodified the dockerfile as previous state * modified the docker file ea mode * dockerfile exit code 100 due to ap install alternative in ea mode dockerfile * execute make after main merge * modified changes in dockerfile ea mode * resolved comments after first level review * Revert "fix: ea fixes for helm app (#5708)" (#5713) This reverts commit 3e31f49. * fix: SkipCiBuildCachePushPull code incorporated with minor refac in handle runtime params validation (#5712) * SkipCiBuildCachePushPull code incorporated with minor refac in handle runtime params validation * minor refactor * minor refactor * migration syn with ent (#5718) * reverted main branch changes * reverted main branch changes --------- Co-authored-by: Prakash <[email protected]> Co-authored-by: Rajeev Ranjan <[email protected]> Co-authored-by: prakhar katiyar <[email protected]> * chore: fix go.sum file (#5734) * misc: Main sync develop (#5737) * migration number changes (#5692) * refrain from checkin autoscalingCheckBeforeTrigger for virt clus (#5696) * fix: Decode secret fix on add update oss (#5695) * ValidateEncodedDataByDecoding in case add or update secret * wire fix from main * minor refactor * comment * saving pco concurrency case handled (#5688) * fix: script for pipelineStageStepVariable, making input value and default_value text from varchar255 (#5701) * script for pipelineStageStepVariable, making input value and default_value text from varchar255 * erro log fix * fix: ea fixes for helm app (#5708) * added the ea apps entry app table * resolved the ea mode multiple rows error during configuration of app * modified the ea dockerfile in ca-certificates cmd * uncommented the code and left the ea helm app making way untouched * remodified the dockerfile as previous state * modified the docker file ea mode * dockerfile exit code 100 due to ap install alternative in ea mode dockerfile * execute make after main merge * modified changes in dockerfile ea mode * resolved comments after first level review * Revert "fix: ea fixes for helm app (#5708)" (#5713) This reverts commit 3e31f49. * fix: SkipCiBuildCachePushPull code incorporated with minor refac in handle runtime params validation (#5712) * SkipCiBuildCachePushPull code incorporated with minor refac in handle runtime params validation * minor refactor * minor refactor * migration syn with ent (#5718) --------- Co-authored-by: Prakash <[email protected]> Co-authored-by: Rajeev Ranjan <[email protected]> Co-authored-by: prakhar katiyar <[email protected]> * fix: Validate config cm cs (#5750) * validateConfigRequest before CMGlobalAddUpdate and CSGlobalAddUpdate * checkIfConfigDataAlreadyExist --------- Co-authored-by: ayu-devtron <[email protected]> Co-authored-by: Vikram Singh <[email protected]> Co-authored-by: Gireesh Naidu <[email protected]> Co-authored-by: Shivam Nagar <[email protected]> Co-authored-by: Prakash <[email protected]> Co-authored-by: adi6859 <[email protected]> Co-authored-by: Rajeev Ranjan <[email protected]> Co-authored-by: iamayushm <[email protected]> Co-authored-by: prakhar katiyar <[email protected]> Co-authored-by: Asutosh Das <[email protected]> Co-authored-by: Vikram <[email protected]> Co-authored-by: Prakarsh <[email protected]>
1 parent 26784d5 commit e677fbd

File tree

681 files changed

+16842
-109674
lines changed

Some content is hidden

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

681 files changed

+16842
-109674
lines changed

Wire.go

+8
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ import (
125125
"github.com/devtron-labs/devtron/pkg/chart/gitOpsConfig"
126126
chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
127127
"github.com/devtron-labs/devtron/pkg/commonService"
128+
"github.com/devtron-labs/devtron/pkg/configDiff"
128129
delete2 "github.com/devtron-labs/devtron/pkg/delete"
129130
deployment2 "github.com/devtron-labs/devtron/pkg/deployment"
130131
"github.com/devtron-labs/devtron/pkg/deployment/common"
@@ -711,6 +712,13 @@ func InitializeApp() (*App, error) {
711712
scopedVariable.NewScopedVariableRestHandlerImpl,
712713
wire.Bind(new(scopedVariable.ScopedVariableRestHandler), new(*scopedVariable.ScopedVariableRestHandlerImpl)),
713714

715+
router.NewDeploymentConfigurationRouter,
716+
wire.Bind(new(router.DeploymentConfigurationRouter), new(*router.DeploymentConfigurationRouterImpl)),
717+
restHandler.NewDeploymentConfigurationRestHandlerImpl,
718+
wire.Bind(new(restHandler.DeploymentConfigurationRestHandler), new(*restHandler.DeploymentConfigurationRestHandlerImpl)),
719+
configDiff.NewDeploymentConfigurationServiceImpl,
720+
wire.Bind(new(configDiff.DeploymentConfigurationService), new(*configDiff.DeploymentConfigurationServiceImpl)),
721+
714722
router.NewTelemetryRouterImpl,
715723
wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)),
716724
restHandler.NewTelemetryRestHandlerImpl,

api/bean/AppView.go

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ type AppEnvironmentContainer struct {
144144
type DeploymentDetailContainer struct {
145145
InstalledAppId int `json:"installedAppId,omitempty"`
146146
AppId int `json:"appId,omitempty"`
147+
PcoId int `json:"pcoId"`
147148
CdPipelineId int `json:"cdPipelineId,omitempty"`
148149
TriggerType string `json:"triggerType,omitempty"`
149150
ParentEnvironmentName string `json:"parentEnvironmentName"`
@@ -183,6 +184,8 @@ type DeploymentDetailContainer struct {
183184
HelmPackageName string `json:"helmPackageName"`
184185
HelmReleaseInstallStatus string `json:"-"`
185186
DeploymentConfig *bean.DeploymentConfig `json:"-"`
187+
IsPipelineTriggered bool `json:"isPipelineTriggered"`
188+
ReleaseMode string `json:"releaseMode"`
186189
}
187190

188191
type AppDetailContainer struct {

api/helm-app/gRPC/applist.pb.go

+100-94
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/helm-app/gRPC/applist.proto

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ service ApplicationService {
4444
rpc ValidateOCIRegistry(RegistryCredential) returns(OCIRegistryResponse) {}
4545
rpc GetResourceTreeForExternalResources(ExternalResourceTreeRequest) returns(ResourceTreeResponse){}
4646
rpc GetFluxAppDetail(FluxAppDetailRequest)returns(FluxAppDetail){}
47+
rpc GetReleaseDetails(ReleaseIdentifier)returns(DeployedAppDetail){}
4748

4849
}
4950

api/helm-app/gRPC/applist_grpc.pb.go

+111-47
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/helm-app/service/HelmAppService.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ func (impl *HelmAppServiceImpl) appListRespProtoTransformer(deployedApps *gRPC.D
11361136
// do not add app in the list which are created using cd_pipelines (check combination of clusterId, namespace, releaseName)
11371137
var toExcludeFromList bool
11381138
for _, helmCdPipeline := range helmCdPipelines {
1139-
helmAppReleaseName := util2.BuildDeployedAppName(helmCdPipeline.App.AppName, helmCdPipeline.Environment.Name)
1139+
helmAppReleaseName := helmCdPipeline.DeploymentAppName
11401140
if deployedapp.AppName == helmAppReleaseName && int(deployedapp.EnvironmentDetail.ClusterId) == helmCdPipeline.Environment.ClusterId && deployedapp.EnvironmentDetail.Namespace == helmCdPipeline.Environment.Namespace {
11411141
toExcludeFromList = true
11421142
break
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
package restHandler
2+
3+
import (
4+
"fmt"
5+
"github.com/devtron-labs/devtron/api/restHandler/common"
6+
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
7+
"github.com/devtron-labs/devtron/pkg/auth/user"
8+
"github.com/devtron-labs/devtron/pkg/configDiff"
9+
"github.com/devtron-labs/devtron/pkg/configDiff/bean"
10+
"github.com/devtron-labs/devtron/util/rbac"
11+
"github.com/gorilla/schema"
12+
"go.uber.org/zap"
13+
"gopkg.in/go-playground/validator.v9"
14+
"net/http"
15+
)
16+
17+
type DeploymentConfigurationRestHandler interface {
18+
ConfigAutoComplete(w http.ResponseWriter, r *http.Request)
19+
GetConfigData(w http.ResponseWriter, r *http.Request)
20+
}
21+
type DeploymentConfigurationRestHandlerImpl struct {
22+
logger *zap.SugaredLogger
23+
userAuthService user.UserService
24+
validator *validator.Validate
25+
enforcerUtil rbac.EnforcerUtil
26+
deploymentConfigurationService configDiff.DeploymentConfigurationService
27+
enforcer casbin.Enforcer
28+
}
29+
30+
func NewDeploymentConfigurationRestHandlerImpl(logger *zap.SugaredLogger,
31+
userAuthService user.UserService,
32+
enforcerUtil rbac.EnforcerUtil,
33+
deploymentConfigurationService configDiff.DeploymentConfigurationService,
34+
enforcer casbin.Enforcer,
35+
) *DeploymentConfigurationRestHandlerImpl {
36+
return &DeploymentConfigurationRestHandlerImpl{
37+
logger: logger,
38+
userAuthService: userAuthService,
39+
enforcerUtil: enforcerUtil,
40+
deploymentConfigurationService: deploymentConfigurationService,
41+
enforcer: enforcer,
42+
}
43+
}
44+
45+
func (handler *DeploymentConfigurationRestHandlerImpl) ConfigAutoComplete(w http.ResponseWriter, r *http.Request) {
46+
userId, err := handler.userAuthService.GetLoggedInUser(r)
47+
if userId == 0 || err != nil {
48+
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
49+
return
50+
}
51+
appId, err := common.ExtractIntQueryParam(w, r, "appId", 0)
52+
if err != nil {
53+
return
54+
}
55+
envId, err := common.ExtractIntQueryParam(w, r, "envId", 0)
56+
if err != nil {
57+
return
58+
}
59+
60+
//RBAC START
61+
token := r.Header.Get(common.TokenHeaderKey)
62+
object := handler.enforcerUtil.GetAppRBACNameByAppId(appId)
63+
ok := handler.enforcerUtil.CheckAppRbacForAppOrJob(token, object, casbin.ActionGet)
64+
if !ok {
65+
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), nil, http.StatusForbidden)
66+
return
67+
}
68+
//RBAC END
69+
70+
res, err := handler.deploymentConfigurationService.ConfigAutoComplete(appId, envId)
71+
if err != nil {
72+
handler.logger.Errorw("service err, ConfigAutoComplete ", "appId", appId, "envId", envId, "err", err)
73+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
74+
return
75+
}
76+
common.WriteJsonResp(w, err, res, http.StatusOK)
77+
}
78+
79+
func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.ResponseWriter, r *http.Request) {
80+
userId, err := handler.userAuthService.GetLoggedInUser(r)
81+
if userId == 0 || err != nil {
82+
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
83+
return
84+
}
85+
configDataQueryParams, err := getConfigDataQueryParams(r)
86+
if err != nil {
87+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
88+
return
89+
}
90+
91+
//RBAC START
92+
token := r.Header.Get(common.TokenHeaderKey)
93+
object := handler.enforcerUtil.GetAppRBACName(configDataQueryParams.AppName)
94+
ok := handler.enforcerUtil.CheckAppRbacForAppOrJob(token, object, casbin.ActionGet)
95+
if !ok {
96+
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), nil, http.StatusForbidden)
97+
return
98+
}
99+
//RBAC END
100+
101+
res, err := handler.deploymentConfigurationService.GetAllConfigData(r.Context(), configDataQueryParams)
102+
if err != nil {
103+
handler.logger.Errorw("service err, GetAllConfigData ", "err", err)
104+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
105+
return
106+
}
107+
res.IsAppAdmin = handler.enforceForAppAndEnv(configDataQueryParams.AppName, configDataQueryParams.EnvName, token, casbin.ActionUpdate)
108+
109+
common.WriteJsonResp(w, nil, res, http.StatusOK)
110+
}
111+
112+
func (handler *DeploymentConfigurationRestHandlerImpl) enforceForAppAndEnv(appName, envName string, token string, action string) bool {
113+
object := handler.enforcerUtil.GetAppRBACNameByAppName(appName)
114+
if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, action, object); !ok {
115+
return false
116+
}
117+
118+
object = handler.enforcerUtil.GetEnvRBACNameByAppAndEnvName(appName, envName)
119+
if ok := handler.enforcer.Enforce(token, casbin.ResourceEnvironment, action, object); !ok {
120+
return false
121+
}
122+
return true
123+
}
124+
func getConfigDataQueryParams(r *http.Request) (*bean.ConfigDataQueryParams, error) {
125+
v := r.URL.Query()
126+
var decoder = schema.NewDecoder()
127+
decoder.IgnoreUnknownKeys(true)
128+
queryParams := bean.ConfigDataQueryParams{}
129+
err := decoder.Decode(&queryParams, v)
130+
if err != nil {
131+
return nil, err
132+
}
133+
134+
return &queryParams, nil
135+
}

api/restHandler/ImageScanRestHandler.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package restHandler
1919
import (
2020
"encoding/json"
2121
"fmt"
22+
securityBean "github.com/devtron-labs/devtron/pkg/security/bean"
2223
"net/http"
2324
"strconv"
2425

@@ -70,7 +71,7 @@ func (impl ImageScanRestHandlerImpl) ScanExecutionList(w http.ResponseWriter, r
7071
}
7172

7273
decoder := json.NewDecoder(r.Body)
73-
var request *security.ImageScanRequest
74+
var request *securityBean.ImageScanRequest
7475
err = decoder.Decode(&request)
7576
if err != nil {
7677
impl.logger.Errorw("request err, ScanExecutionList", "err", err, "payload", request)
@@ -82,8 +83,8 @@ func (impl ImageScanRestHandlerImpl) ScanExecutionList(w http.ResponseWriter, r
8283
if err != nil {
8384
impl.logger.Errorw("service err, ScanExecutionList", "err", err, "payload", request)
8485
if util.IsErrNoRows(err) {
85-
responseList := make([]*security.ImageScanHistoryResponse, 0)
86-
common.WriteJsonResp(w, nil, &security.ImageScanHistoryListingResponse{ImageScanHistoryResponse: responseList}, http.StatusOK)
86+
responseList := make([]*securityBean.ImageScanHistoryResponse, 0)
87+
common.WriteJsonResp(w, nil, &securityBean.ImageScanHistoryListingResponse{ImageScanHistoryResponse: responseList}, http.StatusOK)
8788
} else {
8889
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
8990
}
@@ -126,8 +127,8 @@ func (impl ImageScanRestHandlerImpl) ScanExecutionList(w http.ResponseWriter, r
126127
if err != nil {
127128
impl.logger.Errorw("service err, ScanExecutionList", "err", err, "payload", request)
128129
if util.IsErrNoRows(err) {
129-
responseList := make([]*security.ImageScanHistoryResponse, 0)
130-
common.WriteJsonResp(w, nil, &security.ImageScanHistoryListingResponse{ImageScanHistoryResponse: responseList}, http.StatusOK)
130+
responseList := make([]*securityBean.ImageScanHistoryResponse, 0)
131+
common.WriteJsonResp(w, nil, &securityBean.ImageScanHistoryListingResponse{ImageScanHistoryResponse: responseList}, http.StatusOK)
131132
} else {
132133
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
133134
}
@@ -177,7 +178,7 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
177178
}
178179
}
179180
image := v.Get("image")
180-
request := &security.ImageScanRequest{
181+
request := &securityBean.ImageScanRequest{
181182
ImageScanDeployInfoId: imageScanDeployInfoId,
182183
Image: image,
183184
ArtifactId: artifactId,
@@ -189,7 +190,7 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
189190
if err != nil {
190191
impl.logger.Errorw("service err, FetchExecutionDetail", "err", err, "payload", request)
191192
if util.IsErrNoRows(err) {
192-
common.WriteJsonResp(w, nil, &security.ImageScanExecutionDetail{}, http.StatusOK)
193+
common.WriteJsonResp(w, nil, &securityBean.ImageScanExecutionDetail{}, http.StatusOK)
193194
} else {
194195
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
195196
}
@@ -221,7 +222,7 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
221222
}
222223
//RBAC
223224
} else {
224-
common.WriteJsonResp(w, err, &security.ImageScanExecutionDetail{}, http.StatusOK)
225+
common.WriteJsonResp(w, err, &securityBean.ImageScanExecutionDetail{}, http.StatusOK)
225226
}
226227

227228
common.WriteJsonResp(w, err, executionDetail, http.StatusOK)
@@ -230,7 +231,7 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
230231
func (impl ImageScanRestHandlerImpl) FetchMinScanResultByAppIdAndEnvId(w http.ResponseWriter, r *http.Request) {
231232
v := r.URL.Query()
232233
var appId, envId int
233-
request := &security.ImageScanRequest{}
234+
request := &securityBean.ImageScanRequest{}
234235
appIds := v.Get("appId")
235236
if len(appIds) > 0 {
236237
appId, err := strconv.Atoi(appIds)
@@ -299,8 +300,8 @@ func (impl ImageScanRestHandlerImpl) VulnerabilityExposure(w http.ResponseWriter
299300
if err != nil {
300301
impl.logger.Errorw("service err, VulnerabilityExposure", "err", err, "payload", request)
301302
if util.IsErrNoRows(err) {
302-
responseList := make([]*security.ImageScanHistoryResponse, 0)
303-
common.WriteJsonResp(w, nil, &security.ImageScanHistoryListingResponse{ImageScanHistoryResponse: responseList}, http.StatusOK)
303+
responseList := make([]*securityBean.ImageScanHistoryResponse, 0)
304+
common.WriteJsonResp(w, nil, &securityBean.ImageScanHistoryListingResponse{ImageScanHistoryResponse: responseList}, http.StatusOK)
304305
} else {
305306
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
306307
}

api/restHandler/PolicyRestHandler.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import (
2020
"encoding/json"
2121
"errors"
2222
"fmt"
23+
securityBean "github.com/devtron-labs/devtron/internal/sql/repository/security/bean"
2324
"net/http"
2425
"strconv"
2526

2627
"github.com/devtron-labs/devtron/api/bean"
2728
"github.com/devtron-labs/devtron/api/restHandler/common"
28-
security2 "github.com/devtron-labs/devtron/internal/sql/repository/security"
2929
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
3030
user2 "github.com/devtron-labs/devtron/pkg/auth/user"
3131
"github.com/devtron-labs/devtron/pkg/cluster"
@@ -221,18 +221,18 @@ func (impl PolicyRestHandlerImpl) GetPolicy(w http.ResponseWriter, r *http.Reque
221221
req.Id = ids
222222
}
223223
var clusterId, environmentId, appId int
224-
var policyLevel security2.PolicyLevel
225-
if level == security2.Global.String() {
226-
policyLevel = security2.Global
227-
} else if level == security2.Cluster.String() {
224+
var policyLevel securityBean.PolicyLevel
225+
if level == securityBean.Global.String() {
226+
policyLevel = securityBean.Global
227+
} else if level == securityBean.Cluster.String() {
228228
clusterId = req.Id
229-
policyLevel = security2.Cluster
230-
} else if level == security2.Environment.String() {
229+
policyLevel = securityBean.Cluster
230+
} else if level == securityBean.Environment.String() {
231231
environmentId = req.Id
232-
policyLevel = security2.Environment
233-
} else if level == security2.Application.String() {
232+
policyLevel = securityBean.Environment
233+
} else if level == securityBean.Application.String() {
234234
appId = req.Id
235-
policyLevel = security2.Application
235+
policyLevel = securityBean.Application
236236
}
237237

238238
token := r.Header.Get("token")

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

+5
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ func (handler *PipelineConfigRestHandlerImpl) CreateCdPipeline(w http.ResponseWr
207207
handler.Logger.Infow("request payload, CreateCdPipeline", "payload", cdPipeline)
208208
userUploaded, err := handler.chartService.CheckIfChartRefUserUploadedByAppId(cdPipeline.AppId)
209209
if !userUploaded {
210+
for i, p := range cdPipeline.Pipelines {
211+
if len(p.ReleaseMode) == 0 {
212+
cdPipeline.Pipelines[i].ReleaseMode = util.PIPELINE_RELEASE_MODE_CREATE
213+
}
214+
}
210215
err = handler.validator.Struct(cdPipeline)
211216
if err != nil {
212217
handler.Logger.Errorw("validation err, CreateCdPipeline", "err", err, "payload", cdPipeline)

api/router/DeploymentConfigRouter.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package router
2+
3+
import (
4+
"github.com/devtron-labs/devtron/api/restHandler"
5+
"github.com/gorilla/mux"
6+
)
7+
8+
type DeploymentConfigurationRouter interface {
9+
initDeploymentConfigurationRouter(configRouter *mux.Router)
10+
}
11+
12+
type DeploymentConfigurationRouterImpl struct {
13+
deploymentGroupRestHandler restHandler.DeploymentConfigurationRestHandler
14+
}
15+
16+
func NewDeploymentConfigurationRouter(deploymentGroupRestHandler restHandler.DeploymentConfigurationRestHandler) *DeploymentConfigurationRouterImpl {
17+
router := &DeploymentConfigurationRouterImpl{
18+
deploymentGroupRestHandler: deploymentGroupRestHandler,
19+
}
20+
return router
21+
}
22+
23+
func (router DeploymentConfigurationRouterImpl) initDeploymentConfigurationRouter(configRouter *mux.Router) {
24+
configRouter.Path("/autocomplete").
25+
HandlerFunc(router.deploymentGroupRestHandler.ConfigAutoComplete).
26+
Methods("GET")
27+
configRouter.Path("/data").
28+
HandlerFunc(router.deploymentGroupRestHandler.GetConfigData).
29+
Methods("GET")
30+
31+
}

api/router/router.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ type MuxRouter struct {
114114
rbacRoleRouter user.RbacRoleRouter
115115
scopedVariableRouter ScopedVariableRouter
116116
ciTriggerCron cron.CiTriggerCron
117+
deploymentConfigurationRouter DeploymentConfigurationRouter
117118
infraConfigRouter infraConfig.InfraConfigRouter
118119
argoApplicationRouter argoApplication.ArgoApplicationRouter
119120
fluxApplicationRouter fluxApplication2.FluxApplicationRouter
@@ -146,6 +147,7 @@ func NewMuxRouter(logger *zap.SugaredLogger,
146147
scopedVariableRouter ScopedVariableRouter,
147148
ciTriggerCron cron.CiTriggerCron,
148149
proxyRouter proxy.ProxyRouter,
150+
deploymentConfigurationRouter DeploymentConfigurationRouter,
149151
infraConfigRouter infraConfig.InfraConfigRouter,
150152
argoApplicationRouter argoApplication.ArgoApplicationRouter,
151153
devtronResourceRouter devtronResource.DevtronResourceRouter,
@@ -210,6 +212,7 @@ func NewMuxRouter(logger *zap.SugaredLogger,
210212
rbacRoleRouter: rbacRoleRouter,
211213
scopedVariableRouter: scopedVariableRouter,
212214
ciTriggerCron: ciTriggerCron,
215+
deploymentConfigurationRouter: deploymentConfigurationRouter,
213216
infraConfigRouter: infraConfigRouter,
214217
argoApplicationRouter: argoApplicationRouter,
215218
devtronResourceRouter: devtronResourceRouter,
@@ -293,8 +296,9 @@ func (r MuxRouter) Init() {
293296
chartRefRouter := r.Router.PathPrefix("/orchestrator/chartref").Subrouter()
294297
r.ChartRefRouter.initChartRefRouter(chartRefRouter)
295298

296-
configMapRouter := r.Router.PathPrefix("/orchestrator/config").Subrouter()
297-
r.ConfigMapRouter.initConfigMapRouter(configMapRouter)
299+
configRouter := r.Router.PathPrefix("/orchestrator/config").Subrouter()
300+
r.ConfigMapRouter.initConfigMapRouter(configRouter)
301+
r.deploymentConfigurationRouter.initDeploymentConfigurationRouter(configRouter)
298302

299303
appStoreRouter := r.Router.PathPrefix("/orchestrator/app-store").Subrouter()
300304
r.AppStoreRouter.Init(appStoreRouter)

0 commit comments

Comments
 (0)