@@ -26,7 +26,6 @@ import {
2626 CMSecretConfigData ,
2727 CMSecretExternalType ,
2828 CMSecretPayloadType ,
29- CMSecretYamlData ,
3029 CODE_EDITOR_RADIO_STATE ,
3130 ConfigDatum ,
3231 ConfigMapSecretUseFormProps ,
@@ -36,6 +35,7 @@ import {
3635} from '@Shared/Services'
3736import { hasESO , OverrideMergeStrategyType } from '@Pages/index'
3837
38+ import { KeyValueTableData } from '../KeyValueTable'
3939import { getSelectPickerOptionByValue } from '../SelectPicker'
4040import {
4141 CONFIG_MAP_SECRET_DEFAULT_CURRENT_DATA ,
@@ -93,7 +93,7 @@ export const getSecretDataTypeOptions = (
9393 return isJob ? kubernetesOptions : [ ...kubernetesOptions , ...esoOptions , ...( isHashiOrAWS ? kesOptions : [ ] ) ]
9494}
9595
96- const secureValues = ( data : Record < string , string > , decodeData : boolean ) : CMSecretYamlData [ ] => {
96+ const secureValues = ( data : Record < string , string > , decodeData : boolean ) : KeyValueTableData [ ] => {
9797 let decodedData = data || DEFAULT_SECRET_PLACEHOLDER
9898
9999 if ( decodeData ) {
@@ -104,9 +104,9 @@ const secureValues = (data: Record<string, string>, decodeData: boolean): CMSecr
104104 }
105105 }
106106
107- return Object . keys ( decodedData ) . map ( ( k , id ) => ( {
108- k ,
109- v : typeof decodedData [ k ] === 'object' ? YAMLStringify ( decodedData [ k ] ) : decodedData [ k ] ,
107+ return Object . keys ( decodedData ) . map ( ( key , id ) => ( {
108+ key ,
109+ value : typeof decodedData [ key ] === 'object' ? YAMLStringify ( decodedData [ key ] ) : decodedData [ key ] ,
110110 id,
111111 } ) )
112112}
@@ -150,8 +150,8 @@ const processExternalSubPathValues = ({
150150 return ''
151151}
152152
153- export const convertKeyValuePairToYAML = ( currentData : CMSecretYamlData [ ] ) =>
154- currentData . length ? YAMLStringify ( currentData . reduce ( ( agg , { k , v } ) => ( { ...agg , [ k ] : v } ) , { } ) ) : ''
153+ export const convertKeyValuePairToYAML = ( currentData : KeyValueTableData [ ] ) =>
154+ currentData . length ? YAMLStringify ( currentData . reduce ( ( agg , { key , value } ) => ( { ...agg , [ key ] : value } ) , { } ) ) : ''
155155
156156const getSecretDataFromConfigData = ( {
157157 secretData,
@@ -368,29 +368,30 @@ export const getConfigMapSecretReadOnlyValues = ({
368368 ? [
369369 {
370370 displayName : 'Keys' ,
371- value : currentData ?. length > 0 ? currentData . map ( ( d ) => d . k ) . join ( ', ' ) : 'No keys available' ,
371+ value :
372+ currentData ?. length > 0 ? currentData . map ( ( d ) => d . key ) . join ( ', ' ) : 'No keys available' ,
372373 key : 'keys' ,
373374 } ,
374375 ]
375376 : [ ] ) ,
376377 ] ,
377- data : ! mountExistingExternal ? ( currentData ?. [ 0 ] ?. k && yaml ) || esoSecretYaml || secretDataYaml : null ,
378+ data : ! mountExistingExternal ? ( currentData ?. [ 0 ] ?. key && yaml ) || esoSecretYaml || secretDataYaml : null ,
378379 }
379380}
380381
381- export const convertYAMLToKeyValuePair = ( yaml : string ) : CMSecretYamlData [ ] => {
382+ export const convertYAMLToKeyValuePair = ( yaml : string ) : KeyValueTableData [ ] => {
382383 try {
383384 const obj = yaml && YAML . parse ( yaml )
384385 if ( typeof obj !== 'object' ) {
385386 throw new Error ( )
386387 }
387- const keyValueArray : CMSecretYamlData [ ] = Object . keys ( obj ) . reduce ( ( agg , k , id ) => {
388- if ( ! k && ! obj [ k ] ) {
388+ const keyValueArray = Object . keys ( obj ) . reduce < KeyValueTableData [ ] > ( ( agg , key , id ) => {
389+ if ( ! key && ! obj [ key ] ) {
389390 return CONFIG_MAP_SECRET_DEFAULT_CURRENT_DATA
390391 }
391- const v = obj [ k ] && typeof obj [ k ] === 'object' ? YAMLStringify ( obj [ k ] ) : obj [ k ] . toString ( )
392+ const value = obj [ key ] && typeof obj [ key ] === 'object' ? YAMLStringify ( obj [ key ] ) : obj [ key ] . toString ( )
392393
393- return [ ...agg , { k , v : v ?? '' , id } ]
394+ return [ ...agg , { key , value : value ?? '' , id } ]
394395 } , [ ] )
395396 return keyValueArray
396397 } catch {
@@ -449,14 +450,14 @@ export const getConfigMapSecretPayload = ({
449450 const isESO = isSecret && hasESO ( externalType )
450451 const _currentData = yamlMode ? convertYAMLToKeyValuePair ( yaml ) : currentData
451452 const data = _currentData . reduce ( ( acc , curr ) => {
452- if ( ! curr . k ) {
453+ if ( ! curr . key ) {
453454 return acc
454455 }
455- const value = curr . v ?? ''
456+ const value = curr . value ?? ''
456457
457458 return {
458459 ...acc ,
459- [ curr . k ] : isSecret && externalType === '' ? btoa ( value ) : value ,
460+ [ curr . key ] : isSecret && externalType === '' ? btoa ( value ) : value ,
460461 }
461462 } , { } )
462463
0 commit comments