Skip to content

Commit a83f5cc

Browse files
committed
code review :- 1
1 parent ae9c3aa commit a83f5cc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

api/restHandler/DeploymentConfigurationRestHandler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp
104104
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*")
105105
userHasAdminAccess := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, object)
106106
ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second)
107-
ctx = util2.SetSuperAdminInContext(ctx, isSuperAdmin)
108107
defer cancel()
108+
ctx = util2.SetSuperAdminInContext(ctx, isSuperAdmin)
109109
res, err := handler.deploymentConfigurationService.GetAllConfigData(ctx, configDataQueryParams, userHasAdminAccess)
110110
if err != nil {
111111
handler.logger.Errorw("service err, GetAllConfigData ", "err", err)

pkg/configDiff/DeploymentConfigurationService.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context
263263
var configData []*bean.ConfigData
264264
configList := pipeline.ConfigsList{}
265265
secretList := bean.SecretsList{}
266-
if configType == repository3.CONFIGMAP_TYPE {
266+
switch configType {
267+
case repository3.CONFIGMAP_TYPE:
267268
if len(history.Data) > 0 {
268269
err = json.Unmarshal([]byte(history.Data), &configList)
269270
if err != nil {
@@ -273,7 +274,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context
273274
}
274275
resourceType = bean.CM
275276
configData = configList.ConfigData
276-
} else if configType == repository3.SECRET_TYPE {
277+
case repository3.SECRET_TYPE:
277278
if len(history.Data) > 0 {
278279
err = json.Unmarshal([]byte(history.Data), &secretList)
279280
if err != nil {
@@ -283,6 +284,7 @@ func (impl *DeploymentConfigurationServiceImpl) getCmCsConfigHistory(ctx context
283284
}
284285
resourceType = bean.CS
285286
configData = secretList.ConfigData
287+
286288
}
287289

288290
resolvedDataMap, variableSnapshotMap, err := impl.scopedVariableManager.GetResolvedCMCSHistoryDtos(ctx, configType, adaptor.ReverseConfigListConvertor(configList), history, adaptor.ReverseSecretListConvertor(secretList))
@@ -632,7 +634,6 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedConfigData(ctx conte
632634
}
633635

634636
func (impl *DeploymentConfigurationServiceImpl) getPublishedPipelineStrategyConfig(ctx context.Context, appId int, envId int) (*bean2.DeploymentAndCmCsConfig, error) {
635-
pipelineStrategyJson := json.RawMessage{}
636637
pipelineConfig := bean2.NewDeploymentAndCmCsConfig()
637638
if envId == 0 {
638639
return pipelineConfig, nil
@@ -649,6 +650,7 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedPipelineStrategyConf
649650
} else if errors.IsNotFound(err) {
650651
return pipelineConfig, nil
651652
}
653+
pipelineStrategyJson := json.RawMessage{}
652654
err = pipelineStrategyJson.UnmarshalJSON([]byte(pipelineStrategy.CodeEditorValue.Value))
653655
if err != nil {
654656
impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message", "err", err)

0 commit comments

Comments
 (0)