mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Use common/logger everywhere, remove main/logger export
- in Renderer make it 'console' which a stub for silly level - in Main make it a winston logger with file output as well - in testing make it a jest mock stub - in all other cases make it a winston logger without file output - Turn on no-console - Fix logger during integration testing Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
a5e89b79d6
commit
990000678a
@ -58,6 +58,7 @@ module.exports = {
|
|||||||
"header/header": [2, "./license-header"],
|
"header/header": [2, "./license-header"],
|
||||||
"comma-dangle": ["error", "always-multiline"],
|
"comma-dangle": ["error", "always-multiline"],
|
||||||
"comma-spacing": "error",
|
"comma-spacing": "error",
|
||||||
|
"no-console": "error",
|
||||||
"indent": ["error", 2, {
|
"indent": ["error", 2, {
|
||||||
"SwitchCase": 1,
|
"SwitchCase": 1,
|
||||||
}],
|
}],
|
||||||
@ -124,6 +125,7 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
"no-constant-condition": ["error", { "checkLoops": false }],
|
"no-constant-condition": ["error", { "checkLoops": false }],
|
||||||
"header/header": [2, "./license-header"],
|
"header/header": [2, "./license-header"],
|
||||||
|
"no-console": "error",
|
||||||
"no-invalid-this": "off",
|
"no-invalid-this": "off",
|
||||||
"@typescript-eslint/no-invalid-this": ["error"],
|
"@typescript-eslint/no-invalid-this": ["error"],
|
||||||
"@typescript-eslint/explicit-function-return-type": "off",
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
@ -210,6 +212,7 @@ module.exports = {
|
|||||||
"no-constant-condition": ["error", { "checkLoops": false }],
|
"no-constant-condition": ["error", { "checkLoops": false }],
|
||||||
"header/header": [2, "./license-header"],
|
"header/header": [2, "./license-header"],
|
||||||
"react/prop-types": "off",
|
"react/prop-types": "off",
|
||||||
|
"no-console": "error",
|
||||||
"no-invalid-this": "off",
|
"no-invalid-this": "off",
|
||||||
"@typescript-eslint/no-invalid-this": ["error"],
|
"@typescript-eslint/no-invalid-this": ["error"],
|
||||||
"@typescript-eslint/explicit-function-return-type": "off",
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import defaultBaseLensTheme from "../src/renderer/themes/lens-dark.json";
|
import defaultBaseLensTheme from "../src/renderer/themes/lens-dark.json";
|
||||||
|
import logger from "../src/common/logger";
|
||||||
|
|
||||||
const outputCssFile = path.resolve("src/renderer/themes/theme-vars.css");
|
const outputCssFile = path.resolve("src/renderer/themes/theme-vars.css");
|
||||||
|
|
||||||
@ -42,6 +43,6 @@ ${themeCssVars.join("\n")}
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
// Run
|
// Run
|
||||||
console.info(`"Saving default Lens theme css-variables to "${outputCssFile}""`);
|
logger.info(`"Saving default Lens theme css-variables to "${outputCssFile}""`);
|
||||||
fs.ensureFileSync(outputCssFile);
|
fs.ensureFileSync(outputCssFile);
|
||||||
fs.writeFile(outputCssFile, content);
|
fs.writeFile(outputCssFile, content);
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import path from "path";
|
|||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import jsdom from "jsdom";
|
import jsdom from "jsdom";
|
||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
|
import logger from "../src/common/logger";
|
||||||
|
|
||||||
export async function generateTrayIcon(
|
export async function generateTrayIcon(
|
||||||
{
|
{
|
||||||
@ -52,9 +53,9 @@ export async function generateTrayIcon(
|
|||||||
|
|
||||||
// Save icon
|
// Save icon
|
||||||
await fs.writeFile(pngIconDestPath, pngIconBuffer);
|
await fs.writeFile(pngIconDestPath, pngIconBuffer);
|
||||||
console.info(`[DONE]: Tray icon saved at "${pngIconDestPath}"`);
|
logger.info(`[DONE]: Tray icon saved at "${pngIconDestPath}"`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`[ERROR]: ${err}`);
|
logger.error(`[ERROR]: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,11 +25,11 @@ import * as path from "path";
|
|||||||
|
|
||||||
const helmVersion = packageInfo.config.bundledHelmVersion;
|
const helmVersion = packageInfo.config.bundledHelmVersion;
|
||||||
|
|
||||||
if (!isWindows) {
|
if (isWindows) {
|
||||||
|
new HelmCli(path.join(process.cwd(), "binaries", "client", "x64"), helmVersion).ensureBinary();
|
||||||
|
} else {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
new HelmCli(path.join(process.cwd(), "binaries", "client", "x64"), helmVersion).ensureBinary(),
|
new HelmCli(path.join(process.cwd(), "binaries", "client", "x64"), helmVersion).ensureBinary(),
|
||||||
new HelmCli(path.join(process.cwd(), "binaries", "client", "arm64"), helmVersion).ensureBinary(),
|
new HelmCli(path.join(process.cwd(), "binaries", "client", "arm64"), helmVersion).ensureBinary(),
|
||||||
]);
|
]);
|
||||||
} else {
|
|
||||||
new HelmCli(path.join(process.cwd(), "binaries", "client", "x64"), helmVersion).ensureBinary();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import { ensureDir, pathExists } from "fs-extra";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { noop } from "lodash";
|
import { noop } from "lodash";
|
||||||
import { isLinux, isMac } from "../src/common/vars";
|
import { isLinux, isMac } from "../src/common/vars";
|
||||||
|
import logger from "../src/common/logger";
|
||||||
|
|
||||||
class KubectlDownloader {
|
class KubectlDownloader {
|
||||||
public kubectlVersion: string;
|
public kubectlVersion: string;
|
||||||
@ -48,7 +49,7 @@ class KubectlDownloader {
|
|||||||
method: "HEAD",
|
method: "HEAD",
|
||||||
uri: this.url,
|
uri: this.url,
|
||||||
resolveWithFullResponse: true,
|
resolveWithFullResponse: true,
|
||||||
}).catch(console.error);
|
}).catch(logger.error);
|
||||||
|
|
||||||
if (response.headers["etag"]) {
|
if (response.headers["etag"]) {
|
||||||
return response.headers["etag"].replace(/"/g, "");
|
return response.headers["etag"].replace(/"/g, "");
|
||||||
@ -65,12 +66,12 @@ class KubectlDownloader {
|
|||||||
const etag = await this.urlEtag();
|
const etag = await this.urlEtag();
|
||||||
|
|
||||||
if (hash == etag) {
|
if (hash == etag) {
|
||||||
console.log("Kubectl md5sum matches the remote etag");
|
logger.info("Kubectl md5sum matches the remote etag");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Kubectl md5sum ${hash} does not match the remote etag ${etag}, unlinking and downloading again`);
|
logger.info(`Kubectl md5sum ${hash} does not match the remote etag ${etag}, unlinking and downloading again`);
|
||||||
await fs.promises.unlink(this.path);
|
await fs.promises.unlink(this.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,14 +80,14 @@ class KubectlDownloader {
|
|||||||
|
|
||||||
public async downloadKubectl() {
|
public async downloadKubectl() {
|
||||||
if (await this.checkBinary()) {
|
if (await this.checkBinary()) {
|
||||||
return console.log("Already exists and is valid");
|
return logger.info("Already exists and is valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
await ensureDir(path.dirname(this.path), 0o755);
|
await ensureDir(path.dirname(this.path), 0o755);
|
||||||
|
|
||||||
const file = fs.createWriteStream(this.path);
|
const file = fs.createWriteStream(this.path);
|
||||||
|
|
||||||
console.log(`Downloading kubectl ${this.kubectlVersion} from ${this.url} to ${this.path}`);
|
logger.info(`Downloading kubectl ${this.kubectlVersion} from ${this.url} to ${this.path}`);
|
||||||
const requestOpts: request.UriOptions & request.CoreOptions = {
|
const requestOpts: request.UriOptions & request.CoreOptions = {
|
||||||
uri: this.url,
|
uri: this.url,
|
||||||
gzip: true,
|
gzip: true,
|
||||||
@ -94,19 +95,19 @@ class KubectlDownloader {
|
|||||||
const stream = request(requestOpts);
|
const stream = request(requestOpts);
|
||||||
|
|
||||||
stream.on("complete", () => {
|
stream.on("complete", () => {
|
||||||
console.log("kubectl binary download finished");
|
logger.info("kubectl binary download finished");
|
||||||
file.end(noop);
|
file.end(noop);
|
||||||
});
|
});
|
||||||
|
|
||||||
stream.on("error", (error) => {
|
stream.on("error", (error) => {
|
||||||
console.log(error);
|
logger.info(error);
|
||||||
fs.unlink(this.path, noop);
|
fs.unlink(this.path, noop);
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
file.on("close", () => {
|
file.on("close", () => {
|
||||||
console.log("kubectl binary download closed");
|
logger.info("kubectl binary download closed");
|
||||||
fs.chmod(this.path, 0o755, (err) => {
|
fs.chmod(this.path, 0o755, (err) => {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
});
|
});
|
||||||
@ -133,9 +134,9 @@ if (isMac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloads.forEach((dlOpts) => {
|
downloads.forEach((dlOpts) => {
|
||||||
console.log(dlOpts);
|
logger.info(dlOpts);
|
||||||
const downloader = new KubectlDownloader(downloadVersion, dlOpts.platform, dlOpts.arch, dlOpts.target);
|
const downloader = new KubectlDownloader(downloadVersion, dlOpts.platform, dlOpts.arch, dlOpts.target);
|
||||||
|
|
||||||
console.log(`Downloading: ${JSON.stringify(dlOpts)}`);
|
logger.info(`Downloading: ${JSON.stringify(dlOpts)}`);
|
||||||
downloader.downloadKubectl().then(() => downloader.checkBinary().then(() => console.log("Download complete")));
|
downloader.downloadKubectl().then(() => downloader.checkBinary().then(() => logger.info("Download complete")));
|
||||||
});
|
});
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import * as path from "path";
|
|||||||
import appInfo from "../package.json";
|
import appInfo from "../package.json";
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
import fastGlob from "fast-glob";
|
import fastGlob from "fast-glob";
|
||||||
|
import logger from "../src/common/logger";
|
||||||
|
|
||||||
const packagePath = path.join(__dirname, "../package.json");
|
const packagePath = path.join(__dirname, "../package.json");
|
||||||
const versionInfo = semver.parse(appInfo.version);
|
const versionInfo = semver.parse(appInfo.version);
|
||||||
@ -63,7 +64,7 @@ async function writeOutNewVersions() {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
async function main() {
|
||||||
const prereleaseParts: string[] = [getBuildChannel()];
|
const prereleaseParts: string[] = [getBuildChannel()];
|
||||||
|
|
||||||
if (versionInfo.prerelease && versionInfo.prerelease.length > 1) {
|
if (versionInfo.prerelease && versionInfo.prerelease.length > 1) {
|
||||||
@ -74,11 +75,12 @@ function main() {
|
|||||||
|
|
||||||
appInfo.version = `${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}-${prereleaseParts.join(".")}`;
|
appInfo.version = `${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}-${prereleaseParts.join(".")}`;
|
||||||
|
|
||||||
writeOutNewVersions()
|
try {
|
||||||
.catch((error) => {
|
await writeOutNewVersions();
|
||||||
console.error(error);
|
} catch (error) {
|
||||||
|
logger.error("Failed to write new build versions", error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import semver from "semver";
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
const { ResourceStack, forCluster, StorageClass, Namespace } = Renderer.K8sApi;
|
const { ResourceStack, forCluster, StorageClass, Namespace } = Renderer.K8sApi;
|
||||||
|
const { logger } = Common;
|
||||||
|
|
||||||
type ResourceStack = Renderer.K8sApi.ResourceStack;
|
type ResourceStack = Renderer.K8sApi.ResourceStack;
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ export class MetricsFeature {
|
|||||||
if (e?.error?.code === 404) {
|
if (e?.error?.code === 404) {
|
||||||
status.installed = false;
|
status.installed = false;
|
||||||
} else {
|
} else {
|
||||||
console.warn("[LENS-METRICS] failed to resolve install state", e);
|
logger.warn("[LENS-METRICS] failed to resolve install state", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Cluster tests are run if there is a pre-existing minikube cluster. Before running cluster tests the TEST_NAMESPACE
|
Cluster tests are run if there is a pre-existing minikube cluster. Before running cluster tests the TEST_NAMESPACE
|
||||||
|
|||||||
@ -18,6 +18,8 @@
|
|||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
import { spawnSync } from "child_process";
|
import { spawnSync } from "child_process";
|
||||||
|
|
||||||
export function minikubeReady(testNamespace: string): boolean {
|
export function minikubeReady(testNamespace: string): boolean {
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
import { anyObject } from "jest-mock-extended";
|
import { anyObject } from "jest-mock-extended";
|
||||||
import { merge } from "lodash";
|
import { merge } from "lodash";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import logger from "../../main/logger";
|
import logger from "../logger";
|
||||||
import { AppPaths } from "../app-paths";
|
import { AppPaths } from "../app-paths";
|
||||||
import type { CatalogEntity, CatalogEntityData, CatalogEntityKindData } from "../catalog";
|
import type { CatalogEntity, CatalogEntityData, CatalogEntityKindData } from "../catalog";
|
||||||
import { ClusterStore } from "../cluster-store";
|
import { ClusterStore } from "../cluster-store";
|
||||||
@ -253,21 +253,14 @@ describe("HotbarStore", () => {
|
|||||||
hotbarStore.add({ name: "hottest", id: "hottest" });
|
hotbarStore.add({ name: "hottest", id: "hottest" });
|
||||||
hotbarStore.setActiveHotbar("hottest");
|
hotbarStore.setActiveHotbar("hottest");
|
||||||
|
|
||||||
const { error } = logger;
|
|
||||||
const mocked = jest.fn();
|
|
||||||
|
|
||||||
logger.error = mocked;
|
|
||||||
|
|
||||||
hotbarStore.addToHotbar(testCluster, -1);
|
hotbarStore.addToHotbar(testCluster, -1);
|
||||||
expect(mocked).toBeCalledWith("[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range", anyObject());
|
expect(logger.error).toBeCalledWith("[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range", anyObject());
|
||||||
|
|
||||||
hotbarStore.addToHotbar(testCluster, 12);
|
hotbarStore.addToHotbar(testCluster, 12);
|
||||||
expect(mocked).toBeCalledWith("[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range", anyObject());
|
expect(logger.error).toBeCalledWith("[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range", anyObject());
|
||||||
|
|
||||||
hotbarStore.addToHotbar(testCluster, 13);
|
hotbarStore.addToHotbar(testCluster, 13);
|
||||||
expect(mocked).toBeCalledWith("[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range", anyObject());
|
expect(logger.error).toBeCalledWith("[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range", anyObject());
|
||||||
|
|
||||||
logger.error = error;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error if getId is invalid or returns not a string", () => {
|
it("throws an error if getId is invalid or returns not a string", () => {
|
||||||
@ -305,12 +298,6 @@ describe("HotbarStore", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws if invalid arguments provided", () => {
|
it("throws if invalid arguments provided", () => {
|
||||||
// Prevent writing to stderr during this render.
|
|
||||||
const { error, warn } = console;
|
|
||||||
|
|
||||||
console.error = jest.fn();
|
|
||||||
console.warn = jest.fn();
|
|
||||||
|
|
||||||
const hotbarStore = HotbarStore.getInstance();
|
const hotbarStore = HotbarStore.getInstance();
|
||||||
|
|
||||||
hotbarStore.addToHotbar(testCluster);
|
hotbarStore.addToHotbar(testCluster);
|
||||||
@ -319,10 +306,6 @@ describe("HotbarStore", () => {
|
|||||||
expect(() => hotbarStore.restackItems(2, -1)).toThrow();
|
expect(() => hotbarStore.restackItems(2, -1)).toThrow();
|
||||||
expect(() => hotbarStore.restackItems(14, 1)).toThrow();
|
expect(() => hotbarStore.restackItems(14, 1)).toThrow();
|
||||||
expect(() => hotbarStore.restackItems(11, 112)).toThrow();
|
expect(() => hotbarStore.restackItems(11, 112)).toThrow();
|
||||||
|
|
||||||
// Restore writing to stderr.
|
|
||||||
console.error = error;
|
|
||||||
console.warn = warn;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("checks if entity already pinned to hotbar", () => {
|
it("checks if entity already pinned to hotbar", () => {
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import type { Options as ConfOptions } from "conf/dist/source/types";
|
|||||||
import { ipcMain, ipcRenderer } from "electron";
|
import { ipcMain, ipcRenderer } from "electron";
|
||||||
import { IEqualsComparer, makeObservable, reaction, runInAction } from "mobx";
|
import { IEqualsComparer, makeObservable, reaction, runInAction } from "mobx";
|
||||||
import { getAppVersion, Singleton, toJS, Disposer } from "./utils";
|
import { getAppVersion, Singleton, toJS, Disposer } from "./utils";
|
||||||
import logger from "../main/logger";
|
import logger from "./logger";
|
||||||
import { broadcastMessage, ipcMainOn, ipcRendererOn } from "./ipc";
|
import { broadcastMessage, ipcMainOn, ipcRendererOn } from "./ipc";
|
||||||
import isEqual from "lodash/isEqual";
|
import isEqual from "lodash/isEqual";
|
||||||
import { isTestEnv } from "./vars";
|
import { isTestEnv } from "./vars";
|
||||||
@ -75,7 +75,7 @@ export abstract class BaseStore<T> extends Singleton {
|
|||||||
const res: any = this.fromStore(this.storeConfig.store);
|
const res: any = this.fromStore(this.storeConfig.store);
|
||||||
|
|
||||||
if (res instanceof Promise || (typeof res === "object" && res && typeof res.then === "function")) {
|
if (res instanceof Promise || (typeof res === "object" && res && typeof res.then === "function")) {
|
||||||
console.error(`${this.displayName} extends BaseStore<T>'s fromStore method returns a Promise or promise-like object. This is an error and must be fixed.`);
|
logger.error(`${this.displayName} extends BaseStore<T>'s fromStore method returns a Promise or promise-like object. This is an error and must be fixed.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.enableSync();
|
this.enableSync();
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import { action, comparer, computed, makeObservable, observable, reaction } from
|
|||||||
import { BaseStore } from "./base-store";
|
import { BaseStore } from "./base-store";
|
||||||
import { Cluster } from "../main/cluster";
|
import { Cluster } from "../main/cluster";
|
||||||
import migrations from "../migrations/cluster-store";
|
import migrations from "../migrations/cluster-store";
|
||||||
import logger from "../main/logger";
|
import logger from "../common/logger";
|
||||||
import { appEventBus } from "./event-bus";
|
import { appEventBus } from "./event-bus";
|
||||||
import { ipcMainHandle, requestMain } from "./ipc";
|
import { ipcMainHandle, requestMain } from "./ipc";
|
||||||
import { disposer, toJS } from "./utils";
|
import { disposer, toJS } from "./utils";
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import esbuild from "esbuild";
|
import esbuild from "esbuild";
|
||||||
|
import logger from "./logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function returning webpack ts/tsx loader
|
* A function returning webpack ts/tsx loader
|
||||||
@ -33,7 +34,7 @@ const getTSLoader = (
|
|||||||
testRegExp: RegExp, transpileOnly = true,
|
testRegExp: RegExp, transpileOnly = true,
|
||||||
) => {
|
) => {
|
||||||
if (process.env.LENS_DEV_USE_ESBUILD_LOADER === "true") {
|
if (process.env.LENS_DEV_USE_ESBUILD_LOADER === "true") {
|
||||||
console.info(`\n🚀 using esbuild-loader for ts(x)`);
|
logger.info(`🚀 using esbuild-loader for ts(x)`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
test: testRegExp,
|
test: testRegExp,
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import migrations from "../migrations/hotbar-store";
|
|||||||
import { toJS } from "./utils";
|
import { toJS } from "./utils";
|
||||||
import { CatalogEntity } from "./catalog";
|
import { CatalogEntity } from "./catalog";
|
||||||
import { catalogEntity } from "../main/catalog-sources/general";
|
import { catalogEntity } from "../main/catalog-sources/general";
|
||||||
import logger from "../main/logger";
|
import logger from "./logger";
|
||||||
import { broadcastMessage, HotbarTooManyItems } from "./ipc";
|
import { broadcastMessage, HotbarTooManyItems } from "./ipc";
|
||||||
import { defaultHotbarCells, getEmptyHotbar, Hotbar, CreateHotbarData, CreateHotbarOptions } from "./hotbar-types";
|
import { defaultHotbarCells, getEmptyHotbar, Hotbar, CreateHotbarData, CreateHotbarOptions } from "./hotbar-types";
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
const index = this.hotbars.findIndex((hotbar) => hotbar.id === id);
|
const index = this.hotbars.findIndex((hotbar) => hotbar.id === id);
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return void console.warn(`[HOTBAR-STORE]: cannot setHotbarName: unknown id`, { id });
|
return void logger.warn(`[HOTBAR-STORE]: cannot setHotbarName: unknown id`, { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hotbars[index].name = name;
|
this.hotbars[index].name = name;
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
import { ipcMain, ipcRenderer, webContents } from "electron";
|
import { ipcMain, ipcRenderer, webContents } from "electron";
|
||||||
import { toJS } from "../utils/toJS";
|
import { toJS } from "../utils/toJS";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames";
|
import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames";
|
||||||
import type { Disposer } from "../utils";
|
import type { Disposer } from "../utils";
|
||||||
import type remote from "@electron/remote";
|
import type remote from "@electron/remote";
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
import type { EventEmitter } from "events";
|
import type { EventEmitter } from "events";
|
||||||
import { ipcMain } from "electron";
|
import { ipcMain } from "electron";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
import type { Disposer } from "../utils";
|
import type { Disposer } from "../utils";
|
||||||
import { ipcMainHandle } from "./ipc";
|
import { ipcMainHandle } from "./ipc";
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { anyObject } from "jest-mock-extended";
|
import { anyObject } from "jest-mock-extended";
|
||||||
|
import logger from "../../logger";
|
||||||
import { HelmChart } from "../endpoints/helm-charts.api";
|
import { HelmChart } from "../endpoints/helm-charts.api";
|
||||||
|
|
||||||
describe("HelmChart tests", () => {
|
describe("HelmChart tests", () => {
|
||||||
@ -262,9 +263,6 @@ describe("HelmChart tests", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should warn on unknown fields", () => {
|
it("should warn on unknown fields", () => {
|
||||||
const { warn } = console;
|
|
||||||
const warnFn = console.warn = jest.fn();
|
|
||||||
|
|
||||||
HelmChart.create({
|
HelmChart.create({
|
||||||
apiVersion: "1",
|
apiVersion: "1",
|
||||||
name: "1",
|
name: "1",
|
||||||
@ -280,11 +278,10 @@ describe("HelmChart tests", () => {
|
|||||||
"asdjhajksdhadjks": 1,
|
"asdjhajksdhadjks": 1,
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
expect(warnFn).toHaveBeenCalledWith("HelmChart data has unexpected fields", {
|
expect(logger.warn).toHaveBeenCalledWith("HelmChart data has unexpected fields", {
|
||||||
original: anyObject(),
|
original: anyObject(),
|
||||||
unknownFields: ["asdjhajksdhadjks"],
|
unknownFields: ["asdjhajksdhadjks"],
|
||||||
});
|
});
|
||||||
console.warn = warn;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import { stringify } from "querystring";
|
|||||||
import type { RequestInit } from "node-fetch";
|
import type { RequestInit } from "node-fetch";
|
||||||
import { autoBind, bifurcateArray } from "../../utils";
|
import { autoBind, bifurcateArray } from "../../utils";
|
||||||
import Joi from "joi";
|
import Joi from "joi";
|
||||||
|
import logger from "../../logger";
|
||||||
|
|
||||||
export type RepoHelmChartList = Record<string, RawHelmChart[]>;
|
export type RepoHelmChartList = Record<string, RawHelmChart[]>;
|
||||||
|
|
||||||
@ -321,7 +322,7 @@ export class HelmChart {
|
|||||||
const [actualErrors, unknownDetails] = bifurcateArray(error.details, ({ type }) => type === "object.unknown");
|
const [actualErrors, unknownDetails] = bifurcateArray(error.details, ({ type }) => type === "object.unknown");
|
||||||
|
|
||||||
if (unknownDetails.length > 0) {
|
if (unknownDetails.length > 0) {
|
||||||
console.warn("HelmChart data has unexpected fields", { original: data, unknownFields: unknownDetails.flatMap(d => d.path) });
|
logger.warn("HelmChart data has unexpected fields", { original: data, unknownFields: unknownDetails.flatMap(d => d.path) });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actualErrors.length === 0) {
|
if (actualErrors.length === 0) {
|
||||||
@ -334,7 +335,7 @@ export class HelmChart {
|
|||||||
throw validationError;
|
throw validationError;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn("[HELM-CHART]: failed to validate data", data, validationError);
|
logger.warn("[HELM-CHART]: failed to validate data", data, validationError);
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
import { splitArray } from "../utils";
|
import { splitArray } from "../utils";
|
||||||
import { isDebugging } from "../vars";
|
import { isDebugging } from "../vars";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
import { inspect } from "util";
|
import { inspect } from "util";
|
||||||
|
|
||||||
export interface IKubeObjectRef {
|
export interface IKubeObjectRef {
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
import { isFunction, merge } from "lodash";
|
import { isFunction, merge } from "lodash";
|
||||||
import { stringify } from "querystring";
|
import { stringify } from "querystring";
|
||||||
import { apiKubePrefix, isDevelopment } from "../../common/vars";
|
import { apiKubePrefix, isDevelopment } from "../../common/vars";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
import { apiManager } from "./api-manager";
|
import { apiManager } from "./api-manager";
|
||||||
import { apiBase, apiKube } from "./index";
|
import { apiBase, apiKube } from "./index";
|
||||||
import { createKubeApiURL, parseKubeApi } from "./kube-api-parse";
|
import { createKubeApiURL, parseKubeApi } from "./kube-api-parse";
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import type { RequestInit } from "node-fetch";
|
|||||||
// eslint-disable-next-line import/no-named-as-default
|
// eslint-disable-next-line import/no-named-as-default
|
||||||
import AbortController from "abort-controller";
|
import AbortController from "abort-controller";
|
||||||
import type { Patch } from "rfc6902";
|
import type { Patch } from "rfc6902";
|
||||||
|
import logger from "../logger";
|
||||||
|
|
||||||
export interface KubeObjectStoreLoadingParams {
|
export interface KubeObjectStoreLoadingParams {
|
||||||
namespaces: string[];
|
namespaces: string[];
|
||||||
@ -253,7 +254,7 @@ export abstract class KubeObjectStore<T extends KubeObject> extends ItemStore<T>
|
|||||||
|
|
||||||
return items;
|
return items;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn("[KubeObjectStore] loadAll failed", this.api.apiBase, error);
|
logger.warn("[KubeObjectStore] loadAll failed", this.api.apiBase, error);
|
||||||
this.resetOnError(error);
|
this.resetOnError(error);
|
||||||
this.failedLoading = true;
|
this.failedLoading = true;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@ -86,7 +86,7 @@ class WatchCount {
|
|||||||
|
|
||||||
const newCount = this.#data.get(store) + 1;
|
const newCount = this.#data.get(store) + 1;
|
||||||
|
|
||||||
logger.info(`[KUBE-WATCH-API]: inc() count for ${store.api.objectConstructor.apiBase} is now ${newCount}`);
|
logger.debug(`[KUBE-WATCH-API]: inc() count for ${store.api.objectConstructor.apiBase} is now ${newCount}`);
|
||||||
this.#data.set(store, newCount);
|
this.#data.set(store, newCount);
|
||||||
|
|
||||||
return newCount;
|
return newCount;
|
||||||
@ -151,10 +151,10 @@ export class KubeWatchApi {
|
|||||||
if (curSelectedAll && prevSelectedAll) {
|
if (curSelectedAll && prevSelectedAll) {
|
||||||
const action = namespaces.length > prevNamespaces.length ? "created" : "deleted";
|
const action = namespaces.length > prevNamespaces.length ? "created" : "deleted";
|
||||||
|
|
||||||
return console.debug(`[KUBE-WATCH-API]: Not changing watch for ${store.api.apiBase} because a new namespace was ${action} but all namespaces are selected`);
|
return this.log(`[KUBE-WATCH-API]: Not changing watch for ${store.api.apiBase} because a new namespace was ${action} but all namespaces are selected`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[KUBE-WATCH-API]: changing watch ${store.api.apiBase}`, namespaces);
|
this.log(`[KUBE-WATCH-API]: changing watch ${store.api.apiBase}`, namespaces);
|
||||||
childController.abort();
|
childController.abort();
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
childController = new WrappedAbortController(parent);
|
childController = new WrappedAbortController(parent);
|
||||||
@ -195,10 +195,10 @@ export class KubeWatchApi {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected log(message: any, meta: any) {
|
protected log(message: any, meta: object = {}) {
|
||||||
const log = message instanceof Error
|
const log = message instanceof Error
|
||||||
? console.error
|
? logger.error
|
||||||
: console.debug;
|
: logger.debug;
|
||||||
|
|
||||||
log("[KUBE-WATCH-API]:", message, {
|
log("[KUBE-WATCH-API]:", message, {
|
||||||
time: new Date().toLocaleString(),
|
time: new Date().toLocaleString(),
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import path from "path";
|
|||||||
import hb from "handlebars";
|
import hb from "handlebars";
|
||||||
import { ResourceApplier } from "../../main/resource-applier";
|
import { ResourceApplier } from "../../main/resource-applier";
|
||||||
import type { KubernetesCluster } from "../catalog-entities";
|
import type { KubernetesCluster } from "../catalog-entities";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
import { requestMain } from "../ipc";
|
import { requestMain } from "../ipc";
|
||||||
import { clusterKubectlApplyAllHandler, clusterKubectlDeleteAllHandler } from "../cluster-ipc";
|
import { clusterKubectlApplyAllHandler, clusterKubectlDeleteAllHandler } from "../cluster-ipc";
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import fse from "fs-extra";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import yaml from "js-yaml";
|
import yaml from "js-yaml";
|
||||||
import logger from "../main/logger";
|
import logger from "../common/logger";
|
||||||
import { Cluster, Context, newClusters, newContexts, newUsers, User } from "@kubernetes/client-node/dist/config_types";
|
import { Cluster, Context, newClusters, newContexts, newUsers, User } from "@kubernetes/client-node/dist/config_types";
|
||||||
import { resolvePath } from "./utils";
|
import { resolvePath } from "./utils";
|
||||||
import Joi from "joi";
|
import Joi from "joi";
|
||||||
|
|||||||
@ -19,12 +19,10 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { app, ipcMain } from "electron";
|
import { app, ipcRenderer } from "electron";
|
||||||
import winston, { format } from "winston";
|
import winston, { format } from "winston";
|
||||||
import type Transport from "winston-transport";
|
|
||||||
import { consoleFormat } from "winston-console-format";
|
import { consoleFormat } from "winston-console-format";
|
||||||
import { isDebugging, isTestEnv } from "./vars";
|
import { isDebugging, isTestEnv } from "./vars";
|
||||||
import BrowserConsole from "winston-transport-browserconsole";
|
|
||||||
|
|
||||||
const logLevel = process.env.LOG_LEVEL
|
const logLevel = process.env.LOG_LEVEL
|
||||||
? process.env.LOG_LEVEL
|
? process.env.LOG_LEVEL
|
||||||
@ -34,10 +32,34 @@ const logLevel = process.env.LOG_LEVEL
|
|||||||
? "error"
|
? "error"
|
||||||
: "info";
|
: "info";
|
||||||
|
|
||||||
const transports: Transport[] = [];
|
interface Logger {
|
||||||
|
silly(...args: any[]): void;
|
||||||
|
warn(...args: any[]): void;
|
||||||
|
info(...args: any[]): void;
|
||||||
|
debug(...args: any[]): void;
|
||||||
|
error(...args: any[]): void;
|
||||||
|
}
|
||||||
|
|
||||||
if (ipcMain) {
|
function createRendererLogger(): Logger {
|
||||||
transports.push(
|
return {
|
||||||
|
...console,
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
silly: (...args: any[]) => console.debug(...args),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function createUnitTestingLogger(): Logger {
|
||||||
|
return {
|
||||||
|
silly: jest.fn(),
|
||||||
|
warn: jest.fn(),
|
||||||
|
info: jest.fn(),
|
||||||
|
debug: jest.fn(),
|
||||||
|
error: jest.fn(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function createMainLogger(): Logger {
|
||||||
|
const transports: winston.transport[] = [
|
||||||
new winston.transports.Console({
|
new winston.transports.Console({
|
||||||
handleExceptions: false,
|
handleExceptions: false,
|
||||||
level: logLevel,
|
level: logLevel,
|
||||||
@ -57,18 +79,14 @@ if (ipcMain) {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
);
|
];
|
||||||
|
|
||||||
if (!isTestEnv) {
|
if (app) {
|
||||||
transports.push(
|
transports.push(
|
||||||
new winston.transports.File({
|
new winston.transports.File({
|
||||||
handleExceptions: false,
|
handleExceptions: false,
|
||||||
level: logLevel,
|
level: logLevel,
|
||||||
filename: "lens.log",
|
filename: "lens.log",
|
||||||
/**
|
|
||||||
* SAFTEY: the `ipcMain` check above should mean that this is only
|
|
||||||
* called in the main process
|
|
||||||
*/
|
|
||||||
dirname: app.getPath("logs"),
|
dirname: app.getPath("logs"),
|
||||||
maxsize: 16 * 1024,
|
maxsize: 16 * 1024,
|
||||||
maxFiles: 16,
|
maxFiles: 16,
|
||||||
@ -76,11 +94,24 @@ if (ipcMain) {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
transports.push(new BrowserConsole());
|
|
||||||
}
|
|
||||||
|
|
||||||
export default winston.createLogger({
|
return winston.createLogger({
|
||||||
format: format.simple(),
|
format: format.simple(),
|
||||||
transports,
|
transports,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createLogger(): Logger {
|
||||||
|
if (isTestEnv && !process.env.CICD) {
|
||||||
|
// CICD is present during integration tests
|
||||||
|
return createUnitTestingLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ipcRenderer) {
|
||||||
|
return createRendererLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
return createMainLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createLogger();
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import { match, matchPath } from "react-router";
|
|||||||
import { countBy } from "lodash";
|
import { countBy } from "lodash";
|
||||||
import { iter } from "../utils";
|
import { iter } from "../utils";
|
||||||
import { pathToRegexp } from "path-to-regexp";
|
import { pathToRegexp } from "path-to-regexp";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
import type Url from "url-parse";
|
import type Url from "url-parse";
|
||||||
import { RoutingError, RoutingErrorType } from "./error";
|
import { RoutingError, RoutingErrorType } from "./error";
|
||||||
import { ExtensionsStore } from "../../extensions/extensions-store";
|
import { ExtensionsStore } from "../../extensions/extensions-store";
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import { isMac, isWindows } from "./vars";
|
|||||||
import wincaAPI from "win-ca/api";
|
import wincaAPI from "win-ca/api";
|
||||||
import https from "https";
|
import https from "https";
|
||||||
import { promiseExecFile } from "./utils/promise-exec";
|
import { promiseExecFile } from "./utils/promise-exec";
|
||||||
|
import logger from "./logger";
|
||||||
|
|
||||||
// DST Root CA X3, which was expired on 9.30.2021
|
// DST Root CA X3, which was expired on 9.30.2021
|
||||||
export const DSTRootCAX3 = "-----BEGIN CERTIFICATE-----\nMIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\nMSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\nDkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\nPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\nEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\nAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\nrz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\nOLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\nxiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\naeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\nHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\nSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\nikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\nAvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\nR8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\nJDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\nOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n-----END CERTIFICATE-----\n";
|
export const DSTRootCAX3 = "-----BEGIN CERTIFICATE-----\nMIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\nMSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\nDkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\nPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\nEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\nAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\nrz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\nOLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\nxiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\naeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\nHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\nSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\nikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\nAvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\nR8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\nJDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\nOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n-----END CERTIFICATE-----\n";
|
||||||
@ -101,7 +102,7 @@ export async function injectSystemCAs() {
|
|||||||
|
|
||||||
injectCAs(osxRootCAs);
|
injectCAs(osxRootCAs);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(`[MAC-CA]: Error injecting root CAs from MacOSX. ${error?.message}`);
|
logger.warn(`[MAC-CA]: Error injecting root CAs from MacOSX. ${error?.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ export async function injectSystemCAs() {
|
|||||||
wincaAPI.inject("+", winRootCAs);
|
wincaAPI.inject("+", winRootCAs);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(`[WIN-CA]: Error injecting root CAs from Windows. ${error?.message}`);
|
logger.warn(`[WIN-CA]: Error injecting root CAs from Windows. ${error?.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import { appEventBus } from "../event-bus";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { ObservableToggleSet, toJS } from "../../renderer/utils";
|
import { ObservableToggleSet, toJS } from "../../renderer/utils";
|
||||||
import { DESCRIPTORS, EditorConfiguration, ExtensionRegistry, KubeconfigSyncValue, UserPreferencesModel } from "./preferences-helpers";
|
import { DESCRIPTORS, EditorConfiguration, ExtensionRegistry, KubeconfigSyncValue, UserPreferencesModel } from "./preferences-helpers";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
import { AppPaths } from "../app-paths";
|
import { AppPaths } from "../app-paths";
|
||||||
|
|
||||||
export interface UserStoreModel {
|
export interface UserStoreModel {
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import os from "os";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { broadcastMessage, ipcMainHandle, ipcRendererOn, requestMain } from "../common/ipc";
|
import { broadcastMessage, ipcMainHandle, ipcRendererOn, requestMain } from "../common/ipc";
|
||||||
import { Singleton, toJS } from "../common/utils";
|
import { Singleton, toJS } from "../common/utils";
|
||||||
import logger from "../main/logger";
|
import logger from "../common/logger";
|
||||||
import { ExtensionInstallationStateStore } from "../renderer/components/+extensions/extension-install.store";
|
import { ExtensionInstallationStateStore } from "../renderer/components/+extensions/extension-install.store";
|
||||||
import { extensionInstaller } from "./extension-installer";
|
import { extensionInstaller } from "./extension-installer";
|
||||||
import { ExtensionsStore } from "./extensions-store";
|
import { ExtensionsStore } from "./extensions-store";
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import AwaitLock from "await-lock";
|
|||||||
import child_process from "child_process";
|
import child_process from "child_process";
|
||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import logger from "../main/logger";
|
import logger from "../common/logger";
|
||||||
import { extensionPackagesRoot } from "./extension-loader";
|
import { extensionPackagesRoot } from "./extension-loader";
|
||||||
import type { PackageJson } from "type-fest";
|
import type { PackageJson } from "type-fest";
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import path from "path";
|
|||||||
import { AppPaths } from "../../common/app-paths";
|
import { AppPaths } from "../../common/app-paths";
|
||||||
import { broadcastMessage, ipcMainOn, ipcRendererOn, requestMain, ipcMainHandle } from "../../common/ipc";
|
import { broadcastMessage, ipcMainOn, ipcRendererOn, requestMain, ipcMainHandle } from "../../common/ipc";
|
||||||
import { Disposer, toJS } from "../../common/utils";
|
import { Disposer, toJS } from "../../common/utils";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
import type { KubernetesCluster } from "../common-api/catalog";
|
import type { KubernetesCluster } from "../common-api/catalog";
|
||||||
import type { InstalledExtension } from "../extension-discovery";
|
import type { InstalledExtension } from "../extension-discovery";
|
||||||
import { ExtensionsStore } from "../extensions-store";
|
import { ExtensionsStore } from "../extensions-store";
|
||||||
@ -360,11 +360,7 @@ export class ExtensionLoader {
|
|||||||
try {
|
try {
|
||||||
return __non_webpack_require__(extAbsolutePath).default;
|
return __non_webpack_require__(extAbsolutePath).default;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (ipcRenderer) {
|
logger.error(`${logModule}: can't load ${entryPointName} for "${extension.manifest.name}": ${error.stack || error}`, extension);
|
||||||
console.error(`${logModule}: can't load ${entryPointName} for "${extension.manifest.name}": ${error.stack || error}`, extension);
|
|
||||||
} else {
|
|
||||||
logger.error(`${logModule}: can't load ${entryPointName} for "${extension.manifest.name}": ${error}`, { extension });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import type { LensMainExtension } from "../lens-main-extension";
|
|||||||
import type { Disposer } from "../../common/utils";
|
import type { Disposer } from "../../common/utils";
|
||||||
import { once } from "lodash";
|
import { once } from "lodash";
|
||||||
import { ipcMainHandle } from "../../common/ipc";
|
import { ipcMainHandle } from "../../common/ipc";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
|
|
||||||
export abstract class IpcMain extends IpcRegistrar {
|
export abstract class IpcMain extends IpcRegistrar {
|
||||||
constructor(extension: LensMainExtension) {
|
constructor(extension: LensMainExtension) {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import { Disposers } from "../lens-extension";
|
|||||||
import type { LensRendererExtension } from "../lens-renderer-extension";
|
import type { LensRendererExtension } from "../lens-renderer-extension";
|
||||||
import type { Disposer } from "../../common/utils";
|
import type { Disposer } from "../../common/utils";
|
||||||
import { once } from "lodash";
|
import { once } from "lodash";
|
||||||
|
import logger from "../../common/logger";
|
||||||
|
|
||||||
export abstract class IpcRenderer extends IpcRegistrar {
|
export abstract class IpcRenderer extends IpcRegistrar {
|
||||||
constructor(extension: LensRendererExtension) {
|
constructor(extension: LensRendererExtension) {
|
||||||
@ -44,12 +45,12 @@ export abstract class IpcRenderer extends IpcRegistrar {
|
|||||||
listen(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: any[]) => any): Disposer {
|
listen(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: any[]) => any): Disposer {
|
||||||
const prefixedChannel = `extensions@${this[IpcPrefix]}:${channel}`;
|
const prefixedChannel = `extensions@${this[IpcPrefix]}:${channel}`;
|
||||||
const cleanup = once(() => {
|
const cleanup = once(() => {
|
||||||
console.info(`[IPC-RENDERER]: removing extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version }});
|
logger.info(`[IPC-RENDERER]: removing extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version }});
|
||||||
|
|
||||||
return ipcRenderer.removeListener(prefixedChannel, listener);
|
return ipcRenderer.removeListener(prefixedChannel, listener);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.info(`[IPC-RENDERER]: adding extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version }});
|
logger.info(`[IPC-RENDERER]: adding extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version }});
|
||||||
ipcRenderer.addListener(prefixedChannel, listener);
|
ipcRenderer.addListener(prefixedChannel, listener);
|
||||||
this.extension[Disposers].push(cleanup);
|
this.extension[Disposers].push(cleanup);
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
import type { InstalledExtension } from "./extension-discovery";
|
import type { InstalledExtension } from "./extension-discovery";
|
||||||
import { action, observable, makeObservable, computed } from "mobx";
|
import { action, observable, makeObservable, computed } from "mobx";
|
||||||
import { FilesystemProvisionerStore } from "../main/extension-filesystem";
|
import { FilesystemProvisionerStore } from "../main/extension-filesystem";
|
||||||
import logger from "../main/logger";
|
import logger from "../common/logger";
|
||||||
import type { ProtocolHandlerRegistration } from "./registries";
|
import type { ProtocolHandlerRegistration } from "./registries";
|
||||||
import type { PackageJson } from "type-fest";
|
import type { PackageJson } from "type-fest";
|
||||||
import { Disposer, disposer } from "../common/utils";
|
import { Disposer, disposer } from "../common/utils";
|
||||||
|
|||||||
@ -19,31 +19,6 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const logger = {
|
|
||||||
silly: jest.fn(),
|
|
||||||
debug: jest.fn(),
|
|
||||||
log: jest.fn(),
|
|
||||||
info: jest.fn(),
|
|
||||||
error: jest.fn(),
|
|
||||||
crit: jest.fn(),
|
|
||||||
};
|
|
||||||
|
|
||||||
jest.mock("winston", () => ({
|
|
||||||
format: {
|
|
||||||
colorize: jest.fn(),
|
|
||||||
combine: jest.fn(),
|
|
||||||
simple: jest.fn(),
|
|
||||||
label: jest.fn(),
|
|
||||||
timestamp: jest.fn(),
|
|
||||||
printf: jest.fn(),
|
|
||||||
},
|
|
||||||
createLogger: jest.fn().mockReturnValue(logger),
|
|
||||||
transports: {
|
|
||||||
Console: jest.fn(),
|
|
||||||
File: jest.fn(),
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock("../../common/ipc");
|
jest.mock("../../common/ipc");
|
||||||
jest.mock("../context-handler");
|
jest.mock("../context-handler");
|
||||||
jest.mock("request");
|
jest.mock("request");
|
||||||
|
|||||||
@ -19,31 +19,6 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jest.mock("winston", () => ({
|
|
||||||
format: {
|
|
||||||
colorize: jest.fn(),
|
|
||||||
combine: jest.fn(),
|
|
||||||
simple: jest.fn(),
|
|
||||||
label: jest.fn(),
|
|
||||||
timestamp: jest.fn(),
|
|
||||||
printf: jest.fn(),
|
|
||||||
padLevels: jest.fn(),
|
|
||||||
ms: jest.fn(),
|
|
||||||
},
|
|
||||||
createLogger: jest.fn().mockReturnValue({
|
|
||||||
silly: jest.fn(),
|
|
||||||
debug: jest.fn(),
|
|
||||||
log: jest.fn(),
|
|
||||||
info: jest.fn(),
|
|
||||||
error: jest.fn(),
|
|
||||||
crit: jest.fn(),
|
|
||||||
}),
|
|
||||||
transports: {
|
|
||||||
Console: jest.fn(),
|
|
||||||
File: jest.fn(),
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock("../../common/ipc");
|
jest.mock("../../common/ipc");
|
||||||
jest.mock("child_process");
|
jest.mock("child_process");
|
||||||
jest.mock("tcp-port-used");
|
jest.mock("tcp-port-used");
|
||||||
|
|||||||
@ -19,33 +19,6 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const logger = {
|
|
||||||
silly: jest.fn(),
|
|
||||||
debug: jest.fn(),
|
|
||||||
log: jest.fn(),
|
|
||||||
info: jest.fn(),
|
|
||||||
error: jest.fn(),
|
|
||||||
crit: jest.fn(),
|
|
||||||
};
|
|
||||||
|
|
||||||
jest.mock("winston", () => ({
|
|
||||||
format: {
|
|
||||||
colorize: jest.fn(),
|
|
||||||
combine: jest.fn(),
|
|
||||||
simple: jest.fn(),
|
|
||||||
label: jest.fn(),
|
|
||||||
timestamp: jest.fn(),
|
|
||||||
padLevels: jest.fn(),
|
|
||||||
ms: jest.fn(),
|
|
||||||
printf: jest.fn(),
|
|
||||||
},
|
|
||||||
createLogger: jest.fn().mockReturnValue(logger),
|
|
||||||
transports: {
|
|
||||||
Console: jest.fn(),
|
|
||||||
File: jest.fn(),
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { KubeconfigManager } from "../kubeconfig-manager";
|
import { KubeconfigManager } from "../kubeconfig-manager";
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import { Cluster } from "../cluster";
|
import { Cluster } from "../cluster";
|
||||||
@ -123,7 +96,6 @@ describe("kubeconfig manager tests", () => {
|
|||||||
it("should create 'temp' kube config with proxy", async () => {
|
it("should create 'temp' kube config with proxy", async () => {
|
||||||
const kubeConfManager = new KubeconfigManager(cluster, contextHandler);
|
const kubeConfManager = new KubeconfigManager(cluster, contextHandler);
|
||||||
|
|
||||||
expect(logger.error).not.toBeCalled();
|
|
||||||
expect(await kubeConfManager.getPath()).toBe(`tmp${path.sep}kubeconfig-foo`);
|
expect(await kubeConfManager.getPath()).toBe(`tmp${path.sep}kubeconfig-foo`);
|
||||||
// this causes an intermittent "ENXIO: no such device or address, read" error
|
// this causes an intermittent "ENXIO: no such device or address, read" error
|
||||||
// const file = await fse.readFile(await kubeConfManager.getPath());
|
// const file = await fse.readFile(await kubeConfManager.getPath());
|
||||||
|
|||||||
@ -19,14 +19,28 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import packageInfo from "../../package.json";
|
import packageInfo from "../../../package.json";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { Kubectl } from "../../src/main/kubectl";
|
import { Kubectl } from "../kubectl";
|
||||||
import { isWindows } from "../common/vars";
|
import { isWindows } from "../../common/vars";
|
||||||
|
import { UserStore } from "../../common/user-store";
|
||||||
|
|
||||||
jest.mock("../common/user-store");
|
jest.mock("../../common/app-paths", () => ({
|
||||||
|
AppPaths: {
|
||||||
|
get: () => "tmp",
|
||||||
|
getAsync: () => "tmp",
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
describe("kubectlVersion", () => {
|
describe("kubectlVersion", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
UserStore.createInstance();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
UserStore.resetInstance();
|
||||||
|
});
|
||||||
|
|
||||||
it("returns bundled version if exactly same version used", async () => {
|
it("returns bundled version if exactly same version used", async () => {
|
||||||
const kubectl = new Kubectl(Kubectl.bundled().kubectlVersion);
|
const kubectl = new Kubectl(Kubectl.bundled().kubectlVersion);
|
||||||
|
|
||||||
@ -42,6 +56,14 @@ describe("kubectlVersion", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("getPath()", () => {
|
describe("getPath()", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
UserStore.createInstance();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
UserStore.resetInstance();
|
||||||
|
});
|
||||||
|
|
||||||
it("returns path to downloaded kubectl binary", async () => {
|
it("returns path to downloaded kubectl binary", async () => {
|
||||||
const { bundledKubectlVersion } = packageInfo.config;
|
const { bundledKubectlVersion } = packageInfo.config;
|
||||||
const kubectl = new Kubectl(bundledKubectlVersion);
|
const kubectl = new Kubectl(bundledKubectlVersion);
|
||||||
@ -61,12 +83,7 @@ describe("getPath()", () => {
|
|||||||
const kubectl = new Kubectl(bundledKubectlVersion);
|
const kubectl = new Kubectl(bundledKubectlVersion);
|
||||||
|
|
||||||
jest.spyOn(kubectl, "getBundledPath").mockReturnValue("/invalid/path/kubectl");
|
jest.spyOn(kubectl, "getBundledPath").mockReturnValue("/invalid/path/kubectl");
|
||||||
const kubectlPath = await kubectl.getPath();
|
|
||||||
let binaryName = "kubectl";
|
|
||||||
|
|
||||||
if (isWindows) {
|
expect(await kubectl.getPath()).toBe("kubectl");
|
||||||
binaryName += ".exe";
|
|
||||||
}
|
|
||||||
expect(kubectlPath).toBe(binaryName);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { autoUpdater, UpdateInfo } from "electron-updater";
|
import { autoUpdater, UpdateInfo } from "electron-updater";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { isLinux, isMac, isPublishConfigured, isTestEnv } from "../common/vars";
|
import { isLinux, isMac, isPublishConfigured, isTestEnv } from "../common/vars";
|
||||||
import { delay } from "../common/utils";
|
import { delay } from "../common/utils";
|
||||||
import { areArgsUpdateAvailableToBackchannel, AutoUpdateChecking, AutoUpdateLogPrefix, AutoUpdateNoUpdateAvailable, broadcastMessage, onceCorrect, UpdateAvailableChannel, UpdateAvailableToBackchannel } from "../common/ipc";
|
import { areArgsUpdateAvailableToBackchannel, AutoUpdateChecking, AutoUpdateLogPrefix, AutoUpdateNoUpdateAvailable, broadcastMessage, onceCorrect, UpdateAvailableChannel, UpdateAvailableToBackchannel } from "../common/ipc";
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import fs from "fs";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import type stream from "stream";
|
import type stream from "stream";
|
||||||
import { bytesToUnits, Disposer, ExtendedObservableMap, iter, noop, Singleton, storedKubeConfigFolder } from "../../common/utils";
|
import { bytesToUnits, Disposer, ExtendedObservableMap, iter, noop, Singleton, storedKubeConfigFolder } from "../../common/utils";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import type { KubeConfig } from "@kubernetes/client-node";
|
import type { KubeConfig } from "@kubernetes/client-node";
|
||||||
import { loadConfigFromString, splitConfig } from "../../common/kube-helpers";
|
import { loadConfigFromString, splitConfig } from "../../common/kube-helpers";
|
||||||
import { Cluster } from "../cluster";
|
import { Cluster } from "../cluster";
|
||||||
@ -370,8 +370,7 @@ function watchFileChanges(filePath: string): [IComputedValue<CatalogEntity[]>, D
|
|||||||
})
|
})
|
||||||
.on("error", error => logger.error(`${logPrefix} watching file/folder failed: ${error}`, { filePath }));
|
.on("error", error => logger.error(`${logPrefix} watching file/folder failed: ${error}`, { filePath }));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error.stack);
|
logger.warn(`${logPrefix} failed to start watching changes:`, error);
|
||||||
logger.warn(`${logPrefix} failed to start watching changes: ${error}`);
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import "../common/cluster-ipc";
|
|||||||
import type http from "http";
|
import type http from "http";
|
||||||
import { action, makeObservable, observable, observe, reaction, toJS } from "mobx";
|
import { action, makeObservable, observable, observe, reaction, toJS } from "mobx";
|
||||||
import { Cluster } from "./cluster";
|
import { Cluster } from "./cluster";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { apiKubePrefix } from "../common/vars";
|
import { apiKubePrefix } from "../common/vars";
|
||||||
import { getClusterIdFromHost, Singleton } from "../common/utils";
|
import { getClusterIdFromHost, Singleton } from "../common/utils";
|
||||||
import { catalogEntityRegistry } from "./catalog";
|
import { catalogEntityRegistry } from "./catalog";
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import { Kubectl } from "./kubectl";
|
|||||||
import { KubeconfigManager } from "./kubeconfig-manager";
|
import { KubeconfigManager } from "./kubeconfig-manager";
|
||||||
import { loadConfigFromFile, loadConfigFromFileSync, validateKubeConfig } from "../common/kube-helpers";
|
import { loadConfigFromFile, loadConfigFromFileSync, validateKubeConfig } from "../common/kube-helpers";
|
||||||
import { apiResourceRecord, apiResources, KubeApiResource, KubeResource } from "../common/rbac";
|
import { apiResourceRecord, apiResources, KubeApiResource, KubeResource } from "../common/rbac";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { VersionDetector } from "./cluster-detectors/version-detector";
|
import { VersionDetector } from "./cluster-detectors/version-detector";
|
||||||
import { DetectorRegistry } from "./cluster-detectors/detector-registry";
|
import { DetectorRegistry } from "./cluster-detectors/detector-registry";
|
||||||
import plimit from "p-limit";
|
import plimit from "p-limit";
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import type { Cluster } from "./cluster";
|
|||||||
import type httpProxy from "http-proxy";
|
import type httpProxy from "http-proxy";
|
||||||
import url, { UrlWithStringQuery } from "url";
|
import url, { UrlWithStringQuery } from "url";
|
||||||
import { CoreV1Api } from "@kubernetes/client-node";
|
import { CoreV1Api } from "@kubernetes/client-node";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { KubeAuthProxy } from "./kube-auth-proxy";
|
import { KubeAuthProxy } from "./kube-auth-proxy";
|
||||||
|
|
||||||
export interface PrometheusDetails {
|
export interface PrometheusDetails {
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs Electron developer tools in the development build.
|
* Installs Electron developer tools in the development build.
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import { app } from "electron";
|
|||||||
import { WindowManager } from "./window-manager";
|
import { WindowManager } from "./window-manager";
|
||||||
import { appEventBus } from "../common/event-bus";
|
import { appEventBus } from "../common/event-bus";
|
||||||
import { ClusterManager } from "./cluster-manager";
|
import { ClusterManager } from "./cluster-manager";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
|
|
||||||
export function exitApp() {
|
export function exitApp() {
|
||||||
const windowManager = WindowManager.getInstance(false);
|
const windowManager = WindowManager.getInstance(false);
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import fs from "fs";
|
|||||||
import v8 from "v8";
|
import v8 from "v8";
|
||||||
import * as yaml from "js-yaml";
|
import * as yaml from "js-yaml";
|
||||||
import type { HelmRepo } from "./helm-repo-manager";
|
import type { HelmRepo } from "./helm-repo-manager";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { promiseExecFile } from "../../common/utils/promise-exec";
|
import { promiseExecFile } from "../../common/utils/promise-exec";
|
||||||
import { helmCli } from "./helm-cli";
|
import { helmCli } from "./helm-cli";
|
||||||
import type { RepoHelmChartList } from "../../common/k8s-api/endpoints/helm-charts.api";
|
import type { RepoHelmChartList } from "../../common/k8s-api/endpoints/helm-charts.api";
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import { helmCli } from "./helm-cli";
|
|||||||
import { Singleton } from "../../common/utils/singleton";
|
import { Singleton } from "../../common/utils/singleton";
|
||||||
import { customRequestPromise } from "../../common/request";
|
import { customRequestPromise } from "../../common/request";
|
||||||
import orderBy from "lodash/orderBy";
|
import orderBy from "lodash/orderBy";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import type { ExecFileOptions } from "child_process";
|
import type { ExecFileOptions } from "child_process";
|
||||||
|
|
||||||
export type HelmEnv = Record<string, string> & {
|
export type HelmEnv = Record<string, string> & {
|
||||||
@ -79,7 +79,6 @@ export class HelmRepoManager extends Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async init() {
|
private async init() {
|
||||||
helmCli.setLogger(logger);
|
|
||||||
await helmCli.ensureBinary();
|
await helmCli.ensureBinary();
|
||||||
|
|
||||||
if (!this.initialized) {
|
if (!this.initialized) {
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Cluster } from "../cluster";
|
import type { Cluster } from "../cluster";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { HelmRepoManager } from "./helm-repo-manager";
|
import { HelmRepoManager } from "./helm-repo-manager";
|
||||||
import { HelmChartManager } from "./helm-chart-manager";
|
import { HelmChartManager } from "./helm-chart-manager";
|
||||||
import { deleteRelease, getHistory, getRelease, getValues, installChart, listReleases, rollback, upgradeRelease } from "./helm-release-manager";
|
import { deleteRelease, getHistory, getRelease, getValues, installChart, listReleases, rollback, upgradeRelease } from "./helm-release-manager";
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import { ClusterManager } from "./cluster-manager";
|
|||||||
import { shellSync } from "./shell-sync";
|
import { shellSync } from "./shell-sync";
|
||||||
import { mangleProxyEnv } from "./proxy-env";
|
import { mangleProxyEnv } from "./proxy-env";
|
||||||
import { registerFileProtocol } from "../common/register-protocol";
|
import { registerFileProtocol } from "../common/register-protocol";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { appEventBus } from "../common/event-bus";
|
import { appEventBus } from "../common/event-bus";
|
||||||
import { InstalledExtension, ExtensionDiscovery } from "../extensions/extension-discovery";
|
import { InstalledExtension, ExtensionDiscovery } from "../extensions/extension-discovery";
|
||||||
import type { LensExtensionId } from "../extensions/lens-extension";
|
import type { LensExtensionId } from "../extensions/lens-extension";
|
||||||
@ -285,8 +285,7 @@ app.on("ready", async () => {
|
|||||||
extensionLoader.initExtensions(extensions);
|
extensionLoader.initExtensions(extensions);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dialog.showErrorBox("Lens Error", `Could not load extensions${error?.message ? `: ${error.message}` : ""}`);
|
dialog.showErrorBox("Lens Error", `Could not load extensions${error?.message ? `: ${error.message}` : ""}`);
|
||||||
console.error(error);
|
logger.error(`Could not load extensions`, error);
|
||||||
console.trace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import { waitUntilUsed } from "tcp-port-used";
|
|||||||
import { randomBytes } from "crypto";
|
import { randomBytes } from "crypto";
|
||||||
import type { Cluster } from "./cluster";
|
import type { Cluster } from "./cluster";
|
||||||
import { Kubectl } from "./kubectl";
|
import { Kubectl } from "./kubectl";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import * as url from "url";
|
import * as url from "url";
|
||||||
import { getPortFrom } from "./utils/get-port";
|
import { getPortFrom } from "./utils/get-port";
|
||||||
import { makeObservable, observable, when } from "mobx";
|
import { makeObservable, observable, when } from "mobx";
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import type { ContextHandler } from "./context-handler";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
import { dumpConfigYaml } from "../common/kube-helpers";
|
import { dumpConfigYaml } from "../common/kube-helpers";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { LensProxy } from "./lens-proxy";
|
import { LensProxy } from "./lens-proxy";
|
||||||
import { AppPaths } from "../common/app-paths";
|
import { AppPaths } from "../common/app-paths";
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { promiseExecFile } from "../common/utils/promise-exec";
|
import { promiseExecFile } from "../common/utils/promise-exec";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { ensureDir, pathExists } from "fs-extra";
|
import { ensureDir, pathExists } from "fs-extra";
|
||||||
import * as lockFile from "proper-lockfile";
|
import * as lockFile from "proper-lockfile";
|
||||||
import { helmCli } from "./helm/helm-cli";
|
import { helmCli } from "./helm/helm-cli";
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import request from "request";
|
|||||||
import { ensureDir, pathExists } from "fs-extra";
|
import { ensureDir, pathExists } from "fs-extra";
|
||||||
import * as tar from "tar";
|
import * as tar from "tar";
|
||||||
import { isWindows } from "../common/vars";
|
import { isWindows } from "../common/vars";
|
||||||
import type winston from "winston";
|
import logger from "../common/logger";
|
||||||
|
|
||||||
export type LensBinaryOpts = {
|
export type LensBinaryOpts = {
|
||||||
version: string;
|
version: string;
|
||||||
@ -48,7 +48,6 @@ export class LensBinary {
|
|||||||
protected arch: string;
|
protected arch: string;
|
||||||
protected originalBinaryName: string;
|
protected originalBinaryName: string;
|
||||||
protected requestOpts: request.Options;
|
protected requestOpts: request.Options;
|
||||||
protected logger: Console | winston.Logger;
|
|
||||||
|
|
||||||
constructor(opts: LensBinaryOpts) {
|
constructor(opts: LensBinaryOpts) {
|
||||||
const baseDir = opts.baseDir;
|
const baseDir = opts.baseDir;
|
||||||
@ -57,7 +56,6 @@ export class LensBinary {
|
|||||||
this.binaryName = opts.newBinaryName || opts.originalBinaryName;
|
this.binaryName = opts.newBinaryName || opts.originalBinaryName;
|
||||||
this.binaryVersion = opts.version;
|
this.binaryVersion = opts.version;
|
||||||
this.requestOpts = opts.requestOpts;
|
this.requestOpts = opts.requestOpts;
|
||||||
this.logger = console;
|
|
||||||
let arch = null;
|
let arch = null;
|
||||||
|
|
||||||
if (process.env.BINARY_ARCH) {
|
if (process.env.BINARY_ARCH) {
|
||||||
@ -84,10 +82,6 @@ export class LensBinary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setLogger(logger: Console | winston.Logger) {
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected binaryDir() {
|
protected binaryDir() {
|
||||||
throw new Error("binaryDir not implemented");
|
throw new Error("binaryDir not implemented");
|
||||||
}
|
}
|
||||||
@ -124,7 +118,7 @@ export class LensBinary {
|
|||||||
|
|
||||||
return this.dirname;
|
return this.dirname;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error(err);
|
logger.error(err);
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -141,17 +135,17 @@ export class LensBinary {
|
|||||||
|
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
await this.downloadBinary().catch((error) => {
|
await this.downloadBinary().catch((error) => {
|
||||||
this.logger.error(error);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
if (this.tarPath) await this.untarBinary();
|
if (this.tarPath) await this.untarBinary();
|
||||||
if (this.originalBinaryName != this.binaryName) await this.renameBinary();
|
if (this.originalBinaryName != this.binaryName) await this.renameBinary();
|
||||||
this.logger.info(`${this.originalBinaryName} has been downloaded to ${this.getBinaryPath()}`);
|
logger.info(`${this.originalBinaryName} has been downloaded to ${this.getBinaryPath()}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async untarBinary() {
|
protected async untarBinary() {
|
||||||
return new Promise<void>(resolve => {
|
return new Promise<void>(resolve => {
|
||||||
this.logger.debug(`Extracting ${this.originalBinaryName} binary`);
|
logger.debug(`Extracting ${this.originalBinaryName} binary`);
|
||||||
tar.x({
|
tar.x({
|
||||||
file: this.tarPath,
|
file: this.tarPath,
|
||||||
cwd: this.dirname,
|
cwd: this.dirname,
|
||||||
@ -163,7 +157,7 @@ export class LensBinary {
|
|||||||
|
|
||||||
protected async renameBinary() {
|
protected async renameBinary() {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
this.logger.debug(`Renaming ${this.originalBinaryName} binary to ${this.binaryName}`);
|
logger.debug(`Renaming ${this.originalBinaryName} binary to ${this.binaryName}`);
|
||||||
fs.rename(this.getOriginalBinaryPath(), this.getBinaryPath(), (err) => {
|
fs.rename(this.getOriginalBinaryPath(), this.getBinaryPath(), (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
@ -183,7 +177,7 @@ export class LensBinary {
|
|||||||
const file = fs.createWriteStream(binaryPath);
|
const file = fs.createWriteStream(binaryPath);
|
||||||
const url = this.getUrl();
|
const url = this.getUrl();
|
||||||
|
|
||||||
this.logger.info(`Downloading ${this.originalBinaryName} ${this.binaryVersion} from ${url} to ${binaryPath}`);
|
logger.info(`Downloading ${this.originalBinaryName} ${this.binaryVersion} from ${url} to ${binaryPath}`);
|
||||||
const requestOpts: request.UriOptions & request.CoreOptions = {
|
const requestOpts: request.UriOptions & request.CoreOptions = {
|
||||||
uri: url,
|
uri: url,
|
||||||
gzip: true,
|
gzip: true,
|
||||||
@ -192,12 +186,12 @@ export class LensBinary {
|
|||||||
const stream = request(requestOpts);
|
const stream = request(requestOpts);
|
||||||
|
|
||||||
stream.on("complete", () => {
|
stream.on("complete", () => {
|
||||||
this.logger.info(`Download of ${this.originalBinaryName} finished`);
|
logger.info(`Download of ${this.originalBinaryName} finished`);
|
||||||
file.end();
|
file.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
stream.on("error", (error) => {
|
stream.on("error", (error) => {
|
||||||
this.logger.error(error);
|
logger.error(error);
|
||||||
fs.unlink(binaryPath, () => {
|
fs.unlink(binaryPath, () => {
|
||||||
// do nothing
|
// do nothing
|
||||||
});
|
});
|
||||||
@ -206,7 +200,7 @@ export class LensBinary {
|
|||||||
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
file.on("close", () => {
|
file.on("close", () => {
|
||||||
this.logger.debug(`${this.originalBinaryName} binary download closed`);
|
logger.debug(`${this.originalBinaryName} binary download closed`);
|
||||||
if (!this.tarPath) fs.chmod(binaryPath, 0o755, (err) => {
|
if (!this.tarPath) fs.chmod(binaryPath, 0o755, (err) => {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import httpProxy from "http-proxy";
|
|||||||
import { apiPrefix, apiKubePrefix } from "../common/vars";
|
import { apiPrefix, apiKubePrefix } from "../common/vars";
|
||||||
import type { Router } from "./router";
|
import type { Router } from "./router";
|
||||||
import type { ContextHandler } from "./context-handler";
|
import type { ContextHandler } from "./context-handler";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { Singleton } from "../common/utils";
|
import { Singleton } from "../common/utils";
|
||||||
import type { Cluster } from "./cluster";
|
import type { Cluster } from "./cluster";
|
||||||
import type { ProxyApiRequestArgs } from "./proxy-functions";
|
import type { ProxyApiRequestArgs } from "./proxy-functions";
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2021 OpenLens Authors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
|
||||||
* the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import logger from "../common/logger";
|
|
||||||
|
|
||||||
export default logger;
|
|
||||||
@ -22,7 +22,7 @@ import { app, BrowserWindow, dialog, Menu, MenuItem, MenuItemConstructorOptions,
|
|||||||
import { autorun, IComputedValue } from "mobx";
|
import { autorun, IComputedValue } from "mobx";
|
||||||
import type { WindowManager } from "../window-manager";
|
import type { WindowManager } from "../window-manager";
|
||||||
import { appName, isMac, isWindows, docsUrl, supportUrl, productName } from "../../common/vars";
|
import { appName, isMac, isWindows, docsUrl, supportUrl, productName } from "../../common/vars";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { exitApp } from "../exit-app";
|
import { exitApp } from "../exit-app";
|
||||||
import { broadcastMessage } from "../../common/ipc";
|
import { broadcastMessage } from "../../common/ipc";
|
||||||
import * as packageJson from "../../../package.json";
|
import * as packageJson from "../../../package.json";
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import logger from "../../logger";
|
import logger from "../../../common/logger";
|
||||||
import * as proto from "../../../common/protocol-handler";
|
import * as proto from "../../../common/protocol-handler";
|
||||||
import URLParse from "url-parse";
|
import URLParse from "url-parse";
|
||||||
import type { LensExtension } from "../../../extensions/lens-extension";
|
import type { LensExtension } from "../../../extensions/lens-extension";
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { Server as WebSocketServer } from "ws";
|
import { Server as WebSocketServer } from "ws";
|
||||||
import { NodeShellSession, LocalShellSession } from "../shell-session";
|
import { NodeShellSession, LocalShellSession } from "../shell-session";
|
||||||
import type { ProxyApiRequestArgs } from "./types";
|
import type { ProxyApiRequestArgs } from "./types";
|
||||||
|
|||||||
@ -25,8 +25,8 @@ import { exec } from "child_process";
|
|||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
import * as yaml from "js-yaml";
|
import * as yaml from "js-yaml";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import tempy from "tempy";
|
import * as tempy from "tempy";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { appEventBus } from "../common/event-bus";
|
import { appEventBus } from "../common/event-bus";
|
||||||
import { cloneJsonObject } from "../common/utils";
|
import { cloneJsonObject } from "../common/utils";
|
||||||
import type { Patch } from "rfc6902";
|
import type { Patch } from "rfc6902";
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import { readFile } from "fs-extra";
|
|||||||
import type { Cluster } from "./cluster";
|
import type { Cluster } from "./cluster";
|
||||||
import { apiPrefix, appName, publicPath, isDevelopment, webpackDevServerPort } from "../common/vars";
|
import { apiPrefix, appName, publicPath, isDevelopment, webpackDevServerPort } from "../common/vars";
|
||||||
import { HelmApiRoute, KubeconfigRoute, MetricsRoute, PortForwardRoute, ResourceApplierApiRoute, VersionRoute } from "./routes";
|
import { HelmApiRoute, KubeconfigRoute, MetricsRoute, PortForwardRoute, ResourceApplierApiRoute, VersionRoute } from "./routes";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
|
|
||||||
export interface RouterRequestOpts {
|
export interface RouterRequestOpts {
|
||||||
req: http.IncomingMessage;
|
req: http.IncomingMessage;
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
import type { LensApiRequest } from "../router";
|
import type { LensApiRequest } from "../router";
|
||||||
import { helmService } from "../helm/helm-service";
|
import { helmService } from "../helm/helm-service";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { respondJson, respondText } from "../utils/http-responses";
|
import { respondJson, respondText } from "../utils/http-responses";
|
||||||
import { getBoolean } from "../utils/parse-query";
|
import { getBoolean } from "../utils/parse-query";
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { LensApiRequest } from "../router";
|
|||||||
import { respondJson } from "../utils/http-responses";
|
import { respondJson } from "../utils/http-responses";
|
||||||
import type { Cluster } from "../cluster";
|
import type { Cluster } from "../cluster";
|
||||||
import { ClusterMetadataKey, ClusterPrometheusMetadata } from "../../common/cluster-types";
|
import { ClusterMetadataKey, ClusterPrometheusMetadata } from "../../common/cluster-types";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { getMetrics } from "../k8s-request";
|
import { getMetrics } from "../k8s-request";
|
||||||
import { PrometheusProviderRegistry } from "../prometheus";
|
import { PrometheusProviderRegistry } from "../prometheus";
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { LensApiRequest } from "../router";
|
|||||||
import { spawn, ChildProcessWithoutNullStreams } from "child_process";
|
import { spawn, ChildProcessWithoutNullStreams } from "child_process";
|
||||||
import { Kubectl } from "../kubectl";
|
import { Kubectl } from "../kubectl";
|
||||||
import * as tcpPortUsed from "tcp-port-used";
|
import * as tcpPortUsed from "tcp-port-used";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { getPortFrom } from "../utils/get-port";
|
import { getPortFrom } from "../utils/get-port";
|
||||||
import { respondJson } from "../utils/http-responses";
|
import { respondJson } from "../utils/http-responses";
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import { ShellOpenError, ShellSession } from "./shell-session";
|
|||||||
import { get } from "lodash";
|
import { get } from "lodash";
|
||||||
import { Node, NodesApi } from "../../common/k8s-api/endpoints";
|
import { Node, NodesApi } from "../../common/k8s-api/endpoints";
|
||||||
import { KubeJsonApi } from "../../common/k8s-api/kube-json-api";
|
import { KubeJsonApi } from "../../common/k8s-api/kube-json-api";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { TerminalChannels } from "../../renderer/api/terminal-api";
|
import { TerminalChannels } from "../../renderer/api/terminal-api";
|
||||||
|
|
||||||
export class NodeShellSession extends ShellSession {
|
export class NodeShellSession extends ShellSession {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import { isMac, isWindows } from "../../common/vars";
|
|||||||
import { UserStore } from "../../common/user-store";
|
import { UserStore } from "../../common/user-store";
|
||||||
import * as pty from "node-pty";
|
import * as pty from "node-pty";
|
||||||
import { appEventBus } from "../../common/event-bus";
|
import { appEventBus } from "../../common/event-bus";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { TerminalChannels, TerminalMessage } from "../../renderer/api/terminal-api";
|
import { TerminalChannels, TerminalMessage } from "../../renderer/api/terminal-api";
|
||||||
import { deserialize, serialize } from "v8";
|
import { deserialize, serialize } from "v8";
|
||||||
import { stat } from "fs/promises";
|
import { stat } from "fs/promises";
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
import { shellEnv } from "./utils/shell-env";
|
import { shellEnv } from "./utils/shell-env";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { isSnap } from "../common/vars";
|
import { isSnap } from "../common/vars";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import { autorun, IComputedValue } from "mobx";
|
|||||||
import { showAbout } from "../menu/menu";
|
import { showAbout } from "../menu/menu";
|
||||||
import { checkForUpdates, isAutoUpdateEnabled } from "../app-updater";
|
import { checkForUpdates, isAutoUpdateEnabled } from "../app-updater";
|
||||||
import type { WindowManager } from "../window-manager";
|
import type { WindowManager } from "../window-manager";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
import { isDevelopment, isWindows, productName } from "../../common/vars";
|
import { isDevelopment, isWindows, productName } from "../../common/vars";
|
||||||
import { exitApp } from "../exit-app";
|
import { exitApp } from "../exit-app";
|
||||||
import { preferencesURL } from "../../common/routes";
|
import { preferencesURL } from "../../common/routes";
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
import type { Readable } from "stream";
|
import type { Readable } from "stream";
|
||||||
import URLParse from "url-parse";
|
import URLParse from "url-parse";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
|
|
||||||
interface GetPortArgs {
|
interface GetPortArgs {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import shellEnvironment from "shell-env";
|
import shellEnvironment from "shell-env";
|
||||||
import logger from "../logger";
|
import logger from "../../common/logger";
|
||||||
|
|
||||||
export type EnvironmentVariables = Record<string, string>;
|
export type EnvironmentVariables = Record<string, string>;
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import { BundledExtensionsLoaded, ipcMainOn } from "../common/ipc";
|
|||||||
import { delay, iter, Singleton } from "../common/utils";
|
import { delay, iter, Singleton } from "../common/utils";
|
||||||
import { ClusterFrameInfo, clusterFrameMap } from "../common/cluster-frames";
|
import { ClusterFrameInfo, clusterFrameMap } from "../common/cluster-frames";
|
||||||
import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
||||||
import logger from "./logger";
|
import logger from "../common/logger";
|
||||||
import { isMac, productName } from "../common/vars";
|
import { isMac, productName } from "../common/vars";
|
||||||
import { LensProxy } from "./lens-proxy";
|
import { LensProxy } from "./lens-proxy";
|
||||||
|
|
||||||
|
|||||||
@ -21,13 +21,11 @@
|
|||||||
|
|
||||||
import type Conf from "conf";
|
import type Conf from "conf";
|
||||||
import type { Migrations } from "conf/dist/source/types";
|
import type { Migrations } from "conf/dist/source/types";
|
||||||
|
import logger from "../common/logger";
|
||||||
import { ExtendedMap, iter } from "../common/utils";
|
import { ExtendedMap, iter } from "../common/utils";
|
||||||
import { isTestEnv } from "../common/vars";
|
|
||||||
|
|
||||||
export function migrationLog(...args: any[]) {
|
export function migrationLog(...args: any[]) {
|
||||||
if (!isTestEnv) {
|
logger.info(...args);
|
||||||
console.log(...args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MigrationDeclaration {
|
export interface MigrationDeclaration {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import EventEmitter from "events";
|
|||||||
import type TypedEventEmitter from "typed-emitter";
|
import type TypedEventEmitter from "typed-emitter";
|
||||||
import type { Arguments } from "typed-emitter";
|
import type { Arguments } from "typed-emitter";
|
||||||
import { isDevelopment } from "../../common/vars";
|
import { isDevelopment } from "../../common/vars";
|
||||||
|
import logger from "../../common/logger";
|
||||||
|
|
||||||
interface WebsocketApiParams {
|
interface WebsocketApiParams {
|
||||||
/**
|
/**
|
||||||
@ -136,7 +137,7 @@ export class WebSocketApi<Events extends WebSocketEvents> extends (EventEmitter
|
|||||||
|
|
||||||
reconnect(): void {
|
reconnect(): void {
|
||||||
if (!this.socket) {
|
if (!this.socket) {
|
||||||
return void console.error("[WEBSOCKET-API]: cannot reconnect to a socket that is not connected");
|
return void logger.error("[WEBSOCKET-API]: cannot reconnect to a socket that is not connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connect(this.socket.url);
|
this.connect(this.socket.url);
|
||||||
@ -214,7 +215,7 @@ export class WebSocketApi<Events extends WebSocketEvents> extends (EventEmitter
|
|||||||
|
|
||||||
protected writeLog(...data: any[]) {
|
protected writeLog(...data: any[]) {
|
||||||
if (this.params.logging) {
|
if (this.params.logging) {
|
||||||
console.debug(...data);
|
logger.debug(...data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import { DeploymentScaleDialog } from "./components/+workloads-deployments/deplo
|
|||||||
import { CronJobTriggerDialog } from "./components/+workloads-cronjobs/cronjob-trigger-dialog";
|
import { CronJobTriggerDialog } from "./components/+workloads-cronjobs/cronjob-trigger-dialog";
|
||||||
import { CustomResources } from "./components/+custom-resources/custom-resources";
|
import { CustomResources } from "./components/+custom-resources/custom-resources";
|
||||||
import { isAllowedResource } from "../common/utils/allowed-resource";
|
import { isAllowedResource } from "../common/utils/allowed-resource";
|
||||||
import logger from "../main/logger";
|
import logger from "../common/logger";
|
||||||
import { webFrame } from "electron";
|
import { webFrame } from "electron";
|
||||||
import { ClusterPageRegistry, getExtensionPageUrl } from "../extensions/registries/page-registry";
|
import { ClusterPageRegistry, getExtensionPageUrl } from "../extensions/registries/page-registry";
|
||||||
import type { ExtensionLoader } from "../extensions/extension-loader";
|
import type { ExtensionLoader } from "../extensions/extension-loader";
|
||||||
@ -108,7 +108,7 @@ export class ClusterFrame extends React.Component {
|
|||||||
{
|
{
|
||||||
timeout: 15_000,
|
timeout: 15_000,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.warn("[CLUSTER-FRAME]: error from activeEntity when()", error);
|
logger.warn("[CLUSTER-FRAME]: error from activeEntity when()", error);
|
||||||
Notifications.error("Failed to get KubernetesCluster for this view. Extensions will not be loaded.");
|
Notifications.error("Failed to get KubernetesCluster for this view. Extensions will not be loaded.");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import type { Secret } from "../../../common/k8s-api/endpoints";
|
|||||||
import { secretsStore } from "../+config-secrets/secrets.store";
|
import { secretsStore } from "../+config-secrets/secrets.store";
|
||||||
import { namespaceStore } from "../+namespaces/namespace.store";
|
import { namespaceStore } from "../+namespaces/namespace.store";
|
||||||
import { Notifications } from "../notifications";
|
import { Notifications } from "../notifications";
|
||||||
|
import logger from "../../../common/logger";
|
||||||
|
|
||||||
export class ReleaseStore extends ItemStore<HelmRelease> {
|
export class ReleaseStore extends ItemStore<HelmRelease> {
|
||||||
releaseSecrets = observable.map<string, Secret>();
|
releaseSecrets = observable.map<string, Secret>();
|
||||||
@ -95,7 +96,7 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
|
|||||||
this.failedLoading = false;
|
this.failedLoading = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.failedLoading = true;
|
this.failedLoading = true;
|
||||||
console.warn("Loading Helm Chart releases has failed", error);
|
logger.warn("Loading Helm Chart releases has failed", error);
|
||||||
|
|
||||||
if (error.error) {
|
if (error.error) {
|
||||||
Notifications.error(error.error);
|
Notifications.error(error.error);
|
||||||
|
|||||||
@ -46,6 +46,7 @@ import { HotbarToggleMenuItem } from "./hotbar-toggle-menu-item";
|
|||||||
import { Avatar } from "../avatar";
|
import { Avatar } from "../avatar";
|
||||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||||
import { getLabelBadges } from "./helpers";
|
import { getLabelBadges } from "./helpers";
|
||||||
|
import logger from "../../../common/logger";
|
||||||
|
|
||||||
export const previousActiveTab = createStorage("catalog-previous-active-tab", browseCatalogTab);
|
export const previousActiveTab = createStorage("catalog-previous-active-tab", browseCatalogTab);
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
this.catalogEntityStore.activeCategory = item;
|
this.catalogEntityStore.activeCategory = item;
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
logger.error(`[CATALOG]: Unknown category for ${routeTab}:`, error);
|
||||||
Notifications.error(<p>Unknown category: {routeTab}</p>);
|
Notifications.error(<p>Unknown category: {routeTab}</p>);
|
||||||
}
|
}
|
||||||
}, { fireImmediately: true }),
|
}, { fireImmediately: true }),
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import { SemVer } from "semver";
|
|||||||
import URLParse from "url-parse";
|
import URLParse from "url-parse";
|
||||||
import type { InstallRequest } from "../attempt-install/install-request";
|
import type { InstallRequest } from "../attempt-install/install-request";
|
||||||
import lodash from "lodash";
|
import lodash from "lodash";
|
||||||
|
import logger from "../../../../common/logger";
|
||||||
|
|
||||||
export interface ExtensionInfo {
|
export interface ExtensionInfo {
|
||||||
name: string;
|
name: string;
|
||||||
@ -63,10 +64,10 @@ export const attemptInstallByInfo = ({ attemptInstall, getBaseRegistryUrl }: Dep
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof SyntaxError) {
|
if (error instanceof SyntaxError) {
|
||||||
// assume invalid JSON
|
// assume invalid JSON
|
||||||
console.warn("Set registry has invalid json", { url: baseUrl }, error);
|
logger.warn("Set registry has invalid json", { url: baseUrl }, error);
|
||||||
Notifications.error("Failed to get valid registry information for that extension. Registry did not return valid JSON");
|
Notifications.error("Failed to get valid registry information for that extension. Registry did not return valid JSON");
|
||||||
} else {
|
} else {
|
||||||
console.error("Failed to download registry information", error);
|
logger.error("Failed to download registry information", error);
|
||||||
Notifications.error(`Failed to get valid registry information for that extension. ${error}`);
|
Notifications.error(`Failed to get valid registry information for that extension. ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
import { validatePackage } from "../validate-package/validate-package";
|
import { validatePackage } from "../validate-package/validate-package";
|
||||||
import { ExtensionDiscovery } from "../../../../../extensions/extension-discovery";
|
import { ExtensionDiscovery } from "../../../../../extensions/extension-discovery";
|
||||||
import { getMessageFromError } from "../../get-message-from-error/get-message-from-error";
|
import { getMessageFromError } from "../../get-message-from-error/get-message-from-error";
|
||||||
import logger from "../../../../../main/logger";
|
import logger from "../../../../../common/logger";
|
||||||
import { Notifications } from "../../../notifications";
|
import { Notifications } from "../../../notifications";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import type { InstallRequestValidated } from "../create-temp-files-and-validate/
|
|||||||
import { Disposer, extractTar, noop } from "../../../../../common/utils";
|
import { Disposer, extractTar, noop } from "../../../../../common/utils";
|
||||||
import { ExtensionInstallationStateStore } from "../../extension-install.store";
|
import { ExtensionInstallationStateStore } from "../../extension-install.store";
|
||||||
import { extensionDisplayName } from "../../../../../extensions/lens-extension";
|
import { extensionDisplayName } from "../../../../../extensions/lens-extension";
|
||||||
import logger from "../../../../../main/logger";
|
import logger from "../../../../../common/logger";
|
||||||
import type { ExtensionLoader } from "../../../../../extensions/extension-loader";
|
import type { ExtensionLoader } from "../../../../../extensions/extension-loader";
|
||||||
import { Notifications } from "../../../notifications";
|
import { Notifications } from "../../../notifications";
|
||||||
import { getMessageFromError } from "../../get-message-from-error/get-message-from-error";
|
import { getMessageFromError } from "../../get-message-from-error/get-message-from-error";
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { action, computed, observable } from "mobx";
|
import { action, computed, observable } from "mobx";
|
||||||
import logger from "../../../main/logger";
|
import logger from "../../../common/logger";
|
||||||
import { disposer } from "../../utils";
|
import { disposer } from "../../utils";
|
||||||
import type { ExtendableDisposer } from "../../utils";
|
import type { ExtendableDisposer } from "../../utils";
|
||||||
import * as uuid from "uuid";
|
import * as uuid from "uuid";
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import logger from "../../../../common/logger";
|
||||||
import { defaultExtensionRegistryUrl, ExtensionRegistry, ExtensionRegistryLocation } from "../../../../common/user-store/preferences-helpers";
|
import { defaultExtensionRegistryUrl, ExtensionRegistry, ExtensionRegistryLocation } from "../../../../common/user-store/preferences-helpers";
|
||||||
import { promiseExecFile } from "../../../utils";
|
import { promiseExecFile } from "../../../utils";
|
||||||
import { Notifications } from "../../notifications";
|
import { Notifications } from "../../notifications";
|
||||||
@ -46,7 +47,7 @@ export const getBaseRegistryUrl = ({ getRegistryUrlPreference }: Dependencies) =
|
|||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Notifications.error(<p>Failed to get configured registry from <code>.npmrc</code>. Falling back to default registry</p>);
|
Notifications.error(<p>Failed to get configured registry from <code>.npmrc</code>. Falling back to default registry</p>);
|
||||||
console.warn("[EXTENSIONS]: failed to get configured registry from .npmrc", error);
|
logger.warn("[EXTENSIONS]: failed to get configured registry from .npmrc", error);
|
||||||
}
|
}
|
||||||
// fallthrough
|
// fallthrough
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import { downloadFile, ExtendableDisposer } from "../../../../common/utils";
|
|||||||
import { InputValidators } from "../../input";
|
import { InputValidators } from "../../input";
|
||||||
import { ExtensionInstallationStateStore } from "../extension-install.store";
|
import { ExtensionInstallationStateStore } from "../extension-install.store";
|
||||||
import { getMessageFromError } from "../get-message-from-error/get-message-from-error";
|
import { getMessageFromError } from "../get-message-from-error/get-message-from-error";
|
||||||
import logger from "../../../../main/logger";
|
import logger from "../../../../common/logger";
|
||||||
import { Notifications } from "../../notifications";
|
import { Notifications } from "../../notifications";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
import logger from "../../../../main/logger";
|
import logger from "../../../../common/logger";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
attemptInstalls: (filePaths: string[]) => Promise<void>;
|
attemptInstalls: (filePaths: string[]) => Promise<void>;
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import { getMessageFromError } from "../get-message-from-error/get-message-from-error";
|
import { getMessageFromError } from "../get-message-from-error/get-message-from-error";
|
||||||
import logger from "../../../../main/logger";
|
import logger from "../../../../common/logger";
|
||||||
import { Notifications } from "../../notifications";
|
import { Notifications } from "../../notifications";
|
||||||
|
|
||||||
export const readFileNotify = async (filePath: string, showError = true): Promise<Buffer | null> => {
|
export const readFileNotify = async (filePath: string, showError = true): Promise<Buffer | null> => {
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
import type { ExtensionLoader } from "../../../../extensions/extension-loader";
|
import type { ExtensionLoader } from "../../../../extensions/extension-loader";
|
||||||
import { extensionDisplayName, LensExtensionId } from "../../../../extensions/lens-extension";
|
import { extensionDisplayName, LensExtensionId } from "../../../../extensions/lens-extension";
|
||||||
import logger from "../../../../main/logger";
|
import logger from "../../../../common/logger";
|
||||||
import { ExtensionInstallationStateStore } from "../extension-install.store";
|
import { ExtensionInstallationStateStore } from "../extension-install.store";
|
||||||
import { ExtensionDiscovery } from "../../../../extensions/extension-discovery";
|
import { ExtensionDiscovery } from "../../../../extensions/extension-discovery";
|
||||||
import { Notifications } from "../../notifications";
|
import { Notifications } from "../../notifications";
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import { Notice } from "../+extensions/notice";
|
|||||||
|
|
||||||
import { KubeconfigSyncEntry, KubeconfigSyncValue, UserStore } from "../../../common/user-store";
|
import { KubeconfigSyncEntry, KubeconfigSyncValue, UserStore } from "../../../common/user-store";
|
||||||
import { isWindows } from "../../../common/vars";
|
import { isWindows } from "../../../common/vars";
|
||||||
import logger from "../../../main/logger";
|
import logger from "../../../common/logger";
|
||||||
import { iter, multiSet } from "../../utils";
|
import { iter, multiSet } from "../../utils";
|
||||||
import { SubTitle } from "../layout/sub-title";
|
import { SubTitle } from "../layout/sub-title";
|
||||||
import { PathPicker } from "../path-picker/path-picker";
|
import { PathPicker } from "../path-picker/path-picker";
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import { autoBind, cpuUnitsToNumber, unitsToBytes } from "../../utils";
|
|||||||
import { Pod, PodMetrics, podMetricsApi, podsApi } from "../../../common/k8s-api/endpoints";
|
import { Pod, PodMetrics, podMetricsApi, podsApi } from "../../../common/k8s-api/endpoints";
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
import { apiManager } from "../../../common/k8s-api/api-manager";
|
||||||
import type { WorkloadKubeObject } from "../../../common/k8s-api/workload-kube-object";
|
import type { WorkloadKubeObject } from "../../../common/k8s-api/workload-kube-object";
|
||||||
|
import logger from "../../../common/logger";
|
||||||
|
|
||||||
export class PodsStore extends KubeObjectStore<Pod> {
|
export class PodsStore extends KubeObjectStore<Pod> {
|
||||||
api = podsApi;
|
api = podsApi;
|
||||||
@ -43,7 +44,7 @@ export class PodsStore extends KubeObjectStore<Pod> {
|
|||||||
try {
|
try {
|
||||||
this.kubeMetrics.replace(await podMetricsApi.list({ namespace }));
|
this.kubeMetrics.replace(await podMetricsApi.list({ namespace }));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn("loadKubeMetrics failed", error);
|
logger.warn("loadKubeMetrics failed", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { action, IReactionDisposer, makeObservable, observable, when } from "mobx";
|
import { action, IReactionDisposer, makeObservable, observable, when } from "mobx";
|
||||||
import logger from "../../../main/logger";
|
import logger from "../../../common/logger";
|
||||||
import { clusterVisibilityHandler } from "../../../common/cluster-ipc";
|
import { clusterVisibilityHandler } from "../../../common/cluster-ipc";
|
||||||
import { ClusterStore } from "../../../common/cluster-store";
|
import { ClusterStore } from "../../../common/cluster-store";
|
||||||
import type { ClusterId } from "../../../common/cluster-types";
|
import type { ClusterId } from "../../../common/cluster-types";
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import { orderBy } from "lodash";
|
|||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import registeredCommandsInjectable from "./registered-commands/registered-commands.injectable";
|
import registeredCommandsInjectable from "./registered-commands/registered-commands.injectable";
|
||||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||||
|
import logger from "../../../common/logger";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
commands: IComputedValue<Map<string, RegisteredCommand>>;
|
commands: IComputedValue<Map<string, RegisteredCommand>>;
|
||||||
@ -67,7 +68,7 @@ const NonInjectedCommandDialog = observer(({ commands, activeEntity, closeComman
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[COMMAND-DIALOG] failed to execute command", command.id, error);
|
logger.error("[COMMAND-DIALOG] failed to execute command", command.id, error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ const NonInjectedCommandDialog = observer(({ commands, activeEntity, closeComman
|
|||||||
try {
|
try {
|
||||||
return command.isActive(context);
|
return command.isActive(context);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[COMMAND-DIALOG]: isActive for ${command.id} threw an error, defaulting to false`, error);
|
logger.error(`[COMMAND-DIALOG]: isActive for ${command.id} threw an error, defaulting to false`, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import { TerminalApi, TerminalChannels } from "../../api/terminal-api";
|
|||||||
import { dockStore, DockTab, DockTabCreateSpecific, TabId, TabKind } from "./dock.store";
|
import { dockStore, DockTab, DockTabCreateSpecific, TabId, TabKind } from "./dock.store";
|
||||||
import { WebSocketApiState } from "../../api/websocket-api";
|
import { WebSocketApiState } from "../../api/websocket-api";
|
||||||
import { Notifications } from "../notifications";
|
import { Notifications } from "../notifications";
|
||||||
|
import logger from "../../../common/logger";
|
||||||
|
|
||||||
export interface ITerminalTab extends DockTab {
|
export interface ITerminalTab extends DockTab {
|
||||||
node?: string; // activate node shell mode
|
node?: string; // activate node shell mode
|
||||||
@ -146,7 +147,7 @@ export class TerminalStore extends Singleton {
|
|||||||
data: command,
|
data: command,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.warn("The selected tab is does not have a connection. Cannot send command.", { tabId: dockStore.selectedTabId, command });
|
logger.warn("The selected tab is does not have a connection. Cannot send command.", { tabId: dockStore.selectedTabId, command });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import React from "react";
|
|||||||
import { boundMethod, cssNames, IClassName } from "../../utils";
|
import { boundMethod, cssNames, IClassName } from "../../utils";
|
||||||
import { observable, makeObservable } from "mobx";
|
import { observable, makeObservable } from "mobx";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import logger from "../../../main/logger";
|
import logger from "../../../common/logger";
|
||||||
|
|
||||||
export interface DropFileInputProps extends React.DOMAttributes<any> {
|
export interface DropFileInputProps extends React.DOMAttributes<any> {
|
||||||
className?: IClassName;
|
className?: IClassName;
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
import logger from "../../../common/logger";
|
||||||
import { createPageParam, navigation } from "../../navigation";
|
import { createPageParam, navigation } from "../../navigation";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,7 +63,7 @@ export function hideDetails() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getDetailsUrl(selfLink: string, resetSelected = false, mergeGlobals = true) {
|
export function getDetailsUrl(selfLink: string, resetSelected = false, mergeGlobals = true) {
|
||||||
console.debug("getDetailsUrl", { selfLink, resetSelected, mergeGlobals });
|
logger.debug("getDetailsUrl", { selfLink, resetSelected, mergeGlobals });
|
||||||
const params = new URLSearchParams(mergeGlobals ? navigation.searchParams : "");
|
const params = new URLSearchParams(mergeGlobals ? navigation.searchParams : "");
|
||||||
|
|
||||||
params.set(kubeDetailsUrlParam.name, selfLink);
|
params.set(kubeDetailsUrlParam.name, selfLink);
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import { apiManager } from "../../../common/k8s-api/api-manager";
|
|||||||
import { crdStore } from "../+custom-resources/crd.store";
|
import { crdStore } from "../+custom-resources/crd.store";
|
||||||
import { KubeObjectMenu } from "../kube-object-menu";
|
import { KubeObjectMenu } from "../kube-object-menu";
|
||||||
import { KubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
import { KubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||||
|
import logger from "../../../common/logger";
|
||||||
import { CrdResourceDetails } from "../+custom-resources";
|
import { CrdResourceDetails } from "../+custom-resources";
|
||||||
import { KubeObjectMeta } from "../kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object-meta";
|
||||||
import { hideDetails, kubeDetailsUrlParam } from "../kube-detail-params";
|
import { hideDetails, kubeDetailsUrlParam } from "../kube-detail-params";
|
||||||
@ -61,7 +62,7 @@ export class KubeObjectDetails extends React.Component {
|
|||||||
.getStore(this.path)
|
.getStore(this.path)
|
||||||
?.getByPath(this.path);
|
?.getByPath(this.path);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[KUBE-OBJECT-DETAILS]: failed to get store or object: ${error}`, { path: this.path });
|
logger.error(`[KUBE-OBJECT-DETAILS]: failed to get store or object: ${error}`, { path: this.path });
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,7 @@ import { Config } from "../+config";
|
|||||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||||
import { SidebarCluster } from "./sidebar-cluster";
|
import { SidebarCluster } from "./sidebar-cluster";
|
||||||
import { kubeWatchApi } from "../../../common/k8s-api/kube-watch-api";
|
import { kubeWatchApi } from "../../../common/k8s-api/kube-watch-api";
|
||||||
|
import logger from "../../../common/logger";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -127,7 +128,7 @@ export class Sidebar extends React.Component<Props> {
|
|||||||
const { extensionId, id: pageId, url, components } = page;
|
const { extensionId, id: pageId, url, components } = page;
|
||||||
|
|
||||||
if (subMenu.components.Icon) {
|
if (subMenu.components.Icon) {
|
||||||
console.warn(
|
logger.warn(
|
||||||
"ClusterPageMenuRegistration has components.Icon defined and a valid parentId. Icon will not be displayed",
|
"ClusterPageMenuRegistration has components.Icon defined and a valid parentId. Icon will not be displayed",
|
||||||
{
|
{
|
||||||
id: subMenu.id,
|
id: subMenu.id,
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import { debounce, merge } from "lodash";
|
|||||||
import { cssNames, disposer } from "../../utils";
|
import { cssNames, disposer } from "../../utils";
|
||||||
import { UserStore } from "../../../common/user-store";
|
import { UserStore } from "../../../common/user-store";
|
||||||
import { ThemeStore } from "../../theme.store";
|
import { ThemeStore } from "../../theme.store";
|
||||||
|
import logger from "../../../common/logger";
|
||||||
|
|
||||||
export type MonacoEditorId = string;
|
export type MonacoEditorId = string;
|
||||||
|
|
||||||
@ -70,11 +71,6 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
|
|||||||
public staticId = `editor-id#${Math.round(1e7 * Math.random())}`;
|
public staticId = `editor-id#${Math.round(1e7 * Math.random())}`;
|
||||||
public dispose = disposer();
|
public dispose = disposer();
|
||||||
|
|
||||||
// TODO: investigate how to replace with "common/logger"
|
|
||||||
// currently leads for stucking UI forever & infinite loop.
|
|
||||||
// e.g. happens on tab change/create, maybe some other cases too.
|
|
||||||
logger = console;
|
|
||||||
|
|
||||||
@observable.ref containerElem: HTMLElement;
|
@observable.ref containerElem: HTMLElement;
|
||||||
@observable.ref editor: editor.IStandaloneCodeEditor;
|
@observable.ref editor: editor.IStandaloneCodeEditor;
|
||||||
@observable dimensions: { width?: number, height?: number } = {};
|
@observable dimensions: { width?: number, height?: number } = {};
|
||||||
@ -137,7 +133,7 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onModelChange = (model: editor.ITextModel, oldModel?: editor.ITextModel) => {
|
onModelChange = (model: editor.ITextModel, oldModel?: editor.ITextModel) => {
|
||||||
this.logger?.info("[MONACO]: model change", { model, oldModel }, this.logMetadata);
|
logger.info("[MONACO]: model change", { model, oldModel }, this.logMetadata);
|
||||||
|
|
||||||
if (oldModel) {
|
if (oldModel) {
|
||||||
this.saveViewState(oldModel);
|
this.saveViewState(oldModel);
|
||||||
@ -171,9 +167,9 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
try {
|
try {
|
||||||
this.createEditor();
|
this.createEditor();
|
||||||
this.logger?.info(`[MONACO]: editor did mount`, this.logMetadata);
|
logger.info(`[MONACO]: editor did mount`, this.logMetadata);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger?.error(`[MONACO]: mounting failed: ${error}`, this.logMetadata);
|
logger.error(`[MONACO]: mounting failed: ${error}`, this.logMetadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +195,7 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
|
|||||||
...this.options,
|
...this.options,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.logger?.info(`[MONACO]: editor created for language=${language}, theme=${theme}`, this.logMetadata);
|
logger.info(`[MONACO]: editor created for language=${language}, theme=${theme}`, this.logMetadata);
|
||||||
this.validateLazy(); // validate initial value
|
this.validateLazy(); // validate initial value
|
||||||
this.restoreViewState(this.model); // restore previous state if any
|
this.restoreViewState(this.model); // restore previous state if any
|
||||||
|
|
||||||
|
|||||||
@ -78,19 +78,11 @@ describe("<ScrollSpy/>", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws if no sections founded", () => {
|
it("throws if no sections founded", () => {
|
||||||
// Prevent writing to stderr during this render.
|
|
||||||
const err = console.error;
|
|
||||||
|
|
||||||
console.error = jest.fn();
|
|
||||||
|
|
||||||
expect(() => render(<ScrollSpy render={() => (
|
expect(() => render(<ScrollSpy render={() => (
|
||||||
<div>
|
<div>
|
||||||
Content
|
Content
|
||||||
</div>
|
</div>
|
||||||
)}/>)).toThrow();
|
)}/>)).toThrow();
|
||||||
|
|
||||||
// Restore writing to stderr.
|
|
||||||
console.error = err;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -176,8 +168,6 @@ describe("<TreeView/> dataTree inside <ScrollSpy/>", () => {
|
|||||||
expect(queryByTitle("Application")).toHaveAttribute("aria-expanded");
|
expect(queryByTitle("Application")).toHaveAttribute("aria-expanded");
|
||||||
expect(queryByTitle("Kubernetes")).toHaveAttribute("aria-expanded");
|
expect(queryByTitle("Kubernetes")).toHaveAttribute("aria-expanded");
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log(prettyDOM());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("skips sections without headings", async () => {
|
it("skips sections without headings", async () => {
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import { createPageParam } from "../../navigation";
|
|||||||
import { getSortParams, setSortParams } from "./table.storage";
|
import { getSortParams, setSortParams } from "./table.storage";
|
||||||
import { computed, makeObservable } from "mobx";
|
import { computed, makeObservable } from "mobx";
|
||||||
import { getSorted } from "./sorting";
|
import { getSorted } from "./sorting";
|
||||||
|
import logger from "../../../common/logger";
|
||||||
|
|
||||||
export type TableSortBy = string;
|
export type TableSortBy = string;
|
||||||
export type TableOrderBy = "asc" | "desc" | string;
|
export type TableOrderBy = "asc" | "desc" | string;
|
||||||
@ -110,7 +111,7 @@ export class Table<Item> extends React.Component<TableProps<Item>> {
|
|||||||
const { sortable, tableId } = this.props;
|
const { sortable, tableId } = this.props;
|
||||||
|
|
||||||
if (sortable && !tableId) {
|
if (sortable && !tableId) {
|
||||||
console.error("Table must have props.tableId if props.sortable is specified");
|
logger.error("Table must have props.tableId if props.sortable is specified");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,12 +27,13 @@ import { catalogCategoryRegistry } from "../api/catalog-category-registry";
|
|||||||
import { WeblinkAddCommand } from "../components/catalog-entities/weblink-add-command";
|
import { WeblinkAddCommand } from "../components/catalog-entities/weblink-add-command";
|
||||||
import { loadConfigFromString } from "../../common/kube-helpers";
|
import { loadConfigFromString } from "../../common/kube-helpers";
|
||||||
import { DeleteClusterDialog } from "../components/delete-cluster-dialog";
|
import { DeleteClusterDialog } from "../components/delete-cluster-dialog";
|
||||||
|
import logger from "../../common/logger";
|
||||||
|
|
||||||
async function onClusterDelete(clusterId: string) {
|
async function onClusterDelete(clusterId: string): Promise<void> {
|
||||||
const cluster = ClusterStore.getInstance().getById(clusterId);
|
const cluster = ClusterStore.getInstance().getById(clusterId);
|
||||||
|
|
||||||
if (!cluster) {
|
if (!cluster) {
|
||||||
return console.warn("[KUBERNETES-CLUSTER]: cannot delete cluster, does not exist in store", { clusterId });
|
return void logger.warn("[KUBERNETES-CLUSTER]: cannot delete cluster, does not exist in store", { clusterId });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { config, error } = loadConfigFromString(await fs.promises.readFile(cluster.kubeConfigPath, "utf-8"));
|
const { config, error } = loadConfigFromString(await fs.promises.readFile(cluster.kubeConfigPath, "utf-8"));
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import { ipcRenderer } from "electron";
|
|||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import { getMatchedClusterId, navigate } from "./helpers";
|
import { getMatchedClusterId, navigate } from "./helpers";
|
||||||
import { broadcastMessage, ipcRendererOn } from "../../common/ipc";
|
import { broadcastMessage, ipcRendererOn } from "../../common/ipc";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
|
|
||||||
export const enum IpcRendererNavigationEvents {
|
export const enum IpcRendererNavigationEvents {
|
||||||
RELOAD_PAGE = "renderer:page-reload",
|
RELOAD_PAGE = "renderer:page-reload",
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
import { ipcRenderer } from "electron";
|
import { ipcRenderer } from "electron";
|
||||||
import { createBrowserHistory, createMemoryHistory } from "history";
|
import { createBrowserHistory, createMemoryHistory } from "history";
|
||||||
import { createObservableHistory, ObservableSearchParamsOptions } from "mobx-observable-history";
|
import { createObservableHistory, ObservableSearchParamsOptions } from "mobx-observable-history";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../common/logger";
|
||||||
|
|
||||||
export const searchParamsOptions: ObservableSearchParamsOptions = {
|
export const searchParamsOptions: ObservableSearchParamsOptions = {
|
||||||
skipEmpty: true, // skip empty params, e.g. "?x=&y2=" will be "?y=2"
|
skipEmpty: true, // skip empty params, e.g. "?x=&y2=" will be "?y=2"
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
import { comparer, computed, makeObservable, observable, reaction } from "mobx";
|
import { comparer, computed, makeObservable, observable, reaction } from "mobx";
|
||||||
import { autoBind, Singleton } from "./utils";
|
import { autoBind, Singleton } from "./utils";
|
||||||
import { UserStore } from "../common/user-store";
|
import { UserStore } from "../common/user-store";
|
||||||
import logger from "../main/logger";
|
import logger from "../common/logger";
|
||||||
import lensDarkThemeJson from "./themes/lens-dark.json";
|
import lensDarkThemeJson from "./themes/lens-dark.json";
|
||||||
import lensLightThemeJson from "./themes/lens-light.json";
|
import lensLightThemeJson from "./themes/lens-light.json";
|
||||||
import type { SelectOption } from "./components/select";
|
import type { SelectOption } from "./components/select";
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user