Skip to content

Commit 25eb9e2

Browse files
Laeeqdevkishan789dev
authored andcommitted
resolved PR review comments also remove check for virtual cluster (#5095)
1 parent 0bcf3b9 commit 25eb9e2

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

api/helm-app/service/HelmAppService.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type HelmAppService interface {
7373
ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *gRPC.RegistryCredential) bool
7474
GetRevisionHistoryMaxValue(appType bean.SourceAppType) int32
7575
GetResourceTreeForExternalResources(ctx context.Context, clusterId int, clusterConfig *gRPC.ClusterConfig, resources []*gRPC.ExternalResourceDetail) (*gRPC.ResourceTreeResponse, error)
76-
CheckIfNsExistsForClusterIds(clusterIdToNsMap map[int]string, clusterIds []int) error
76+
CheckIfNsExistsForClusterIds(clusterIdToNsMap map[int]string) error
7777
}
7878

7979
type HelmAppServiceImpl struct {
@@ -540,9 +540,7 @@ func (impl *HelmAppServiceImpl) DeleteApplication(ctx context.Context, app *AppI
540540
clusterIdToNsMap := map[int]string{
541541
app.ClusterId: app.Namespace,
542542
}
543-
clusterId := make([]int, 0)
544-
clusterId = append(clusterId, app.ClusterId)
545-
err = impl.CheckIfNsExistsForClusterIds(clusterIdToNsMap, clusterId)
543+
err = impl.CheckIfNsExistsForClusterIds(clusterIdToNsMap)
546544
if err != nil {
547545
return nil, err
548546
}
@@ -1111,14 +1109,20 @@ func (impl *HelmAppServiceImpl) GetRevisionHistoryMaxValue(appType bean.SourceAp
11111109
return 0
11121110
}
11131111
}
1114-
func (impl *HelmAppServiceImpl) CheckIfNsExistsForClusterIds(clusterIdToNsMap map[int]string, clusterIds []int) error {
1115-
1112+
func (impl *HelmAppServiceImpl) CheckIfNsExistsForClusterIds(clusterIdToNsMap map[int]string) error {
1113+
clusterIds := make([]int, 0)
1114+
for clusterId, _ := range clusterIdToNsMap {
1115+
clusterIds = append(clusterIds, clusterId)
1116+
}
11161117
clusterBeans, err := impl.clusterService.FindByIds(clusterIds)
11171118
if err != nil {
11181119
impl.logger.Errorw("error in getting cluster bean", "error", err, "clusterIds", clusterIds)
11191120
return err
11201121
}
11211122
for _, clusterBean := range clusterBeans {
1123+
if clusterBean.IsVirtualCluster {
1124+
continue
1125+
}
11221126
if namespace, ok := clusterIdToNsMap[clusterBean.Id]; ok {
11231127
exists, err := impl.checkIfNsExists(namespace, &clusterBean)
11241128
if err != nil {

pkg/appStore/installedApp/service/AppStoreDeploymentService.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ func (impl *AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *
142142
clusterIdToNsMap := map[int]string{
143143
installAppVersionRequest.ClusterId: installAppVersionRequest.Namespace,
144144
}
145-
clusterId := make([]int, 0)
146-
clusterId = append(clusterId, installAppVersionRequest.ClusterId)
147-
err = impl.helmAppService.CheckIfNsExistsForClusterIds(clusterIdToNsMap, clusterId)
145+
err = impl.helmAppService.CheckIfNsExistsForClusterIds(clusterIdToNsMap)
148146
if err != nil {
149147
return nil, err
150148
}
@@ -583,9 +581,8 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex
583581
clusterIdToNsMap := map[int]string{
584582
installedApp.Environment.ClusterId: installedApp.Environment.Namespace,
585583
}
586-
clusterId := make([]int, 0)
587-
clusterId = append(clusterId, installedApp.Environment.ClusterId)
588-
err = impl.helmAppService.CheckIfNsExistsForClusterIds(clusterIdToNsMap, clusterId)
584+
585+
err = impl.helmAppService.CheckIfNsExistsForClusterIds(clusterIdToNsMap)
589586
if err != nil {
590587
return nil, err
591588
}

pkg/deployment/trigger/devtronApps/TriggerService.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,7 @@ func (impl *TriggerServiceImpl) ManualCdTrigger(triggerContext bean.TriggerConte
294294
clusterIdToNsMap := map[int]string{
295295
cdPipeline.Environment.ClusterId: cdPipeline.Environment.Namespace,
296296
}
297-
clusterId := make([]int, 0)
298-
clusterId = append(clusterId, cdPipeline.Environment.ClusterId)
299-
err = impl.helmAppService.CheckIfNsExistsForClusterIds(clusterIdToNsMap, clusterId)
297+
err = impl.helmAppService.CheckIfNsExistsForClusterIds(clusterIdToNsMap)
300298
if err != nil {
301299
return 0, err
302300
}

pkg/pipeline/DeploymentPipelineConfigService.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,12 +2077,11 @@ func (impl *CdPipelineConfigServiceImpl) checkIfNsExistsForEnvIds(envIds []*int)
20772077
return fmt.Errorf("error in fetching environment err:", err)
20782078
}
20792079
clusterIdToNsMap := make(map[int]string, 0)
2080-
clusterIds := make([]int, 0)
20812080
for _, environment := range environmentList {
2082-
clusterIds = append(clusterIds, environment.ClusterId)
2081+
20832082
clusterIdToNsMap[environment.ClusterId] = environment.Namespace
20842083
}
2085-
err = impl.helmAppService.CheckIfNsExistsForClusterIds(clusterIdToNsMap, clusterIds)
2084+
err = impl.helmAppService.CheckIfNsExistsForClusterIds(clusterIdToNsMap)
20862085
if err != nil {
20872086
return err
20882087
}

0 commit comments

Comments
 (0)