Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit d6d907e

Browse files
NotTheEvilOnematofeder
authored andcommitted
Reuse existing "images.CreateOpts" for node image releases
This reapplies the change in an updated form. This reverts commit e0ca13f. Signed-off-by: Tobias Wolf <[email protected]>
1 parent 8d2ae75 commit d6d907e

File tree

2 files changed

+4
-35
lines changed

2 files changed

+4
-35
lines changed

api/v1alpha1/openstacknodeimagerelease_types.go

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,7 @@ type OpenStackNodeImage struct {
4444
}
4545

4646
// CreateOpts represents options used to create an image.
47-
// CreateOpts attributes are taken from github.com/gophercloud/gophercloud/openstack/imageservice/v2/images.
48-
// Consider.
49-
type CreateOpts struct {
50-
// Name is the name of the new image.
51-
Name string `json:"name" yaml:"name" required:"true"`
52-
// Id is the the image ID.
53-
ID string `json:"id,omitempty" yaml:"id,omitempty"`
54-
// Visibility defines who can see/use the image.
55-
Visibility *images.ImageVisibility `json:"visibility,omitempty" yaml:"visibility,omitempty"`
56-
// Hidden is whether the image is listed in default image list or not.
57-
Hidden *bool `json:"os_hidden,omitempty" yaml:"os_hidden,omitempty"` //nolint:tagliatelle // OS API expects snake case query attrs
58-
// Tags is a set of image tags.
59-
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
60-
// ContainerFormat is the format of the
61-
// container. Valid values are ami, ari, aki, bare, and ovf.
62-
ContainerFormat string `json:"container_format,omitempty" yaml:"container_format,omitempty"` //nolint:tagliatelle // OS API expects snake case query attrs
63-
// DiskFormat is the format of the disk. If set,
64-
// valid values are ami, ari, aki, vhd, vmdk, raw, qcow2, vdi,
65-
// and iso.
66-
DiskFormat string `json:"disk_format,omitempty" yaml:"disk_format,omitempty"` //nolint:tagliatelle // OS API expects snake case query attrs
67-
// MinDisk is the amount of disk space in
68-
// GB that is required to boot the image.
69-
MinDisk int `json:"min_disk,omitempty" yaml:"min_disk,omitempty"` //nolint:tagliatelle // OS API expects snake case query attrs
70-
// MinRAM is the amount of RAM in MB that
71-
// is required to boot the image.
72-
MinRAM int `json:"min_ram,omitempty" yaml:"min_ram,omitempty"` //nolint:tagliatelle // OS API expects snake case query attrs
73-
// protected is whether the image is not deletable.
74-
Protected *bool `json:"protected,omitempty" yaml:"protected,omitempty"`
75-
// properties is a set of properties, if any, that
76-
// are associated with the image.
77-
Properties map[string]string `json:"-" yaml:"-"`
78-
}
47+
type CreateOpts images.CreateOpts
7948

8049
// OpenStackNodeImageReleaseStatus defines the observed state of OpenStackNodeImageRelease.
8150
type OpenStackNodeImageReleaseStatus struct {

internal/controller/openstacknodeimagerelease_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (r *OpenStackNodeImageReleaseReconciler) Reconcile(ctx context.Context, req
147147
conditions.MarkFalse(openstacknodeimagerelease, apiv1alpha1.OpenStackImageImportStartCondition, apiv1alpha1.OpenStackImageImportNotStartReason, clusterv1beta1.ConditionSeverityInfo, "image import not start yet")
148148
openstacknodeimagerelease.Status.Ready = false
149149

150-
imageCreateOpts := (*images.CreateOpts)(openstacknodeimagerelease.Spec.Image.CreateOpts)
150+
imageCreateOpts := openstacknodeimagerelease.Spec.Image.CreateOpts
151151
imageCreated, err := createImage(imageClient, imageCreateOpts)
152152
if err != nil {
153153
conditions.MarkFalse(openstacknodeimagerelease,
@@ -316,8 +316,8 @@ func findImageByName(imagesClient *gophercloud.ServiceClient, imageName string)
316316
return "", nil
317317
}
318318

319-
func createImage(imageClient *gophercloud.ServiceClient, createOpts *images.CreateOpts) (*images.Image, error) {
320-
image, err := images.Create(imageClient, createOpts).Extract()
319+
func createImage(imageClient *gophercloud.ServiceClient, createOpts *apiv1alpha1.CreateOpts) (*images.Image, error) {
320+
image, err := images.Create(imageClient, (*images.CreateOpts)(createOpts)).Extract()
321321
if err != nil {
322322
return nil, fmt.Errorf("failed to create image with name %s: %w", createOpts.Name, err)
323323
}

0 commit comments

Comments
 (0)