Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/pipeline/GitopsOrHelmOption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestGitopsOrHelmOption(t *testing.T) {
nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil)
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil)

pipelineCreateRequest := &bean.CdPipelines{
Pipelines: []*bean.CDPipelineConfigObject{
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestGitopsOrHelmOption(t *testing.T) {
nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil)
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil)

pipelineCreateRequest := &bean.CdPipelines{
Pipelines: []*bean.CDPipelineConfigObject{
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestGitopsOrHelmOption(t *testing.T) {
nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: true}, nil, nil, nil, nil, nil, nil, nil)
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: true}, nil, nil, nil, nil, nil, nil, nil, nil)

pipelineCreateRequestHelm := &bean.CdPipelines{
Pipelines: []*bean.CDPipelineConfigObject{
Expand Down Expand Up @@ -221,7 +221,7 @@ func TestGitopsOrHelmOption(t *testing.T) {
nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil)
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil)

pipelineCreateRequest := &bean.CdPipelines{
Pipelines: []*bean.CDPipelineConfigObject{
Expand Down Expand Up @@ -278,7 +278,7 @@ func TestGitopsOrHelmOption(t *testing.T) {
nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: true}, nil, nil, nil, nil, nil, nil, nil)
nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: true}, nil, nil, nil, nil, nil, nil, nil, nil)

pipelineCreateRequest := &bean.CdPipelines{
Pipelines: []*bean.CDPipelineConfigObject{
Expand Down
26 changes: 25 additions & 1 deletion pkg/pipeline/PipelineBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ import (
"go.uber.org/zap"
)

const DashboardConfigMap = "dashboard-cm"
const ConfigMapNamespace = "devtroncd"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check similar constants already used, remove namespace const.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dashboard-cm const is not used, removed namespace const.


var DefaultPipelineValue = []byte(`{"ConfigMaps":{"enabled":false},"ConfigSecrets":{"enabled":false},"ContainerPort":[],"EnvVariables":[],"GracePeriod":30,"LivenessProbe":{},"MaxSurge":1,"MaxUnavailable":0,"MinReadySeconds":60,"ReadinessProbe":{},"Spec":{"Affinity":{"Values":"nodes","key":""}},"app":"13","appMetrics":false,"args":{},"autoscaling":{},"command":{"enabled":false,"value":[]},"containers":[],"dbMigrationConfig":{"enabled":false},"deployment":{"strategy":{"rolling":{"maxSurge":"25%","maxUnavailable":1}}},"deploymentType":"ROLLING","env":"1","envoyproxy":{"configMapName":"","image":"","resources":{"limits":{"cpu":"50m","memory":"50Mi"},"requests":{"cpu":"50m","memory":"50Mi"}}},"image":{"pullPolicy":"IfNotPresent"},"ingress":{},"ingressInternal":{"annotations":{},"enabled":false,"host":"","path":"","tls":[]},"initContainers":[],"pauseForSecondsBeforeSwitchActive":30,"pipelineName":"","prometheus":{"release":"monitoring"},"rawYaml":[],"releaseVersion":"1","replicaCount":1,"resources":{"limits":{"cpu":"0.05","memory":"50Mi"},"requests":{"cpu":"0.01","memory":"10Mi"}},"secret":{"data":{},"enabled":false},"server":{"deployment":{"image":"","image_tag":""}},"service":{"annotations":{},"type":"ClusterIP"},"servicemonitor":{"additionalLabels":{}},"tolerations":[],"volumeMounts":[],"volumes":[],"waitForSecondsBeforeScalingDown":30}`)

type EcrConfig struct {
Expand Down Expand Up @@ -211,6 +214,7 @@ type PipelineBuilderImpl struct {
enforcerUtil rbac.EnforcerUtil
appGroupService appGroup2.AppGroupService
chartDeploymentService util.ChartDeploymentService
K8sUtil *util.K8sUtil
}

func NewPipelineBuilderImpl(logger *zap.SugaredLogger,
Expand Down Expand Up @@ -261,7 +265,8 @@ func NewPipelineBuilderImpl(logger *zap.SugaredLogger,
enforcerUtil rbac.EnforcerUtil, ArgoUserService argo.ArgoUserService,
ciWorkflowRepository pipelineConfig.CiWorkflowRepository,
appGroupService appGroup2.AppGroupService,
chartDeploymentService util.ChartDeploymentService) *PipelineBuilderImpl {
chartDeploymentService util.ChartDeploymentService,
K8sUtil *util.K8sUtil) *PipelineBuilderImpl {
return &PipelineBuilderImpl{
logger: logger,
ciCdPipelineOrchestrator: ciCdPipelineOrchestrator,
Expand Down Expand Up @@ -320,6 +325,7 @@ func NewPipelineBuilderImpl(logger *zap.SugaredLogger,
ciWorkflowRepository: ciWorkflowRepository,
appGroupService: appGroupService,
chartDeploymentService: chartDeploymentService,
K8sUtil: K8sUtil,
}
}

Expand Down Expand Up @@ -1413,6 +1419,24 @@ func (impl PipelineBuilderImpl) PatchCiPipeline(request *bean.CiPatchRequest) (c
ciConfig.AppWorkflowId = request.AppWorkflowId
ciConfig.UserId = request.UserId
if request.CiPipeline != nil {
client, err := impl.K8sUtil.GetClientForInCluster()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it works only for in cluster ? if not handle by cluster id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes working .

if err != nil {
impl.logger.Errorw("exception while getting unique client id", "error", err)
return nil, err
}
cm, err := impl.K8sUtil.GetConfigMap(ConfigMapNamespace, DashboardConfigMap, client)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle error here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if err != nil {
impl.logger.Errorw("error while getting dashboard-cm", "error", err)
return nil, err
}
datamap := cm.Data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if cm is nil, handle that case also

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not able to see it handled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might not be showing that time, handled it.

forceScanConfig, err := strconv.ParseBool(datamap["FORCE_SECURITY_SCANNING"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add nil check for datamap and add constant for KEY

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if err != nil {
forceScanConfig = false
}
if forceScanConfig {
request.CiPipeline.ScanEnabled = true
}
ciConfig.ScanEnabled = request.CiPipeline.ScanEnabled
}
switch request.Action {
Expand Down
2 changes: 1 addition & 1 deletion wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.