8282import io .harness .plancreator .stages .stage .StageElementConfig ;
8383import io .harness .plancreator .steps .ParallelStepElementConfig ;
8484import io .harness .plancreator .steps .StepElementConfig ;
85+ import io .harness .plancreator .steps .StepGroupElementConfig ;
8586import io .harness .pms .contracts .plan .ExecutionTriggerInfo ;
8687import io .harness .pms .contracts .plan .PlanCreationContextValue ;
8788import io .harness .pms .contracts .plan .TriggerType ;
@@ -136,6 +137,14 @@ public StepElementConfig getStepElementConfig(ExecutionWrapperConfig executionWr
136137 }
137138 }
138139
140+ public StepGroupElementConfig getStepGroupElementConfig (ExecutionWrapperConfig executionWrapperConfig ) {
141+ try {
142+ return YamlUtils .read (executionWrapperConfig .getStepGroup ().toString (), StepGroupElementConfig .class );
143+ } catch (Exception ex ) {
144+ throw new CIStageExecutionException ("Failed to deserialize ExecutionWrapperConfig step node" , ex );
145+ }
146+ }
147+
139148 public CodeBase getCiCodeBase (YamlNode ciCodeBase ) {
140149 try {
141150 return YamlUtils .read (ciCodeBase .toString (), CodeBase .class );
@@ -388,12 +397,16 @@ public static List<StepElementConfig> getAllSteps(List<ExecutionWrapperConfig> e
388397 continue ;
389398 }
390399
391- if (executionWrapper .getStep () != null ) {
400+ if (executionWrapper .getStep () != null && ! executionWrapper . getStep (). isNull () ) {
392401 stepElementConfigs .add (getStepElementConfig (executionWrapper ));
393- } else if (executionWrapper .getParallel () != null ) {
402+ } else if (executionWrapper .getParallel () != null && ! executionWrapper . getParallel (). isNull () ) {
394403 ParallelStepElementConfig parallelStepElementConfig = getParallelStepElementConfig (executionWrapper );
395404 List <StepElementConfig > fromParallel = getAllSteps (parallelStepElementConfig .getSections ());
396405 stepElementConfigs .addAll (fromParallel );
406+ } else if (executionWrapper .getStepGroup () != null && !executionWrapper .getStepGroup ().isNull ()) {
407+ StepGroupElementConfig stepGroupElementConfig = getStepGroupElementConfig (executionWrapper );
408+ List <StepElementConfig > fromStepGroup = getAllSteps (stepGroupElementConfig .getSteps ());
409+ stepElementConfigs .addAll (fromStepGroup );
397410 }
398411 }
399412 return stepElementConfigs ;
@@ -546,9 +559,9 @@ public OSType getK8OS(Infrastructure infrastructure) {
546559 return resolveOSType (k8sDirectInfraYaml .getSpec ().getOs ());
547560 }
548561
549- public List <String > getStageConnectorRefs ( IntegrationStageConfig integrationStageConfig ) {
562+ public ArrayList <String > populateConnectorIdentifiers ( List < ExecutionWrapperConfig > wrappers ) {
550563 ArrayList <String > connectorIdentifiers = new ArrayList <>();
551- for (ExecutionWrapperConfig executionWrapper : integrationStageConfig . getExecution (). getSteps () ) {
564+ for (ExecutionWrapperConfig executionWrapper : wrappers ) {
552565 if (executionWrapper .getStep () != null && !executionWrapper .getStep ().isNull ()) {
553566 StepElementConfig stepElementConfig = IntegrationStageUtils .getStepElementConfig (executionWrapper );
554567 String identifier = getConnectorIdentifier (stepElementConfig );
@@ -559,20 +572,30 @@ public List<String> getStageConnectorRefs(IntegrationStageConfig integrationStag
559572 ParallelStepElementConfig parallelStepElementConfig =
560573 IntegrationStageUtils .getParallelStepElementConfig (executionWrapper );
561574 if (isNotEmpty (parallelStepElementConfig .getSections ())) {
562- for (ExecutionWrapperConfig executionWrapperInParallel : parallelStepElementConfig .getSections ()) {
563- if (executionWrapperInParallel .getStep () == null || executionWrapperInParallel .getStep ().isNull ()) {
564- continue ;
565- }
566- StepElementConfig stepElementConfig =
567- IntegrationStageUtils .getStepElementConfig (executionWrapperInParallel );
568- String identifier = getConnectorIdentifier (stepElementConfig );
569- if (identifier != null ) {
570- connectorIdentifiers .add (identifier );
571- }
575+ ArrayList <String > connectorIdentifiersForParallel =
576+ populateConnectorIdentifiers (parallelStepElementConfig .getSections ());
577+ if (connectorIdentifiersForParallel != null && connectorIdentifiersForParallel .size () > 0 ) {
578+ connectorIdentifiers .addAll (connectorIdentifiersForParallel );
579+ }
580+ }
581+ } else {
582+ StepGroupElementConfig stepGroupElementConfig =
583+ IntegrationStageUtils .getStepGroupElementConfig (executionWrapper );
584+ if (isNotEmpty (stepGroupElementConfig .getSteps ())) {
585+ ArrayList <String > connectorIdentifiersForStepGroup =
586+ populateConnectorIdentifiers (stepGroupElementConfig .getSteps ());
587+ if (connectorIdentifiersForStepGroup != null && connectorIdentifiersForStepGroup .size () > 0 ) {
588+ connectorIdentifiers .addAll (connectorIdentifiersForStepGroup );
572589 }
573590 }
574591 }
575592 }
593+ return connectorIdentifiers ;
594+ }
595+
596+ public List <String > getStageConnectorRefs (IntegrationStageConfig integrationStageConfig ) {
597+ ArrayList <String > connectorIdentifiers = new ArrayList <>();
598+ connectorIdentifiers = populateConnectorIdentifiers (integrationStageConfig .getExecution ().getSteps ());
576599
577600 if (integrationStageConfig .getServiceDependencies () == null
578601 || isEmpty (integrationStageConfig .getServiceDependencies ().getValue ())) {
0 commit comments