Skip to content

Commit

Permalink
chore(baremetal): remove exclude on partitioning schema type (#1458)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan R. <[email protected]>
  • Loading branch information
scaleway-bot and jremy42 authored Oct 4, 2024
1 parent 6829c46 commit cf904b0
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 70 deletions.
151 changes: 81 additions & 70 deletions packages/clients/src/api/baremetal/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ const unmarshalServerInstall = (data: unknown): ServerInstall => {
return {
hostname: data.hostname,
osId: data.os_id,
partitioningSchema: data.partitioning_schema
? unmarshalSchema(data.partitioning_schema)
: undefined,
serviceUrl: data.service_url,
serviceUser: data.service_user,
sshKeyIds: data.ssh_key_ids,
Expand Down Expand Up @@ -759,12 +762,86 @@ export const marshalAddOptionServerRequest = (
expires_at: request.expiresAt,
})

const marshalSchemaPartition = (
request: SchemaPartition,
defaults: DefaultValues,
): Record<string, unknown> => ({
label: request.label,
number: request.number,
size: request.size,
})

const marshalSchemaPool = (
request: SchemaPool,
defaults: DefaultValues,
): Record<string, unknown> => ({
devices: request.devices,
filesystem_options: request.filesystemOptions,
name: request.name,
options: request.options,
type: request.type,
})

const marshalSchemaDisk = (
request: SchemaDisk,
defaults: DefaultValues,
): Record<string, unknown> => ({
device: request.device,
partitions: request.partitions.map(elt =>
marshalSchemaPartition(elt, defaults),
),
})

const marshalSchemaFilesystem = (
request: SchemaFilesystem,
defaults: DefaultValues,
): Record<string, unknown> => ({
device: request.device,
format: request.format,
mountpoint: request.mountpoint,
})

const marshalSchemaRAID = (
request: SchemaRAID,
defaults: DefaultValues,
): Record<string, unknown> => ({
devices: request.devices,
level: request.level,
name: request.name,
})

const marshalSchemaZFS = (
request: SchemaZFS,
defaults: DefaultValues,
): Record<string, unknown> => ({
pools: request.pools.map(elt => marshalSchemaPool(elt, defaults)),
})

export const marshalSchema = (
request: Schema,
defaults: DefaultValues,
): Record<string, unknown> => ({
disks: request.disks.map(elt => marshalSchemaDisk(elt, defaults)),
filesystems: request.filesystems.map(elt =>
marshalSchemaFilesystem(elt, defaults),
),
raids: request.raids.map(elt => marshalSchemaRAID(elt, defaults)),
zfs:
request.zfs !== undefined
? marshalSchemaZFS(request.zfs, defaults)
: undefined,
})

const marshalCreateServerRequestInstall = (
request: CreateServerRequestInstall,
defaults: DefaultValues,
): Record<string, unknown> => ({
hostname: request.hostname,
os_id: request.osId,
partitioning_schema:
request.partitioningSchema !== undefined
? marshalSchema(request.partitioningSchema, defaults)
: undefined,
password: request.password,
service_password: request.servicePassword,
service_user: request.serviceUser,
Expand Down Expand Up @@ -805,6 +882,10 @@ export const marshalInstallServerRequest = (
): Record<string, unknown> => ({
hostname: request.hostname,
os_id: request.osId,
partitioning_schema:
request.partitioningSchema !== undefined
? marshalSchema(request.partitioningSchema, defaults)
: undefined,
password: request.password,
service_password: request.servicePassword,
service_user: request.serviceUser,
Expand Down Expand Up @@ -870,76 +951,6 @@ export const marshalUpdateSettingRequest = (
enabled: request.enabled,
})

const marshalSchemaPartition = (
request: SchemaPartition,
defaults: DefaultValues,
): Record<string, unknown> => ({
label: request.label,
number: request.number,
size: request.size,
})

const marshalSchemaPool = (
request: SchemaPool,
defaults: DefaultValues,
): Record<string, unknown> => ({
devices: request.devices,
filesystem_options: request.filesystemOptions,
name: request.name,
options: request.options,
type: request.type,
})

const marshalSchemaDisk = (
request: SchemaDisk,
defaults: DefaultValues,
): Record<string, unknown> => ({
device: request.device,
partitions: request.partitions.map(elt =>
marshalSchemaPartition(elt, defaults),
),
})

const marshalSchemaFilesystem = (
request: SchemaFilesystem,
defaults: DefaultValues,
): Record<string, unknown> => ({
device: request.device,
format: request.format,
mountpoint: request.mountpoint,
})

const marshalSchemaRAID = (
request: SchemaRAID,
defaults: DefaultValues,
): Record<string, unknown> => ({
devices: request.devices,
level: request.level,
name: request.name,
})

const marshalSchemaZFS = (
request: SchemaZFS,
defaults: DefaultValues,
): Record<string, unknown> => ({
pools: request.pools.map(elt => marshalSchemaPool(elt, defaults)),
})

export const marshalSchema = (
request: Schema,
defaults: DefaultValues,
): Record<string, unknown> => ({
disks: request.disks.map(elt => marshalSchemaDisk(elt, defaults)),
filesystems: request.filesystems.map(elt =>
marshalSchemaFilesystem(elt, defaults),
),
raids: request.raids.map(elt => marshalSchemaRAID(elt, defaults)),
zfs:
request.zfs !== undefined
? marshalSchemaZFS(request.zfs, defaults)
: undefined,
})

export const marshalValidatePartitioningSchemaRequest = (
request: ValidatePartitioningSchemaRequest,
defaults: DefaultValues,
Expand Down
6 changes: 6 additions & 0 deletions packages/clients/src/api/baremetal/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ export interface ServerInstall {
serviceUser: string
/** Address of the installed service. */
serviceUrl: string
/** Partitioning schema. */
partitioningSchema?: Schema
}

export interface ServerOption {
Expand Down Expand Up @@ -377,6 +379,8 @@ export interface CreateServerRequestInstall {
serviceUser?: string
/** Password used for the service to install. */
servicePassword?: string
/** Partitioning schema. */
partitioningSchema?: Schema
}

export interface OS {
Expand Down Expand Up @@ -748,6 +752,8 @@ export type InstallServerRequest = {
serviceUser?: string
/** Password used for the service to install. */
servicePassword?: string
/** Partitioning schema. */
partitioningSchema?: Schema
}

export type ListOSRequest = {
Expand Down

0 comments on commit cf904b0

Please sign in to comment.