All files / modules/70-pipeline/components/PipelineSteps/AdvancedSteps/FailureStrategyPanel/StrategySelection StrategyConfig.ts

100% Statements 9/9
75% Branches 3/4
100% Functions 1/1
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95              65x 65x 65x   65x     131x   3x                                     128x                                                         65x                                                            
/*
 * Copyright 2021 Harness Inc. All rights reserved.
 * Use of this source code is governed by the PolyForm Shield 1.0.0 license
 * that can be found in the licenses directory at the root of this repository, also available at
 * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
 */
 
import { Strategy, ErrorType, FailureErrorType } from '@pipeline/utils/FailureStrategyUtils'
import { StageType } from '@pipeline/utils/stageHelpers'
import { StepMode as Modes } from '@pipeline/utils/stepUtils'
 
export const allowedStrategiesAsPerStep: (domain: StageType) => Record<Modes, Strategy[]> = (
  domain = StageType.DEPLOY
) => {
  switch (domain) {
    case StageType.BUILD:
      return {
        [Modes.STEP]: [
          Strategy.ManualIntervention,
          Strategy.Ignore,
          Strategy.Retry,
          Strategy.MarkAsSuccess,
          Strategy.Abort
        ],
        [Modes.STEP_GROUP]: [
          Strategy.ManualIntervention,
          Strategy.Ignore,
          Strategy.Retry,
          Strategy.MarkAsSuccess,
          Strategy.Abort
        ],
        [Modes.STAGE]: [Strategy.Ignore, Strategy.Retry, Strategy.MarkAsSuccess, Strategy.Abort]
      }
    case StageType.DEPLOY:
    default:
      return {
        [Modes.STEP]: [
          Strategy.ManualIntervention,
          Strategy.StageRollback,
          Strategy.Ignore,
          Strategy.Retry,
          Strategy.MarkAsSuccess,
          Strategy.Abort
        ],
        [Modes.STEP_GROUP]: [
          Strategy.ManualIntervention,
          Strategy.StageRollback,
          Strategy.Ignore,
          Strategy.Retry,
          Strategy.MarkAsSuccess,
          Strategy.Abort
        ],
        [Modes.STAGE]: [
          Strategy.ManualIntervention,
          Strategy.StageRollback,
          Strategy.Ignore,
          Strategy.Retry,
          Strategy.MarkAsSuccess,
          Strategy.Abort
        ]
      }
  }
}
 
export const errorTypesForStages: Record<StageType, FailureErrorType[]> = {
  [StageType.DEPLOY]: [
    ErrorType.Authentication,
    ErrorType.Authorization,
    ErrorType.Connectivity,
    ErrorType.DelegateProvisioning,
    ErrorType.Timeout,
    ErrorType.Unknown,
    ErrorType.Verification,
    ErrorType.PolicyEvaluationFailure,
    ErrorType.AllErrors
  ],
  [StageType.BUILD]: [ErrorType.Timeout, ErrorType.Unknown, ErrorType.AllErrors],
  [StageType.APPROVAL]: [
    ErrorType.Authentication,
    ErrorType.Authorization,
    ErrorType.Connectivity,
    ErrorType.DelegateProvisioning,
    ErrorType.Timeout,
    ErrorType.Unknown,
    ErrorType.Verification,
    ErrorType.AllErrors,
    ErrorType.PolicyEvaluationFailure
  ],
  [StageType.FEATURE]: [],
  [StageType.SECURITY]: [],
  [StageType.PIPELINE]: [],
  [StageType.CUSTOM]: [],
  [StageType.Template]: []
}