mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Release/v5.4.4 (#5099)
* Emit AppEvent when opening Catalog and changing Catalog Category (#5071) * Emit AppEvent when opening Catalog and changing Catalog Category. Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Add getName method to CatalogCategory Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Fix winston logger missing splat format (#5070) * Fix KubeJsonApi.forCluster throwing on renderer (#5034) * test relied on typing of newer version of ogre-tools Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com> * release v5.4.4 Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com> Co-authored-by: Panu Horsmalahti <phorsmalahti@mirantis.com> Co-authored-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Co-authored-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
14 files changed
+179
-65
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { CatalogCategory, CatalogCategorySpec } from "../catalog";
|
||||
|
||||
class TestCatalogCategory extends CatalogCategory {
|
||||
public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
|
||||
public readonly kind = "CatalogCategory";
|
||||
public metadata = {
|
||||
name: "Test Category",
|
||||
icon: "",
|
||||
};
|
||||
public spec: CatalogCategorySpec = {
|
||||
group: "entity.k8slens.dev",
|
||||
versions: [],
|
||||
names: {
|
||||
kind: "Test",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe("CatalogCategory", () => {
|
||||
it("returns name", () => {
|
||||
const category = new TestCatalogCategory();
|
||||
|
||||
expect(category.getName()).toEqual("Test Category");
|
||||
});
|
||||
});
|
||||
@@ -173,6 +173,13 @@ export abstract class CatalogCategory extends (EventEmitter as new () => TypedEm
|
||||
return `${this.spec.group}/${this.spec.names.kind}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this category
|
||||
*/
|
||||
public getName(): string {
|
||||
return this.metadata.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a filter for menu items of catalogAddMenu
|
||||
* @param fn The function that should return a truthy value if that menu item should be displayed
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { JsonApi } from "./json-api";
|
||||
import { apiPrefix, isDebugging, isDevelopment } from "../vars";
|
||||
import { appEventBus } from "../app-event-bus/event-bus";
|
||||
|
||||
export let apiBase: JsonApi;
|
||||
|
||||
if (typeof window === "undefined") {
|
||||
appEventBus.addListener((event) => {
|
||||
if (event.name !== "lens-proxy" && event.action !== "listen") return;
|
||||
|
||||
const params = event.params as { port?: number };
|
||||
|
||||
if (!params.port) return;
|
||||
|
||||
apiBase = new JsonApi({
|
||||
serverAddress: `http://127.0.0.1:${params.port}`,
|
||||
apiBase: apiPrefix,
|
||||
debug: isDevelopment || isDebugging,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": `localhost:${params.port}`,
|
||||
},
|
||||
});
|
||||
});
|
||||
} else {
|
||||
apiBase = new JsonApi({
|
||||
serverAddress: `http://127.0.0.1:${window.location.port}`,
|
||||
apiBase: apiPrefix,
|
||||
debug: isDevelopment || isDebugging,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": window.location.host,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { isClusterPageContext } from "../utils";
|
||||
import { KubeJsonApi } from "./kube-json-api";
|
||||
import { apiKubePrefix, isDevelopment } from "../vars";
|
||||
|
||||
export const apiKube = isClusterPageContext()
|
||||
? new KubeJsonApi({
|
||||
serverAddress: `http://127.0.0.1:${window.location.port}`,
|
||||
apiBase: apiKubePrefix,
|
||||
debug: isDevelopment,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": window.location.host,
|
||||
},
|
||||
})
|
||||
: undefined;
|
||||
@@ -3,58 +3,5 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { JsonApi } from "./json-api";
|
||||
import { KubeJsonApi } from "./kube-json-api";
|
||||
import { apiKubePrefix, apiPrefix, isDebugging, isDevelopment } from "../../common/vars";
|
||||
import { isClusterPageContext } from "../utils/cluster-id-url-parsing";
|
||||
import { appEventBus } from "../app-event-bus/event-bus";
|
||||
|
||||
let apiBase: JsonApi;
|
||||
let apiKube: KubeJsonApi;
|
||||
|
||||
if (typeof window === "undefined") {
|
||||
appEventBus.addListener((event) => {
|
||||
if (event.name !== "lens-proxy" && event.action !== "listen") return;
|
||||
|
||||
const params = event.params as { port?: number };
|
||||
|
||||
if (!params.port) return;
|
||||
|
||||
apiBase = new JsonApi({
|
||||
serverAddress: `http://127.0.0.1:${params.port}`,
|
||||
apiBase: apiPrefix,
|
||||
debug: isDevelopment || isDebugging,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": `localhost:${params.port}`,
|
||||
},
|
||||
});
|
||||
});
|
||||
} else {
|
||||
apiBase = new JsonApi({
|
||||
serverAddress: `http://127.0.0.1:${window.location.port}`,
|
||||
apiBase: apiPrefix,
|
||||
debug: isDevelopment || isDebugging,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": window.location.host,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (isClusterPageContext()) {
|
||||
apiKube = new KubeJsonApi({
|
||||
serverAddress: `http://127.0.0.1:${window.location.port}`,
|
||||
apiBase: apiKubePrefix,
|
||||
debug: isDevelopment,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": window.location.host,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
apiBase,
|
||||
apiKube,
|
||||
};
|
||||
export { apiBase } from "./api-base";
|
||||
export { apiKube } from "./api-kube";
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
import { JsonApi, JsonApiData, JsonApiError } from "./json-api";
|
||||
import type { Response } from "node-fetch";
|
||||
import { LensProxy } from "../../main/lens-proxy";
|
||||
import { apiKubePrefix, isDebugging } from "../vars";
|
||||
import { apiBase } from "./api-base";
|
||||
|
||||
export interface KubeJsonApiListMetadata {
|
||||
resourceVersion: string;
|
||||
@@ -57,15 +57,15 @@ export interface KubeJsonApiError extends JsonApiError {
|
||||
|
||||
export class KubeJsonApi extends JsonApi<KubeJsonApiData> {
|
||||
static forCluster(clusterId: string): KubeJsonApi {
|
||||
const port = LensProxy.getInstance().port;
|
||||
const url = new URL(apiBase.config.serverAddress);
|
||||
|
||||
return new this({
|
||||
serverAddress: `http://127.0.0.1:${port}`,
|
||||
serverAddress: apiBase.config.serverAddress,
|
||||
apiBase: apiKubePrefix,
|
||||
debug: isDebugging,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": `${clusterId}.localhost:${port}`,
|
||||
"Host": `${clusterId}.localhost:${url.port}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,6 +65,9 @@ if (ipcMain) {
|
||||
}
|
||||
|
||||
export default winston.createLogger({
|
||||
format: format.simple(),
|
||||
format: format.combine(
|
||||
format.splat(),
|
||||
format.simple(),
|
||||
),
|
||||
transports,
|
||||
});
|
||||
Reference in new issue
Block a user