Skip to content

Commit 29e7130

Browse files
Image registry bug fix (#4887)
* 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 <[email protected]> * 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 <[email protected]> * Rectified import order imported @utils before `./StudioOverview.module.scss`, rectified as per the frontend check pipeline error Signed-off-by: aditya3103 <[email protected]> * Fixed max character limit warning - kubernetesBlankCanvasTemplate function Signed-off-by: aditya3103 <[email protected]> * Fixed max character limit & trailing comma warning Signed-off-by: aditya3103 <[email protected]> * Fixed trailing comma warning - kubernetesBlankCanvasTemplate Signed-off-by: Aditya Sridasyam <[email protected]> Signed-off-by: aditya3103 <[email protected]> --------- Signed-off-by: Aditya Sridasyam <[email protected]> Signed-off-by: aditya3103 <[email protected]> Co-authored-by: Saranya Jena <[email protected]>
1 parent 101557c commit 29e7130

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

chaoscenter/web/src/views/ExperimentBuilderTemplateSelection/blankCanvasTemplate.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ export default function blankCanvasTemplate(
1010

1111
switch (infrastructureType) {
1212
case InfrastructureType.KUBERNETES:
13-
return kubernetesBlankCanvasTemplate(experimentName, experiment?.chaosInfrastructure?.namespace);
13+
return kubernetesBlankCanvasTemplate(
14+
experimentName,
15+
experiment?.chaosInfrastructure?.namespace,
16+
undefined,
17+
experiment?.imageRegistry,
18+
);
1419
}
1520
}
1621

chaoscenter/web/src/views/StudioOverview/StudioOverview.tsx

+26-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { ChaosInfrastructureReferenceFieldProps, StudioErrorState, StudioTabs }
2323
import experimentYamlService from 'services/experiment';
2424
import KubernetesChaosInfrastructureReferenceFieldController from '@controllers/KubernetesChaosInfrastructureReferenceField';
2525
import { InfrastructureType } from '@api/entities';
26+
import { getImageRegistry } from '@api/core/ImageRegistry';
27+
import { getScope } from '@utils';
2628
import css from './StudioOverview.module.scss';
2729

2830
interface StudioOverviewViewProps {
@@ -52,6 +54,20 @@ export default function StudioOverviewView({
5254

5355
const [currentExperiment, setCurrentExperiment] = React.useState<ExperimentMetadata | undefined>();
5456

57+
const scope = getScope();
58+
59+
// Fetch the image registry data using Apollo's useQuery hook
60+
const { data: getImageRegistryData, loading: imageRegistryLoading } = getImageRegistry({
61+
projectID: scope.projectID,
62+
});
63+
64+
const imageRegistry = getImageRegistryData?.getImageRegistry?{
65+
name: getImageRegistryData.getImageRegistry.imageRegistryInfo.imageRegistryName,
66+
repo: getImageRegistryData.getImageRegistry.imageRegistryInfo.imageRepoName,
67+
secret: getImageRegistryData.getImageRegistry.imageRegistryInfo.secretName,
68+
}
69+
: undefined;
70+
5571
React.useEffect(() => {
5672
experimentHandler?.getExperiment(experimentKey).then(experiment => {
5773
delete experiment?.manifest;
@@ -85,6 +101,9 @@ export default function StudioOverviewView({
85101
})
86102
})}
87103
onSubmit={values => {
104+
105+
values.imageRegistry = imageRegistry
106+
88107
if (values.chaosInfrastructure.namespace === undefined) {
89108
delete values.chaosInfrastructure.namespace;
90109
}
@@ -144,7 +163,13 @@ export default function StudioOverviewView({
144163
text={getString('cancel')}
145164
onClick={openDiscardDialog}
146165
/>
147-
<Button type="submit" intent="primary" text={getString('next')} rightIcon="chevron-right" />
166+
<Button
167+
type="submit"
168+
intent="primary"
169+
text={getString('next')}
170+
rightIcon="chevron-right"
171+
disabled={imageRegistryLoading}
172+
/>
148173
</Layout.Horizontal>
149174
</Form>
150175
</Layout.Vertical>

0 commit comments

Comments
 (0)