Skip to content

Commit c30b6ea

Browse files
committed
api: Connect customization validation to CRC
1 parent cafe850 commit c30b6ea

15 files changed

Lines changed: 223 additions & 406 deletions

File tree

api/config/imageBuilder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const config: ConfigFile = {
2727
'deleteBlueprint',
2828
'getBlueprint',
2929
'getDistributions',
30+
'getDistribution',
3031
'recommendPackage',
3132
'fixupBlueprint',
3233
],

src/store/api/backend/hosted/imageBuilderApi.ts

Lines changed: 153 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ const injectedRtkApi = api.injectEndpoints({
1515
},
1616
}),
1717
}),
18+
getDistribution: build.query<
19+
GetDistributionApiResponse,
20+
GetDistributionApiArg
21+
>({
22+
query: (queryArg) => ({
23+
url: `/distributions/${queryArg.distro}`,
24+
params: {
25+
image_type: queryArg.imageType,
26+
architecture: queryArg.architecture,
27+
},
28+
}),
29+
}),
1830
getArchitectures: build.query<
1931
GetArchitecturesApiResponse,
2032
GetArchitecturesApiArg
@@ -199,6 +211,16 @@ export type GetDistributionsApiArg = {
199211
*/
200212
type?: string;
201213
};
214+
export type GetDistributionApiResponse =
215+
/** status 200 Distribution details */ DistributionDetails;
216+
export type GetDistributionApiArg = {
217+
/** Name of the distribution */
218+
distro: string;
219+
/** Filter by image type. Multiple values can be specified. */
220+
imageType?: string[];
221+
/** Filter by architecture. Multiple values can be specified. */
222+
architecture?: string[];
223+
};
202224
export type GetArchitecturesApiResponse =
203225
/** status 200 a list of available architectures and their associated image types */ Architectures;
204226
export type GetArchitecturesApiArg = {
@@ -369,6 +391,135 @@ export type DistributionsResponse = (
369391
| BootcDistributionItem
370392
)[];
371393
export type DistributionKind = "bootc";
394+
export type PartitionType = "gpt" | "dos";
395+
export type Minsize = string;
396+
export type FilesystemTyped = {
397+
type?: "plain" | undefined;
398+
/** The partition type GUID for GPT partitions. For DOS partitions, this field can be used to set the (2 hex digit) partition type. If not set, the type will be automatically set based on the mountpoint or the payload type.
399+
*/
400+
part_type?: string | undefined;
401+
minsize?: Minsize | undefined;
402+
mountpoint?: string | undefined;
403+
label?: string | undefined;
404+
/** The filesystem type. Swap partitions must have an empty mountpoint.
405+
*/
406+
fs_type: "ext4" | "xfs" | "vfat" | "swap";
407+
};
408+
export type BtrfsSubvolume = {
409+
/** The name of the subvolume, which defines the location (path) on the root volume
410+
*/
411+
name: string;
412+
/** Mountpoint for the subvolume
413+
*/
414+
mountpoint: string;
415+
};
416+
export type BtrfsVolume = {
417+
type: "btrfs";
418+
/** The partition type GUID for GPT partitions. For DOS partitions, this field can be used to set the (2 hex digit) partition type. If not set, the type will be automatically set based on the mountpoint or the payload type.
419+
*/
420+
part_type?: string | undefined;
421+
minsize?: Minsize | undefined;
422+
subvolumes: BtrfsSubvolume[];
423+
};
424+
export type LogicalVolume = {
425+
name?: string | undefined;
426+
minsize?: Minsize | undefined;
427+
/** Mountpoint for the logical volume
428+
*/
429+
mountpoint?: string | undefined;
430+
label?: string | undefined;
431+
/** The filesystem type for the logical volume. Swap LVs must have an empty mountpoint.
432+
*/
433+
fs_type: "ext4" | "xfs" | "vfat" | "swap";
434+
};
435+
export type VolumeGroup = {
436+
type: "lvm";
437+
/** The partition type GUID for GPT partitions. For DOS partitions, this field can be used to set the (2 hex digit) partition type. If not set, the type will be automatically set based on the mountpoint or the payload type.
438+
*/
439+
part_type?: string | undefined;
440+
/** Volume group name (will be automatically generated if omitted)
441+
*/
442+
name?: string | undefined;
443+
minsize?: Minsize | undefined;
444+
logical_volumes: LogicalVolume[];
445+
};
446+
export type Partition = FilesystemTyped | BtrfsVolume | VolumeGroup;
447+
export type Disk = {
448+
/** Type of the partition table
449+
*/
450+
type?: ("gpt" | "dos") | undefined;
451+
minsize?: Minsize | undefined;
452+
partitions: Partition[];
453+
};
454+
export type BootMode = "legacy" | "uefi" | "hybrid" | "none";
455+
export type ImageTypeInfo = {
456+
/** Image type name */
457+
name: string;
458+
/** Alternative names for this image type */
459+
aliases?: string[] | undefined;
460+
/** Canonical filename for the image */
461+
filename?: string | undefined;
462+
/** MIME type of the image */
463+
mime_type?: string | undefined;
464+
/** Default OSTree ref for this image type */
465+
ostree_ref?: string | undefined;
466+
/** ISO label (only for ISO image types) */
467+
iso_label?: string | undefined;
468+
/** Default image size in bytes */
469+
default_size?: number | undefined;
470+
/** Partition table type */
471+
partition_type?: PartitionType | undefined;
472+
base_partition_table?: Disk | undefined;
473+
/** Boot mode for the image */
474+
boot_mode?: BootMode | undefined;
475+
/** Package set names safe for custom packages via custom repos */
476+
payload_package_sets?: string[] | undefined;
477+
/** Names of stages that produce the build output */
478+
exports?: string[] | undefined;
479+
/** Customization options required by this image type */
480+
required_blueprint_options?: string[] | undefined;
481+
/** Customization options supported by this image type */
482+
supported_blueprint_options?: string[] | undefined;
483+
};
484+
export type ArchitectureInfo = {
485+
/** Architecture name */
486+
name: string;
487+
/** Map of image type names to their details */
488+
image_types?:
489+
| {
490+
[key: string]: ImageTypeInfo;
491+
}
492+
| undefined;
493+
};
494+
export type DistributionDetails = {
495+
/** Name of the distribution */
496+
name: string;
497+
/** Codename of the distribution */
498+
codename?: string | undefined;
499+
/** Release version used in repo files */
500+
releasever?: string | undefined;
501+
/** Full OS version including minor version */
502+
os_version?: string | undefined;
503+
/** Module platform ID for DNF modularity */
504+
module_platform_id?: string | undefined;
505+
/** Product name */
506+
product?: string | undefined;
507+
/** Default OSTree reference template */
508+
ostree_ref?: string | undefined;
509+
/** Map of architecture names to their details */
510+
architectures?:
511+
| {
512+
[key: string]: ArchitectureInfo;
513+
}
514+
| undefined;
515+
};
516+
export type HttpError = {
517+
title: string;
518+
detail: string;
519+
};
520+
export type HttpErrorList = {
521+
errors: HttpError[];
522+
};
372523
export type Repository = {
373524
/** An ID referring to a repository defined in content sources can be used instead of
374525
'baseurl', 'mirrorlist' or 'metalink'.
@@ -393,13 +544,6 @@ export type ArchitectureItem = {
393544
repositories: Repository[];
394545
};
395546
export type Architectures = ArchitectureItem[];
396-
export type HttpError = {
397-
title: string;
398-
detail: string;
399-
};
400-
export type HttpErrorList = {
401-
errors: HttpError[];
402-
};
403547
export type Distributions =
404548
| "rhel-8"
405549
| "rhel-8-nightly"
@@ -697,65 +841,6 @@ export type Filesystem = {
697841
/** size of the filesystem in bytes */
698842
min_size: any;
699843
};
700-
export type Minsize = string;
701-
export type FilesystemTyped = {
702-
type?: "plain" | undefined;
703-
/** The partition type GUID for GPT partitions. For DOS partitions, this field can be used to set the (2 hex digit) partition type. If not set, the type will be automatically set based on the mountpoint or the payload type.
704-
*/
705-
part_type?: string | undefined;
706-
minsize?: Minsize | undefined;
707-
mountpoint?: string | undefined;
708-
label?: string | undefined;
709-
/** The filesystem type. Swap partitions must have an empty mountpoint.
710-
*/
711-
fs_type: "ext4" | "xfs" | "vfat" | "swap";
712-
};
713-
export type BtrfsSubvolume = {
714-
/** The name of the subvolume, which defines the location (path) on the root volume
715-
*/
716-
name: string;
717-
/** Mountpoint for the subvolume
718-
*/
719-
mountpoint: string;
720-
};
721-
export type BtrfsVolume = {
722-
type: "btrfs";
723-
/** The partition type GUID for GPT partitions. For DOS partitions, this field can be used to set the (2 hex digit) partition type. If not set, the type will be automatically set based on the mountpoint or the payload type.
724-
*/
725-
part_type?: string | undefined;
726-
minsize?: Minsize | undefined;
727-
subvolumes: BtrfsSubvolume[];
728-
};
729-
export type LogicalVolume = {
730-
name?: string | undefined;
731-
minsize?: Minsize | undefined;
732-
/** Mountpoint for the logical volume
733-
*/
734-
mountpoint?: string | undefined;
735-
label?: string | undefined;
736-
/** The filesystem type for the logical volume. Swap LVs must have an empty mountpoint.
737-
*/
738-
fs_type: "ext4" | "xfs" | "vfat" | "swap";
739-
};
740-
export type VolumeGroup = {
741-
type: "lvm";
742-
/** The partition type GUID for GPT partitions. For DOS partitions, this field can be used to set the (2 hex digit) partition type. If not set, the type will be automatically set based on the mountpoint or the payload type.
743-
*/
744-
part_type?: string | undefined;
745-
/** Volume group name (will be automatically generated if omitted)
746-
*/
747-
name?: string | undefined;
748-
minsize?: Minsize | undefined;
749-
logical_volumes: LogicalVolume[];
750-
};
751-
export type Partition = FilesystemTyped | BtrfsVolume | VolumeGroup;
752-
export type Disk = {
753-
/** Type of the partition table
754-
*/
755-
type?: ("gpt" | "dos") | undefined;
756-
minsize?: Minsize | undefined;
757-
partitions: Partition[];
758-
};
759844
export type User = {
760845
name: string;
761846
/** List of groups to add the user to. The 'wheel' group should be added explicitly, as the
@@ -1080,6 +1165,8 @@ export type RecommendPackageRequest = {
10801165
export const {
10811166
useGetDistributionsQuery,
10821167
useLazyGetDistributionsQuery,
1168+
useGetDistributionQuery,
1169+
useLazyGetDistributionQuery,
10831170
useGetArchitecturesQuery,
10841171
useLazyGetArchitecturesQuery,
10851172
useGetBlueprintsQuery,

src/store/api/backend/hosted/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export {
1111
useGetBlueprintQuery,
1212
useGetBlueprintsQuery,
1313
useGetDistributionsQuery,
14+
useGetDistributionQuery,
1415
useGetComposesQuery,
1516
useGetComposeStatusQuery,
1617
useGetOscapCustomizationsForPolicyQuery,

src/store/api/backend/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ export const useGetComposeStatusQuery = process.env.IS_ON_PREMISE
7575
? composerQueries.useGetComposeStatusQuery
7676
: serviceQueries.useGetComposeStatusQuery;
7777

78+
export const useGetDistributionQuery = (
79+
process.env.IS_ON_PREMISE
80+
? composerQueries.useGetDistributionQuery
81+
: serviceQueries.useGetDistributionQuery
82+
) as typeof serviceQueries.useGetDistributionQuery;
83+
7884
export const useBackendPrefetch = process.env.IS_ON_PREMISE
7985
? composerApi.usePrefetch
8086
: imageBuilderApi.usePrefetch;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { OnPremBuilder, onPremQueryHandler } from '@/store/api/shared';
2+
3+
import {
4+
GetDistributionApiArg,
5+
GetDistributionApiResponse,
6+
} from '../../hosted';
7+
8+
export const distributionEndpoints = (builder: OnPremBuilder) => ({
9+
getDistribution: builder.query<
10+
GetDistributionApiResponse,
11+
GetDistributionApiArg
12+
>({
13+
queryFn: onPremQueryHandler(async ({ queryArgs, baseQuery }) => {
14+
const params: Record<string, string[]> = {};
15+
if (queryArgs.imageType) {
16+
params['image_type'] = queryArgs.imageType;
17+
}
18+
if (queryArgs.architecture) {
19+
params['architecture'] = queryArgs.architecture;
20+
}
21+
22+
const result = await baseQuery({
23+
url: `/distributions/${queryArgs.distro}`,
24+
method: 'GET',
25+
params,
26+
});
27+
28+
if (result.error) {
29+
throw result.error;
30+
}
31+
32+
return result.data as GetDistributionApiResponse;
33+
}),
34+
}),
35+
});

src/store/api/backend/onprem/composerApi/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { architectureEndpoints } from './architecture';
22
import { blueprintEndpoints } from './blueprints';
33
import { composeEndpoints } from './composes';
4+
import { distributionEndpoints } from './distribution';
45
import { oscapEndpoints } from './oscap';
56
import { podmanEndpoints } from './podman';
67
import { workerEndpoints } from './worker';
@@ -13,6 +14,7 @@ export const composerApi = emptyComposerApi.injectEndpoints({
1314
...architectureEndpoints(builder),
1415
...blueprintEndpoints(builder),
1516
...composeEndpoints(builder),
17+
...distributionEndpoints(builder),
1618
...oscapEndpoints(builder),
1719
...workerEndpoints(builder),
1820
...podmanEndpoints(builder),
@@ -34,6 +36,7 @@ export const {
3436
useDeleteBlueprintMutation,
3537
useExportBlueprintCockpitQuery,
3638
useLazyExportBlueprintCockpitQuery,
39+
useGetDistributionQuery,
3740
useGetOscapProfilesQuery,
3841
useGetOscapCustomizationsQuery,
3942
useLazyGetOscapCustomizationsQuery,

0 commit comments

Comments
 (0)