Keystone: Implement Region controller#862
Conversation
$ go run ./cmd/scaffold-controller -interactive=false \
-kind=Region \
-gophercloud-client=NewIdentityV3 \
-gophercloud-module=github.com/gophercloud/gophercloud/v2/openstack/identity/v3/regions \
-gophercloud-type=Region \
-openstack-json-object=region
On-behalf-of: SAP nils.gondermann@sap.com
Register with the resource generator On-behalf-of: SAP nils.gondermann@sap.com
Add the OpenStack client to scope On-behalf-of: SAP nils.gondermann@sap.com
Register the controller On-behalf-of: SAP nils.gondermann@sap.com
On-behalf-of: SAP nils.gondermann@sap.com
On-behalf-of: SAP nils.gondermann@sap.com
On-behalf-of: SAP nils.gondermann@sap.com
On-behalf-of: SAP nils.gondermann@sap.com
Generate the OLM bundle On-behalf-of: SAP nils.gondermann@sap.com
On-behalf-of: SAP nils.gondermann@sap.com
9fdcdd6 to
0c56e56
Compare
winiciusallan
left a comment
There was a problem hiding this comment.
Hey @gndrmnn, great work! At a first glance, this looks very good to me. I left a few comments, but I'm still missing a review in the tests. Will do it later.
|
|
||
| // RegionResourceSpec contains the desired state of the resource. | ||
| type RegionResourceSpec struct { | ||
| // name will be the ID of the Region. |
There was a problem hiding this comment.
Let's add this as a note and keep the doc more descriptive. Something like:
| // name will be the ID of the Region. | |
| // name is the name of the Region resource. This field will be passed as the region ID in the Keystone API. |
|
|
||
| // RegionResourceStatus represents the observed state of the resource. | ||
| type RegionResourceStatus struct { | ||
| // name is the ID for the resource. |
There was a problem hiding this comment.
The same suggestion as from spec.name
| // RegionResourceSpec contains the desired state of the resource. | ||
| type RegionResourceSpec struct { | ||
| // name will be the ID of the Region. | ||
| // +required |
There was a problem hiding this comment.
I think we can have this field optional and fallback to the k8s resource name, still using it as the RegionID. Wdyt?
| // so we must use client-side filtering. | ||
| filters := []osclients.ResourceFilter[osResourceT]{ | ||
| func(r *regions.Region) bool { | ||
| return r.ID == string(orcObject.Spec.Resource.Name) |
There was a problem hiding this comment.
nit: you already have the resourceSpec stored in a variable. You can use:
| return r.ID == string(orcObject.Spec.Resource.Name) | |
| return r.ID == string(resourceSpec.Name) |
| // TODO(scaffolding): Add more resource-specific validation tests. | ||
| // Some common things to test: | ||
| // - Immutability of fields with `self == oldSelf` validation | ||
| // - Enum validation (valid and invalid values) | ||
| // - Numeric range validation (min/max bounds) | ||
| // - Tag uniqueness (if the resource has tags with listType=set) | ||
| // - Format validation (CIDR, UUID, etc.) | ||
| // - Cross-field validation rules | ||
| }) |
There was a problem hiding this comment.
Please, take a look at these. The code comment is very good wrt what you could implement here.
Regions are weird in that they have an
idfield, which is used as a name (no UUID) but they lack a propernamefield.I took the liberty to do a
name->idmapping in the actuator and status as I think that makes more sense form a k-orc perspective. Though if you want I can rename the field toidjust to be consistent with the upstream naming.