Skip to content

Commit 98d9f86

Browse files
authored
Merge pull request #496 from devtron-labs/fix/runtime-params-env-variables
fix: runtime params env variables
2 parents 276dea9 + 0652266 commit 98d9f86

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
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": "1.3.0-patch-5",
3+
"version": "1.3.0-patch-6",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Common.service.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import {
4848
import { ApiResourceType } from '../Pages'
4949
import { API_TOKEN_PREFIX } from '@Shared/constants'
5050
import { DefaultUserKey } from '@Shared/types'
51-
import { RefVariableType } from './CIPipeline.Types'
51+
import { RefVariableType, VariableTypeFormat } from './CIPipeline.Types'
5252

5353
export const getTeamListMin = (): Promise<TeamList> => {
5454
// ignore active field
@@ -225,7 +225,7 @@ const cdMaterialListModal = ({
225225
deploymentWindowArtifactMetadata: material.deploymentWindowArtifactMetadata ?? null,
226226
configuredInReleases: material.configuredInReleases ?? [],
227227
appWorkflowId: material.appWorkflowId ?? null,
228-
deploymentBlockedState: sanitizeDeploymentBlockedState(material.deploymentBlockedState)
228+
deploymentBlockedState: sanitizeDeploymentBlockedState(material.deploymentBlockedState),
229229
}
230230
})
231231
return materials
@@ -338,8 +338,37 @@ const processCDMaterialsApprovalInfo = (enableApproval: boolean, cdMaterialsResu
338338
}
339339
}
340340

341-
export const parseRuntimeParams = (response: RuntimeParamsAPIResponseType): RuntimePluginVariables[] =>
342-
(response?.runtimePluginVariables ?? []).map((variable) => ({ ...variable, defaultValue: variable.value }))
341+
export const parseRuntimeParams = (response: RuntimeParamsAPIResponseType): RuntimePluginVariables[] => {
342+
const envVariables = Object.entries(response?.envVariables || {}).map<RuntimePluginVariables>(
343+
([key, value]) => ({
344+
name: key,
345+
value,
346+
defaultValue: '',
347+
format: VariableTypeFormat.STRING,
348+
isRequired: false,
349+
valueType: RefVariableType.NEW,
350+
variableStepScope: RefVariableType.GLOBAL,
351+
stepName: null,
352+
stepType: null,
353+
// TODO: (Rohit/Eshank) Replace this with getUniqueId (nanoId method)
354+
stepVariableId: Math.floor(new Date().valueOf() * Math.random()),
355+
valueConstraint: null,
356+
description: null,
357+
fileReferenceId: null,
358+
fileMountDir: null,
359+
}),
360+
)
361+
362+
const runtimeParams = (response?.runtimePluginVariables ?? []).map<RuntimePluginVariables>((variable) => ({
363+
...variable,
364+
defaultValue: variable.value,
365+
}))
366+
367+
runtimeParams.push(...envVariables)
368+
runtimeParams.sort((a, b) => stringComparatorBySortOrder(a.name, b.name))
369+
370+
return runtimeParams
371+
}
343372

344373
const processCDMaterialsMetaInfo = (cdMaterialsResult): CDMaterialsMetaInfo => {
345374
if (!cdMaterialsResult) {

0 commit comments

Comments
 (0)