Skip to content

DistributionDetails: Try implement the api endpoint #4448

@kingsleyzissou

Description

@kingsleyzissou

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,
};
},
}),
}),
});

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions