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

Commit 7731919

Browse files
committed
Add image import logic and adjust types accordingly
Signed-off-by: Matej Feder <[email protected]>
1 parent e0d6c0d commit 7731919

File tree

89 files changed

+5982
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+5982
-304
lines changed

api/v1alpha1/conditions_const.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
21+
)
22+
23+
const (
24+
// ClusterStackReleaseAssetsReadyCondition reports on whether the download of cluster stack release assets is complete.
25+
ClusterStackReleaseAssetsReadyCondition clusterv1beta1.ConditionType = "ClusterStackReleaseDownloaded"
26+
27+
// ReleaseAssetsNotDownloadedYetReason is used when release assets are not yet downloaded.
28+
ReleaseAssetsNotDownloadedYetReason = "ReleaseAssetsNotDownloadedYet"
29+
30+
// IssueWithReleaseAssetsReason is used when release assets have an issue.
31+
IssueWithReleaseAssetsReason = "IssueWithReleaseAssets"
32+
)
33+
34+
const (
35+
// OpenStackNodeImageReleasesReadyCondition reports on whether all relevant OpenStackNodeImageRelease objects are ready.
36+
OpenStackNodeImageReleasesReadyCondition clusterv1beta1.ConditionType = "OpenStackNodeImageReleasesReady"
37+
38+
// ProcessOngoingReason is used when the process of the OpenStackNodeImageRelease object is still ongoing.
39+
ProcessOngoingReason = "ProcessOngoing"
40+
)
41+
42+
const (
43+
// GitAPIAvailableCondition is used when Git API is available.
44+
GitAPIAvailableCondition = "GitAPIAvailable"
45+
46+
// GitTokenOrEnvVariableNotSetReason is used when user don't specify the token or environment variable.
47+
GitTokenOrEnvVariableNotSetReason = "GitTokenOrEnvVariableNotSet" //#nosec
48+
)
49+
50+
const (
51+
// CloudAvailableCondition is used when cloud is available.
52+
CloudAvailableCondition = "CloudAvailable"
53+
54+
// CloudNotSetReason is used when user don't specify a valid clouds.yaml inside a secret.
55+
CloudNotSetReason = "CloudNotSet"
56+
)
57+
58+
const (
59+
// OpenStackImageServiceClientAvailableCondition is used when OpenStack Image Service Client is available.
60+
OpenStackImageServiceClientAvailableCondition = "OpenStackImageServiceClientAvailable"
61+
62+
// OpenStackImageServiceClientNotSetReason is used when OpenStack Image Service Client is not available.
63+
OpenStackImageServiceClientNotSetReason = "OpenStackImageServiceClientNotSet"
64+
)
65+
66+
const (
67+
// OpenStackImageReadyCondition reports on whether the image of cluster stack release is imported and actice.
68+
OpenStackImageReadyCondition clusterv1beta1.ConditionType = "OpenStackImageActive"
69+
70+
// OpenStackImageNotCreatedYetReason is used when image is not yet created.
71+
OpenStackImageNotCreatedYetReason = "OpenStackImageNotCreateYet"
72+
73+
// OpenStackImageNotImportedYetReason is used when image is not yet imported.
74+
OpenStackImageNotImportedYetReason = "OpenStackImageNotImportedYet"
75+
76+
// IssueWithOpenStackImageReason is used when image has an issue.
77+
IssueWithOpenStackImageReason = "IssueWithOpenStackImage"
78+
)

api/v1alpha1/openstackclusterstackrelease_types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ type OpenStackClusterStackReleaseSpec struct {
3030
// The name of the cloud to use from the clouds secret
3131
CloudName string `json:"cloudName"`
3232
// IdentityRef is a reference to a identity to be used when reconciling this cluster
33-
IdentityRef *apiv1alpha7.OpenStackIdentityReference `json:"identityRef,omitempty"`
33+
IdentityRef *apiv1alpha7.OpenStackIdentityReference `json:"identityRef"`
3434
}
3535

