mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Fix lint after rebase
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
69324ff555
commit
369f934159
@ -20,12 +20,24 @@
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
"./main": {
|
||||
"types": "./static/build/main/src/library.d.ts",
|
||||
"default": "./static/build/library/main.js"
|
||||
"import": {
|
||||
"types": "./static/build/library/src/main/library.d.ts",
|
||||
"default": "./static/build/library/main.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./static/build/library/src/main/library.d.ts",
|
||||
"default": "./static/build/library/main.js"
|
||||
}
|
||||
},
|
||||
"./renderer": {
|
||||
"types": "./static/build/library/src/renderer/library.d.ts",
|
||||
"default": "./static/build/library/renderer.js"
|
||||
"import": {
|
||||
"types": "./static/build/library/src/renderer/library.d.ts",
|
||||
"default": "./static/build/library/renderer.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./static/build/library/src/renderer/library.d.ts",
|
||||
"default": "./static/build/library/renderer.js"
|
||||
}
|
||||
},
|
||||
"./styles": "./static/build/library/renderer.css",
|
||||
"./template.html": "./src/renderer/template.html",
|
||||
|
||||
@ -18,9 +18,9 @@ describe("cluster - custom resources in sidebar", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.afterWindowStart(({ windowDi }) => {
|
||||
await builder.setEnvironmentToClusterFrame();
|
||||
await builder.afterWindowStart(({ windowDi }) => {
|
||||
customResourceDefinitionStore = windowDi.inject(customResourceDefinitionStoreInjectable);
|
||||
customResourceDefinition = new CustomResourceDefinition({
|
||||
apiVersion: "apiextensions.k8s.io/v1",
|
||||
|
||||
@ -57,10 +57,6 @@ class NonInjectedReplicationControllerDetails extends React.Component<KubeObject
|
||||
render() {
|
||||
const { object: resource } = this.props;
|
||||
|
||||
if (!resource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(resource instanceof ReplicationController)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -2,11 +2,9 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { mainExtensionApi as Main, commonExtensionApi as Common } from "@k8slens/core/main";
|
||||
import { rendererExtensionApi as Renderer } from "@k8slens/core/renderer";
|
||||
import { mainExtensionApi, commonExtensionApi } from "@k8slens/core/main";
|
||||
import { rendererExtensionApi } from "@k8slens/core/renderer";
|
||||
|
||||
export {
|
||||
Main,
|
||||
Common,
|
||||
Renderer,
|
||||
};
|
||||
export const Main = mainExtensionApi;
|
||||
export const Common = commonExtensionApi;
|
||||
export const Renderer = rendererExtensionApi;
|
||||
|
||||
6
packages/logger/.eslintrc.js
Normal file
6
packages/logger/.eslintrc.js
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
extends: "@k8slens/eslint-config/eslint",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
};
|
||||
@ -38,7 +38,7 @@
|
||||
"winston": "^3.8.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@k8slens/eslint-config": "6.5.0-alpha.1",
|
||||
"@k8slens/eslint-config": "^6.5.0",
|
||||
"@k8slens/jest": "^6.5.0",
|
||||
"@k8slens/react-testing-library-discovery": "^1.0.0",
|
||||
"@k8slens/webpack": "^6.5.0"
|
||||
|
||||
@ -20,6 +20,25 @@ export interface Logger {
|
||||
silly: LogFunction;
|
||||
}
|
||||
|
||||
const screamingKebabCase = (str: string) => pipeline(str, kebabCase, toUpper);
|
||||
|
||||
const getLogFunctionFor = (
|
||||
scenario: keyof Logger,
|
||||
namespace: string | undefined
|
||||
) => {
|
||||
const prefix = namespace
|
||||
? `[${screamingKebabCase(namespace.replace(/-feature$/, ""))}]: `
|
||||
: "";
|
||||
|
||||
return (di: DiContainerForInjection): LogFunction => {
|
||||
const winstonLogger = di.inject(winstonLoggerInjectable);
|
||||
|
||||
return (message, ...data) => {
|
||||
winstonLogger[scenario](`${prefix}${message}`, ...data);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/** @deprecated Use specific injectionToken, eg. logErrorInjectionToken */
|
||||
export const loggerInjectionToken = getInjectionToken<Logger>({
|
||||
id: "logger-injection-token",
|
||||
@ -61,25 +80,6 @@ export const logSillyInjectionToken = getInjectionToken<LogFunction>({
|
||||
id: "log-silly-injection-token",
|
||||
});
|
||||
|
||||
const screamingKebabCase = (str: string) => pipeline(str, kebabCase, toUpper);
|
||||
|
||||
const getLogFunctionFor = (
|
||||
scenario: keyof Logger,
|
||||
namespace: string | undefined
|
||||
) => {
|
||||
const prefix = namespace
|
||||
? `[${screamingKebabCase(namespace.replace(/-feature$/, ""))}]: `
|
||||
: "";
|
||||
|
||||
return (di: DiContainerForInjection): LogFunction => {
|
||||
const winstonLogger = di.inject(winstonLoggerInjectable);
|
||||
|
||||
return (message, ...data) => {
|
||||
winstonLogger[scenario](`${prefix}${message}`, ...data);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const logDebugInjectable = getInjectable({
|
||||
id: "log-debug",
|
||||
instantiate: (di) => getLogFunctionFor("debug", di.sourceNamespace)(di),
|
||||
|
||||
@ -7,7 +7,7 @@ import { KubeJsonApi, DeploymentApi } from "@k8slens/kube-api";
|
||||
|
||||
describe("DeploymentApi", () => {
|
||||
let deploymentApi: DeploymentApi;
|
||||
let kubeJsonApi: jest.Mocked<KubeJsonApi>;
|
||||
let kubeJsonApi: KubeJsonApi;
|
||||
|
||||
beforeEach(() => {
|
||||
kubeJsonApi = {
|
||||
@ -17,14 +17,16 @@ describe("DeploymentApi", () => {
|
||||
put: jest.fn(),
|
||||
patch: jest.fn(),
|
||||
del: jest.fn(),
|
||||
} as never;
|
||||
} as Partial<KubeJsonApi> as KubeJsonApi;
|
||||
|
||||
deploymentApi = new DeploymentApi({
|
||||
logger: {
|
||||
info: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
} as any,
|
||||
silly: jest.fn(),
|
||||
warn: jest.fn(),
|
||||
},
|
||||
maybeKubeApi: kubeJsonApi,
|
||||
});
|
||||
});
|
||||
@ -33,6 +35,7 @@ describe("DeploymentApi", () => {
|
||||
it("requests Kubernetes API with PATCH verb and correct amount of replicas", async () => {
|
||||
await deploymentApi.scale({ namespace: "default", name: "deployment-1" }, 5);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
expect(kubeJsonApi.patch).toHaveBeenCalledWith(
|
||||
"/apis/apps/v1/namespaces/default/deployments/deployment-1/scale",
|
||||
{
|
||||
|
||||
@ -26,7 +26,9 @@ describe("StatefulSetApi", () => {
|
||||
info: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
} as any,
|
||||
silly: jest.fn(),
|
||||
warn: jest.fn(),
|
||||
},
|
||||
maybeKubeApi: kubeJsonApi,
|
||||
});
|
||||
});
|
||||
@ -60,7 +62,9 @@ describe("StatefulSetApi", () => {
|
||||
const req = statefulSetApi.getReplicas({ namespace: "default", name: "statefulset-1" });
|
||||
|
||||
await flushPromises();
|
||||
expect(kubeJsonApi.get).toHaveBeenCalledWith("/apis/apps/v1/namespaces/default/statefulsets/statefulset-1/scale");
|
||||
expect(kubeJsonApiGetMock).toHaveBeenCalledWith(
|
||||
"/apis/apps/v1/namespaces/default/statefulsets/statefulset-1/scale",
|
||||
);
|
||||
await kubeJsonApiGetMock.resolve({ status: { replicas: 10 } });
|
||||
|
||||
expect(await req).toBe(10);
|
||||
|
||||
@ -28,7 +28,9 @@ describe("KubeApi", () => {
|
||||
info: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
} as any;
|
||||
silly: jest.fn(),
|
||||
warn: jest.fn(),
|
||||
};
|
||||
|
||||
kubeJsonApi = new KubeJsonApi(
|
||||
{
|
||||
|
||||
@ -20,7 +20,7 @@ export const createMockResponseFromString = (url: string, data: string, statusCo
|
||||
body: new PassThrough(),
|
||||
bodyUsed: false,
|
||||
headers: new NodeFetchHeaders(),
|
||||
json: jest.fn(async () => JSON.parse(await res.text())),
|
||||
json: jest.fn(async () => JSON.parse(await res.text()) as unknown),
|
||||
ok: 200 <= statusCode && statusCode < 300,
|
||||
redirected: 300 <= statusCode && statusCode < 400,
|
||||
size: data.length,
|
||||
@ -52,7 +52,7 @@ export const createMockResponseFromStream = (url: string, stream: NodeJS.Readabl
|
||||
body: stream,
|
||||
bodyUsed: false,
|
||||
headers: new NodeFetchHeaders(),
|
||||
json: jest.fn(async () => JSON.parse(await res.text())),
|
||||
json: jest.fn(async () => JSON.parse(await res.text()) as unknown),
|
||||
ok: 200 <= statusCode && statusCode < 300,
|
||||
redirected: 300 <= statusCode && statusCode < 400,
|
||||
size: 10,
|
||||
@ -62,7 +62,7 @@ export const createMockResponseFromStream = (url: string, stream: NodeJS.Readabl
|
||||
const chunks: Buffer[] = [];
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
||||
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk as [])));
|
||||
stream.on("error", (err) => reject(err));
|
||||
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user