Skip to content

Commit 70b04ef

Browse files
committed
fix(cli/gen-models): Add error handling on extra CRDs parsing
1 parent 69c8a1c commit 70b04ef

File tree

1 file changed

+9
-4
lines changed
  • packages/cli/src/commands/gen-models

1 file changed

+9
-4
lines changed

packages/cli/src/commands/gen-models/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,15 @@ async function genModelsAction(): Promise<void> {
153153
moduleLogger.info("Config file exists, searching extra CRDs...")
154154
const configFile = await fs.readFile("config.yaml", "utf8")
155155
const config = YAML.parse(configFile)
156-
// FIXME handle config.extraCrds not existing
157-
const crds = await fetchExtraCRDs(config.extraCrds)
158-
for (const crd of crds) {
159-
documents.push(crd)
156+
if (!config.extraCrds) {
157+
moduleLogger.info("Config file has no extra CRDs")
158+
} else if (!Array.isArray(config.extraCrds)) {
159+
moduleLogger.warn("Config file extraCrds field is not an array!")
160+
} else {
161+
const crds = await fetchExtraCRDs(config.extraCrds)
162+
for (const crd of crds) {
163+
documents.push(crd)
164+
}
160165
}
161166
}
162167

0 commit comments

Comments
 (0)