Skip to content

Commit 199185a

Browse files
authored
Merge pull request #313 from devtron-labs/feat/secret-eso-dataFrom-template
feat: add SubPath values in prepareConfigMapAndSecretData service
2 parents f111df9 + 79ce5bc commit 199185a

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
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.3.15",
3+
"version": "0.3.19",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/CICDHistory/service.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@ export const prepareConfigMapAndSecretData = (
202202
}
203203
if (rawData.subPath) {
204204
secretValues['subPath'] = { displayName: 'Set SubPath', value: 'Yes' }
205+
206+
if (rawData.esoSubPath) {
207+
secretValues['subPathValues'] = { displayName: 'SubPath', value: rawData.esoSubPath.join(', ') }
208+
} else if (
209+
rawData.external &&
210+
rawData.externalType === 'KubernetesSecret' &&
211+
historyData.codeEditorValue?.resolvedValue
212+
) {
213+
const resolvedSecretData = JSON.parse(historyData.codeEditorValue.resolvedValue)
214+
secretValues['subPathValues'] = {
215+
displayName: 'SubPath',
216+
value: Object.keys(resolvedSecretData).join(', '),
217+
}
218+
}
205219
}
206220
if (rawData.filePermission) {
207221
secretValues['filePermission'] = {

src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.utils.tsx

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import { DEPLOYMENT_HISTORY_CONFIGURATION_LIST_MAP } from '@Shared/constants'
66
import { YAMLStringify } from '@Common/Helper'
77
import { SortingOrder } from '@Common/Constants'
88
import {
9-
AppEnvDeploymentConfigListParams,
109
DeploymentConfigDiffProps,
10+
DeploymentHistorySingleValue,
11+
AppEnvDeploymentConfigListParams,
1112
DiffHeadingDataType,
1213
prepareHistoryData,
1314
} from '@Shared/Components'
@@ -77,6 +78,20 @@ export const mergeConfigDataArraysByName = (
7778
return Array.from(dataMap.values())
7879
}
7980

81+
/**
82+
* Checks if the given secret is an external Kubernetes secret.
83+
*
84+
* @param secret - The secret data object to check.
85+
* @returns `true` if the secret is an external Kubernetes secret else `false` \
86+
* or `null` if the secret is invalid.
87+
*/
88+
const isExternalKubernetesSecret = (secret: ConfigMapSecretDataConfigDatumDTO) => {
89+
if (!secret) {
90+
return null
91+
}
92+
return secret.subPath && secret.external && secret.externalType === 'KubernetesSecret'
93+
}
94+
8095
/**
8196
* Retrieves data for a given configuration, depending on the type.
8297
*
@@ -179,8 +194,8 @@ const getCodeEditorData = (
179194
const compareToConfigData = getConfigData(compareToValue, type)
180195
const compareWithConfigData = getConfigData(compareWithValue, type)
181196

182-
let compareToCodeEditorData
183-
let compareWithCodeEditorData
197+
let compareToCodeEditorData: DeploymentHistorySingleValue
198+
let compareWithCodeEditorData: DeploymentHistorySingleValue
184199

185200
if (type === ConfigResourceType.Secret) {
186201
const { compareToObfuscatedData, compareWithObfuscatedData } = getObfuscatedData(
@@ -192,12 +207,26 @@ const getCodeEditorData = (
192207

193208
compareToCodeEditorData = {
194209
displayName: 'data',
195-
value: JSON.stringify(compareToObfuscatedData) || '',
210+
...(isExternalKubernetesSecret(compareToValue)
211+
? {
212+
value: null,
213+
resolvedValue: JSON.stringify(compareToObfuscatedData) || '',
214+
}
215+
: {
216+
value: JSON.stringify(compareToObfuscatedData) || '',
217+
}),
196218
}
197219

198220
compareWithCodeEditorData = {
199221
displayName: 'data',
200-
value: JSON.stringify(compareWithObfuscatedData) || '',
222+
...(isExternalKubernetesSecret(compareWithValue)
223+
? {
224+
value: null,
225+
resolvedValue: JSON.stringify(compareWithObfuscatedData) || '',
226+
}
227+
: {
228+
value: JSON.stringify(compareWithObfuscatedData) || '',
229+
}),
201230
}
202231
} else {
203232
compareToCodeEditorData = {

0 commit comments

Comments
 (0)