Skip to content
This repository has been archived by the owner on Apr 19, 2021. It is now read-only.

Enable auto-kubernetes-client to report API group errors and continu #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,13 @@ function connect(config) {
}, api);
}

return k8sRequest(groupPath, {}).then(createApiFromResources);
return k8sRequest(groupPath, {})
.then(
createApiFromResources,
() => {
console.error(`auto-kubernetes-client failed to acquire API definition for '${apiName}' from '${groupPath}'`);
}
);
}

const coreVersion = config.version || 'v1';
Expand All @@ -378,10 +384,12 @@ function connect(config) {
}).then(apis => {
return apis.reduce((result, api) => {
// Build a compatible name for this API. Note that both api.name and api.version can end up empty here.
const apiNamePrefix = api.name ? `${api.name}/` : '';
result[`${apiNamePrefix}${api.version}`] = api;
if (api.preferred) {
result[api.name] = api;
if (api) {
const apiNamePrefix = api.name ? `${api.name}/` : '';
result[`${apiNamePrefix}${api.version}`] = api;
if (api.preferred) {
result[api.name] = api;
}
}
return result;
}, {});
Expand Down