mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Readd space between key and value in ENV display (#6183)
Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
167f42330b
commit
4a033a49f0
@ -0,0 +1,182 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`<ContainerEnv /> renders both env and configMapRef envFrom 1`] = `
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="DrawerItem ContainerEnvironment"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="name"
|
||||||
|
>
|
||||||
|
Environment
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="value"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="variable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="var-name"
|
||||||
|
>
|
||||||
|
foobar
|
||||||
|
</span>
|
||||||
|
:
|
||||||
|
https://localhost:12345
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="variable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="var-name"
|
||||||
|
>
|
||||||
|
configFoo
|
||||||
|
</span>
|
||||||
|
:
|
||||||
|
configBar
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`<ContainerEnv /> renders env 1`] = `
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="DrawerItem ContainerEnvironment"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="name"
|
||||||
|
>
|
||||||
|
Environment
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="value"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="variable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="var-name"
|
||||||
|
>
|
||||||
|
foobar
|
||||||
|
</span>
|
||||||
|
:
|
||||||
|
https://localhost:12345
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`<ContainerEnv /> renders env 2`] = `
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="DrawerItem ContainerEnvironment"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="name"
|
||||||
|
>
|
||||||
|
Environment
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="value"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="variable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="var-name"
|
||||||
|
>
|
||||||
|
foobar
|
||||||
|
</span>
|
||||||
|
:
|
||||||
|
https://localhost:12345
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`<ContainerEnv /> renders envFrom when given a configMapRef 1`] = `
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="DrawerItem ContainerEnvironment"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="name"
|
||||||
|
>
|
||||||
|
Environment
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="value"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="variable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="var-name"
|
||||||
|
>
|
||||||
|
configFoo
|
||||||
|
</span>
|
||||||
|
:
|
||||||
|
configBar
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`<ContainerEnv /> renders envFrom when given a secretRef 1`] = `
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="DrawerItem ContainerEnvironment"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="name"
|
||||||
|
>
|
||||||
|
Environment
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="value"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="variable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="var-name"
|
||||||
|
>
|
||||||
|
bar
|
||||||
|
</span>
|
||||||
|
:
|
||||||
|
secretKeyRef(my-secret.bar)
|
||||||
|
|
||||||
|
<i
|
||||||
|
class="Icon secret-button material interactive focusable"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="icon"
|
||||||
|
data-icon-name="visibility"
|
||||||
|
>
|
||||||
|
visibility
|
||||||
|
</span>
|
||||||
|
</i>
|
||||||
|
<div>
|
||||||
|
Show
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
`;
|
||||||
@ -0,0 +1,252 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from "react";
|
||||||
|
import type { ConfigMapStore } from "../../+config-maps/store";
|
||||||
|
import configMapStoreInjectable from "../../+config-maps/store.injectable";
|
||||||
|
import type { SecretStore } from "../../+config-secrets/store";
|
||||||
|
import secretStoreInjectable from "../../+config-secrets/store.injectable";
|
||||||
|
import type { Container } from "../../../../common/k8s-api/endpoints";
|
||||||
|
import { Secret, ConfigMap, Pod, SecretType } from "../../../../common/k8s-api/endpoints";
|
||||||
|
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
|
||||||
|
import type { DiRender } from "../../test-utils/renderFor";
|
||||||
|
import { renderFor } from "../../test-utils/renderFor";
|
||||||
|
import { ContainerEnvironment } from "../pod-container-env";
|
||||||
|
|
||||||
|
describe("<ContainerEnv />", () => {
|
||||||
|
let render: DiRender;
|
||||||
|
let secretStore: jest.Mocked<Pick<SecretStore, "load" | "getByName">>;
|
||||||
|
let configMapStore: jest.Mocked<Pick<ConfigMapStore, "load" | "getByName">>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
|
|
||||||
|
secretStore = ({
|
||||||
|
load: jest.fn().mockImplementation(async () => {
|
||||||
|
return {} as Secret;
|
||||||
|
}),
|
||||||
|
getByName: jest.fn(),
|
||||||
|
});
|
||||||
|
configMapStore = ({
|
||||||
|
load: jest.fn().mockImplementation(async () => {
|
||||||
|
return {} as ConfigMap;
|
||||||
|
}),
|
||||||
|
getByName: jest.fn(),
|
||||||
|
});
|
||||||
|
|
||||||
|
di.override(secretStoreInjectable, () => secretStore as jest.Mocked<SecretStore>);
|
||||||
|
di.override(configMapStoreInjectable, () => configMapStore as jest.Mocked<ConfigMapStore>);
|
||||||
|
|
||||||
|
render = renderFor(di);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders env", () => {
|
||||||
|
const container: Container = {
|
||||||
|
image: "my-image",
|
||||||
|
name: "my-first-container",
|
||||||
|
env: [{
|
||||||
|
name: "foobar",
|
||||||
|
value: "https://localhost:12345",
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
const pod = new Pod({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Pod",
|
||||||
|
metadata: {
|
||||||
|
name: "my-pod",
|
||||||
|
namespace: "default",
|
||||||
|
resourceVersion: "1",
|
||||||
|
selfLink: "/api/v1/pods/default/my-pod",
|
||||||
|
uid: "1234",
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
containers: [container],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const result = render(<ContainerEnvironment container={container} namespace={pod.getNs()} />);
|
||||||
|
|
||||||
|
expect(result.baseElement).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders envFrom when given a configMapRef", () => {
|
||||||
|
configMapStore.getByName.mockImplementation((name, namespace) => {
|
||||||
|
expect(name).toBe("my-config-map");
|
||||||
|
expect(namespace).toBe("default");
|
||||||
|
|
||||||
|
return new ConfigMap({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "ConfigMap",
|
||||||
|
metadata: {
|
||||||
|
name: "my-config-map",
|
||||||
|
namespace: "default",
|
||||||
|
resourceVersion: "2",
|
||||||
|
selfLink: "/api/v1/configmaps/default/my-config-map",
|
||||||
|
uid: "456",
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
configFoo: "configBar",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const container: Container = {
|
||||||
|
image: "my-image",
|
||||||
|
name: "my-first-container",
|
||||||
|
envFrom: [{
|
||||||
|
configMapRef: {
|
||||||
|
name: "my-config-map",
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
const pod = new Pod({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Pod",
|
||||||
|
metadata: {
|
||||||
|
name: "my-pod",
|
||||||
|
namespace: "default",
|
||||||
|
resourceVersion: "1",
|
||||||
|
selfLink: "/api/v1/pods/default/my-pod",
|
||||||
|
uid: "1234",
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
containers: [container],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const result = render(<ContainerEnvironment container={container} namespace={pod.getNs()} />);
|
||||||
|
|
||||||
|
expect(result.baseElement).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders envFrom when given a secretRef", () => {
|
||||||
|
secretStore.getByName.mockImplementation((name, namespace) => {
|
||||||
|
expect(name).toBe("my-secret");
|
||||||
|
expect(namespace).toBe("default");
|
||||||
|
|
||||||
|
return new Secret({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Secret",
|
||||||
|
metadata: {
|
||||||
|
name: "my-secret",
|
||||||
|
namespace: "default",
|
||||||
|
resourceVersion: "3",
|
||||||
|
selfLink: "/api/v1/secrets/default/my-secret",
|
||||||
|
uid: "237",
|
||||||
|
},
|
||||||
|
type: SecretType.BasicAuth,
|
||||||
|
data: {
|
||||||
|
bar: "bat",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const container: Container = {
|
||||||
|
image: "my-image",
|
||||||
|
name: "my-first-container",
|
||||||
|
envFrom: [{
|
||||||
|
secretRef: {
|
||||||
|
name: "my-secret",
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
const pod = new Pod({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Pod",
|
||||||
|
metadata: {
|
||||||
|
name: "my-pod",
|
||||||
|
namespace: "default",
|
||||||
|
resourceVersion: "1",
|
||||||
|
selfLink: "/api/v1/pods/default/my-pod",
|
||||||
|
uid: "1234",
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
containers: [container],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const result = render(<ContainerEnvironment container={container} namespace={pod.getNs()} />);
|
||||||
|
|
||||||
|
expect(result.baseElement).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders env", () => {
|
||||||
|
const container: Container = {
|
||||||
|
image: "my-image",
|
||||||
|
name: "my-first-container",
|
||||||
|
env: [{
|
||||||
|
name: "foobar",
|
||||||
|
value: "https://localhost:12345",
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
const pod = new Pod({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Pod",
|
||||||
|
metadata: {
|
||||||
|
name: "my-pod",
|
||||||
|
namespace: "default",
|
||||||
|
resourceVersion: "1",
|
||||||
|
selfLink: "/api/v1/pods/default/my-pod",
|
||||||
|
uid: "1234",
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
containers: [container],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const result = render(<ContainerEnvironment container={container} namespace={pod.getNs()} />);
|
||||||
|
|
||||||
|
expect(result.baseElement).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders both env and configMapRef envFrom", () => {
|
||||||
|
configMapStore.getByName.mockImplementation((name, namespace) => {
|
||||||
|
expect(name).toBe("my-config-map");
|
||||||
|
expect(namespace).toBe("default");
|
||||||
|
|
||||||
|
return new ConfigMap({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "ConfigMap",
|
||||||
|
metadata: {
|
||||||
|
name: "my-config-map",
|
||||||
|
namespace: "default",
|
||||||
|
resourceVersion: "2",
|
||||||
|
selfLink: "/api/v1/configmaps/default/my-config-map",
|
||||||
|
uid: "456",
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
configFoo: "configBar",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const container: Container = {
|
||||||
|
image: "my-image",
|
||||||
|
name: "my-first-container",
|
||||||
|
envFrom: [{
|
||||||
|
configMapRef: {
|
||||||
|
name: "my-config-map",
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
env: [{
|
||||||
|
name: "foobar",
|
||||||
|
value: "https://localhost:12345",
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
const pod = new Pod({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Pod",
|
||||||
|
metadata: {
|
||||||
|
name: "my-pod",
|
||||||
|
namespace: "default",
|
||||||
|
resourceVersion: "1",
|
||||||
|
selfLink: "/api/v1/pods/default/my-pod",
|
||||||
|
uid: "1234",
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
containers: [container],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const result = render(<ContainerEnvironment container={container} namespace={pod.getNs()} />);
|
||||||
|
|
||||||
|
expect(result.baseElement).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -83,16 +83,16 @@ const NonInjectedContainerEnvironment = observer((props: Dependencies & Containe
|
|||||||
const { name, key } = configMapKeyRef;
|
const { name, key } = configMapKeyRef;
|
||||||
const configMap = configMapStore.getByName(name, namespace);
|
const configMap = configMapStore.getByName(name, namespace);
|
||||||
|
|
||||||
secretValue = configMap ?
|
secretValue = configMap
|
||||||
configMap.data[key] :
|
? configMap.data[key]
|
||||||
`configMapKeyRef(${name}${key})`;
|
: `configMapKeyRef(${name}${key})`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="variable" key={name}>
|
<div className="variable" key={name}>
|
||||||
<span className="var-name">{name}</span>
|
<span className="var-name">{name}</span>
|
||||||
:
|
{` : `}
|
||||||
{secretValue}
|
{secretValue}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -126,7 +126,7 @@ const NonInjectedContainerEnvironment = observer((props: Dependencies & Containe
|
|||||||
{prefix}
|
{prefix}
|
||||||
{name}
|
{name}
|
||||||
</span>
|
</span>
|
||||||
:
|
{` : `}
|
||||||
{value}
|
{value}
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
@ -144,14 +144,15 @@ const NonInjectedContainerEnvironment = observer((props: Dependencies & Containe
|
|||||||
{prefix}
|
{prefix}
|
||||||
{key}
|
{key}
|
||||||
</span>
|
</span>
|
||||||
:
|
{` : `}
|
||||||
<SecretKey
|
<SecretKey
|
||||||
reference={{
|
reference={{
|
||||||
name: secret.getName(),
|
name: secret.getName(),
|
||||||
key,
|
key,
|
||||||
}}
|
}}
|
||||||
namespace={namespace}
|
namespace={namespace}
|
||||||
secretStore={secretStore} />
|
secretStore={secretStore}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user