3636
// OpenStackClusterStackReleaseStatus defines the observed state of OpenStackClusterStackRelease.
3737
type OpenStackClusterStackReleaseStatus struct {
3838
// +optional
3939
// +kubebuilder:default:=false
4040
Ready bool `json:"ready,omitempty"`
41-
// Conditions defines current service state of the ClusterAddon.
41+
// Conditions defines current service state of the OpenStackClusterStackRelease.
4242
// +optional
4343
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
4444
}
@@ -47,8 +47,8 @@ type OpenStackClusterStackReleaseStatus struct {
4747
//+kubebuilder:subresource:status
4848
//+kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready"
4949
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of OpenStackClusterStackRelease"
50-
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
51-
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message"
50+
//+kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
51+
//+kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message"
5252

5353
// OpenStackClusterStackRelease is the Schema for the openstackclusterstackreleases API.
5454
type OpenStackClusterStackRelease struct {
@@ -59,12 +59,12 @@ type OpenStackClusterStackRelease struct {
5959
Status OpenStackClusterStackReleaseStatus `json:"status,omitempty"`
6060
}
6161

62-
// GetConditions returns the observations of the operational state of the ClusterAddon resource.
62+
// GetConditions returns the observations of the operational state of the OpenStackClusterStackRelease resource.
6363
func (r *OpenStackClusterStackRelease) GetConditions() clusterv1beta1.Conditions {
6464
return r.Status.Conditions
6565
}
6666

67-
// SetConditions sets the underlying service state of the ClusterAddon to the predescribed clusterv1.Conditions.
67+
// SetConditions sets the underlying service state of the OpenStackClusterStackRelease to the predescribed clusterv1.Conditions.
6868
func (r *OpenStackClusterStackRelease) SetConditions(conditions clusterv1beta1.Conditions) {
6969
r.Status.Conditions = conditions
7070
}

api/v1alpha1/openstacknodeimagerelease_types.go

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,82 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
"github.com/gophercloud/gophercloud/openstack/imageservice/v2/images"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
apiv1alpha7 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
23+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
2224
)
2325

2426
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2527
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2628

2729
// OpenStackNodeImageReleaseSpec defines the desired state of OpenStackNodeImageRelease.
2830
type OpenStackNodeImageReleaseSpec struct {
29-
// The name of the node image
30-
Name string `json:"name"`
31-
// The URL of the node image
32-
URL string `json:"url"`
33-
// The DiskFormat of the node image
34-
DiskFormat string `json:"diskFormat"`
35-
// The ContainerFormat of the node image
36-
ContainerFormat string `json:"containerFormat"`
3731
// The name of the cloud to use from the clouds secret
3832
CloudName string `json:"cloudName"`
3933
// IdentityRef is a reference to a identity to be used when reconciling this cluster
40-
IdentityRef *apiv1alpha7.OpenStackIdentityReference `json:"identityRef,omitempty"`
34+
IdentityRef *apiv1alpha7.OpenStackIdentityReference `json:"identityRef"`
35+
// Image represents options used to upload an image
36+
Image *OpenStackNodeImage `json:"image"`
37+
}
38+
39+
// OpenStackNodeImage defines image fields required for image upload.
40+
type OpenStackNodeImage struct {
41+
URL string `json:"url" yaml:"url"`
42+
// CreateOpts represents options used to create an image.
43+
CreateOpts *CreateOpts `json:"createOpts" yaml:"createOpts"`
44+
}
45+
46+
// 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:"-"`
4178
}
4279

4380
// OpenStackNodeImageReleaseStatus defines the observed state of OpenStackNodeImageRelease.
4481
type OpenStackNodeImageReleaseStatus struct {
4582
// +optional
4683
// +kubebuilder:default:=false
4784
Ready bool `json:"ready,omitempty"`
85+
// Conditions defines current service state of the OpenStackNodeImageRelease.
86+
// +optional
87+
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
4888
}
4989

5090
//+kubebuilder:object:root=true
5191
//+kubebuilder:subresource:status
5292
//+kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready"
5393
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of OpenStackNodeImageRelease"
94+
//+kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
95+
//+kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message"
5496

5597
// OpenStackNodeImageRelease is the Schema for the openstacknodeimagereleases API.
5698
type OpenStackNodeImageRelease struct {
@@ -61,6 +103,16 @@ type OpenStackNodeImageRelease struct {
61103
Status OpenStackNodeImageReleaseStatus `json:"status,omitempty"`
62104
}
63105

106+
// GetConditions returns the observations of the operational state of the OpenStackNodeImageRelease resource.
107+
func (r *OpenStackNodeImageRelease) GetConditions() clusterv1beta1.Conditions {
108+
return r.Status.Conditions
109+
}
110+
111+
// SetConditions sets the underlying service state of the OpenStackNodeImageRelease to the predescribed clusterv1.Conditions.
112+
func (r *OpenStackNodeImageRelease) SetConditions(conditions clusterv1beta1.Conditions) {
113+
r.Status.Conditions = conditions
114+
}
115+
64116
//+kubebuilder:object:root=true
65117

66118
// OpenStackNodeImageReleaseList contains a list of OpenStackNodeImageRelease.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 76 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,14 @@ spec:
7373
type: object
7474
required:
7575
- cloudName
76+
- identityRef
7677
type: object
7778
status:
7879
description: OpenStackClusterStackReleaseStatus defines the observed state
7980
of OpenStackClusterStackRelease.
8081
properties:
8182
conditions:
82-
description: Conditions defines current service state of the ClusterAddon.
83+
description: Conditions defines current service state of the OpenStackClusterStackRelease.
8384
items:
8485
description: Condition defines an observation of a Cluster API resource
8586
operational state.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ spec:
7171
type: object
7272
required:
7373
- cloudName
74+
- identityRef
7475
type: object
7576
required:
7677
- spec

0 commit comments

Comments
 (0)