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
59 changes: 30 additions & 29 deletions pkg/appClone/AppCloneService.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,37 +917,38 @@ func (impl *AppCloneServiceImpl) CreateCdPipeline(req *cloneCdPipelineRequest, c
deploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_ACD
} else if AllowedDeploymentAppTypes[util.PIPELINE_DEPLOYMENT_TYPE_HELM] {
deploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM
}

if refCdPipeline.ParentPipelineType == "WEBHOOK" {
cdPipeline := &bean.CDPipelineConfigObject{
Id: 0,
EnvironmentId: refCdPipeline.EnvironmentId,
CiPipelineId: 0,
TriggerType: refCdPipeline.TriggerType,
Name: pipelineName,
Strategies: refCdPipeline.Strategies,
Namespace: refCdPipeline.Namespace,
AppWorkflowId: 0,
DeploymentTemplate: refCdPipeline.DeploymentTemplate,
PreStage: refCdPipeline.PreStage, //FIXME
PostStage: refCdPipeline.PostStage,
PreStageConfigMapSecretNames: refCdPipeline.PreStageConfigMapSecretNames,
PostStageConfigMapSecretNames: refCdPipeline.PostStageConfigMapSecretNames,
RunPostStageInEnv: refCdPipeline.RunPostStageInEnv,
RunPreStageInEnv: refCdPipeline.RunPreStageInEnv,
DeploymentAppType: refCdPipeline.DeploymentAppType,
ParentPipelineId: 0,
ParentPipelineType: refCdPipeline.ParentPipelineType,
}
cdPipelineReq := &bean.CdPipelines{
Pipelines: []*bean.CDPipelineConfigObject{cdPipeline},
AppId: req.appId,
UserId: req.userId,
}
cdPipelineRes, err := impl.pipelineBuilder.CreateCdPipelines(cdPipelineReq, ctx)
return cdPipelineRes, err
}
if refCdPipeline.ParentPipelineType == "WEBHOOK" {
cdPipeline := &bean.CDPipelineConfigObject{
Id: 0,
EnvironmentId: refCdPipeline.EnvironmentId,
CiPipelineId: 0,
TriggerType: refCdPipeline.TriggerType,
Name: pipelineName,
Strategies: refCdPipeline.Strategies,
Namespace: refCdPipeline.Namespace,
AppWorkflowId: 0,
DeploymentTemplate: refCdPipeline.DeploymentTemplate,
PreStage: refCdPipeline.PreStage, //FIXME
PostStage: refCdPipeline.PostStage,
PreStageConfigMapSecretNames: refCdPipeline.PreStageConfigMapSecretNames,
PostStageConfigMapSecretNames: refCdPipeline.PostStageConfigMapSecretNames,
RunPostStageInEnv: refCdPipeline.RunPostStageInEnv,
RunPreStageInEnv: refCdPipeline.RunPreStageInEnv,
DeploymentAppType: refCdPipeline.DeploymentAppType,
ParentPipelineId: 0,
ParentPipelineType: refCdPipeline.ParentPipelineType,
}
cdPipelineReq := &bean.CdPipelines{
Pipelines: []*bean.CDPipelineConfigObject{cdPipeline},
AppId: req.appId,
UserId: req.userId,
}
cdPipelineRes, err := impl.pipelineBuilder.CreateCdPipelines(cdPipelineReq, ctx)
return cdPipelineRes, err
}

cdPipeline := &bean.CDPipelineConfigObject{
Id: 0,
EnvironmentId: refCdPipeline.EnvironmentId,
Expand Down
38 changes: 38 additions & 0 deletions pkg/bulkAction/BulkUpdateService.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
"github.com/devtron-labs/devtron/api/bean"
Expand Down Expand Up @@ -1149,9 +1150,46 @@ func (impl BulkUpdateServiceImpl) BulkUnHibernate(request *BulkApplicationForEnv
bulkOperationResponse.Response = response
return bulkOperationResponse, nil
}

func (impl BulkUpdateServiceImpl) BulkDeploy(request *BulkApplicationForEnvironmentPayload, emailId string, checkAuthBatch func(emailId string, appObject []string, envObject []string) (map[string]bool, map[string]bool)) (*BulkApplicationForEnvironmentResponse, error) {
var pipelines []*pipelineConfig.Pipeline
var err error

if len(request.AppNamesIncludes) > 0 {
r, err := impl.appRepository.FindIdsByNames(request.AppNamesIncludes)
if err != nil {
impl.logger.Errorw("error in fetching Ids", "err", err)
return nil, err
}
for _, id := range r {
request.AppIdIncludes = append(request.AppIdIncludes, id)
}
}
if len(request.AppNamesExcludes) > 0 {
r, err := impl.appRepository.FindIdsByNames(request.AppNamesExcludes)
if err != nil {
impl.logger.Errorw("error in fetching Ids", "err", err)
return nil, err
}
for _, id := range r {
request.AppIdExcludes = append(request.AppIdExcludes, id)
}
}
if len(request.EnvName) > 0 {
r, err := impl.environmentRepository.FindByName(request.EnvName)
if err != nil {
impl.logger.Errorw("error in fetching env details", "err", err)
return nil, err
}
if request.EnvId != 0 && request.EnvId != r.Id {
return nil, errors.New("environment id and environment name is different select only one environment")
} else if request.EnvId == 0 {
request.EnvId = r.Id
}
}
if len(request.EnvName) == 0 && request.EnvId == 0 {
return nil, errors.New("please mention environment id or environment name")
}
if len(request.AppIdIncludes) > 0 {
pipelines, err = impl.pipelineRepository.FindActiveByInFilter(request.EnvId, request.AppIdIncludes)
} else if len(request.AppIdExcludes) > 0 {
Expand Down
13 changes: 8 additions & 5 deletions pkg/bulkAction/bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ type CmAndSecretBulkUpdateResponse struct {
}

type BulkApplicationForEnvironmentPayload struct {
AppIdIncludes []int `json:"appIdIncludes,omitempty"`
AppIdExcludes []int `json:"appIdExcludes,omitempty"`
EnvId int `json:"envId"`
UserId int32 `json:"-"`
InvalidateCache bool `json:"invalidateCache"`
AppIdIncludes []int `json:"appIdIncludes,omitempty"`
AppIdExcludes []int `json:"appIdExcludes,omitempty"`
EnvId int `json:"envId,omitempty"`
EnvName string `json:"envName,omitempty"`
AppNamesIncludes []string `json:"appNamesIncludes,omitempty"`
AppNamesExcludes []string `json:"appNamesExcludes,omitempty"`
UserId int32 `json:"-"`
InvalidateCache bool `json:"invalidateCache"`
}

type BulkApplicationForEnvironmentResponse struct {
Expand Down