Skip to content

Commit

Permalink
fix(k8s): confusing error message when resource type doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Jan 18, 2021
1 parent 4cee1a8 commit ef70e19
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions core/src/plugins/kubernetes/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,23 @@ export class KubeApi {
}

log.debug(`Kubernetes: Getting API resource info for group ${apiVersion}`)
const res = await this.request({ log, path: getGroupBasePath(apiVersion) })

// We're only interested in the entities themselves, not the sub-resources
const resources = res.body.resources.filter((r: any) => !r.name.includes("/"))
try {
const res = await this.request({ log, path: getGroupBasePath(apiVersion) })

// We're only interested in the entities themselves, not the sub-resources
const resources = res.body.resources.filter((r: any) => !r.name.includes("/"))

apiResources[apiVersion] = keyBy(resources, "kind")
return apiResources[apiVersion]
apiResources[apiVersion] = keyBy(resources, "kind")
return apiResources[apiVersion]
} catch (err) {
if (err.statusCode === 404) {
// Could not find the resource type
return {}
} else {
throw err
}
}
}))

const resource = resourceMap[kind]
Expand Down

0 comments on commit ef70e19

Please sign in to comment.