-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:devtron-labs/devtron into cdwork…
…flow-read
- Loading branch information
Showing
18 changed files
with
818 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package configDiff | ||
|
||
import ( | ||
"errors" | ||
"github.com/devtron-labs/devtron/pkg/configDiff/bean" | ||
) | ||
|
||
var validConfigCategories = map[string]bool{bean.Secret.ToString(): true, bean.ConfigMap.ToString(): true, bean.DeploymentTemplate.ToString(): true, bean.PipelineStrategy.ToString(): true} | ||
var ErrInvalidConfigCategory = errors.New("invalid config category provided") | ||
var ErrInvalidComparisonItems = errors.New("invalid comparison items, only 2 items are supported for comparison") | ||
var ErrInvalidIndexValInComparisonItems = errors.New("invalid index values in comparison items") | ||
|
||
func validateComparisonRequest(configCategory string, comparisonRequestDto bean.ComparisonRequestDto) error { | ||
if ok := validConfigCategories[configCategory]; !ok { | ||
return ErrInvalidConfigCategory | ||
} | ||
// comparison items expects exactly two items | ||
if len(comparisonRequestDto.ComparisonItems) != 2 { | ||
return ErrInvalidComparisonItems | ||
} | ||
// if index value is other than 0 or 1 then throw invalid index error | ||
if len(comparisonRequestDto.ComparisonItems) > 1 && (comparisonRequestDto.ComparisonItems[0].Index != 0 && comparisonRequestDto.ComparisonItems[1].Index != 1) { | ||
return ErrInvalidIndexValInComparisonItems | ||
} | ||
return nil | ||
} |
15 changes: 9 additions & 6 deletions
15
api/router/DeploymentConfigRouter.go → .../app/configDiff/DeploymentConfigRouter.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
package router | ||
package configDiff | ||
|
||
import ( | ||
"github.com/devtron-labs/devtron/api/restHandler" | ||
"github.com/devtron-labs/devtron/api/restHandler/app/configDiff" | ||
"github.com/gorilla/mux" | ||
) | ||
|
||
type DeploymentConfigurationRouter interface { | ||
initDeploymentConfigurationRouter(configRouter *mux.Router) | ||
InitDeploymentConfigurationRouter(configRouter *mux.Router) | ||
} | ||
|
||
type DeploymentConfigurationRouterImpl struct { | ||
deploymentGroupRestHandler restHandler.DeploymentConfigurationRestHandler | ||
deploymentGroupRestHandler configDiff.DeploymentConfigurationRestHandler | ||
} | ||
|
||
func NewDeploymentConfigurationRouter(deploymentGroupRestHandler restHandler.DeploymentConfigurationRestHandler) *DeploymentConfigurationRouterImpl { | ||
func NewDeploymentConfigurationRouter(deploymentGroupRestHandler configDiff.DeploymentConfigurationRestHandler) *DeploymentConfigurationRouterImpl { | ||
router := &DeploymentConfigurationRouterImpl{ | ||
deploymentGroupRestHandler: deploymentGroupRestHandler, | ||
} | ||
return router | ||
} | ||
|
||
func (router DeploymentConfigurationRouterImpl) initDeploymentConfigurationRouter(configRouter *mux.Router) { | ||
func (router DeploymentConfigurationRouterImpl) InitDeploymentConfigurationRouter(configRouter *mux.Router) { | ||
configRouter.Path("/autocomplete"). | ||
HandlerFunc(router.deploymentGroupRestHandler.ConfigAutoComplete). | ||
Methods("GET") | ||
configRouter.Path("/data"). | ||
HandlerFunc(router.deploymentGroupRestHandler.GetConfigData). | ||
Methods("GET") | ||
configRouter.Path("/compare/{resource}"). | ||
HandlerFunc(router.deploymentGroupRestHandler.CompareCategoryWiseConfigData). | ||
Methods("GET") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.