From 29e7130f4e3cbcaefe3394320eee3be1b0fe627b Mon Sep 17 00:00:00 2001 From: aditya3103 <85363167+aditya3103@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:28:13 +0530 Subject: [PATCH] Image registry bug fix (#4887) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: fetch image registry data correctly in StudioOverviewView Fixes an issue where the image registry data was not being fetched Why: Previously, the image registry data was not being fetched, even though ExperimentMetadata has a field ‘imageRegistry’. This change ensures that the form receives the correct image registry data. How: Added a check for loading state by disabling the ‘next’ button and assigned the fetched image registry data to a variable before form submission. This ensures the `values.imageRegistry` field is populated correctly. Signed-off-by: Aditya Sridasyam * fix: passed imageRegistry in kubernetesBlankCanvasTemplate Fixes an issue where the image registry data was not being passed in the kubernetesBlankCanvasTemplate function Why: kubernetesBlankCanvasTemplate is expecting imageRegistry but never being passed, it is overridden always by default imageRegistry values. Signed-off-by: Aditya Sridasyam * Rectified import order imported @utils before `./StudioOverview.module.scss`, rectified as per the frontend check pipeline error Signed-off-by: aditya3103 <85363167+aditya3103@users.noreply.github.com> * Fixed max character limit warning - kubernetesBlankCanvasTemplate function Signed-off-by: aditya3103 <85363167+aditya3103@users.noreply.github.com> * Fixed max character limit & trailing comma warning Signed-off-by: aditya3103 <85363167+aditya3103@users.noreply.github.com> * Fixed trailing comma warning - kubernetesBlankCanvasTemplate Signed-off-by: Aditya Sridasyam Signed-off-by: aditya3103 <85363167+aditya3103@users.noreply.github.com> --------- Signed-off-by: Aditya Sridasyam Signed-off-by: aditya3103 <85363167+aditya3103@users.noreply.github.com> Co-authored-by: Saranya Jena --- .../blankCanvasTemplate.ts | 7 ++++- .../views/StudioOverview/StudioOverview.tsx | 27 ++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/chaoscenter/web/src/views/ExperimentBuilderTemplateSelection/blankCanvasTemplate.ts b/chaoscenter/web/src/views/ExperimentBuilderTemplateSelection/blankCanvasTemplate.ts index 6f13e4a8e61..1474014dcc2 100644 --- a/chaoscenter/web/src/views/ExperimentBuilderTemplateSelection/blankCanvasTemplate.ts +++ b/chaoscenter/web/src/views/ExperimentBuilderTemplateSelection/blankCanvasTemplate.ts @@ -10,7 +10,12 @@ export default function blankCanvasTemplate( switch (infrastructureType) { case InfrastructureType.KUBERNETES: - return kubernetesBlankCanvasTemplate(experimentName, experiment?.chaosInfrastructure?.namespace); + return kubernetesBlankCanvasTemplate( + experimentName, + experiment?.chaosInfrastructure?.namespace, + undefined, + experiment?.imageRegistry, + ); } } diff --git a/chaoscenter/web/src/views/StudioOverview/StudioOverview.tsx b/chaoscenter/web/src/views/StudioOverview/StudioOverview.tsx index 89f8207357d..ac0b9ac926c 100644 --- a/chaoscenter/web/src/views/StudioOverview/StudioOverview.tsx +++ b/chaoscenter/web/src/views/StudioOverview/StudioOverview.tsx @@ -23,6 +23,8 @@ import { ChaosInfrastructureReferenceFieldProps, StudioErrorState, StudioTabs } import experimentYamlService from 'services/experiment'; import KubernetesChaosInfrastructureReferenceFieldController from '@controllers/KubernetesChaosInfrastructureReferenceField'; import { InfrastructureType } from '@api/entities'; +import { getImageRegistry } from '@api/core/ImageRegistry'; +import { getScope } from '@utils'; import css from './StudioOverview.module.scss'; interface StudioOverviewViewProps { @@ -52,6 +54,20 @@ export default function StudioOverviewView({ const [currentExperiment, setCurrentExperiment] = React.useState(); + const scope = getScope(); + + // Fetch the image registry data using Apollo's useQuery hook + const { data: getImageRegistryData, loading: imageRegistryLoading } = getImageRegistry({ + projectID: scope.projectID, + }); + + const imageRegistry = getImageRegistryData?.getImageRegistry?{ + name: getImageRegistryData.getImageRegistry.imageRegistryInfo.imageRegistryName, + repo: getImageRegistryData.getImageRegistry.imageRegistryInfo.imageRepoName, + secret: getImageRegistryData.getImageRegistry.imageRegistryInfo.secretName, + } + : undefined; + React.useEffect(() => { experimentHandler?.getExperiment(experimentKey).then(experiment => { delete experiment?.manifest; @@ -85,6 +101,9 @@ export default function StudioOverviewView({ }) })} onSubmit={values => { + + values.imageRegistry = imageRegistry + if (values.chaosInfrastructure.namespace === undefined) { delete values.chaosInfrastructure.namespace; } @@ -144,7 +163,13 @@ export default function StudioOverviewView({ text={getString('cancel')} onClick={openDiscardDialog} /> -