mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Explicitly return emty link if no 'kind' available
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
1301e6611d
commit
44b74d6a45
@ -117,10 +117,12 @@ export function createKubeApiURL(ref: IKubeApiLinkRef): string {
|
|||||||
|
|
||||||
export function lookupApiLink(ref: IKubeObjectRef, parentObject: KubeObject): string {
|
export function lookupApiLink(ref: IKubeObjectRef, parentObject: KubeObject): string {
|
||||||
const {
|
const {
|
||||||
kind = "", apiVersion, name,
|
kind, apiVersion, name,
|
||||||
namespace = parentObject.getNs()
|
namespace = parentObject.getNs()
|
||||||
} = ref;
|
} = ref;
|
||||||
|
|
||||||
|
if (!kind) return "";
|
||||||
|
|
||||||
// search in registered apis by 'kind' & 'apiVersion'
|
// search in registered apis by 'kind' & 'apiVersion'
|
||||||
const api = apiManager.getApi(api => api.kind === kind && api.apiVersionWithGroup == apiVersion)
|
const api = apiManager.getApi(api => api.kind === kind && api.apiVersionWithGroup == apiVersion)
|
||||||
if (api) {
|
if (api) {
|
||||||
@ -129,7 +131,7 @@ export function lookupApiLink(ref: IKubeObjectRef, parentObject: KubeObject): st
|
|||||||
|
|
||||||
// lookup api by generated resource link
|
// lookup api by generated resource link
|
||||||
const apiPrefixes = ["/apis", "/api"];
|
const apiPrefixes = ["/apis", "/api"];
|
||||||
const resource = kind.endsWith("s") ? `${kind}es` : `${kind}s`;
|
const resource = kind.endsWith("s") ? `${kind.toLowerCase()}es` : `${kind.toLowerCase()}s`;
|
||||||
for (const apiPrefix of apiPrefixes) {
|
for (const apiPrefix of apiPrefixes) {
|
||||||
const apiLink = createKubeApiURL({ apiPrefix, apiVersion, name, namespace, resource });
|
const apiLink = createKubeApiURL({ apiPrefix, apiVersion, name, namespace, resource });
|
||||||
if (apiManager.getApi(apiLink)) {
|
if (apiManager.getApi(apiLink)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user