cloudapi/v2: minsize can be a string or integer

Define a reusable minsize property in the cloud API schema.
The minsize type is either a uint64 or a string with data units.

Internally, this creates a union (json.RawMessage) type called Minsize
and optional uses of the property are of type *Minsize.  We define an
internal decodeMinsize() function to convert *Minsize to uint64.  This
is similar to the decodeSize() function in the blueprint, but made
specifically to handle *Minsize.
This commit is contained in:
Achilleas Koutsou 2025-03-18 15:53:04 +01:00 committed by Sanne Raymaekers
parent 82ac185e7c
commit ad0cb80bed
4 changed files with 452 additions and 253 deletions

View file

@ -2161,9 +2161,7 @@ components:
type: string
example: '/var'
minsize:
x-go-type: uint64
example: 2147483648
description: 'size of the filesystem in bytes'
$ref: '#/components/schemas/minsize'
OSTree:
type: object
properties:
@ -2599,9 +2597,7 @@ components:
description: |
Type of the partition table
minsize:
x-go-type: uint64
example: 2147483648
description: 'size of the filesystem in bytes'
$ref: '#/components/schemas/minsize'
partitions:
type: array
items:
@ -2627,9 +2623,7 @@ components:
description: |
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.
minsize:
x-go-type: uint64
example: 2147483648
description: 'minimum size of the filesystem in bytes'
$ref: '#/components/schemas/minsize'
mountpoint:
type: string
label:
@ -2656,9 +2650,7 @@ components:
description: |
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.
minsize:
x-go-type: uint64
example: 2147483648
description: 'minimum size of the btrfs volume in bytes'
$ref: '#/components/schemas/minsize'
subvolumes:
type: array
items:
@ -2695,9 +2687,7 @@ components:
description: |
Volume group name (will be automatically generated if omitted)
minsize:
x-go-type: uint64
example: 2147483648
description: 'minimum size of the volume group in bytes'
$ref: '#/components/schemas/minsize'
logical_volumes:
type: array
items:
@ -2710,9 +2700,7 @@ components:
name:
type: string
minsize:
x-go-type: uint64
example: 2147483648
description: 'minimum size of the logical volume in bytes'
$ref: '#/components/schemas/minsize'
mountpoint:
type: string
description: |
@ -2727,6 +2715,14 @@ components:
- vfat
description: |
The filesystem type for the logical volume
minsize:
oneOf:
- x-go-type: uint64
example: 2147483648
description: 'size in bytes'
- type: string
example: "2 GiB"
description: 'size with data units'
parameters:
page: