Skip to content

Commit 258225c

Browse files
committed
feat: add yaml validator util
1 parent 9db3e13 commit 258225c

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/Common/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const URLS = {
7777
DEPLOYMENT_HISTORY_CONFIGURATIONS: '/configuration',
7878
GLOBAL_CONFIG_SCOPED_VARIABLES: '/global-config/scoped-variables',
7979
GLOBAL_CONFIG_DEPLOYMENT_CHARTS_LIST: '/global-config/deployment-charts',
80+
GLOBAL_CONFIG_DEPLOYMENT_CHARTS_UPLOAD_CHART: '/global-config/deployment-charts/upload-chart',
8081
NETWORK_STATUS_INTERFACE: '/network-status-interface',
8182
CONFIG_DRIFT: 'config-drift',
8283
RESOURCE_BROWSER: '/resource-browser',

src/Shared/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,3 +960,8 @@ export const TriggerType = {
960960
Auto: 'AUTOMATIC',
961961
Manual: 'MANUAL',
962962
} as const
963+
964+
export interface AppEnvIdType {
965+
appId: number
966+
envId: number
967+
}

src/Shared/validations.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { getSanitizedIframe } from '@Common/Helper'
1818
import { PATTERNS } from '@Common/Constants'
19+
import { parse } from 'yaml'
1920
import { URLProtocolType } from './types'
2021
import { SKIP_LABEL_KEY_VALIDATION_PREFIX } from './constants'
2122

@@ -453,3 +454,19 @@ export const validateCMVolumeMountPath = (value: string): { isValid: boolean; me
453454
}
454455
return { isValid: true, message: '' }
455456
}
457+
458+
export const validateYAML = (yamlString: string): ValidationResponseType => {
459+
try {
460+
if (yamlString) {
461+
parse(yamlString)
462+
}
463+
return {
464+
isValid: true,
465+
}
466+
} catch (err) {
467+
return {
468+
isValid: false,
469+
message: err.message,
470+
}
471+
}
472+
}

0 commit comments

Comments
 (0)