Skip to content

Commit ed901b4

Browse files
Merge pull request #355 from devtron-labs/feat/ci-pipeline-mandatory-plugins
feat: ci/cd pipeline mandatory plugins
2 parents 463d2eb + 840efff commit ed901b4

File tree

10 files changed

+91
-46
lines changed

10 files changed

+91
-46
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.5.8-beta-1",
3+
"version": "0.5.8-beta-2",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/CIPipeline.Types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export interface StepType {
170170
inlineStepDetail?: InlineStepDetailType
171171
pluginRefStepDetail?: PluginRefStepDetailType
172172
triggerIfParentStageFail: boolean
173-
isMandatory?: boolean
174173
}
175174

176175
export interface BuildStageType {

src/Common/Policy.Types.ts

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,35 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { PluginDataStoreType } from '../Shared'
17+
import { PipelineFormType } from '@Pages/Applications'
18+
import { PluginDataStoreType, PluginDetailPayloadType, ResourceKindType } from '../Shared'
1819
import { VariableType } from './CIPipeline.Types'
1920
import { ServerErrors } from './ServerError'
20-
import { ResponseType } from './Types'
2121

2222
export enum ApplyPolicyToStage {
2323
PRE_CI = 'PRE_CI',
2424
POST_CI = 'POST_CI',
25-
PRE_CD = 'PRE_CD',
26-
POST_CD = 'POST_CD',
2725
/**
2826
* @deprecated in mandatory plugin policy v2
2927
*/
3028
PRE_OR_POST_CI = 'PRE_OR_POST_CI',
29+
PRE_CD = 'PRE_CD',
30+
POST_CD = 'POST_CD',
3131
}
3232

33+
// FIXME: The name build is getting is used in CDPipeline.
34+
// This enum is mapping values from BuildStageVariable
3335
export enum PluginRequiredStage {
34-
PRE_CI = 'preBuildStage',
35-
POST_CI = 'postBuildStage',
36-
PRE_OR_POST_CI = 'PRE_OR_POST_CI',
36+
PRE_STAGE = 'preBuildStage',
37+
POST_STAGE = 'postBuildStage',
38+
PRE_OR_POST_STAGE = 'PRE_OR_POST_CI',
3739
}
3840

3941
export interface DefinitionSourceType {
40-
projectName: string
41-
isDueToProductionEnvironment: boolean
42-
isDueToLinkedPipeline: boolean
43-
policyName: string
44-
appName?: string
45-
clusterName?: string
46-
environmentName?: string
47-
branchNames?: string[]
48-
ciPipelineName?: string
42+
policyNames: string[]
43+
linkedCIPipelineNames?: string[]
4944
}
45+
5046
export interface MandatoryPluginDetailType {
5147
id: number
5248
parentPluginId: number
@@ -57,7 +53,7 @@ export interface MandatoryPluginDetailType {
5753
applied?: boolean
5854
inputVariables?: VariableType[]
5955
outputVariables?: VariableType[]
60-
definitionSources?: DefinitionSourceType[]
56+
definitionSources?: DefinitionSourceType
6157
}
6258
export interface MandatoryPluginDataType {
6359
pluginData: MandatoryPluginDetailType[]
@@ -71,6 +67,37 @@ export interface ProcessPluginDataReturnType {
7167
mandatoryPluginsError?: ServerErrors
7268
}
7369

70+
export type ProcessPluginDataCIParamsType = {
71+
resourceKind: ResourceKindType.ciPipeline
72+
ciPipelineId: number
73+
/**
74+
* Comma separated branch names used for v1 api
75+
* For v2 format is [branchName1],[branchName2]
76+
*/
77+
branchName?: string
78+
79+
envName?: never
80+
}
81+
82+
export type ProcessPluginDataCDParamsType = {
83+
resourceKind: ResourceKindType.cdPipeline
84+
envName?: string
85+
86+
ciPipelineId?: never
87+
branchName?: never
88+
}
89+
90+
export type ProcessPluginDataParamsType = {
91+
formData: PipelineFormType
92+
pluginDataStoreState: PluginDataStoreType
93+
appId: number
94+
appName: string
95+
/**
96+
* Would be sent in case we have to get data for steps
97+
*/
98+
requiredPluginIds?: PluginDetailPayloadType['pluginId']
99+
} & (ProcessPluginDataCIParamsType | ProcessPluginDataCDParamsType)
100+
74101
export enum ConsequenceAction {
75102
/**
76103
* This is used if the policy is enforced immediately.
@@ -104,7 +131,3 @@ export interface BlockedStateData {
104131
isCITriggerBlocked: boolean
105132
ciBlockState: ConsequenceType
106133
}
107-
108-
export interface GetBlockedStateResponse extends ResponseType {
109-
result?: BlockedStateData
110-
}

src/Common/Types.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ import React, { ReactNode, CSSProperties, ReactElement } from 'react'
1818
import { Placement } from 'tippy.js'
1919
import { UserGroupDTO } from '@Pages/GlobalConfigurations'
2020
import { ImageComment, ReleaseTag } from './ImageTags.Types'
21-
import { ACTION_STATE, ConsequenceType, DEPLOYMENT_WINDOW_TYPE, DockerConfigOverrideType, SortingOrder, TaskErrorObj } from '.'
22-
import { RegistryType, RuntimeParamsListItemType, Severity } from '../Shared'
21+
import { MandatoryPluginBaseStateType, RegistryType, RuntimeParamsListItemType, Severity } from '../Shared'
22+
import {
23+
ACTION_STATE,
24+
ConsequenceType,
25+
DEPLOYMENT_WINDOW_TYPE,
26+
DockerConfigOverrideType,
27+
SortingOrder,
28+
TaskErrorObj,
29+
} from '.'
2330

2431
/**
2532
* Generic response type object with support for overriding the result type
@@ -450,12 +457,12 @@ export interface ArtifactReleaseMappingType {
450457
}
451458

452459
export interface CDMaterialListModalServiceUtilProps {
453-
artifacts: any[],
454-
offset: number,
455-
artifactId?: number,
456-
artifactStatus?: string,
457-
disableDefaultSelection?: boolean,
458-
userApprovalConfig?: UserApprovalConfigType,
460+
artifacts: any[]
461+
offset: number
462+
artifactId?: number
463+
artifactStatus?: string
464+
disableDefaultSelection?: boolean
465+
userApprovalConfig?: UserApprovalConfigType
459466
}
460467

461468
export interface CDMaterialType {
@@ -552,7 +559,7 @@ export interface DownstreamNodesEnvironmentsType {
552559
environmentName: string
553560
}
554561

555-
export interface CommonNodeAttr {
562+
export interface CommonNodeAttr extends Pick<MandatoryPluginBaseStateType, 'isTriggerBlocked' | 'pluginBlockState'> {
556563
connectingCiPipelineId?: number
557564
parents: string | number[] | string[]
558565
x: number
@@ -602,12 +609,10 @@ export interface CommonNodeAttr {
602609
approvalUsers?: string[]
603610
userApprovalConfig?: UserApprovalConfigType
604611
requestedUserId?: number
605-
showPluginWarning?: boolean
612+
showPluginWarning: boolean
606613
helmPackageName?: string
607614
isVirtualEnvironment?: boolean
608615
deploymentAppType?: DeploymentAppTypes
609-
isCITriggerBlocked?: boolean
610-
ciBlockState?: ConsequenceType
611616
appReleaseTagNames?: string[]
612617
tagsEditable?: boolean
613618
isGitOpsRepoNotConfigured?: boolean
@@ -790,7 +795,7 @@ export interface CDStageConfigMapSecretNames {
790795
secrets: any[]
791796
}
792797

793-
export interface PrePostDeployStageType {
798+
export interface PrePostDeployStageType extends MandatoryPluginBaseStateType {
794799
isValid: boolean
795800
steps: TaskErrorObj[]
796801
triggerType: string
@@ -828,6 +833,8 @@ export interface CdPipeline {
828833
preDeployStage?: PrePostDeployStageType
829834
postDeployStage?: PrePostDeployStageType
830835
isProdEnv?: boolean
836+
isGitOpsRepoNotConfigured?: boolean
837+
isDeploymentBlocked?: boolean
831838
}
832839

833840
export interface ExternalCiConfig {

src/Shared/Components/InfoIconTippy/InfoIconTippy.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ const InfoIconTippy = ({
3030
placement = 'bottom',
3131
dataTestid = 'info-tippy-button',
3232
children,
33+
headingInfo,
3334
}: InfoIconTippyProps) => (
3435
<TippyCustomized
3536
theme={TippyTheme.white}
37+
headingInfo={headingInfo}
3638
className="w-300 h-100 dc__no-text-transform"
3739
placement={placement}
3840
Icon={HelpIcon}

src/Shared/Components/Plugin/types.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { MutableRefObject } from 'react'
18-
import { VariableType } from '../../../Common'
18+
import { ConsequenceType, VariableType } from '../../../Common'
1919
import { BaseFilterQueryParams } from '../../types'
2020
import { ImageWithFallbackProps } from '../ImageWithFallback'
2121
import { getPluginStoreData } from './service'
@@ -104,18 +104,15 @@ export interface PluginListFiltersType extends Pick<BaseFilterQueryParams<unknow
104104
selectedTags: string[]
105105
}
106106

107-
interface ParentPluginType
107+
export interface ParentPluginType
108108
extends Pick<ParentPluginDTO, 'id' | 'name' | 'description' | 'type' | 'icon' | 'pluginIdentifier'> {
109109
latestVersionId: MinimalPluginVersionDataDTO['id']
110110
pluginVersions: MinimalPluginVersionDataDTO[]
111111
}
112112

113113
interface DetailedPluginVersionType
114114
extends Pick<MinimalPluginVersionDataDTO, 'id' | 'description' | 'name' | 'pluginVersion'>,
115-
Pick<
116-
DetailedPluginVersionDTO,
117-
'tags' | 'isLatest' | 'inputVariables' | 'outputVariables' | 'updatedBy' | 'docLink'
118-
>,
115+
Pick<DetailedPluginVersionDTO, 'tags' | 'inputVariables' | 'outputVariables' | 'updatedBy' | 'docLink'>,
119116
Pick<ParentPluginType, 'icon' | 'type' | 'pluginIdentifier'> {
120117
parentPluginId: ParentPluginType['id']
121118
}
@@ -253,3 +250,20 @@ export interface PluginTagsContainerProps {
253250
export interface PluginImageContainerProps extends Pick<ImageWithFallbackProps, 'imageProps'> {
254251
fallbackImageClassName?: string
255252
}
253+
254+
export enum PipelineStageTaskActionModalType {
255+
DELETE = 'DELETE',
256+
MOVE_PLUGIN = 'MOVE_PLUGIN',
257+
}
258+
259+
export interface PipelineStageTaskActionModalStateType {
260+
type: PipelineStageTaskActionModalType
261+
pluginId: PluginDetailType['id']
262+
taskIndex: number
263+
}
264+
265+
export interface MandatoryPluginBaseStateType {
266+
isOffendingMandatoryPlugin: boolean
267+
isTriggerBlocked: boolean
268+
pluginBlockState: ConsequenceType
269+
}

src/Shared/Components/Plugin/utils.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export const parsePluginDetailsDTOIntoPluginStore = (pluginData: ParentPluginDTO
8484
plugin.type === PluginCreationType.SHARED ? pluginVersionData.updatedBy : DEFAULT_PLUGIN_CREATED_BY,
8585
outputVariables: pluginVersionData.outputVariables || [],
8686
inputVariables: pluginVersionData.inputVariables || [],
87-
isLatest: pluginVersionData.isLatest || false,
8887
tags: sortedUniqueTags,
8988
parentPluginId: plugin.id,
9089
icon: plugin.icon || '',

src/Shared/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ export enum ResourceKindType {
439439
tenant = 'tenant',
440440
installation = 'installation',
441441
environment = 'environment',
442-
ciPipeline = 'ci-pipeline',
443442
cdPipeline = 'cd-pipeline',
443+
ciPipeline = 'ci-pipeline',
444444
project = 'project',
445445
}
446446

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export interface customEnv {
7676
SYSTEM_CONTROLLER_LISTING_TIMEOUT?: number
7777
FEATURE_STEP_WISE_LOGS_ENABLE?: boolean
7878
FEATURE_IMAGE_PROMOTION_ENABLE?: boolean
79+
FEATURE_CD_MANDATORY_PLUGINS_ENABLE?: boolean
7980
FEATURE_CONFIG_DRIFT_ENABLE: boolean
8081
}
8182
declare global {

0 commit comments

Comments
 (0)