File tree Expand file tree Collapse file tree 2 files changed +25
-14
lines changed
server/src/importer/normalizer
server-build/src/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) => {
43
43
* @param operator
44
44
*/
45
45
const 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 , '' ) ;
47
51
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 ) ;
52
56
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
+ }
55
61
}
56
62
}
57
63
return null ;
Original file line number Diff line number Diff line change @@ -43,20 +43,25 @@ export const normalizeCapabilityLevel = (capability: string) => {
43
43
* @param operator
44
44
*/
45
45
const 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 , '' ) ;
47
50
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 ) ;
52
55
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
+ }
55
59
}
56
60
}
57
61
return null ;
58
62
} ;
59
63
64
+
60
65
/**
61
66
* Normalize single CRD
62
67
* @param crd
You can’t perform that action at this time.
0 commit comments