Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/config/imageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const config: ConfigFile = {
'deleteBlueprint',
'getBlueprint',
'getDistributions',
'getDistribution',
'recommendPackage',
'fixupBlueprint',
],
Expand Down
219 changes: 153 additions & 66 deletions src/store/api/backend/hosted/imageBuilderApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ const injectedRtkApi = api.injectEndpoints({
},
}),
}),
getDistribution: build.query<
GetDistributionApiResponse,
GetDistributionApiArg
>({
query: (queryArg) => ({
url: `/distributions/${queryArg.distro}`,
params: {
image_type: queryArg.imageType,
architecture: queryArg.architecture,
},
}),
}),
getArchitectures: build.query<
GetArchitecturesApiResponse,
GetArchitecturesApiArg
Expand Down Expand Up @@ -199,6 +211,16 @@ export type GetDistributionsApiArg = {
*/
type?: string;
};
export type GetDistributionApiResponse =
/** status 200 Distribution details */ DistributionDetails;
export type GetDistributionApiArg = {
/** Name of the distribution */
distro: string;
/** Filter by image type. Multiple values can be specified. */
imageType?: string[];
/** Filter by architecture. Multiple values can be specified. */
architecture?: string[];
};
export type GetArchitecturesApiResponse =
/** status 200 a list of available architectures and their associated image types */ Architectures;
export type GetArchitecturesApiArg = {
Expand Down Expand Up @@ -369,6 +391,135 @@ export type DistributionsResponse = (
| BootcDistributionItem
)[];
export type DistributionKind = "bootc";
export type PartitionType = "gpt" | "dos";
export type Minsize = string;
export type FilesystemTyped = {
type?: "plain" | undefined;
/** 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.
*/
part_type?: string | undefined;
minsize?: Minsize | undefined;
mountpoint?: string | undefined;
label?: string | undefined;
/** The filesystem type. Swap partitions must have an empty mountpoint.
*/
fs_type: "ext4" | "xfs" | "vfat" | "swap";
};
export type BtrfsSubvolume = {
/** The name of the subvolume, which defines the location (path) on the root volume
*/
name: string;
/** Mountpoint for the subvolume
*/
mountpoint: string;
};
export type BtrfsVolume = {
type: "btrfs";
/** 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.
*/
part_type?: string | undefined;
minsize?: Minsize | undefined;
subvolumes: BtrfsSubvolume[];
};
export type LogicalVolume = {
name?: string | undefined;
minsize?: Minsize | undefined;
/** Mountpoint for the logical volume
*/
mountpoint?: string | undefined;
label?: string | undefined;
/** The filesystem type for the logical volume. Swap LVs must have an empty mountpoint.
*/
fs_type: "ext4" | "xfs" | "vfat" | "swap";
};
export type VolumeGroup = {
type: "lvm";
/** 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.
*/
part_type?: string | undefined;
/** Volume group name (will be automatically generated if omitted)
*/
name?: string | undefined;
minsize?: Minsize | undefined;
logical_volumes: LogicalVolume[];
};
export type Partition = FilesystemTyped | BtrfsVolume | VolumeGroup;
export type Disk = {
/** Type of the partition table
*/
type?: ("gpt" | "dos") | undefined;
minsize?: Minsize | undefined;
partitions: Partition[];
};
export type BootMode = "legacy" | "uefi" | "hybrid" | "none";
export type ImageTypeInfo = {
/** Image type name */
name: string;
/** Alternative names for this image type */
aliases?: string[] | undefined;
/** Canonical filename for the image */
filename?: string | undefined;
/** MIME type of the image */
mime_type?: string | undefined;
/** Default OSTree ref for this image type */
ostree_ref?: string | undefined;
/** ISO label (only for ISO image types) */
iso_label?: string | undefined;
/** Default image size in bytes */
default_size?: number | undefined;
/** Partition table type */
partition_type?: PartitionType | undefined;
base_partition_table?: Disk | undefined;
/** Boot mode for the image */
boot_mode?: BootMode | undefined;
/** Package set names safe for custom packages via custom repos */
payload_package_sets?: string[] | undefined;
/** Names of stages that produce the build output */
exports?: string[] | undefined;
/** Customization options required by this image type */
required_blueprint_options?: string[] | undefined;
/** Customization options supported by this image type */
supported_blueprint_options?: string[] | undefined;
};
export type ArchitectureInfo = {
/** Architecture name */
name: string;
/** Map of image type names to their details */
image_types?:
| {
[key: string]: ImageTypeInfo;
}
| undefined;
};
export type DistributionDetails = {
/** Name of the distribution */
name: string;
/** Codename of the distribution */
codename?: string | undefined;
/** Release version used in repo files */
releasever?: string | undefined;
/** Full OS version including minor version */
os_version?: string | undefined;
/** Module platform ID for DNF modularity */
module_platform_id?: string | undefined;
/** Product name */
product?: string | undefined;
/** Default OSTree reference template */
ostree_ref?: string | undefined;
/** Map of architecture names to their details */
architectures?:
| {
[key: string]: ArchitectureInfo;
}
| undefined;
};
export type HttpError = {
title: string;
detail: string;
};
export type HttpErrorList = {
errors: HttpError[];
};
export type Repository = {
/** An ID referring to a repository defined in content sources can be used instead of
'baseurl', 'mirrorlist' or 'metalink'.
Expand All @@ -393,13 +544,6 @@ export type ArchitectureItem = {
repositories: Repository[];
};
export type Architectures = ArchitectureItem[];
export type HttpError = {
title: string;
detail: string;
};
export type HttpErrorList = {
errors: HttpError[];
};
export type Distributions =
| "rhel-8"
| "rhel-8-nightly"
Expand Down Expand Up @@ -697,65 +841,6 @@ export type Filesystem = {
/** size of the filesystem in bytes */
min_size: any;
};
export type Minsize = string;
export type FilesystemTyped = {
type?: "plain" | undefined;
/** 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.
*/
part_type?: string | undefined;
minsize?: Minsize | undefined;
mountpoint?: string | undefined;
label?: string | undefined;
/** The filesystem type. Swap partitions must have an empty mountpoint.
*/
fs_type: "ext4" | "xfs" | "vfat" | "swap";
};
export type BtrfsSubvolume = {
/** The name of the subvolume, which defines the location (path) on the root volume
*/
name: string;
/** Mountpoint for the subvolume
*/
mountpoint: string;
};
export type BtrfsVolume = {
type: "btrfs";
/** 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.
*/
part_type?: string | undefined;
minsize?: Minsize | undefined;
subvolumes: BtrfsSubvolume[];
};
export type LogicalVolume = {
name?: string | undefined;
minsize?: Minsize | undefined;
/** Mountpoint for the logical volume
*/
mountpoint?: string | undefined;
label?: string | undefined;
/** The filesystem type for the logical volume. Swap LVs must have an empty mountpoint.
*/
fs_type: "ext4" | "xfs" | "vfat" | "swap";
};
export type VolumeGroup = {
type: "lvm";
/** 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.
*/
part_type?: string | undefined;
/** Volume group name (will be automatically generated if omitted)
*/
name?: string | undefined;
minsize?: Minsize | undefined;
logical_volumes: LogicalVolume[];
};
export type Partition = FilesystemTyped | BtrfsVolume | VolumeGroup;
export type Disk = {
/** Type of the partition table
*/
type?: ("gpt" | "dos") | undefined;
minsize?: Minsize | undefined;
partitions: Partition[];
};
export type User = {
name: string;
/** List of groups to add the user to. The 'wheel' group should be added explicitly, as the
Expand Down Expand Up @@ -1080,6 +1165,8 @@ export type RecommendPackageRequest = {
export const {
useGetDistributionsQuery,
useLazyGetDistributionsQuery,
useGetDistributionQuery,
useLazyGetDistributionQuery,
useGetArchitecturesQuery,
useLazyGetArchitecturesQuery,
useGetBlueprintsQuery,
Expand Down
1 change: 1 addition & 0 deletions src/store/api/backend/hosted/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export {
useGetBlueprintQuery,
useGetBlueprintsQuery,
useGetDistributionsQuery,
useGetDistributionQuery,
useGetComposesQuery,
useGetComposeStatusQuery,
useGetOscapCustomizationsForPolicyQuery,
Expand Down
6 changes: 6 additions & 0 deletions src/store/api/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ export const useGetComposeStatusQuery = process.env.IS_ON_PREMISE
? composerQueries.useGetComposeStatusQuery
: serviceQueries.useGetComposeStatusQuery;

export const useGetDistributionQuery = (
process.env.IS_ON_PREMISE
? composerQueries.useGetDistributionQuery
: serviceQueries.useGetDistributionQuery
) as typeof serviceQueries.useGetDistributionQuery;

export const useBackendPrefetch = process.env.IS_ON_PREMISE
? composerApi.usePrefetch
: imageBuilderApi.usePrefetch;
Expand Down
35 changes: 35 additions & 0 deletions src/store/api/backend/onprem/composerApi/distribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { OnPremBuilder, onPremQueryHandler } from '@/store/api/shared';

import {
GetDistributionApiArg,
GetDistributionApiResponse,
} from '../../hosted';

export const distributionEndpoints = (builder: OnPremBuilder) => ({
getDistribution: builder.query<
GetDistributionApiResponse,
GetDistributionApiArg
>({
queryFn: onPremQueryHandler(async ({ queryArgs, baseQuery }) => {
const params: Record<string, string[]> = {};
if (queryArgs.imageType?.length) {
params['image_type'] = queryArgs.imageType;
}
if (queryArgs.architecture?.length) {
params['architecture'] = queryArgs.architecture;
}

const result = await baseQuery({
url: `/distributions/${queryArgs.distro}`,
method: 'GET',
params,
});

if (result.error) {
throw result.error;
}

return result.data as GetDistributionApiResponse;
}),
}),
});
3 changes: 3 additions & 0 deletions src/store/api/backend/onprem/composerApi/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { architectureEndpoints } from './architecture';
import { blueprintEndpoints } from './blueprints';
import { composeEndpoints } from './composes';
import { distributionEndpoints } from './distribution';
import { oscapEndpoints } from './oscap';
import { workerEndpoints } from './worker';

Expand All @@ -12,6 +13,7 @@ export const composerApi = emptyComposerApi.injectEndpoints({
...architectureEndpoints(builder),
...blueprintEndpoints(builder),
...composeEndpoints(builder),
...distributionEndpoints(builder),
...oscapEndpoints(builder),
...workerEndpoints(builder),
};
Expand All @@ -33,6 +35,7 @@ export const {
useDeleteBlueprintMutation,
useExportBlueprintCockpitQuery,
useLazyExportBlueprintCockpitQuery,
useGetDistributionQuery,
useGetOscapProfilesQuery,
useGetOscapCustomizationsQuery,
useLazyGetOscapCustomizationsQuery,
Expand Down
Loading
Loading