Skip to content

Commit 5ed5a2d

Browse files
authored
Merge pull request #1601 from devtron-labs/feat-image-digest-fix
feat: image digest fix
2 parents 3cb534b + 5d31852 commit 5ed5a2d

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

src/components/cdPipeline/BuildCD.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export default function BuildCD({
150150
? GeneratedHelmPush.DO_NOT_PUSH
151151
: GeneratedHelmPush.PUSH
152152
_form.allowedDeploymentTypes = selection.allowedDeploymentTypes
153+
_form.isDigestEnforcedForEnv = _form.environments.find((env) => env.id == selection.id)?.isDigestEnforcedForEnv
153154
setFormDataErrorObj(_formDataErrorObj)
154155
setFormData(_form)
155156
} else {

src/components/cdPipeline/NewCDPipeline.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export default function NewCDPipeline({
263263
description: env.description,
264264
isVirtualEnvironment: env.isVirtualEnvironment,
265265
allowedDeploymentTypes: env.allowedDeploymentTypes || [],
266+
isDigestEnforcedForEnv: env.isDigestEnforcedForEnv,
266267
}
267268
})
268269
sortObjectArrayAlphabetically(list, 'name')
@@ -447,7 +448,7 @@ export default function NewCDPipeline({
447448
form.enableCustomTag = pipelineConfigFromRes.enableCustomTag
448449
form.customTagStage = pipelineConfigFromRes.customTagStage
449450
form.isDigestEnforcedForEnv = pipelineConfigFromRes.isDigestEnforcedForEnv
450-
form.isDigestEnforcedForPipeline = pipelineConfigFromRes.isDigestEnforcedForEnv || pipelineConfigFromRes.isDigestEnforcedForPipeline
451+
form.isDigestEnforcedForPipeline = pipelineConfigFromRes.isDigestEnforcedForPipeline
451452

452453
if (pipelineConfigFromRes?.preDeployStage) {
453454
if(pipelineConfigFromRes.preDeployStage.steps?.length > 0){

src/components/cdPipeline/PullImageDigestToggle.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33
import Tippy from '@tippyjs/react'
44
import { ReactComponent as DockerWithImage } from '../../assets/icons/ic-docker-with-image.svg'
55
import { PullImageDigestToggleType } from './types'
6-
import { DIGEST_DISABLE_TOGGLE_MESSAGE } from '../../config'
6+
import { DIGEST_DISABLE_TOGGLE_MESSAGE_FOR_PIPELINE, DIGEST_DISABLE_TOGGLE_MESSAGE_GLOBAL } from '../../config'
77

88
function PullImageDigestToggle({ formData, setFormData }: PullImageDigestToggleType): JSX.Element {
99
const handleImageDigestToggle = (): void => {
@@ -12,19 +12,29 @@ function PullImageDigestToggle({ formData, setFormData }: PullImageDigestToggleT
1212
setFormData(_formData)
1313
}
1414

15+
const getContentText = () => {
16+
let text = ''
17+
if (formData.isDigestEnforcedForEnv) {
18+
text = DIGEST_DISABLE_TOGGLE_MESSAGE_GLOBAL
19+
} else if (formData.isDigestEnforcedForPipeline) {
20+
text = DIGEST_DISABLE_TOGGLE_MESSAGE_FOR_PIPELINE
21+
}
22+
return text
23+
}
24+
1525
const renderDogestToggle = () => {
1626
return (
1727
<ConditionalWrap
1828
condition={formData.isDigestEnforcedForEnv}
1929
wrap={(children) => (
20-
<Tippy className="default-tt w-200" content={DIGEST_DISABLE_TOGGLE_MESSAGE}>
30+
<Tippy className="default-tt w-200" content={getContentText()}>
2131
<div>{children}</div>
2232
</Tippy>
2333
)}
2434
>
2535
<div className={`w-32 h-20 ${formData.isDigestEnforcedForEnv ? 'dc__opacity-0_4' : ''}`}>
2636
<Toggle
27-
selected={formData.isDigestEnforcedForPipeline}
37+
selected={formData.isDigestEnforcedForPipeline || formData.isDigestEnforcedForEnv}
2838
onSelect={handleImageDigestToggle}
2939
dataTestId="create-build-pipeline-image-pull-digest-toggle"
3040
disabled={formData.isDigestEnforcedForEnv}

src/components/cdPipeline/cdPipeline.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface Environment {
5858
isClusterCdActive: boolean
5959
isVirtualEnvironment?: boolean
6060
allowedDeploymentTypes?: DeploymentAppTypes[]
61+
isDigestEnforcedForEnv?: boolean
6162
}
6263
export interface CommonError {
6364
isValid: boolean
@@ -135,6 +136,7 @@ export interface PipelineConfig {
135136
userApprovalConfig?: {
136137
requiredCount: number
137138
}
139+
isDigestEnforcedForEnv?: boolean
138140
}
139141

140142
export interface BasicCDPipelineModalProps {

src/config/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,4 +812,6 @@ export const CVE_ID_NOT_FOUND = "CVE ID not found"
812812
export const CONFIGURE_LINK_NO_NAME = "Please provide name for the tool you want to link"
813813
export const NO_HOST_URL = "Please enter host url"
814814
export const WEBHOOK_NO_API_TOKEN_ERROR = "API Token is required to execute webhook"
815-
export const DIGEST_DISABLE_TOGGLE_MESSAGE= "Pull image digest policy is enforced in Global Configurations. Go to Global Configurations to change."
815+
export const DIGEST_DISABLE_TOGGLE_MESSAGE_GLOBAL= "Pull image digest policy is enforced in Global Configurations. Go to Global Configurations to change."
816+
export const DIGEST_DISABLE_TOGGLE_MESSAGE_FOR_PIPELINE= "Enforced from Global Configurations. To change, first disable it in Global Configurations, then come back here."
817+

0 commit comments

Comments
 (0)