1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix StatefulSet.getImages to handle null case

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-08-17 12:05:16 -04:00
parent b71e489868
commit 9cae810634

View File

@ -19,12 +19,11 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import get from "lodash/get";
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
import { autoBind } from "../../utils";
import { KubeApi } from "../kube-api";
import { metricsApi } from "./metrics.api";
import type { IPodContainer, IPodMetrics } from "./pods.api";
import type { IPodMetrics } from "./pods.api";
import type { KubeJsonApiData } from "../kube-json-api";
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
@ -91,7 +90,7 @@ export class StatefulSet extends WorkloadKubeObject {
};
};
spec: {
containers: {
containers: null | {
name: string;
image: string;
ports: {
@ -144,9 +143,9 @@ export class StatefulSet extends WorkloadKubeObject {
}
getImages() {
const containers: IPodContainer[] = get(this, "spec.template.spec.containers", []);
const containers = this.spec.template?.spec?.containers ?? [];
return [...containers].map(container => container.image);
return containers.map(container => container.image);
}
}