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 4601468
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,16 @@ 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) => {
const almExamples = csv?.metadata?.annotations?.['alm-examples'] ?? '[]';
try {
return JSON.parse(almExamples);
} 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 4601468

Please sign in to comment.