mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'master' into detect-kind
This commit is contained in:
commit
de3bea4bc6
@ -41,10 +41,12 @@ jobs:
|
|||||||
displayName: Generate npm package
|
displayName: Generate npm package
|
||||||
- script: make -j2 build-extensions
|
- script: make -j2 build-extensions
|
||||||
displayName: Build bundled extensions
|
displayName: Build bundled extensions
|
||||||
- script: make integration-win
|
- script: make test
|
||||||
displayName: Run integration tests
|
displayName: Run tests
|
||||||
- script: make test-extensions
|
- script: make test-extensions
|
||||||
displayName: Run In-tree Extension tests
|
displayName: Run In-tree Extension tests
|
||||||
|
- script: make integration-win
|
||||||
|
displayName: Run integration tests
|
||||||
- script: make build
|
- script: make build
|
||||||
condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))"
|
condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))"
|
||||||
displayName: Build
|
displayName: Build
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import { getFreePort } from "../port";
|
|||||||
import fse from "fs-extra";
|
import fse from "fs-extra";
|
||||||
import { loadYaml } from "@kubernetes/client-node";
|
import { loadYaml } from "@kubernetes/client-node";
|
||||||
import { Console } from "console";
|
import { Console } from "console";
|
||||||
|
import * as path from "path";
|
||||||
|
|
||||||
console = new Console(process.stdout, process.stderr); // fix mockFS
|
console = new Console(process.stdout, process.stderr); // fix mockFS
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ describe("kubeconfig manager tests", () => {
|
|||||||
const kubeConfManager = await KubeconfigManager.create(cluster, contextHandler, port);
|
const kubeConfManager = await KubeconfigManager.create(cluster, contextHandler, port);
|
||||||
|
|
||||||
expect(logger.error).not.toBeCalled();
|
expect(logger.error).not.toBeCalled();
|
||||||
expect(kubeConfManager.getPath()).toBe("tmp/kubeconfig-foo");
|
expect(kubeConfManager.getPath()).toBe(`tmp${path.sep}kubeconfig-foo`);
|
||||||
const file = await fse.readFile(kubeConfManager.getPath());
|
const file = await fse.readFile(kubeConfManager.getPath());
|
||||||
const yml = loadYaml<any>(file.toString());
|
const yml = loadYaml<any>(file.toString());
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,12 @@ export class DistributionDetector extends BaseClusterDetector {
|
|||||||
public async detect() {
|
public async detect() {
|
||||||
this.version = await this.getKubernetesVersion();
|
this.version = await this.getKubernetesVersion();
|
||||||
|
|
||||||
if (await this.isRancher()) {
|
if (this.isRke()) {
|
||||||
return { value: "rancher", accuracy: 80};
|
return { value: "rke", accuracy: 80};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isK3s()) {
|
||||||
|
return { value: "k3s", accuracy: 80};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isGKE()) {
|
if (this.isGKE()) {
|
||||||
@ -32,6 +36,10 @@ export class DistributionDetector extends BaseClusterDetector {
|
|||||||
return { value: "digitalocean", accuracy: 90};
|
return { value: "digitalocean", accuracy: 90};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isMirantis()) {
|
||||||
|
return { value: "mirantis", accuracy: 90};
|
||||||
|
}
|
||||||
|
|
||||||
if (this.isMinikube()) {
|
if (this.isMinikube()) {
|
||||||
return { value: "minikube", accuracy: 80};
|
return { value: "minikube", accuracy: 80};
|
||||||
}
|
}
|
||||||
@ -44,6 +52,10 @@ export class DistributionDetector extends BaseClusterDetector {
|
|||||||
return { value: "kind", accuracy: 70};
|
return { value: "kind", accuracy: 70};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isDockerDesktop()) {
|
||||||
|
return { value: "docker-desktop", accuracy: 80};
|
||||||
|
}
|
||||||
|
|
||||||
if (this.isCustom()) {
|
if (this.isCustom()) {
|
||||||
return { value: "custom", accuracy: 10};
|
return { value: "custom", accuracy: 10};
|
||||||
}
|
}
|
||||||
@ -75,6 +87,10 @@ export class DistributionDetector extends BaseClusterDetector {
|
|||||||
return this.cluster.apiUrl.endsWith("azmk8s.io");
|
return this.cluster.apiUrl.endsWith("azmk8s.io");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected isMirantis() {
|
||||||
|
return this.version.includes("-mirantis-") || this.version.includes("-docker-");
|
||||||
|
}
|
||||||
|
|
||||||
protected isDigitalOcean() {
|
protected isDigitalOcean() {
|
||||||
return this.cluster.apiUrl.endsWith("k8s.ondigitalocean.com");
|
return this.cluster.apiUrl.endsWith("k8s.ondigitalocean.com");
|
||||||
}
|
}
|
||||||
@ -91,17 +107,19 @@ export class DistributionDetector extends BaseClusterDetector {
|
|||||||
return this.cluster.contextName.startsWith("kubernetes-admin@kind-");
|
return this.cluster.contextName.startsWith("kubernetes-admin@kind-");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected isDockerDesktop() {
|
||||||
|
return this.cluster.contextName === "docker-desktop";
|
||||||
|
}
|
||||||
|
|
||||||
protected isCustom() {
|
protected isCustom() {
|
||||||
return this.version.includes("+");
|
return this.version.includes("+");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async isRancher() {
|
protected isRke() {
|
||||||
try {
|
return this.version.includes("-rancher");
|
||||||
const response = await this.k8sRequest("");
|
}
|
||||||
|
|
||||||
return response.data.find((api: any) => api?.apiVersion?.group === "meta.cattle.io") !== undefined;
|
protected isK3s() {
|
||||||
} catch (e) {
|
return this.version.includes("+k3s");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import { LineProgress } from "../line-progress";
|
|||||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||||
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||||
import { ReplicaSetDetails } from "../+workloads-replicasets";
|
|
||||||
|
|
||||||
interface Props extends KubeObjectDetailsProps<ResourceQuota> {
|
interface Props extends KubeObjectDetailsProps<ResourceQuota> {
|
||||||
}
|
}
|
||||||
@ -103,6 +102,6 @@ kubeObjectDetailRegistry.add({
|
|||||||
kind: "ResourceQuota",
|
kind: "ResourceQuota",
|
||||||
apiVersions: ["v1"],
|
apiVersions: ["v1"],
|
||||||
components: {
|
components: {
|
||||||
Details: (props) => <ReplicaSetDetails {...props} />
|
Details: (props) => <ResourceQuotaDetails {...props} />
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user