mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Add links for ingresses Signed-off-by: Sebastian Malton <sebastian@malton.name> * Add back the arrow service Signed-off-by: Sebastian Malton <sebastian@malton.name> * Only display link if host is defined Signed-off-by: Sebastian Malton <sebastian@malton.name> * Resolve PR comments - Fix crash in IngressDetails - Make ingress routes scrollable - Don't display link if the URL contains "*" - Consolidate rendering of rules to all use the same transform function Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix http(s) formatting and add some tests Signed-off-by: Sebastian Malton <sebastian@malton.name>
109 lines
2.3 KiB
TypeScript
109 lines
2.3 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
|
|
import { computeRuleDeclarations, Ingress } from "../endpoints";
|
|
|
|
describe("computeRuleDeclarations", () => {
|
|
it("given no tls field, should format links as http://", () => {
|
|
const ingress = new Ingress({
|
|
apiVersion: "networking.k8s.io/v1",
|
|
kind: "Ingress",
|
|
metadata: {
|
|
name: "foo",
|
|
resourceVersion: "1",
|
|
uid: "bar",
|
|
},
|
|
});
|
|
|
|
const result = computeRuleDeclarations(ingress, {
|
|
host: "foo.bar",
|
|
http: {
|
|
paths: [{
|
|
backend: {
|
|
service: {
|
|
name: "my-service",
|
|
port: {
|
|
number: 8080,
|
|
},
|
|
},
|
|
},
|
|
}],
|
|
},
|
|
});
|
|
|
|
expect(result[0].url).toBe("http://foo.bar/");
|
|
});
|
|
|
|
it("given no tls entries, should format links as http://", () => {
|
|
const ingress = new Ingress({
|
|
apiVersion: "networking.k8s.io/v1",
|
|
kind: "Ingress",
|
|
metadata: {
|
|
name: "foo",
|
|
resourceVersion: "1",
|
|
uid: "bar",
|
|
},
|
|
});
|
|
|
|
ingress.spec = {
|
|
tls: [],
|
|
};
|
|
|
|
const result = computeRuleDeclarations(ingress, {
|
|
host: "foo.bar",
|
|
http: {
|
|
paths: [{
|
|
backend: {
|
|
service: {
|
|
name: "my-service",
|
|
port: {
|
|
number: 8080,
|
|
},
|
|
},
|
|
},
|
|
}],
|
|
},
|
|
});
|
|
|
|
expect(result[0].url).toBe("http://foo.bar/");
|
|
});
|
|
|
|
it("given some tls entries, should format links as https://", () => {
|
|
const ingress = new Ingress({
|
|
apiVersion: "networking.k8s.io/v1",
|
|
kind: "Ingress",
|
|
metadata: {
|
|
name: "foo",
|
|
resourceVersion: "1",
|
|
uid: "bar",
|
|
},
|
|
});
|
|
|
|
ingress.spec = {
|
|
tls: [{
|
|
secretName: "my-secret",
|
|
}],
|
|
};
|
|
|
|
const result = computeRuleDeclarations(ingress, {
|
|
host: "foo.bar",
|
|
http: {
|
|
paths: [{
|
|
backend: {
|
|
service: {
|
|
name: "my-service",
|
|
port: {
|
|
number: 8080,
|
|
},
|
|
},
|
|
},
|
|
}],
|
|
},
|
|
});
|
|
|
|
expect(result[0].url).toBe("https://foo.bar/");
|
|
});
|
|
});
|