Skip to content

Commit 310f423

Browse files
committed
RegisteredLimit Type Declaration
On-behalf-of: SAP nils.gondermann@sap.com
1 parent f05b655 commit 310f423

9 files changed

Lines changed: 222 additions & 109 deletions

File tree

api/v1alpha1/registeredlimit_types.go

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ package v1alpha1
1818

1919
// RegisteredLimitResourceSpec contains the desired state of the resource.
2020
type RegisteredLimitResourceSpec struct {
21-
// name will be the name of the created resource. If not specified, the
22-
// name of the ORC object will be used.
23-
// +optional
24-
Name *OpenStackName `json:"name,omitempty"`
25-
2621
// description is a human-readable description for the resource.
2722
// +kubebuilder:validation:MinLength:=1
2823
// +kubebuilder:validation:MaxLength:=255
@@ -34,51 +29,64 @@ type RegisteredLimitResourceSpec struct {
3429
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="serviceRef is immutable"
3530
ServiceRef KubernetesNameRef `json:"serviceRef,omitempty"`
3631

37-
// TODO(scaffolding): Add more types.
38-
// To see what is supported, you can take inspiration from the CreateOpts structure from
39-
// github.com/gophercloud/gophercloud/v2/openstack/identity/v3/registeredlimits
40-
//
41-
// Until you have implemented mutability for the field, you must add a CEL validation
42-
// preventing the field being modified:
43-
// `// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="<fieldname> is immutable"`
32+
// resourceName is name of the resource to be limited.
33+
// +kubebuilder:validation:MinLength:=1
34+
// +kubebuilder:validation:MaxLength:=255
35+
// +required
36+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="resourceName is immutable"
37+
ResourceName string `json:"resourceName,omitempty"`
38+
39+
// defaultLimit is limit of the specified resource in the given context.
40+
// +kubebuilder:validation:Minimum=-1
41+
// +required
42+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="defaultLimit is immutable"
43+
DefaultLimit int32 `json:"defaultLimit,omitempty"`
4444
}
4545

4646
// RegisteredLimitFilter defines an existing resource by its properties
4747
// +kubebuilder:validation:MinProperties:=1
4848
type RegisteredLimitFilter struct {
49-
// name of the existing resource
50-
// +optional
51-
Name *OpenStackName `json:"name,omitempty"`
52-
5349
// description of the existing resource
5450
// +kubebuilder:validation:MinLength:=1
5551
// +kubebuilder:validation:MaxLength:=255
5652
// +optional
5753
Description *string `json:"description,omitempty"`
5854

59-
// TODO(scaffolding): Add more types.
60-
// To see what is supported, you can take inspiration from the ListOpts structure from
61-
// github.com/gophercloud/gophercloud/v2/openstack/identity/v3/registeredlimits
55+
// serviceRef is a reference to the ORC Service which this resource is associated with.
56+
// +optional
57+
ServiceRef *KubernetesNameRef `json:"serviceRef,omitempty"`
58+
59+
// resourceName is name of the resource to be limited.
60+
// +kubebuilder:validation:MinLength:=1
61+
// +kubebuilder:validation:MaxLength:=255
62+
// +optional
63+
ResourceName *string `json:"resourceName,omitempty"`
6264
}
6365

6466
// RegisteredLimitResourceStatus represents the observed state of the resource.
6567
type RegisteredLimitResourceStatus struct {
66-
// name is a Human-readable name for the resource. Might not be unique.
67-
// +kubebuilder:validation:MaxLength=1024
68-
// +optional
69-
Name string `json:"name,omitempty"`
70-
7168
// description is a human-readable description for the resource.
7269
// +kubebuilder:validation:MaxLength=1024
7370
// +optional
7471
Description string `json:"description,omitempty"`
7572

76-
// serviceID is the ID of the Service to which the resource is associated.
77-
// +kubebuilder:validation:MaxLength=1024
73+
// resourceName is name of the resource to be limited.
74+
// +kubebuilder:validation:MinLength:=1
75+
// +kubebuilder:validation:MaxLength:=255
76+
// +optional
77+
ResourceName string `json:"resourceName,omitempty"`
78+
79+
// regionID is the ID of the region that contains the service endpoint.
80+
// +kubebuilder:validation:MaxLength:=1024
81+
// +optional
82+
RegionID string `json:"regionID,omitempty"`
83+
84+
// serviceID is a reference to the ORC Service which this resource is associated with.
85+
// +kubebuilder:validation:MaxLength:=1024
7886
// +optional
7987
ServiceID string `json:"serviceID,omitempty"`
8088

81-
// TODO(scaffolding): Add more types.
82-
// To see what is supported, you can take inspiration from the RegisteredLimit structure from
83-
// github.com/gophercloud/gophercloud/v2/openstack/identity/v3/registeredlimits
89+
// defaultLimit is limit of the specified resource in the given context.
90+
// +optional
91+
DefaultLimit int32 `json:"defaultLimit,omitempty"`
8492
}

api/v1alpha1/zz_generated.deepcopy.go

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

cmd/models-schema/zz_generated.openapi.go

Lines changed: 44 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/openstack.k-orc.cloud_registeredlimits.yaml

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,16 @@ spec:
9696
maxLength: 255
9797
minLength: 1
9898
type: string
99-
name:
100-
description: name of the existing resource
99+
resourceName:
100+
description: resourceName is name of the resource to be limited.
101101
maxLength: 255
102102
minLength: 1
103-
pattern: ^[^,]+$
103+
type: string
104+
serviceRef:
105+
description: serviceRef is a reference to the ORC Service
106+
which this resource is associated with.
107+
maxLength: 253
108+
minLength: 1
104109
type: string
105110
type: object
106111
id:
@@ -150,20 +155,29 @@ spec:
150155
151156
resource must be specified if the management policy is `managed`.
152157
properties:
158+
defaultLimit:
159+
description: defaultLimit is limit of the specified resource in
160+
the given context.
161+
format: int32
162+
minimum: -1
163+
type: integer
164+
x-kubernetes-validations:
165+
- message: defaultLimit is immutable
166+
rule: self == oldSelf
153167
description:
154168
description: description is a human-readable description for the
155169
resource.
156170
maxLength: 255
157171
minLength: 1
158172
type: string
159-
name:
160-
description: |-
161-
name will be the name of the created resource. If not specified, the
162-
name of the ORC object will be used.
173+
resourceName:
174+
description: resourceName is name of the resource to be limited.
163175
maxLength: 255
164176
minLength: 1
165-
pattern: ^[^,]+$
166177
type: string
178+
x-kubernetes-validations:
179+
- message: resourceName is immutable
180+
rule: self == oldSelf
167181
serviceRef:
168182
description: serviceRef is a reference to the ORC Service which
169183
this resource is associated with.
@@ -174,6 +188,8 @@ spec:
174188
- message: serviceRef is immutable
175189
rule: self == oldSelf
176190
required:
191+
- defaultLimit
192+
- resourceName
177193
- serviceRef
178194
type: object
179195
required:
@@ -279,19 +295,29 @@ spec:
279295
description: resource contains the observed state of the OpenStack
280296
resource.
281297
properties:
298+
defaultLimit:
299+
description: defaultLimit is limit of the specified resource in
300+
the given context.
301+
format: int32
302+
type: integer
282303
description:
283304
description: description is a human-readable description for the
284305
resource.
285306
maxLength: 1024
286307
type: string
287-
name:
288-
description: name is a Human-readable name for the resource. Might
289-
not be unique.
308+
regionID:
309+
description: regionID is the ID of the region that contains the
310+
service endpoint.
290311
maxLength: 1024
291312
type: string
313+
resourceName:
314+
description: resourceName is name of the resource to be limited.
315+
maxLength: 255
316+
minLength: 1
317+
type: string
292318
serviceID:
293-
description: serviceID is the ID of the Service to which the resource
294-
is associated.
319+
description: serviceID is a reference to the ORC Service which
320+
this resource is associated with.
295321
maxLength: 1024
296322
type: string
297323
type: object

0 commit comments

Comments
 (0)