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,13 +20,25 @@
|
|||||||
"exports": {
|
"exports": {
|
||||||
"./package.json": "./package.json",
|
"./package.json": "./package.json",
|
||||||
"./main": {
|
"./main": {
|
||||||
"types": "./static/build/main/src/library.d.ts",
|
"import": {
|
||||||
|
"types": "./static/build/library/src/main/library.d.ts",
|
||||||
"default": "./static/build/library/main.js"
|
"default": "./static/build/library/main.js"
|
||||||
},
|
},
|
||||||
|
"require": {
|
||||||
|
"types": "./static/build/library/src/main/library.d.ts",
|
||||||
|
"default": "./static/build/library/main.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"./renderer": {
|
"./renderer": {
|
||||||
|
"import": {
|
||||||
"types": "./static/build/library/src/renderer/library.d.ts",
|
"types": "./static/build/library/src/renderer/library.d.ts",
|
||||||
"default": "./static/build/library/renderer.js"
|
"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",
|
"./styles": "./static/build/library/renderer.css",
|
||||||
"./template.html": "./src/renderer/template.html",
|
"./template.html": "./src/renderer/template.html",
|
||||||
"./vars.scss": "./src/renderer/components/vars.scss",
|
"./vars.scss": "./src/renderer/components/vars.scss",
|
||||||
|
|||||||
@ -18,9 +18,9 @@ describe("cluster - custom resources in sidebar", () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
builder.setEnvironmentToClusterFrame();
|
|
||||||
|
|
||||||
builder.afterWindowStart(({ windowDi }) => {
|
await builder.setEnvironmentToClusterFrame();
|
||||||
|
await builder.afterWindowStart(({ windowDi }) => {
|
||||||
customResourceDefinitionStore = windowDi.inject(customResourceDefinitionStoreInjectable);
|
customResourceDefinitionStore = windowDi.inject(customResourceDefinitionStoreInjectable);
|
||||||
customResourceDefinition = new CustomResourceDefinition({
|
customResourceDefinition = new CustomResourceDefinition({
|
||||||
apiVersion: "apiextensions.k8s.io/v1",
|
apiVersion: "apiextensions.k8s.io/v1",
|
||||||
|
|||||||
@ -57,10 +57,6 @@ class NonInjectedReplicationControllerDetails extends React.Component<KubeObject
|
|||||||
render() {
|
render() {
|
||||||
const { object: resource } = this.props;
|
const { object: resource } = this.props;
|
||||||
|
|
||||||
if (!resource) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(resource instanceof ReplicationController)) {
|
if (!(resource instanceof ReplicationController)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,9 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { mainExtensionApi as Main, commonExtensionApi as Common } from "@k8slens/core/main";
|
import { mainExtensionApi, commonExtensionApi } from "@k8slens/core/main";
|
||||||
import { rendererExtensionApi as Renderer } from "@k8slens/core/renderer";
|
import { rendererExtensionApi } from "@k8slens/core/renderer";
|
||||||
|
|
||||||
export {
|
export const Main = mainExtensionApi;
|
||||||
Main,
|
export const Common = commonExtensionApi;
|
||||||
Common,
|
export const Renderer = rendererExtensionApi;
|
||||||
Renderer,
|
|
||||||
};
|
|
||||||
|
|||||||
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"
|
"winston": "^3.8.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@k8slens/eslint-config": "6.5.0-alpha.1",
|
"@k8slens/eslint-config": "^6.5.0",
|
||||||
"@k8slens/jest": "^6.5.0",
|
"@k8slens/jest": "^6.5.0",
|
||||||
"@k8slens/react-testing-library-discovery": "^1.0.0",
|
"@k8slens/react-testing-library-discovery": "^1.0.0",
|
||||||
"@k8slens/webpack": "^6.5.0"
|
"@k8slens/webpack": "^6.5.0"
|
||||||
|
|||||||
@ -20,6 +20,25 @@ export interface Logger {
|
|||||||
silly: LogFunction;
|
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 */
|
/** @deprecated Use specific injectionToken, eg. logErrorInjectionToken */
|
||||||
export const loggerInjectionToken = getInjectionToken<Logger>({
|
export const loggerInjectionToken = getInjectionToken<Logger>({
|
||||||
id: "logger-injection-token",
|
id: "logger-injection-token",
|
||||||
@ -61,25 +80,6 @@ export const logSillyInjectionToken = getInjectionToken<LogFunction>({
|
|||||||
id: "log-silly-injection-token",
|
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({
|
export const logDebugInjectable = getInjectable({
|
||||||
id: "log-debug",
|
id: "log-debug",
|
||||||
instantiate: (di) => getLogFunctionFor("debug", di.sourceNamespace)(di),
|
instantiate: (di) => getLogFunctionFor("debug", di.sourceNamespace)(di),
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { KubeJsonApi, DeploymentApi } from "@k8slens/kube-api";
|
|||||||
|
|
||||||
describe("DeploymentApi", () => {
|
describe("DeploymentApi", () => {
|
||||||
let deploymentApi: DeploymentApi;
|
let deploymentApi: DeploymentApi;
|
||||||
let kubeJsonApi: jest.Mocked<KubeJsonApi>;
|
let kubeJsonApi: KubeJsonApi;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
kubeJsonApi = {
|
kubeJsonApi = {
|
||||||
@ -17,14 +17,16 @@ describe("DeploymentApi", () => {
|
|||||||
put: jest.fn(),
|
put: jest.fn(),
|
||||||
patch: jest.fn(),
|
patch: jest.fn(),
|
||||||
del: jest.fn(),
|
del: jest.fn(),
|
||||||
} as never;
|
} as Partial<KubeJsonApi> as KubeJsonApi;
|
||||||
|
|
||||||
deploymentApi = new DeploymentApi({
|
deploymentApi = new DeploymentApi({
|
||||||
logger: {
|
logger: {
|
||||||
info: jest.fn(),
|
info: jest.fn(),
|
||||||
debug: jest.fn(),
|
debug: jest.fn(),
|
||||||
error: jest.fn(),
|
error: jest.fn(),
|
||||||
} as any,
|
silly: jest.fn(),
|
||||||
|
warn: jest.fn(),
|
||||||
|
},
|
||||||
maybeKubeApi: kubeJsonApi,
|
maybeKubeApi: kubeJsonApi,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -33,6 +35,7 @@ describe("DeploymentApi", () => {
|
|||||||
it("requests Kubernetes API with PATCH verb and correct amount of replicas", async () => {
|
it("requests Kubernetes API with PATCH verb and correct amount of replicas", async () => {
|
||||||
await deploymentApi.scale({ namespace: "default", name: "deployment-1" }, 5);
|
await deploymentApi.scale({ namespace: "default", name: "deployment-1" }, 5);
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||||
expect(kubeJsonApi.patch).toHaveBeenCalledWith(
|
expect(kubeJsonApi.patch).toHaveBeenCalledWith(
|
||||||
"/apis/apps/v1/namespaces/default/deployments/deployment-1/scale",
|
"/apis/apps/v1/namespaces/default/deployments/deployment-1/scale",
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,7 +26,9 @@ describe("StatefulSetApi", () => {
|
|||||||
info: jest.fn(),
|
info: jest.fn(),
|
||||||
debug: jest.fn(),
|
debug: jest.fn(),
|
||||||
error: jest.fn(),
|
error: jest.fn(),
|
||||||
} as any,
|
silly: jest.fn(),
|
||||||
|
warn: jest.fn(),
|
||||||
|
},
|
||||||
maybeKubeApi: kubeJsonApi,
|
maybeKubeApi: kubeJsonApi,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -60,7 +62,9 @@ describe("StatefulSetApi", () => {
|
|||||||
const req = statefulSetApi.getReplicas({ namespace: "default", name: "statefulset-1" });
|
const req = statefulSetApi.getReplicas({ namespace: "default", name: "statefulset-1" });
|
||||||
|
|
||||||
await flushPromises();
|
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 } });
|
await kubeJsonApiGetMock.resolve({ status: { replicas: 10 } });
|
||||||
|
|
||||||
expect(await req).toBe(10);
|
expect(await req).toBe(10);
|
||||||
|
|||||||
@ -28,7 +28,9 @@ describe("KubeApi", () => {
|
|||||||
info: jest.fn(),
|
info: jest.fn(),
|
||||||
debug: jest.fn(),
|
debug: jest.fn(),
|
||||||
error: jest.fn(),
|
error: jest.fn(),
|
||||||
} as any;
|
silly: jest.fn(),
|
||||||
|
warn: jest.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
kubeJsonApi = new KubeJsonApi(
|
kubeJsonApi = new KubeJsonApi(
|
||||||
{
|
{
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export const createMockResponseFromString = (url: string, data: string, statusCo
|
|||||||
body: new PassThrough(),
|
body: new PassThrough(),
|
||||||
bodyUsed: false,
|
bodyUsed: false,
|
||||||
headers: new NodeFetchHeaders(),
|
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,
|
ok: 200 <= statusCode && statusCode < 300,
|
||||||
redirected: 300 <= statusCode && statusCode < 400,
|
redirected: 300 <= statusCode && statusCode < 400,
|
||||||
size: data.length,
|
size: data.length,
|
||||||
@ -52,7 +52,7 @@ export const createMockResponseFromStream = (url: string, stream: NodeJS.Readabl
|
|||||||
body: stream,
|
body: stream,
|
||||||
bodyUsed: false,
|
bodyUsed: false,
|
||||||
headers: new NodeFetchHeaders(),
|
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,
|
ok: 200 <= statusCode && statusCode < 300,
|
||||||
redirected: 300 <= statusCode && statusCode < 400,
|
redirected: 300 <= statusCode && statusCode < 400,
|
||||||
size: 10,
|
size: 10,
|
||||||
@ -62,7 +62,7 @@ export const createMockResponseFromStream = (url: string, stream: NodeJS.Readabl
|
|||||||
const chunks: Buffer[] = [];
|
const chunks: Buffer[] = [];
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
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("error", (err) => reject(err));
|
||||||
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user