File tree Expand file tree Collapse file tree 2 files changed +25
-14
lines changed
server-build/src/normalizer
server/src/importer/normalizer Expand file tree Collapse file tree 2 files changed +25
-14
lines changed Original file line number Diff line number Diff line change @@ -43,15 +43,21 @@ export const normalizeCapabilityLevel = (capability: string) => {
4343 * @param operator
4444 */
4545const getExampleYAML = ( kind : string , operator : Operator ) : AlmExample | null => {
46- const examples : string = get ( operator , 'metadata.annotations.alm-examples' ) ;
46+ // const examples: string = get(operator, 'metadata.annotations.alm-examples');
47+ const examples_ : string = get ( operator , 'metadata.annotations.alm-examples' ) ;
48+ if ( examples_ ) {
49+ let regex = / \, (? ! \s * ?[ \{ \[ \" \' \w ] ) / g;
50+ let examples = examples_ . replace ( regex , '' ) ;
4751
48- if ( examples ) {
49- try {
50- const yamlExamples : any [ ] = JSON . parse ( examples ) ;
51- return yamlExamples . find ( example => example . kind === kind ) ;
52+ if ( examples ) {
53+ try {
54+ const yamlExamples : any [ ] = JSON . parse ( examples ) ;
55+ return yamlExamples . find ( example => example . kind === kind ) ;
5256
53- } catch ( e ) {
54- Logger . error ( `getExampleYAML > failed to parse example for CRD ${ kind } ` , e ) ;
57+ } catch ( e ) {
58+ Logger . error ( `getExampleYAML > failed to parse example for CRD ${ kind } ` , e ) ;
59+ process . exit ( 1 ) ;
60+ }
5561 }
5662 }
5763 return null ;
Original file line number Diff line number Diff line change @@ -43,20 +43,25 @@ export const normalizeCapabilityLevel = (capability: string) => {
4343 * @param operator
4444 */
4545const getExampleYAML = ( kind : string , operator : Operator ) : AlmExample | null => {
46- const examples : string = get ( operator , 'metadata.annotations.alm-examples' ) ;
46+ const examples_ : string = get ( operator , 'metadata.annotations.alm-examples' ) ;
47+ if ( examples_ ) {
48+ let regex = / \, (? ! \s * ?[ \{ \[ \" \' \w ] ) / g;
49+ let examples = examples_ . replace ( regex , '' ) ;
4750
48- if ( examples ) {
49- try {
50- const yamlExamples : any [ ] = JSON . parse ( examples ) ;
51- return yamlExamples . find ( example => example . kind === kind ) ;
51+ if ( examples ) {
52+ try {
53+ const yamlExamples : any [ ] = JSON . parse ( examples ) ;
54+ return yamlExamples . find ( example => example . kind === kind ) ;
5255
53- } catch ( e ) {
54- Logger . error ( `getExampleYAML > failed to parse example for CRD ${ kind } ` , e ) ;
56+ } catch ( e ) {
57+ Logger . error ( `getExampleYAML > failed to parse example for CRD ${ kind } ` , e ) ;
58+ }
5559 }
5660 }
5761 return null ;
5862} ;
5963
64+
6065/**
6166 * Normalize single CRD
6267 * @param crd
You can’t perform that action at this time.
0 commit comments