diff --git a/packages/renderer/src/lib/kube/KubePlayYAML.svelte b/packages/renderer/src/lib/kube/KubePlayYAML.svelte index 3ead75708a764..be6ba4600b374 100644 --- a/packages/renderer/src/lib/kube/KubePlayYAML.svelte +++ b/packages/renderer/src/lib/kube/KubePlayYAML.svelte @@ -10,13 +10,16 @@ import NoContainerEngineEmptyScreen from '../image/NoContainerEngineEmptyScreen. import NavPage from '../ui/NavPage.svelte'; import KubePlayIcon from '../kube/KubePlayIcon.svelte'; import ErrorMessage from '../ui/ErrorMessage.svelte'; +import WarningMessage from '../ui/WarningMessage.svelte'; import type { V1NamespaceList } from '@kubernetes/client-node/dist/api'; import { faCircleCheck } from '@fortawesome/free-solid-svg-icons'; import Fa from 'svelte-fa/src/fa.svelte'; +import * as jsYaml from 'js-yaml'; let runStarted = false; let runFinished = false; let runError = ''; +let runWarning = ''; let kubernetesYamlFilePath = undefined; let hasInvalidFields = true; @@ -25,6 +28,7 @@ let currentNamespace: string; let allNamespaces: V1NamespaceList; let playKubeResultRaw; +let playKubeResultJSON; let userChoice: 'podman' | 'kubernetes' = 'podman'; @@ -57,8 +61,24 @@ async function playKubeFile(): Promise { if (userChoice === 'podman') { try { const result = await window.playKube(kubernetesYamlFilePath, selectedProvider); + // remove the null values from the result playKubeResultRaw = JSON.stringify(removeEmptyOrNull(result), null, 2); + playKubeResultJSON = JSON.parse(playKubeResultRaw); + + // If there are container errors, that means that it was *able* to create the container + // but if failed to start. We will add this to the "warning" section as we were able to create the + // We add this with comma deliminated errors + if (playKubeResultJSON.Pods.length > 0) { + const containerErrors = playKubeResultJSON.Pods.filter(pod => pod.ContainerErrors.length > 0); + // For each Pod that has container errors, we will add the container errors to the warning message + if (containerErrors.length > 0) { + runWarning = `The following pods were created but failed to start: ${containerErrors + .map(pod => pod.ContainerErrors.join(', ')) + .join(', ')}`; + } + } + runFinished = true; } catch (error) { runError = error; @@ -107,6 +127,10 @@ onDestroy(() => { } }); +function goBackToHistory(): void { + window.history.go(-1); +} + async function getKubernetesfileLocation() { const result = await window.openFileDialog('Select a .yaml file to play', { name: 'YAML files', @@ -274,17 +298,38 @@ async function getKubernetesfileLocation() { complete... {/if} -
+ + {#if runWarning} + + {/if} + + {#if runError} + + {/if} + + {#if playKubeResultJSON} + +
+
+
+ {#if playKubeResultJSON?.Pods.length > 1} + Created pods: + {:else} + Created pod: + {/if} +
+
+ +
+ +
+
+ {/if} + {#if runFinished} - - + {/if} - {#if playKubeResultRaw} -
- -
- {/if} {/if}