From 5988c42b6f7a7b7482932c986c3470f593fda8e4 Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Fri, 10 Jan 2025 12:43:20 +0000 Subject: [PATCH] store/cockpitApi: getArchitectures endpoint We were making a call to a dead endpoint to get the architectures. Instead, create a custom query function to return the list of architectures and image types. --- .../steps/ImageOutput/TargetEnvironment.tsx | 6 ++-- .../steps/Packages/Packages.tsx | 6 ++-- src/store/backendApi.ts | 6 ++++ src/store/cockpitApi.ts | 33 +++++++++++++++++-- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/Components/CreateImageWizard/steps/ImageOutput/TargetEnvironment.tsx b/src/Components/CreateImageWizard/steps/ImageOutput/TargetEnvironment.tsx index ede934d9..48115963 100644 --- a/src/Components/CreateImageWizard/steps/ImageOutput/TargetEnvironment.tsx +++ b/src/Components/CreateImageWizard/steps/ImageOutput/TargetEnvironment.tsx @@ -13,11 +13,9 @@ import { } from '@patternfly/react-core'; import { HelpIcon } from '@patternfly/react-icons'; +import { useGetArchitecturesQuery } from '../../../../store/backendApi'; import { useAppSelector, useAppDispatch } from '../../../../store/hooks'; -import { - ImageTypes, - useGetArchitecturesQuery, -} from '../../../../store/imageBuilderApi'; +import { ImageTypes } from '../../../../store/imageBuilderApi'; import { provisioningApi } from '../../../../store/provisioningApi'; import { rhsmApi } from '../../../../store/rhsmApi'; import { diff --git a/src/Components/CreateImageWizard/steps/Packages/Packages.tsx b/src/Components/CreateImageWizard/steps/Packages/Packages.tsx index c662e45c..52eeefb9 100644 --- a/src/Components/CreateImageWizard/steps/Packages/Packages.tsx +++ b/src/Components/CreateImageWizard/steps/Packages/Packages.tsx @@ -49,6 +49,7 @@ import { EPEL_9_REPO_DEFINITION, RH_ICON_SIZE, } from '../../../../constants'; +import { useGetArchitecturesQuery } from '../../../../store/backendApi'; import { ApiRepositoryResponseRead, useCreateRepositoryMutation, @@ -57,10 +58,7 @@ import { useSearchPackageGroupMutation, } from '../../../../store/contentSourcesApi'; import { useAppSelector } from '../../../../store/hooks'; -import { - Package, - useGetArchitecturesQuery, -} from '../../../../store/imageBuilderApi'; +import { Package } from '../../../../store/imageBuilderApi'; import { selectArchitecture, selectPackages, diff --git a/src/store/backendApi.ts b/src/store/backendApi.ts index 1a156415..733801d9 100644 --- a/src/store/backendApi.ts +++ b/src/store/backendApi.ts @@ -1,14 +1,20 @@ import { + useGetArchitecturesQuery as useCockpitGetArchitecturesQuery, useGetBlueprintsQuery as useCockpitGetBlueprintsQuery, useDeleteBlueprintMutation as useCockpitDeleteMutation, } from './cockpitApi'; import { cockpitApi } from './enhancedCockpitApi'; import { imageBuilderApi } from './enhancedImageBuilderApi'; import { + useGetArchitecturesQuery as useImageBuilderGetArchitecturesQuery, useGetBlueprintsQuery as useImageBuilderGetBlueprintsQuery, useDeleteBlueprintMutation as useImageBuilderDeleteMutation, } from './imageBuilderApi'; +export const useGetArchitecturesQuery = process.env.IS_ON_PREMISE + ? useCockpitGetArchitecturesQuery + : useImageBuilderGetArchitecturesQuery; + export const useGetBlueprintsQuery = process.env.IS_ON_PREMISE ? useCockpitGetBlueprintsQuery : useImageBuilderGetBlueprintsQuery; diff --git a/src/store/cockpitApi.ts b/src/store/cockpitApi.ts index 9e5f6d5d..661f20ca 100644 --- a/src/store/cockpitApi.ts +++ b/src/store/cockpitApi.ts @@ -39,9 +39,36 @@ export const cockpitApi = emptyCockpitApi.injectEndpoints({ GetArchitecturesApiResponse, GetArchitecturesApiArg >({ - query: (queryArg) => ({ - url: `/architectures/${queryArg.distribution}`, - }), + queryFn: () => { + // TODO: this is hardcoded for now, but we may need to query + // the cloudapi endpoint on the composer socket to get the + // available information + return { + data: [ + { + arch: 'aarch64', + image_types: ['aws', 'guest-image', 'image-installer'], + repositories: [], + }, + { + arch: 'x86_64', + image_types: [ + 'aws', + 'gcp', + 'azure', + 'rhel-edge-commit', + 'rhel-edge-installer', + 'edge-commit', + 'edge-installer', + 'guest-image', + 'image-installer', + 'vsphere', + ], + repositories: [], + }, + ], + }; + }, }), getBlueprints: builder.query< GetBlueprintsApiResponse,