Skip to content

Commit a52da8a

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

9 files changed

Lines changed: 229 additions & 109 deletions

File tree

api/v1alpha1/registeredlimit_types.go

Lines changed: 38 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,65 @@ 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+
// +kubebuilder:validation:Maximum=2147483647
42+
// +required
43+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="defaultLimit is immutable"
44+
DefaultLimit *int32 `json:"defaultLimit,omitempty"`
4445
}
4546

4647
// RegisteredLimitFilter defines an existing resource by its properties
4748
// +kubebuilder:validation:MinProperties:=1
4849
type RegisteredLimitFilter struct {
49-
// name of the existing resource
50-
// +optional
51-
Name *OpenStackName `json:"name,omitempty"`
52-
5350
// description of the existing resource
5451
// +kubebuilder:validation:MinLength:=1
5552
// +kubebuilder:validation:MaxLength:=255
5653
// +optional
5754
Description *string `json:"description,omitempty"`
5855

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
56+
// serviceRef is a reference to the ORC Service which this resource is associated with.
57+
// +optional
58+
ServiceRef *KubernetesNameRef `json:"serviceRef,omitempty"`
59+
60+
// resourceName is name of the resource to be limited.
61+
// +kubebuilder:validation:MinLength:=1
62+
// +kubebuilder:validation:MaxLength:=255
63+
// +optional
64+
ResourceName *string `json:"resourceName,omitempty"`
6265
}
6366

6467
// RegisteredLimitResourceStatus represents the observed state of the resource.
6568
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-
7169
// description is a human-readable description for the resource.
7270
// +kubebuilder:validation:MaxLength=1024
7371
// +optional
7472
Description string `json:"description,omitempty"`
7573

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

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
90+
// defaultLimit is limit of the specified resource in the given context.
91+
// +optional
92+
DefaultLimit int32 `json:"defaultLimit,omitempty"`
8493
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 15 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: 40 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,30 @@ 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+
maximum: 2147483647
163+
minimum: -1
164+
type: integer
165+
x-kubernetes-validations:
166+
- message: defaultLimit is immutable
167+
rule: self == oldSelf
153168
description:
154169
description: description is a human-readable description for the
155170
resource.
156171
maxLength: 255
157172
minLength: 1
158173
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.
174+
resourceName:
175+
description: resourceName is name of the resource to be limited.
163176
maxLength: 255
164177
minLength: 1
165-
pattern: ^[^,]+$
166178
type: string
179+
x-kubernetes-validations:
180+
- message: resourceName is immutable
181+
rule: self == oldSelf
167182
serviceRef:
168183
description: serviceRef is a reference to the ORC Service which
169184
this resource is associated with.
@@ -174,6 +189,8 @@ spec:
174189
- message: serviceRef is immutable
175190
rule: self == oldSelf
176191
required:
192+
- defaultLimit
193+
- resourceName
177194
- serviceRef
178195
type: object
179196
required:
@@ -279,19 +296,29 @@ spec:
279296
description: resource contains the observed state of the OpenStack
280297
resource.
281298
properties:
299+
defaultLimit:
300+
description: defaultLimit is limit of the specified resource in
301+
the given context.
302+
format: int32
303+
type: integer
282304
description:
283305
description: description is a human-readable description for the
284306
resource.
285307
maxLength: 1024
286308
type: string
287-
name:
288-
description: name is a Human-readable name for the resource. Might
289-
not be unique.
309+
regionID:
310+
description: regionID is the ID of the region that contains the
311+
service endpoint.
290312
maxLength: 1024
291313
type: string
314+
resourceName:
315+
description: resourceName is name of the resource to be limited.
316+
maxLength: 255
317+
minLength: 1
318+
type: string
292319
serviceID:
293-
description: serviceID is the ID of the Service to which the resource
294-
is associated.
320+
description: serviceID is a reference to the ORC Service which
321+
this resource is associated with.
295322
maxLength: 1024
296323
type: string
297324
type: object

0 commit comments

Comments
 (0)