Skip to content

Commit afeee9f

Browse files
committed
Fix image properties propagation
Signed-off-by: Matej Feder <[email protected]>
1 parent f048fa7 commit afeee9f

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

api/v1alpha1/openstacknodeimagerelease_types.go

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,59 @@ type OpenStackNodeImage struct {
4242
}
4343

4444
// CreateOpts represents options used to create an image.
45-
type CreateOpts images.CreateOpts
45+
// TODO: Reimplement logic to import `images.CreateOpts` from Gophercloud with a `Properties` override.
46+
// The current `images.CreateOpts` defines `json:"-"` for the `Properties` field, making it unsuitable
47+
// for proper unmarshalling required for `CreateOpts` used in Kubernetes resources
48+
// and `nodeimagerelease.yaml`.
49+
//
50+
// One solution is to create a new struct specifically for unmarshalling
51+
// that embeds `images.CreateOpts` and redefines the `Properties` field to allow proper handling.
52+
type CreateOpts struct {
53+
// Name is the name of the new image.
54+
Name string `json:"name" required:"true"`
55+
56+
// Id is the the image ID.
57+
ID string `json:"id,omitempty"`
58+
59+
// Visibility defines who can see/use the image.
60+
Visibility *images.ImageVisibility `json:"visibility,omitempty"`
61+
62+
// Hidden is whether the image is listed in default image list or not.
63+
//nolint:tagliatelle
64+
Hidden *bool `json:"os_hidden,omitempty"`
65+
66+
// Tags is a set of image tags.
67+
Tags []string `json:"tags,omitempty"`
68+
69+
// ContainerFormat is the format of the
70+
// container. Valid values are ami, ari, aki, bare, and ovf.
71+
//nolint:tagliatelle
72+
ContainerFormat string `json:"container_format,omitempty"`
73+
74+
// DiskFormat is the format of the disk. If set,
75+
// valid values are ami, ari, aki, vhd, vmdk, raw, qcow2, vdi,
76+
// and iso.
77+
//nolint:tagliatelle
78+
DiskFormat string `json:"disk_format,omitempty"`
79+
80+
// MinDisk is the amount of disk space in
81+
// GB that is required to boot the image.
82+
//nolint:tagliatelle
83+
MinDisk int `json:"min_disk,omitempty"`
84+
85+
// MinRAM is the amount of RAM in MB that
86+
// is required to boot the image.
87+
//nolint:tagliatelle
88+
MinRAM int `json:"min_ram,omitempty"`
89+
90+
// protected is whether the image is not deletable.
91+
Protected *bool `json:"protected,omitempty"`
92+
93+
// properties is a set of properties, if any, that
94+
// are associated with the image.
95+
Properties map[string]string `json:"properties,omitempty"`
96+
}
97+
4698

4799
// OpenStackNodeImageReleaseStatus defines the observed state of OpenStackNodeImageRelease.
48100
type OpenStackNodeImageReleaseStatus struct {

config/crd/bases/infrastructure.clusterstack.x-k8s.io_openstacknodeimagereleases.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ spec:
114114
description: Hidden is whether the image is listed in default
115115
image list or not.
116116
type: boolean
117+
properties:
118+
additionalProperties:
119+
type: string
120+
description: |-
121+
properties is a set of properties, if any, that
122+
are associated with the image.
123+
type: object
117124
protected:
118125
description: protected is whether the image is not deletable.
119126
type: boolean

0 commit comments

Comments
 (0)