Skip to content

Commit

Permalink
Image registry bug fix (#4887)
Browse files Browse the repository at this point in the history
* 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 <sridasyamaditya@gmail.com>

* 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 <sridasyamaditya@gmail.com>

* 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 <sridasyamaditya@gmail.com>

Signed-off-by: aditya3103 <85363167+aditya3103@users.noreply.github.com>

---------

Signed-off-by: Aditya Sridasyam <sridasyamaditya@gmail.com>
Signed-off-by: aditya3103 <85363167+aditya3103@users.noreply.github.com>
Co-authored-by: Saranya Jena <saranya.jena@harness.io>
  • Loading branch information
aditya3103 and Saranya-jena authored Oct 7, 2024
1 parent 101557c commit 29e7130
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
}

Expand Down
27 changes: 26 additions & 1 deletion chaoscenter/web/src/views/StudioOverview/StudioOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -52,6 +54,20 @@ export default function StudioOverviewView({

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

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;
Expand Down Expand Up @@ -85,6 +101,9 @@ export default function StudioOverviewView({
})
})}
onSubmit={values => {

values.imageRegistry = imageRegistry

if (values.chaosInfrastructure.namespace === undefined) {
delete values.chaosInfrastructure.namespace;
}
Expand Down Expand Up @@ -144,7 +163,13 @@ export default function StudioOverviewView({
text={getString('cancel')}
onClick={openDiscardDialog}
/>
<Button type="submit" intent="primary" text={getString('next')} rightIcon="chevron-right" />
<Button
type="submit"
intent="primary"
text={getString('next')}
rightIcon="chevron-right"
disabled={imageRegistryLoading}
/>
</Layout.Horizontal>
</Form>
</Layout.Vertical>
Expand Down

0 comments on commit 29e7130

Please sign in to comment.