Skip to content

Commit

Permalink
Fix json parsing exception in create operand workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealJon committed Apr 30, 2020
1 parent 9384794 commit d8276ed
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,15 @@ export const providedAPIForModel = (csv: ClusterServiceVersionKind, model: K8sKi
(crd) => referenceForProvidedAPI(crd) === referenceForModel(model),
);

export const parseALMExamples = (csv: ClusterServiceVersionKind) =>
JSON.parse(_.get(csv, 'metadata.annotations.alm-examples', '[]'));
export const parseALMExamples = (csv: ClusterServiceVersionKind) => {
try {
return JSON.parse(csv?.metadata?.annotations?.['alm-examples'] ?? '[]');
} catch (e) {
// eslint-disable-next-line no-console
console.warn('Unable to parse ALM expamples\n', e);
return [];
}
};

export const exampleForModel = (csv: ClusterServiceVersionKind, model: K8sKind) =>
_.defaultsDeep(
Expand Down

0 comments on commit d8276ed

Please sign in to comment.