This code was introduced as a temporary measure while we were waiting for the api from CRC to land.
This has landed now, so we could maybe try and remove this abstraction
|
export const distroDetailsApi = imageBuilderApi.injectEndpoints({ |
|
endpoints: (builder) => ({ |
|
getDistributionDetails: builder.query< |
|
DistributionDetailsCustomizationApi, |
|
DistributionDetailsCustomizationArgs |
|
>({ |
|
queryFn: ({ distro, architecture, imageType }) => { |
|
const data: DistributionDetails = { |
|
name: distro, |
|
architectures: {}, |
|
}; |
|
|
|
// we define this above, so it's not undefined |
|
const architectures = data.architectures!; |
|
for (const arch of architecture) { |
|
architectures[arch] = { |
|
name: arch, |
|
image_types: {}, |
|
}; |
|
for (const it of imageType) { |
|
// eslint complains about this always being truthy, it's not a |
|
// complete list of image types, so there is a chance it is undefined |
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition |
|
if (DISTRO_DETAILS[it]) { |
|
architectures[arch].image_types![it] = DISTRO_DETAILS[it]; |
|
} |
|
} |
|
} |
|
data.architectures = architectures; |
|
|
|
return { |
|
data, |
|
}; |
|
}, |
|
}), |
|
}), |
|
}); |
This code was introduced as a temporary measure while we were waiting for the api from CRC to land.
This has landed now, so we could maybe try and remove this abstraction
image-builder-frontend/src/store/api/distributions/distributionDetailsApi.ts
Lines 10 to 46 in ab244ca