diff --git a/.golangci.yml b/.golangci.yml
index 1576fd4b2..dbee4374f 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -96,6 +96,12 @@ linters:
- linters:
- kubeapilinter
path-except: ^api/*
+ # RBACPolicy.TargetProjectID is an ID by design: the target project is often not
+ # managed by ORC.
+ - linters:
+ - kubeapilinter
+ path: api/v1alpha1/rbacpolicy_types\.go
+ text: noopenstackidref
paths:
- third_party$
- builtin$
diff --git a/PROJECT b/PROJECT
index 592c664ca..da1886580 100644
--- a/PROJECT
+++ b/PROJECT
@@ -120,6 +120,14 @@ resources:
kind: Project
path: github.com/k-orc/openstack-resource-controller/api/v1alpha1
version: v1alpha1
+- api:
+ crdVersion: v1
+ namespaced: true
+ domain: k-orc.cloud
+ group: openstack
+ kind: RBACPolicy
+ path: github.com/k-orc/openstack-resource-controller/api/v1alpha1
+ version: v1alpha1
- api:
crdVersion: v1
namespaced: true
diff --git a/README.md b/README.md
index 950aad958..4ef3dc280 100644
--- a/README.md
+++ b/README.md
@@ -81,6 +81,7 @@ kubectl delete -f $ORC_RELEASE
| network | | ◐ | ◐ |
| port | | ◐ | ◐ |
| project | | ◐ | ◐ |
+| rbac policy | | | ◐ |
| region | | | ◐ |
| registered limits | | | ◐ |
| role | | ✔ | ✔ |
diff --git a/api/v1alpha1/rbacpolicy_types.go b/api/v1alpha1/rbacpolicy_types.go
new file mode 100644
index 000000000..a161f8c2b
--- /dev/null
+++ b/api/v1alpha1/rbacpolicy_types.go
@@ -0,0 +1,103 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1alpha1
+
+// RBACPolicyAction is the type of access being granted by an RBAC policy.
+// +kubebuilder:validation:Enum:=access_as_shared;access_as_external
+type RBACPolicyAction string
+
+const (
+ // RBACPolicyActionAccessShared grants the target project permission to attach ports to
+ // (use) the network, without granting any ability to manage the network itself.
+ RBACPolicyActionAccessShared RBACPolicyAction = "access_as_shared"
+
+ // RBACPolicyActionAccessExternal grants the target project permission to use the network
+ // as an external gateway.
+ RBACPolicyActionAccessExternal RBACPolicyAction = "access_as_external"
+)
+
+// RBACPolicyResourceSpec contains the desired state of the resource. Only network policies
+// are supported.
+// +kubebuilder:validation:XValidation:rule="has(self.targetProjectRef) != has(self.targetProjectID)",message="exactly one of targetProjectRef and targetProjectID must be set"
+type RBACPolicyResourceSpec struct {
+ // networkRef is a reference to the ORC Network this policy grants access to.
+ // +required
+ // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="networkRef is immutable"
+ // +orc:kustomize:ref=Network
+ NetworkRef KubernetesNameRef `json:"networkRef,omitempty"`
+
+ // action is the type of access being granted to the target project.
+ // +required
+ // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="action is immutable"
+ Action RBACPolicyAction `json:"action,omitempty"`
+
+ // targetProjectRef is a reference to the ORC Project to grant access to.
+ // +optional
+ // +orc:kustomize:ref=Project
+ TargetProjectRef *KubernetesNameRef `json:"targetProjectRef,omitempty"`
+
+ // targetProjectID is the ID of the project to grant access to, for when it can't be
+ // referenced: the target is another project, which the network owner's credentials usually
+ // can't read, so it can't be imported with them.
+ // +optional
+ // +kubebuilder:validation:MinLength:=1
+ // +kubebuilder:validation:MaxLength:=64
+ TargetProjectID *string `json:"targetProjectID,omitempty"`
+}
+
+// RBACPolicyFilter defines an existing resource by its properties
+// +kubebuilder:validation:MinProperties:=1
+// +kubebuilder:validation:XValidation:rule="!(has(self.targetProjectRef) && has(self.targetProjectID))",message="only one of targetProjectRef and targetProjectID can be set"
+type RBACPolicyFilter struct {
+ // action of the existing resource
+ // +optional
+ Action *RBACPolicyAction `json:"action,omitempty"`
+
+ // targetProjectRef is a reference to the ORC Project of the existing resource's target
+ // +optional
+ // +orc:kustomize:ref=Project
+ TargetProjectRef *KubernetesNameRef `json:"targetProjectRef,omitempty"`
+
+ // targetProjectID of the existing resource
+ // +kubebuilder:validation:MinLength:=1
+ // +kubebuilder:validation:MaxLength:=64
+ // +optional
+ TargetProjectID *string `json:"targetProjectID,omitempty"`
+}
+
+// RBACPolicyResourceStatus represents the observed state of the resource.
+type RBACPolicyResourceStatus struct {
+ // networkID is the ID of the Network this policy applies to.
+ // +kubebuilder:validation:MaxLength=1024
+ // +optional
+ NetworkID string `json:"networkID,omitempty"`
+
+ // action is the type of access granted to targetProjectID.
+ // +kubebuilder:validation:MaxLength=1024
+ // +optional
+ Action string `json:"action,omitempty"`
+
+ // targetProjectID is the OpenStack project ID this policy grants access to.
+ // +kubebuilder:validation:MaxLength=1024
+ // +optional
+ TargetProjectID string `json:"targetProjectID,omitempty"`
+
+ // projectID is the ID of the project that owns this policy.
+ // +kubebuilder:validation:MaxLength=1024
+ // +optional
+ ProjectID string `json:"projectID,omitempty"`
+}
diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go
index 5a1115253..0a01cfccd 100644
--- a/api/v1alpha1/zz_generated.deepcopy.go
+++ b/api/v1alpha1/zz_generated.deepcopy.go
@@ -4478,6 +4478,232 @@ func (in *ProviderSegmentSpec) DeepCopy() *ProviderSegmentSpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RBACPolicy) DeepCopyInto(out *RBACPolicy) {
+ *out = *in
+ out.TypeMeta = in.TypeMeta
+ in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
+ in.Spec.DeepCopyInto(&out.Spec)
+ in.Status.DeepCopyInto(&out.Status)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBACPolicy.
+func (in *RBACPolicy) DeepCopy() *RBACPolicy {
+ if in == nil {
+ return nil
+ }
+ out := new(RBACPolicy)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+func (in *RBACPolicy) DeepCopyObject() runtime.Object {
+ if c := in.DeepCopy(); c != nil {
+ return c
+ }
+ return nil
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RBACPolicyFilter) DeepCopyInto(out *RBACPolicyFilter) {
+ *out = *in
+ if in.Action != nil {
+ in, out := &in.Action, &out.Action
+ *out = new(RBACPolicyAction)
+ **out = **in
+ }
+ if in.TargetProjectRef != nil {
+ in, out := &in.TargetProjectRef, &out.TargetProjectRef
+ *out = new(KubernetesNameRef)
+ **out = **in
+ }
+ if in.TargetProjectID != nil {
+ in, out := &in.TargetProjectID, &out.TargetProjectID
+ *out = new(string)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBACPolicyFilter.
+func (in *RBACPolicyFilter) DeepCopy() *RBACPolicyFilter {
+ if in == nil {
+ return nil
+ }
+ out := new(RBACPolicyFilter)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RBACPolicyImport) DeepCopyInto(out *RBACPolicyImport) {
+ *out = *in
+ if in.ID != nil {
+ in, out := &in.ID, &out.ID
+ *out = new(string)
+ **out = **in
+ }
+ if in.Filter != nil {
+ in, out := &in.Filter, &out.Filter
+ *out = new(RBACPolicyFilter)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBACPolicyImport.
+func (in *RBACPolicyImport) DeepCopy() *RBACPolicyImport {
+ if in == nil {
+ return nil
+ }
+ out := new(RBACPolicyImport)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RBACPolicyList) DeepCopyInto(out *RBACPolicyList) {
+ *out = *in
+ out.TypeMeta = in.TypeMeta
+ in.ListMeta.DeepCopyInto(&out.ListMeta)
+ if in.Items != nil {
+ in, out := &in.Items, &out.Items
+ *out = make([]RBACPolicy, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBACPolicyList.
+func (in *RBACPolicyList) DeepCopy() *RBACPolicyList {
+ if in == nil {
+ return nil
+ }
+ out := new(RBACPolicyList)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+func (in *RBACPolicyList) DeepCopyObject() runtime.Object {
+ if c := in.DeepCopy(); c != nil {
+ return c
+ }
+ return nil
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RBACPolicyResourceSpec) DeepCopyInto(out *RBACPolicyResourceSpec) {
+ *out = *in
+ if in.TargetProjectRef != nil {
+ in, out := &in.TargetProjectRef, &out.TargetProjectRef
+ *out = new(KubernetesNameRef)
+ **out = **in
+ }
+ if in.TargetProjectID != nil {
+ in, out := &in.TargetProjectID, &out.TargetProjectID
+ *out = new(string)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBACPolicyResourceSpec.
+func (in *RBACPolicyResourceSpec) DeepCopy() *RBACPolicyResourceSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(RBACPolicyResourceSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RBACPolicyResourceStatus) DeepCopyInto(out *RBACPolicyResourceStatus) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBACPolicyResourceStatus.
+func (in *RBACPolicyResourceStatus) DeepCopy() *RBACPolicyResourceStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(RBACPolicyResourceStatus)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RBACPolicySpec) DeepCopyInto(out *RBACPolicySpec) {
+ *out = *in
+ if in.Import != nil {
+ in, out := &in.Import, &out.Import
+ *out = new(RBACPolicyImport)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Resource != nil {
+ in, out := &in.Resource, &out.Resource
+ *out = new(RBACPolicyResourceSpec)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.ManagedOptions != nil {
+ in, out := &in.ManagedOptions, &out.ManagedOptions
+ *out = new(ManagedOptions)
+ **out = **in
+ }
+ if in.ResyncPeriod != nil {
+ in, out := &in.ResyncPeriod, &out.ResyncPeriod
+ *out = new(v1.Duration)
+ **out = **in
+ }
+ out.CloudCredentialsRef = in.CloudCredentialsRef
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBACPolicySpec.
+func (in *RBACPolicySpec) DeepCopy() *RBACPolicySpec {
+ if in == nil {
+ return nil
+ }
+ out := new(RBACPolicySpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *RBACPolicyStatus) DeepCopyInto(out *RBACPolicyStatus) {
+ *out = *in
+ if in.Conditions != nil {
+ in, out := &in.Conditions, &out.Conditions
+ *out = make([]v1.Condition, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.ID != nil {
+ in, out := &in.ID, &out.ID
+ *out = new(string)
+ **out = **in
+ }
+ if in.Resource != nil {
+ in, out := &in.Resource, &out.Resource
+ *out = new(RBACPolicyResourceStatus)
+ **out = **in
+ }
+ if in.LastSyncTime != nil {
+ in, out := &in.LastSyncTime, &out.LastSyncTime
+ *out = (*in).DeepCopy()
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBACPolicyStatus.
+func (in *RBACPolicyStatus) DeepCopy() *RBACPolicyStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(RBACPolicyStatus)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RecordSet) DeepCopyInto(out *RecordSet) {
*out = *in
diff --git a/api/v1alpha1/zz_generated.rbacpolicy-resource.go b/api/v1alpha1/zz_generated.rbacpolicy-resource.go
new file mode 100644
index 000000000..bdebabc65
--- /dev/null
+++ b/api/v1alpha1/zz_generated.rbacpolicy-resource.go
@@ -0,0 +1,194 @@
+// Code generated by resource-generator. DO NOT EDIT.
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1alpha1
+
+import (
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+)
+
+// RBACPolicyImport specifies an existing resource which will be imported instead of
+// creating a new one
+// +kubebuilder:validation:MinProperties:=1
+// +kubebuilder:validation:MaxProperties:=1
+type RBACPolicyImport struct {
+ // id contains the unique identifier of an existing OpenStack resource. Note
+ // that when specifying an import by ID, the resource MUST already exist.
+ // The ORC object will enter an error state if the resource does not exist.
+ // +kubebuilder:validation:Format:=uuid
+ // +kubebuilder:validation:MaxLength:=36
+ // +optional
+ ID *string `json:"id,omitempty"` //nolint:kubeapilinter
+
+ // filter contains a resource query which is expected to return a single
+ // result. The controller will continue to retry if filter returns no
+ // results. If filter returns multiple results the controller will set an
+ // error state and will not continue to retry.
+ // +optional
+ Filter *RBACPolicyFilter `json:"filter,omitempty"`
+}
+
+// RBACPolicySpec defines the desired state of an ORC object.
+// +kubebuilder:validation:XValidation:rule="self.managementPolicy == 'managed' ? has(self.resource) : true",message="resource must be specified when policy is managed"
+// +kubebuilder:validation:XValidation:rule="self.managementPolicy == 'managed' ? !has(self.__import__) : true",message="import may not be specified when policy is managed"
+// +kubebuilder:validation:XValidation:rule="self.managementPolicy == 'unmanaged' ? !has(self.resource) : true",message="resource may not be specified when policy is unmanaged"
+// +kubebuilder:validation:XValidation:rule="self.managementPolicy == 'unmanaged' ? has(self.__import__) : true",message="import must be specified when policy is unmanaged"
+// +kubebuilder:validation:XValidation:rule="has(self.managedOptions) ? self.managementPolicy == 'managed' : true",message="managedOptions may only be provided when policy is managed"
+type RBACPolicySpec struct {
+ // import refers to an existing OpenStack resource which will be imported instead of
+ // creating a new one.
+ // +optional
+ Import *RBACPolicyImport `json:"import,omitempty"`
+
+ // resource specifies the desired state of the resource.
+ //
+ // resource may not be specified if the management policy is `unmanaged`.
+ //
+ // resource must be specified if the management policy is `managed`.
+ // +optional
+ Resource *RBACPolicyResourceSpec `json:"resource,omitempty"`
+
+ // managementPolicy defines how ORC will treat the object. Valid values are
+ // `managed`: ORC will create, update, and delete the resource; `unmanaged`:
+ // ORC will import an existing resource, and will not apply updates to it or
+ // delete it.
+ // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="managementPolicy is immutable"
+ // +kubebuilder:default:=managed
+ // +optional
+ ManagementPolicy ManagementPolicy `json:"managementPolicy,omitempty"`
+
+ // managedOptions specifies options which may be applied to managed objects.
+ // +optional
+ ManagedOptions *ManagedOptions `json:"managedOptions,omitempty"`
+
+ // resyncPeriod defines how frequently the controller will re-reconcile
+ // this resource even when no changes have been detected. This overrides
+ // the global default resync period. The value must be a valid Go duration
+ // string, e.g. "10m", "1h". Set to "0s" to disable periodic resync for
+ // this resource. Very low values may cause excessive OpenStack API load.
+ // +optional
+ ResyncPeriod *metav1.Duration `json:"resyncPeriod,omitempty"` //nolint:kubeapilinter // metav1.Duration is appropriate for user-facing duration config
+
+ // cloudCredentialsRef points to a secret containing OpenStack credentials
+ // +required
+ CloudCredentialsRef CloudCredentialsReference `json:"cloudCredentialsRef,omitzero"`
+}
+
+// RBACPolicyStatus defines the observed state of an ORC resource.
+type RBACPolicyStatus struct {
+ // conditions represents the observed status of the object.
+ // Known .status.conditions.type are: "Available", "Progressing"
+ //
+ // Available represents the availability of the OpenStack resource. If it is
+ // true then the resource is ready for use.
+ //
+ // Progressing indicates whether the controller is still attempting to
+ // reconcile the current state of the OpenStack resource to the desired
+ // state. Progressing will be False either because the desired state has
+ // been achieved, or because some terminal error prevents it from ever being
+ // achieved and the controller is no longer attempting to reconcile. If
+ // Progressing is True, an observer waiting on the resource should continue
+ // to wait.
+ //
+ // +kubebuilder:validation:MaxItems:=32
+ // +patchMergeKey=type
+ // +patchStrategy=merge
+ // +listType=map
+ // +listMapKey=type
+ // +optional
+ Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
+
+ // id is the unique identifier of the OpenStack resource.
+ // +kubebuilder:validation:MaxLength:=1024
+ // +optional
+ ID *string `json:"id,omitempty"`
+
+ // resource contains the observed state of the OpenStack resource.
+ // +optional
+ Resource *RBACPolicyResourceStatus `json:"resource,omitempty"`
+
+ // lastSyncTime is the timestamp of the last successful reconciliation
+ // that fetched state from OpenStack. It is updated each time the
+ // controller successfully reads the resource state from the OpenStack
+ // API.
+ // +optional
+ LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
+}
+
+var _ ObjectWithConditions = &RBACPolicy{}
+
+func (i *RBACPolicy) GetConditions() []metav1.Condition {
+ return i.Status.Conditions
+}
+
+// +genclient
+// +kubebuilder:object:root=true
+// +kubebuilder:resource:categories=openstack
+// +kubebuilder:subresource:status
+// +kubebuilder:printcolumn:name="ID",type="string",JSONPath=".status.id",description="Resource ID"
+// +kubebuilder:printcolumn:name="Available",type="string",JSONPath=".status.conditions[?(@.type=='Available')].status",description="Availability status of resource"
+// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Progressing')].message",description="Message describing current progress status"
+
+// RBACPolicy is the Schema for an ORC resource.
+type RBACPolicy struct {
+ metav1.TypeMeta `json:",inline"`
+
+ // metadata contains the object metadata
+ // +optional
+ metav1.ObjectMeta `json:"metadata,omitempty"`
+
+ // spec specifies the desired state of the resource.
+ // +required
+ Spec RBACPolicySpec `json:"spec,omitzero"`
+
+ // status defines the observed state of the resource.
+ // +optional
+ Status RBACPolicyStatus `json:"status,omitempty"`
+}
+
+// +kubebuilder:object:root=true
+
+// RBACPolicyList contains a list of RBACPolicy.
+type RBACPolicyList struct {
+ metav1.TypeMeta `json:",inline"`
+
+ // metadata contains the list metadata
+ // +optional
+ metav1.ListMeta `json:"metadata,omitempty"`
+
+ // items contains a list of RBACPolicy.
+ // +required
+ Items []RBACPolicy `json:"items"`
+}
+
+func (l *RBACPolicyList) GetItems() []RBACPolicy {
+ return l.Items
+}
+
+func init() {
+ SchemeBuilder.Register(&RBACPolicy{}, &RBACPolicyList{})
+}
+
+func (i *RBACPolicy) GetCloudCredentialsRef() (*string, *CloudCredentialsReference) {
+ if i == nil {
+ return nil, nil
+ }
+
+ return &i.Namespace, &i.Spec.CloudCredentialsRef
+}
+
+var _ CloudCredentialsRefProvider = &RBACPolicy{}
diff --git a/charts/orc-crds/templates/aggregate-edit-clusterrole.yaml b/charts/orc-crds/templates/aggregate-edit-clusterrole.yaml
index 6f8fdd2a8..35d663f54 100644
--- a/charts/orc-crds/templates/aggregate-edit-clusterrole.yaml
+++ b/charts/orc-crds/templates/aggregate-edit-clusterrole.yaml
@@ -28,6 +28,7 @@ rules:
- networks
- ports
- projects
+ - rbacpolicies
- recordsets
- regions
- registeredlimits
diff --git a/charts/orc-crds/templates/aggregate-view-clusterrole.yaml b/charts/orc-crds/templates/aggregate-view-clusterrole.yaml
index 4cb4245a3..2dbf3648b 100644
--- a/charts/orc-crds/templates/aggregate-view-clusterrole.yaml
+++ b/charts/orc-crds/templates/aggregate-view-clusterrole.yaml
@@ -29,6 +29,7 @@ rules:
- networks
- ports
- projects
+ - rbacpolicies
- recordsets
- regions
- registeredlimits
@@ -68,6 +69,7 @@ rules:
- networks/status
- ports/status
- projects/status
+ - rbacpolicies/status
- recordsets/status
- regions/status
- registeredlimits/status
diff --git a/charts/orc/templates/rbac/manager-clusterrole.yaml b/charts/orc/templates/rbac/manager-clusterrole.yaml
index 03b46834f..f3e9a2142 100644
--- a/charts/orc/templates/rbac/manager-clusterrole.yaml
+++ b/charts/orc/templates/rbac/manager-clusterrole.yaml
@@ -35,6 +35,7 @@ rules:
- networks
- ports
- projects
+ - rbacpolicies
- recordsets
- regions
- registeredlimits
@@ -78,6 +79,7 @@ rules:
- networks/status
- ports/status
- projects/status
+ - rbacpolicies/status
- recordsets/status
- regions/status
- registeredlimits/status
diff --git a/cmd/manager/main.go b/cmd/manager/main.go
index b8c378db8..2115b2817 100644
--- a/cmd/manager/main.go
+++ b/cmd/manager/main.go
@@ -42,6 +42,7 @@ import (
"github.com/k-orc/openstack-resource-controller/v3/internal/controllers/network"
"github.com/k-orc/openstack-resource-controller/v3/internal/controllers/port"
"github.com/k-orc/openstack-resource-controller/v3/internal/controllers/project"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/controllers/rbacpolicy"
recordsetcontroller "github.com/k-orc/openstack-resource-controller/v3/internal/controllers/recordset"
"github.com/k-orc/openstack-resource-controller/v3/internal/controllers/region"
"github.com/k-orc/openstack-resource-controller/v3/internal/controllers/registeredlimit"
@@ -155,6 +156,7 @@ func main() {
role.New(scopeFactory),
roleassignment.New(scopeFactory),
limit.New(scopeFactory),
+ rbacpolicy.New(scopeFactory),
}
restConfig := ctrl.GetConfigOrDie()
diff --git a/cmd/models-schema/zz_generated.openapi.go b/cmd/models-schema/zz_generated.openapi.go
index 121cb3984..e9a5ed11d 100644
--- a/cmd/models-schema/zz_generated.openapi.go
+++ b/cmd/models-schema/zz_generated.openapi.go
@@ -177,6 +177,14 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.ProjectStatus": schema_openstack_resource_controller_v3_api_v1alpha1_ProjectStatus(ref),
"github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.ProviderPropertiesStatus": schema_openstack_resource_controller_v3_api_v1alpha1_ProviderPropertiesStatus(ref),
"github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.ProviderSegmentSpec": schema_openstack_resource_controller_v3_api_v1alpha1_ProviderSegmentSpec(ref),
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicy": schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicy(ref),
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyFilter": schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyFilter(ref),
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyImport": schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyImport(ref),
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyList": schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyList(ref),
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyResourceSpec": schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyResourceSpec(ref),
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyResourceStatus": schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyResourceStatus(ref),
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicySpec": schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicySpec(ref),
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyStatus": schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyStatus(ref),
"github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RecordSet": schema_openstack_resource_controller_v3_api_v1alpha1_RecordSet(ref),
"github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RecordSetFilter": schema_openstack_resource_controller_v3_api_v1alpha1_RecordSetFilter(ref),
"github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RecordSetImport": schema_openstack_resource_controller_v3_api_v1alpha1_RecordSetImport(ref),
@@ -8434,6 +8442,365 @@ func schema_openstack_resource_controller_v3_api_v1alpha1_ProviderSegmentSpec(re
}
}
+func schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicy(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "RBACPolicy is the Schema for an ORC resource.",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "kind": {
+ SchemaProps: spec.SchemaProps{
+ Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "apiVersion": {
+ SchemaProps: spec.SchemaProps{
+ Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "metadata": {
+ SchemaProps: spec.SchemaProps{
+ Description: "metadata contains the object metadata",
+ Default: map[string]interface{}{},
+ Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
+ },
+ },
+ "spec": {
+ SchemaProps: spec.SchemaProps{
+ Description: "spec specifies the desired state of the resource.",
+ Default: map[string]interface{}{},
+ Ref: ref("github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicySpec"),
+ },
+ },
+ "status": {
+ SchemaProps: spec.SchemaProps{
+ Description: "status defines the observed state of the resource.",
+ Default: map[string]interface{}{},
+ Ref: ref("github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyStatus"),
+ },
+ },
+ },
+ Required: []string{"spec"},
+ },
+ },
+ Dependencies: []string{
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicySpec", "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
+ }
+}
+
+func schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyFilter(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "RBACPolicyFilter defines an existing resource by its properties",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "action": {
+ SchemaProps: spec.SchemaProps{
+ Description: "action of the existing resource",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "targetProjectRef": {
+ SchemaProps: spec.SchemaProps{
+ Description: "targetProjectRef is a reference to the ORC Project of the existing resource's target",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "targetProjectID": {
+ SchemaProps: spec.SchemaProps{
+ Description: "targetProjectID of the existing resource",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ },
+ },
+ },
+ }
+}
+
+func schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyImport(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "RBACPolicyImport specifies an existing resource which will be imported instead of creating a new one",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "id": {
+ SchemaProps: spec.SchemaProps{
+ Description: "id contains the unique identifier of an existing OpenStack resource. Note that when specifying an import by ID, the resource MUST already exist. The ORC object will enter an error state if the resource does not exist.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "filter": {
+ SchemaProps: spec.SchemaProps{
+ Description: "filter contains a resource query which is expected to return a single result. The controller will continue to retry if filter returns no results. If filter returns multiple results the controller will set an error state and will not continue to retry.",
+ Ref: ref("github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyFilter"),
+ },
+ },
+ },
+ },
+ },
+ Dependencies: []string{
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyFilter"},
+ }
+}
+
+func schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyList(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "RBACPolicyList contains a list of RBACPolicy.",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "kind": {
+ SchemaProps: spec.SchemaProps{
+ Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "apiVersion": {
+ SchemaProps: spec.SchemaProps{
+ Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "metadata": {
+ SchemaProps: spec.SchemaProps{
+ Description: "metadata contains the list metadata",
+ Default: map[string]interface{}{},
+ Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
+ },
+ },
+ "items": {
+ SchemaProps: spec.SchemaProps{
+ Description: "items contains a list of RBACPolicy.",
+ Type: []string{"array"},
+ Items: &spec.SchemaOrArray{
+ Schema: &spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Default: map[string]interface{}{},
+ Ref: ref("github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicy"),
+ },
+ },
+ },
+ },
+ },
+ },
+ Required: []string{"items"},
+ },
+ },
+ Dependencies: []string{
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicy", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
+ }
+}
+
+func schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyResourceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "RBACPolicyResourceSpec contains the desired state of the resource. Only network policies are supported.",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "networkRef": {
+ SchemaProps: spec.SchemaProps{
+ Description: "networkRef is a reference to the ORC Network this policy grants access to.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "action": {
+ SchemaProps: spec.SchemaProps{
+ Description: "action is the type of access being granted to the target project.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "targetProjectRef": {
+ SchemaProps: spec.SchemaProps{
+ Description: "targetProjectRef is a reference to the ORC Project to grant access to.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "targetProjectID": {
+ SchemaProps: spec.SchemaProps{
+ Description: "targetProjectID is the ID of the project to grant access to, for when it can't be referenced: the target is another project, which the network owner's credentials usually can't read, so it can't be imported with them.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ },
+ Required: []string{"networkRef", "action"},
+ },
+ },
+ }
+}
+
+func schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyResourceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "RBACPolicyResourceStatus represents the observed state of the resource.",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "networkID": {
+ SchemaProps: spec.SchemaProps{
+ Description: "networkID is the ID of the Network this policy applies to.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "action": {
+ SchemaProps: spec.SchemaProps{
+ Description: "action is the type of access granted to targetProjectID.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "targetProjectID": {
+ SchemaProps: spec.SchemaProps{
+ Description: "targetProjectID is the OpenStack project ID this policy grants access to.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "projectID": {
+ SchemaProps: spec.SchemaProps{
+ Description: "projectID is the ID of the project that owns this policy.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ },
+ },
+ },
+ }
+}
+
+func schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicySpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "RBACPolicySpec defines the desired state of an ORC object.",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "import": {
+ SchemaProps: spec.SchemaProps{
+ Description: "import refers to an existing OpenStack resource which will be imported instead of creating a new one.",
+ Ref: ref("github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyImport"),
+ },
+ },
+ "resource": {
+ SchemaProps: spec.SchemaProps{
+ Description: "resource specifies the desired state of the resource.\n\nresource may not be specified if the management policy is `unmanaged`.\n\nresource must be specified if the management policy is `managed`.",
+ Ref: ref("github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyResourceSpec"),
+ },
+ },
+ "managementPolicy": {
+ SchemaProps: spec.SchemaProps{
+ Description: "managementPolicy defines how ORC will treat the object. Valid values are `managed`: ORC will create, update, and delete the resource; `unmanaged`: ORC will import an existing resource, and will not apply updates to it or delete it.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "managedOptions": {
+ SchemaProps: spec.SchemaProps{
+ Description: "managedOptions specifies options which may be applied to managed objects.",
+ Ref: ref("github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.ManagedOptions"),
+ },
+ },
+ "resyncPeriod": {
+ SchemaProps: spec.SchemaProps{
+ Description: "resyncPeriod defines how frequently the controller will re-reconcile this resource even when no changes have been detected. This overrides the global default resync period. The value must be a valid Go duration string, e.g. \"10m\", \"1h\". Set to \"0s\" to disable periodic resync for this resource. Very low values may cause excessive OpenStack API load.",
+ Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"),
+ },
+ },
+ "cloudCredentialsRef": {
+ SchemaProps: spec.SchemaProps{
+ Description: "cloudCredentialsRef points to a secret containing OpenStack credentials",
+ Default: map[string]interface{}{},
+ Ref: ref("github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.CloudCredentialsReference"),
+ },
+ },
+ },
+ Required: []string{"cloudCredentialsRef"},
+ },
+ },
+ Dependencies: []string{
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.CloudCredentialsReference", "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.ManagedOptions", "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyImport", "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyResourceSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration"},
+ }
+}
+
+func schema_openstack_resource_controller_v3_api_v1alpha1_RBACPolicyStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "RBACPolicyStatus defines the observed state of an ORC resource.",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "conditions": {
+ VendorExtensible: spec.VendorExtensible{
+ Extensions: spec.Extensions{
+ "x-kubernetes-list-map-keys": []interface{}{
+ "type",
+ },
+ "x-kubernetes-list-type": "map",
+ "x-kubernetes-patch-merge-key": "type",
+ "x-kubernetes-patch-strategy": "merge",
+ },
+ },
+ SchemaProps: spec.SchemaProps{
+ Description: "conditions represents the observed status of the object. Known .status.conditions.type are: \"Available\", \"Progressing\"\n\nAvailable represents the availability of the OpenStack resource. If it is true then the resource is ready for use.\n\nProgressing indicates whether the controller is still attempting to reconcile the current state of the OpenStack resource to the desired state. Progressing will be False either because the desired state has been achieved, or because some terminal error prevents it from ever being achieved and the controller is no longer attempting to reconcile. If Progressing is True, an observer waiting on the resource should continue to wait.",
+ Type: []string{"array"},
+ Items: &spec.SchemaOrArray{
+ Schema: &spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Default: map[string]interface{}{},
+ Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"),
+ },
+ },
+ },
+ },
+ },
+ "id": {
+ SchemaProps: spec.SchemaProps{
+ Description: "id is the unique identifier of the OpenStack resource.",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "resource": {
+ SchemaProps: spec.SchemaProps{
+ Description: "resource contains the observed state of the OpenStack resource.",
+ Ref: ref("github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyResourceStatus"),
+ },
+ },
+ "lastSyncTime": {
+ SchemaProps: spec.SchemaProps{
+ Description: "lastSyncTime is the timestamp of the last successful reconciliation that fetched state from OpenStack. It is updated each time the controller successfully reads the resource state from the OpenStack API.",
+ Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"),
+ },
+ },
+ },
+ },
+ },
+ Dependencies: []string{
+ "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1.RBACPolicyResourceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"},
+ }
+}
+
func schema_openstack_resource_controller_v3_api_v1alpha1_RecordSet(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
diff --git a/cmd/resource-generator/main.go b/cmd/resource-generator/main.go
index 24a0d1f54..228208b1b 100644
--- a/cmd/resource-generator/main.go
+++ b/cmd/resource-generator/main.go
@@ -149,6 +149,13 @@ var resources []templateFields = []templateFields{
Name: "Project",
ExistingOSClient: true,
},
+ {
+ // RBACPolicy has no name/description in Neutron's API (gophercloud's RBACPolicy
+ // struct has neither) - same reasoning as FloatingIP above.
+ Name: "RBACPolicy",
+ IsNotNamed: true,
+ ExistingOSClient: true,
+ },
{
Name: "Role",
},
diff --git a/config/crd/bases/openstack.k-orc.cloud_rbacpolicies.yaml b/config/crd/bases/openstack.k-orc.cloud_rbacpolicies.yaml
new file mode 100644
index 000000000..6a69e9c56
--- /dev/null
+++ b/config/crd/bases/openstack.k-orc.cloud_rbacpolicies.yaml
@@ -0,0 +1,350 @@
+---
+apiVersion: apiextensions.k8s.io/v1
+kind: CustomResourceDefinition
+metadata:
+ annotations:
+ controller-gen.kubebuilder.io/version: v0.20.1
+ name: rbacpolicies.openstack.k-orc.cloud
+spec:
+ group: openstack.k-orc.cloud
+ names:
+ categories:
+ - openstack
+ kind: RBACPolicy
+ listKind: RBACPolicyList
+ plural: rbacpolicies
+ singular: rbacpolicy
+ scope: Namespaced
+ versions:
+ - additionalPrinterColumns:
+ - description: Resource ID
+ jsonPath: .status.id
+ name: ID
+ type: string
+ - description: Availability status of resource
+ jsonPath: .status.conditions[?(@.type=='Available')].status
+ name: Available
+ type: string
+ - description: Message describing current progress status
+ jsonPath: .status.conditions[?(@.type=='Progressing')].message
+ name: Message
+ type: string
+ name: v1alpha1
+ schema:
+ openAPIV3Schema:
+ description: RBACPolicy is the Schema for an ORC resource.
+ properties:
+ apiVersion:
+ description: |-
+ APIVersion defines the versioned schema of this representation of an object.
+ Servers should convert recognized schemas to the latest internal value, and
+ may reject unrecognized values.
+ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
+ type: string
+ kind:
+ description: |-
+ Kind is a string value representing the REST resource this object represents.
+ Servers may infer this from the endpoint the client submits requests to.
+ Cannot be updated.
+ In CamelCase.
+ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
+ type: string
+ metadata:
+ type: object
+ spec:
+ description: spec specifies the desired state of the resource.
+ properties:
+ cloudCredentialsRef:
+ description: cloudCredentialsRef points to a secret containing OpenStack
+ credentials
+ properties:
+ cloudName:
+ description: cloudName specifies the name of the entry in the
+ clouds.yaml file to use.
+ maxLength: 256
+ minLength: 1
+ type: string
+ secretName:
+ description: |-
+ secretName is the name of a secret in the same namespace as the resource being provisioned.
+ The secret must contain a key named `clouds.yaml` which contains an OpenStack clouds.yaml file.
+ The secret may optionally contain a key named `cacert` containing a PEM-encoded CA certificate.
+ maxLength: 253
+ minLength: 1
+ type: string
+ required:
+ - cloudName
+ - secretName
+ type: object
+ import:
+ description: |-
+ import refers to an existing OpenStack resource which will be imported instead of
+ creating a new one.
+ maxProperties: 1
+ minProperties: 1
+ properties:
+ filter:
+ description: |-
+ filter contains a resource query which is expected to return a single
+ result. The controller will continue to retry if filter returns no
+ results. If filter returns multiple results the controller will set an
+ error state and will not continue to retry.
+ minProperties: 1
+ properties:
+ action:
+ description: action of the existing resource
+ enum:
+ - access_as_shared
+ - access_as_external
+ type: string
+ targetProjectID:
+ description: targetProjectID of the existing resource
+ maxLength: 64
+ minLength: 1
+ type: string
+ targetProjectRef:
+ description: targetProjectRef is a reference to the ORC Project
+ of the existing resource's target
+ maxLength: 253
+ minLength: 1
+ type: string
+ type: object
+ x-kubernetes-validations:
+ - message: only one of targetProjectRef and targetProjectID can
+ be set
+ rule: '!(has(self.targetProjectRef) && has(self.targetProjectID))'
+ id:
+ description: |-
+ id contains the unique identifier of an existing OpenStack resource. Note
+ that when specifying an import by ID, the resource MUST already exist.
+ The ORC object will enter an error state if the resource does not exist.
+ format: uuid
+ maxLength: 36
+ type: string
+ type: object
+ managedOptions:
+ description: managedOptions specifies options which may be applied
+ to managed objects.
+ properties:
+ onDelete:
+ default: delete
+ description: |-
+ onDelete specifies the behaviour of the controller when the ORC
+ object is deleted. Options are `delete` - delete the OpenStack resource;
+ `detach` - do not delete the OpenStack resource. If not specified, the
+ default is `delete`.
+ enum:
+ - delete
+ - detach
+ type: string
+ type: object
+ managementPolicy:
+ default: managed
+ description: |-
+ managementPolicy defines how ORC will treat the object. Valid values are
+ `managed`: ORC will create, update, and delete the resource; `unmanaged`:
+ ORC will import an existing resource, and will not apply updates to it or
+ delete it.
+ enum:
+ - managed
+ - unmanaged
+ type: string
+ x-kubernetes-validations:
+ - message: managementPolicy is immutable
+ rule: self == oldSelf
+ resource:
+ description: |-
+ resource specifies the desired state of the resource.
+
+ resource may not be specified if the management policy is `unmanaged`.
+
+ resource must be specified if the management policy is `managed`.
+ properties:
+ action:
+ description: action is the type of access being granted to the
+ target project.
+ enum:
+ - access_as_shared
+ - access_as_external
+ type: string
+ x-kubernetes-validations:
+ - message: action is immutable
+ rule: self == oldSelf
+ networkRef:
+ description: networkRef is a reference to the ORC Network this
+ policy grants access to.
+ maxLength: 253
+ minLength: 1
+ type: string
+ x-kubernetes-validations:
+ - message: networkRef is immutable
+ rule: self == oldSelf
+ targetProjectID:
+ description: |-
+ targetProjectID is the ID of the project to grant access to, for when it can't be
+ referenced: the target is another project, which the network owner's credentials usually
+ can't read, so it can't be imported with them.
+ maxLength: 64
+ minLength: 1
+ type: string
+ targetProjectRef:
+ description: targetProjectRef is a reference to the ORC Project
+ to grant access to.
+ maxLength: 253
+ minLength: 1
+ type: string
+ required:
+ - action
+ - networkRef
+ type: object
+ x-kubernetes-validations:
+ - message: exactly one of targetProjectRef and targetProjectID must
+ be set
+ rule: has(self.targetProjectRef) != has(self.targetProjectID)
+ resyncPeriod:
+ description: |-
+ resyncPeriod defines how frequently the controller will re-reconcile
+ this resource even when no changes have been detected. This overrides
+ the global default resync period. The value must be a valid Go duration
+ string, e.g. "10m", "1h". Set to "0s" to disable periodic resync for
+ this resource. Very low values may cause excessive OpenStack API load.
+ type: string
+ required:
+ - cloudCredentialsRef
+ type: object
+ x-kubernetes-validations:
+ - message: resource must be specified when policy is managed
+ rule: 'self.managementPolicy == ''managed'' ? has(self.resource) : true'
+ - message: import may not be specified when policy is managed
+ rule: 'self.managementPolicy == ''managed'' ? !has(self.__import__)
+ : true'
+ - message: resource may not be specified when policy is unmanaged
+ rule: 'self.managementPolicy == ''unmanaged'' ? !has(self.resource)
+ : true'
+ - message: import must be specified when policy is unmanaged
+ rule: 'self.managementPolicy == ''unmanaged'' ? has(self.__import__)
+ : true'
+ - message: managedOptions may only be provided when policy is managed
+ rule: 'has(self.managedOptions) ? self.managementPolicy == ''managed''
+ : true'
+ status:
+ description: status defines the observed state of the resource.
+ properties:
+ conditions:
+ description: |-
+ conditions represents the observed status of the object.
+ Known .status.conditions.type are: "Available", "Progressing"
+
+ Available represents the availability of the OpenStack resource. If it is
+ true then the resource is ready for use.
+
+ Progressing indicates whether the controller is still attempting to
+ reconcile the current state of the OpenStack resource to the desired
+ state. Progressing will be False either because the desired state has
+ been achieved, or because some terminal error prevents it from ever being
+ achieved and the controller is no longer attempting to reconcile. If
+ Progressing is True, an observer waiting on the resource should continue
+ to wait.
+ items:
+ description: Condition contains details for one aspect of the current
+ state of this API Resource.
+ properties:
+ lastTransitionTime:
+ description: |-
+ lastTransitionTime is the last time the condition transitioned from one status to another.
+ This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
+ format: date-time
+ type: string
+ message:
+ description: |-
+ message is a human readable message indicating details about the transition.
+ This may be an empty string.
+ maxLength: 32768
+ type: string
+ observedGeneration:
+ description: |-
+ observedGeneration represents the .metadata.generation that the condition was set based upon.
+ For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
+ with respect to the current state of the instance.
+ format: int64
+ minimum: 0
+ type: integer
+ reason:
+ description: |-
+ reason contains a programmatic identifier indicating the reason for the condition's last transition.
+ Producers of specific condition types may define expected values and meanings for this field,
+ and whether the values are considered a guaranteed API.
+ The value should be a CamelCase string.
+ This field may not be empty.
+ maxLength: 1024
+ minLength: 1
+ pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
+ type: string
+ status:
+ description: status of the condition, one of True, False, Unknown.
+ enum:
+ - "True"
+ - "False"
+ - Unknown
+ type: string
+ type:
+ description: type of condition in CamelCase or in foo.example.com/CamelCase.
+ maxLength: 316
+ pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
+ type: string
+ required:
+ - lastTransitionTime
+ - message
+ - reason
+ - status
+ - type
+ type: object
+ maxItems: 32
+ type: array
+ x-kubernetes-list-map-keys:
+ - type
+ x-kubernetes-list-type: map
+ id:
+ description: id is the unique identifier of the OpenStack resource.
+ maxLength: 1024
+ type: string
+ lastSyncTime:
+ description: |-
+ lastSyncTime is the timestamp of the last successful reconciliation
+ that fetched state from OpenStack. It is updated each time the
+ controller successfully reads the resource state from the OpenStack
+ API.
+ format: date-time
+ type: string
+ resource:
+ description: resource contains the observed state of the OpenStack
+ resource.
+ properties:
+ action:
+ description: action is the type of access granted to targetProjectID.
+ maxLength: 1024
+ type: string
+ networkID:
+ description: networkID is the ID of the Network this policy applies
+ to.
+ maxLength: 1024
+ type: string
+ projectID:
+ description: projectID is the ID of the project that owns this
+ policy.
+ maxLength: 1024
+ type: string
+ targetProjectID:
+ description: targetProjectID is the OpenStack project ID this
+ policy grants access to.
+ maxLength: 1024
+ type: string
+ type: object
+ type: object
+ required:
+ - spec
+ type: object
+ served: true
+ storage: true
+ subresources:
+ status: {}
diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml
index d57614d47..018bd9605 100644
--- a/config/crd/kustomization.yaml
+++ b/config/crd/kustomization.yaml
@@ -17,6 +17,7 @@ resources:
- bases/openstack.k-orc.cloud_networks.yaml
- bases/openstack.k-orc.cloud_ports.yaml
- bases/openstack.k-orc.cloud_projects.yaml
+- bases/openstack.k-orc.cloud_rbacpolicies.yaml
- bases/openstack.k-orc.cloud_recordsets.yaml
- bases/openstack.k-orc.cloud_regions.yaml
- bases/openstack.k-orc.cloud_registeredlimits.yaml
diff --git a/config/manifests/bases/orc.clusterserviceversion.yaml b/config/manifests/bases/orc.clusterserviceversion.yaml
index 7b9f1e3ed..0744f1860 100644
--- a/config/manifests/bases/orc.clusterserviceversion.yaml
+++ b/config/manifests/bases/orc.clusterserviceversion.yaml
@@ -94,6 +94,11 @@ spec:
kind: Project
name: projects.openstack.k-orc.cloud
version: v1alpha1
+ - description: RBACPolicy is the Schema for an ORC resource.
+ displayName: RBACPolicy
+ kind: RBACPolicy
+ name: rbacpolicies.openstack.k-orc.cloud
+ version: v1alpha1
- description: RecordSet is the Schema for an ORC resource.
displayName: Record Set
kind: RecordSet
diff --git a/config/rbac/aggregate_edit_role.yaml b/config/rbac/aggregate_edit_role.yaml
index 2bcd2209a..c834e6336 100644
--- a/config/rbac/aggregate_edit_role.yaml
+++ b/config/rbac/aggregate_edit_role.yaml
@@ -28,6 +28,7 @@ rules:
- networks
- ports
- projects
+ - rbacpolicies
- recordsets
- regions
- registeredlimits
diff --git a/config/rbac/aggregate_view_role.yaml b/config/rbac/aggregate_view_role.yaml
index b8bcfadbc..f16d47cc5 100644
--- a/config/rbac/aggregate_view_role.yaml
+++ b/config/rbac/aggregate_view_role.yaml
@@ -31,6 +31,7 @@ rules:
- networks
- ports
- projects
+ - rbacpolicies
- recordsets
- regions
- registeredlimits
@@ -70,6 +71,7 @@ rules:
- networks/status
- ports/status
- projects/status
+ - rbacpolicies/status
- recordsets/status
- regions/status
- registeredlimits/status
diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml
index 7741c2e26..b87e438e9 100644
--- a/config/rbac/role.yaml
+++ b/config/rbac/role.yaml
@@ -31,6 +31,7 @@ rules:
- networks
- ports
- projects
+ - rbacpolicies
- recordsets
- regions
- registeredlimits
@@ -74,6 +75,7 @@ rules:
- networks/status
- ports/status
- projects/status
+ - rbacpolicies/status
- recordsets/status
- regions/status
- registeredlimits/status
diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml
index 62554df60..72c5eabf6 100644
--- a/config/samples/kustomization.yaml
+++ b/config/samples/kustomization.yaml
@@ -15,6 +15,7 @@ resources:
- openstack_v1alpha1_network.yaml
- openstack_v1alpha1_port.yaml
- openstack_v1alpha1_project.yaml
+- openstack_v1alpha1_rbacpolicy.yaml
- openstack_v1alpha1_recordset.yaml
- openstack_v1alpha1_region.yaml
- openstack_v1alpha1_registeredlimit.yaml
diff --git a/config/samples/openstack_v1alpha1_rbacpolicy.yaml b/config/samples/openstack_v1alpha1_rbacpolicy.yaml
new file mode 100644
index 000000000..a22eda167
--- /dev/null
+++ b/config/samples/openstack_v1alpha1_rbacpolicy.yaml
@@ -0,0 +1,14 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-sample
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: network-sample
+ action: access_as_shared
+ targetProjectRef: project-sample
diff --git a/examples/components/kustomizeconfig/kustomizeconfig.yaml b/examples/components/kustomizeconfig/kustomizeconfig.yaml
index 51546f908..7b775c577 100644
--- a/examples/components/kustomizeconfig/kustomizeconfig.yaml
+++ b/examples/components/kustomizeconfig/kustomizeconfig.yaml
@@ -76,6 +76,8 @@ nameReference:
path: spec/import/filter/networkRef
- kind: Port
path: spec/resource/networkRef
+ - kind: RBACPolicy
+ path: spec/resource/networkRef
- kind: Router
path: spec/resource/externalGateways[]/networkRef
- kind: ShareNetwork
@@ -122,6 +124,10 @@ nameReference:
path: spec/import/filter/projectRef
- kind: Port
path: spec/resource/projectRef
+ - kind: RBACPolicy
+ path: spec/import/filter/targetProjectRef
+ - kind: RBACPolicy
+ path: spec/resource/targetProjectRef
- kind: RoleAssignment
path: spec/import/filter/projectRef
- kind: RoleAssignment
@@ -208,6 +214,8 @@ nameReference:
path: spec/cloudCredentialsRef/secretName
- kind: Project
path: spec/cloudCredentialsRef/secretName
+ - kind: RBACPolicy
+ path: spec/cloudCredentialsRef/secretName
- kind: RecordSet
path: spec/cloudCredentialsRef/secretName
- kind: Region
diff --git a/internal/controllers/rbacpolicy/actuator.go b/internal/controllers/rbacpolicy/actuator.go
new file mode 100644
index 000000000..dcf99b455
--- /dev/null
+++ b/internal/controllers/rbacpolicy/actuator.go
@@ -0,0 +1,234 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package rbacpolicy
+
+import (
+ "context"
+ "iter"
+
+ "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/rbacpolicies"
+ corev1 "k8s.io/api/core/v1"
+ "k8s.io/utils/ptr"
+ ctrl "sigs.k8s.io/controller-runtime"
+ "sigs.k8s.io/controller-runtime/pkg/client"
+
+ orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/controllers/generic/interfaces"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/controllers/generic/progress"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/logging"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/osclients"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/util/dependency"
+ orcerrors "github.com/k-orc/openstack-resource-controller/v3/internal/util/errors"
+)
+
+const objectTypeNetwork = "network"
+
+// OpenStack resource types
+type (
+ osResourceT = rbacpolicies.RBACPolicy
+
+ createResourceActuator = interfaces.CreateResourceActuator[orcObjectPT, orcObjectT, filterT, osResourceT]
+ deleteResourceActuator = interfaces.DeleteResourceActuator[orcObjectPT, orcObjectT, osResourceT]
+ resourceReconciler = interfaces.ResourceReconciler[orcObjectPT, osResourceT]
+ helperFactory = interfaces.ResourceHelperFactory[orcObjectPT, orcObjectT, resourceSpecT, filterT, osResourceT]
+)
+
+type rbacpolicyActuator struct {
+ osClient osclients.NetworkClient
+ k8sClient client.Client
+}
+
+var _ createResourceActuator = rbacpolicyActuator{}
+var _ deleteResourceActuator = rbacpolicyActuator{}
+
+func (rbacpolicyActuator) GetResourceID(osResource *osResourceT) string {
+ return osResource.ID
+}
+
+func (actuator rbacpolicyActuator) GetOSResourceByID(ctx context.Context, id string) (*osResourceT, progress.ReconcileStatus) {
+ resource, err := actuator.osClient.GetRBACPolicy(ctx, id)
+ if err != nil {
+ return nil, progress.WrapError(err)
+ }
+ return resource, nil
+}
+
+func (actuator rbacpolicyActuator) ListOSResourcesForAdoption(ctx context.Context, orcObject orcObjectPT) (iter.Seq2[*osResourceT, error], bool) {
+ resourceSpec := orcObject.Spec.Resource
+ if resourceSpec == nil {
+ return nil, false
+ }
+
+ network, rs := dependency.FetchDependency[*orcv1alpha1.Network](
+ ctx, actuator.k8sClient, orcObject.Namespace, &resourceSpec.NetworkRef, "Network",
+ orcv1alpha1.IsAvailable,
+ )
+ if needsReschedule, _ := rs.NeedsReschedule(); needsReschedule {
+ return nil, false
+ }
+
+ targetProjectID, rs := actuator.targetProjectID(ctx, orcObject)
+ if needsReschedule, _ := rs.NeedsReschedule(); needsReschedule {
+ return nil, false
+ }
+
+ listOpts := rbacpolicies.ListOpts{
+ ObjectType: objectTypeNetwork,
+ ObjectID: ptr.Deref(network.Status.ID, ""),
+ Action: rbacpolicies.PolicyAction(resourceSpec.Action),
+ TargetTenant: targetProjectID,
+ }
+
+ return actuator.osClient.ListRBACPolicy(ctx, listOpts), true
+}
+
+// targetProjectID returns spec.resource.targetProjectID, or the ID of the referenced Project.
+func (actuator rbacpolicyActuator) targetProjectID(ctx context.Context, obj orcObjectPT) (string, progress.ReconcileStatus) {
+ resource := obj.Spec.Resource
+ if resource.TargetProjectID != nil {
+ return *resource.TargetProjectID, nil
+ }
+ project, rs := projectDependency.RequireDependency(ctx, actuator.k8sClient, obj, orcv1alpha1.IsAvailable)
+ if needsReschedule, _ := rs.NeedsReschedule(); needsReschedule {
+ return "", rs
+ }
+ return ptr.Deref(project.Status.ID, ""), nil
+}
+
+func (actuator rbacpolicyActuator) ListOSResourcesForImport(ctx context.Context, obj orcObjectPT, filter filterT) (iter.Seq2[*osResourceT, error], progress.ReconcileStatus) {
+ project, rs := dependency.FetchDependency[*orcv1alpha1.Project](
+ ctx, actuator.k8sClient, obj.Namespace, filter.TargetProjectRef, "Project",
+ orcv1alpha1.IsAvailable,
+ )
+ if needsReschedule, _ := rs.NeedsReschedule(); needsReschedule {
+ return nil, rs
+ }
+
+ listOpts := rbacpolicies.ListOpts{
+ ObjectType: objectTypeNetwork,
+ Action: rbacpolicies.PolicyAction(ptr.Deref(filter.Action, "")),
+ TargetTenant: ptr.Deref(filter.TargetProjectID, ptr.Deref(project.Status.ID, "")),
+ }
+
+ return actuator.osClient.ListRBACPolicy(ctx, listOpts), nil
+}
+
+func (actuator rbacpolicyActuator) CreateResource(ctx context.Context, obj orcObjectPT) (*osResourceT, progress.ReconcileStatus) {
+ resource := obj.Spec.Resource
+
+ network, reconcileStatus := networkDependency.RequireDependency(
+ ctx, actuator.k8sClient, obj, orcv1alpha1.IsAvailable,
+ )
+ targetProjectID, rs := actuator.targetProjectID(ctx, obj)
+ reconcileStatus = reconcileStatus.WithReconcileStatus(rs)
+ if needsReschedule, _ := reconcileStatus.NeedsReschedule(); needsReschedule {
+ return nil, reconcileStatus
+ }
+
+ createOpts := rbacpolicies.CreateOpts{
+ Action: rbacpolicies.PolicyAction(resource.Action),
+ ObjectType: objectTypeNetwork,
+ ObjectID: ptr.Deref(network.Status.ID, ""),
+ TargetTenant: targetProjectID,
+ }
+
+ osResource, err := actuator.osClient.CreateRBACPolicy(ctx, createOpts)
+ if err != nil {
+ if !orcerrors.IsRetryable(err) {
+ err = orcerrors.Terminal(orcv1alpha1.ConditionReasonInvalidConfiguration, "invalid configuration creating resource: "+err.Error(), err)
+ }
+ return nil, progress.WrapError(err)
+ }
+
+ return osResource, nil
+}
+
+func (actuator rbacpolicyActuator) DeleteResource(ctx context.Context, _ orcObjectPT, resource *osResourceT) progress.ReconcileStatus {
+ return progress.WrapError(actuator.osClient.DeleteRBACPolicy(ctx, resource.ID))
+}
+
+// The target project is the only field Neutron allows updating.
+func (actuator rbacpolicyActuator) updateResource(ctx context.Context, obj orcObjectPT, osResource *osResourceT) progress.ReconcileStatus {
+ log := ctrl.LoggerFrom(ctx)
+
+ targetProjectID, rs := actuator.targetProjectID(ctx, obj)
+ if needsReschedule, _ := rs.NeedsReschedule(); needsReschedule {
+ return rs
+ }
+
+ if osResource.TargetTenant == targetProjectID {
+ log.V(logging.Debug).Info("No changes")
+ return nil
+ }
+
+ updateOpts := rbacpolicies.UpdateOpts{TargetTenant: targetProjectID}
+ _, err := actuator.osClient.UpdateRBACPolicy(ctx, osResource.ID, updateOpts)
+ if err != nil {
+ if !orcerrors.IsRetryable(err) {
+ err = orcerrors.Terminal(orcv1alpha1.ConditionReasonInvalidConfiguration, "invalid configuration updating resource: "+err.Error(), err)
+ }
+ return progress.WrapError(err)
+ }
+
+ return progress.NeedsRefresh()
+}
+
+func (actuator rbacpolicyActuator) GetResourceReconcilers(ctx context.Context, orcObject orcObjectPT, osResource *osResourceT, controller interfaces.ResourceController) ([]resourceReconciler, progress.ReconcileStatus) {
+ return []resourceReconciler{
+ actuator.updateResource,
+ }, nil
+}
+
+type rbacpolicyHelperFactory struct{}
+
+var _ helperFactory = rbacpolicyHelperFactory{}
+
+func newActuator(ctx context.Context, orcObject *orcv1alpha1.RBACPolicy, controller interfaces.ResourceController) (rbacpolicyActuator, progress.ReconcileStatus) {
+ log := ctrl.LoggerFrom(ctx)
+
+ // Ensure credential secrets exist and have our finalizer
+ _, reconcileStatus := credentialsDependency.RequireDependencies(ctx, controller.GetK8sClient(), orcObject, func(*corev1.Secret) bool { return true })
+ if needsReschedule, _ := reconcileStatus.NeedsReschedule(); needsReschedule {
+ return rbacpolicyActuator{}, reconcileStatus
+ }
+
+ clientScope, err := controller.GetScopeFactory().NewClientScopeFromObject(ctx, controller.GetK8sClient(), log, orcObject)
+ if err != nil {
+ return rbacpolicyActuator{}, progress.WrapError(err)
+ }
+ osClient, err := clientScope.NewNetworkClient()
+ if err != nil {
+ return rbacpolicyActuator{}, progress.WrapError(err)
+ }
+
+ return rbacpolicyActuator{
+ osClient: osClient,
+ k8sClient: controller.GetK8sClient(),
+ }, nil
+}
+
+func (rbacpolicyHelperFactory) NewAPIObjectAdapter(obj orcObjectPT) adapterI {
+ return rbacpolicyAdapter{obj}
+}
+
+func (rbacpolicyHelperFactory) NewCreateActuator(ctx context.Context, orcObject orcObjectPT, controller interfaces.ResourceController) (createResourceActuator, progress.ReconcileStatus) {
+ return newActuator(ctx, orcObject, controller)
+}
+
+func (rbacpolicyHelperFactory) NewDeleteActuator(ctx context.Context, orcObject orcObjectPT, controller interfaces.ResourceController) (deleteResourceActuator, progress.ReconcileStatus) {
+ return newActuator(ctx, orcObject, controller)
+}
diff --git a/internal/controllers/rbacpolicy/actuator_test.go b/internal/controllers/rbacpolicy/actuator_test.go
new file mode 100644
index 000000000..c593f4f0f
--- /dev/null
+++ b/internal/controllers/rbacpolicy/actuator_test.go
@@ -0,0 +1,122 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package rbacpolicy
+
+import (
+ "context"
+ "errors"
+ "testing"
+
+ "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/rbacpolicies"
+ "go.uber.org/mock/gomock"
+ "k8s.io/utils/ptr"
+
+ orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/osclients/mock"
+)
+
+func Test_rbacpolicyActuator_updateResource(t *testing.T) {
+ const (
+ policyID = "939da9ca-27c2-4fa6-881f-17f9038f8107"
+ )
+
+ updateError := errors.New("test update error")
+
+ orcObjectWithTarget := func(targetProjectID string) orcObjectPT {
+ return &orcv1alpha1.RBACPolicy{
+ Spec: orcv1alpha1.RBACPolicySpec{
+ Resource: &orcv1alpha1.RBACPolicyResourceSpec{
+ Action: orcv1alpha1.RBACPolicyActionAccessShared,
+ TargetProjectID: ptr.To(targetProjectID),
+ },
+ },
+ }
+ }
+
+ osResourceWithTarget := func(targetProjectID string) *osResourceT {
+ return &rbacpolicies.RBACPolicy{
+ ID: policyID,
+ Action: rbacpolicies.ActionAccessShared,
+ TargetTenant: targetProjectID,
+ }
+ }
+
+ tests := []struct {
+ name string
+ orcObject orcObjectPT
+ osResource *osResourceT
+ expect func(*mock.MockNetworkClientMockRecorder)
+ wantReschedule bool
+ wantErr error
+ }{
+ {
+ name: "target project unchanged, no update call",
+ orcObject: orcObjectWithTarget("project-a"),
+ osResource: osResourceWithTarget("project-a"),
+ },
+ {
+ name: "target project changed, calls UpdateRBACPolicy",
+ orcObject: orcObjectWithTarget("project-b"),
+ osResource: osResourceWithTarget("project-a"),
+ expect: func(recorder *mock.MockNetworkClientMockRecorder) {
+ recorder.UpdateRBACPolicy(gomock.Any(), policyID, rbacpolicies.UpdateOpts{TargetTenant: "project-b"}).
+ Return(nil, nil)
+ },
+ wantReschedule: true,
+ },
+ {
+ name: "update error is propagated",
+ orcObject: orcObjectWithTarget("project-b"),
+ osResource: osResourceWithTarget("project-a"),
+ expect: func(recorder *mock.MockNetworkClientMockRecorder) {
+ recorder.UpdateRBACPolicy(gomock.Any(), policyID, rbacpolicies.UpdateOpts{TargetTenant: "project-b"}).
+ Return(nil, updateError)
+ },
+ // A plain error (not classified non-retryable by orcerrors.IsRetryable)
+ // defaults to retryable, so the generic reconciler still reschedules.
+ wantReschedule: true,
+ wantErr: updateError,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ mockctrl := gomock.NewController(t)
+ networkClient := mock.NewMockNetworkClient(mockctrl)
+
+ actuator := rbacpolicyActuator{osClient: networkClient}
+
+ recorder := networkClient.EXPECT()
+ if tt.expect != nil {
+ tt.expect(recorder)
+ }
+
+ reconcileStatus := actuator.updateResource(context.TODO(), tt.orcObject, tt.osResource)
+ needsReschedule, err := reconcileStatus.NeedsReschedule()
+
+ if tt.wantErr == nil && err != nil {
+ t.Errorf("updateResource() error = %v, want no error", err)
+ }
+ if tt.wantErr != nil && !errors.Is(err, tt.wantErr) {
+ t.Errorf("updateResource() error = %v, want %v", err, tt.wantErr)
+ }
+ if needsReschedule != tt.wantReschedule {
+ t.Errorf("updateResource() needsReschedule = %v, want %v", needsReschedule, tt.wantReschedule)
+ }
+ })
+ }
+}
diff --git a/internal/controllers/rbacpolicy/controller.go b/internal/controllers/rbacpolicy/controller.go
new file mode 100644
index 000000000..ec3bfaa48
--- /dev/null
+++ b/internal/controllers/rbacpolicy/controller.go
@@ -0,0 +1,139 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package rbacpolicy
+
+import (
+ "context"
+ "errors"
+ "time"
+
+ ctrl "sigs.k8s.io/controller-runtime"
+ "sigs.k8s.io/controller-runtime/pkg/builder"
+ "sigs.k8s.io/controller-runtime/pkg/controller"
+
+ orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+
+ "github.com/k-orc/openstack-resource-controller/v3/internal/controllers/generic/interfaces"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/controllers/generic/reconciler"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/scope"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/util/credentials"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/util/dependency"
+ "github.com/k-orc/openstack-resource-controller/v3/pkg/predicates"
+)
+
+const controllerName = "rbacpolicy"
+
+// +kubebuilder:rbac:groups=openstack.k-orc.cloud,resources=rbacpolicies,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=openstack.k-orc.cloud,resources=rbacpolicies/status,verbs=get;update;patch
+
+type rbacpolicyReconcilerConstructor struct {
+ scopeFactory scope.Factory
+ defaultResyncPeriod time.Duration
+}
+
+func New(scopeFactory scope.Factory) interfaces.Controller {
+ return &rbacpolicyReconcilerConstructor{scopeFactory: scopeFactory}
+}
+
+func (rbacpolicyReconcilerConstructor) GetName() string {
+ return controllerName
+}
+
+func (c *rbacpolicyReconcilerConstructor) SetDefaultResyncPeriod(d time.Duration) {
+ c.defaultResyncPeriod = d
+}
+
+var networkDependency = dependency.NewDeletionGuardDependency[*orcv1alpha1.RBACPolicyList, *orcv1alpha1.Network](
+ "spec.resource.networkRef",
+ func(rbacpolicy *orcv1alpha1.RBACPolicy) []string {
+ resource := rbacpolicy.Spec.Resource
+ if resource == nil {
+ return nil
+ }
+ return []string{string(resource.NetworkRef)}
+ },
+ finalizer, externalObjectFieldOwner,
+)
+
+var projectDependency = dependency.NewDeletionGuardDependency[*orcv1alpha1.RBACPolicyList, *orcv1alpha1.Project](
+ "spec.resource.targetProjectRef",
+ func(rbacpolicy *orcv1alpha1.RBACPolicy) []string {
+ resource := rbacpolicy.Spec.Resource
+ if resource == nil || resource.TargetProjectRef == nil {
+ return nil
+ }
+ return []string{string(*resource.TargetProjectRef)}
+ },
+ finalizer, externalObjectFieldOwner,
+)
+
+var projectImportDependency = dependency.NewDependency[*orcv1alpha1.RBACPolicyList, *orcv1alpha1.Project](
+ "spec.import.filter.targetProjectRef",
+ func(rbacpolicy *orcv1alpha1.RBACPolicy) []string {
+ resource := rbacpolicy.Spec.Import
+ if resource == nil || resource.Filter == nil || resource.Filter.TargetProjectRef == nil {
+ return nil
+ }
+ return []string{string(*resource.Filter.TargetProjectRef)}
+ },
+)
+
+// SetupWithManager sets up the controller with the Manager.
+func (c *rbacpolicyReconcilerConstructor) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
+ log := ctrl.LoggerFrom(ctx)
+ k8sClient := mgr.GetClient()
+
+ networkWatchEventHandler, err := networkDependency.WatchEventHandler(log, k8sClient)
+ if err != nil {
+ return err
+ }
+ projectWatchEventHandler, err := projectDependency.WatchEventHandler(log, k8sClient)
+ if err != nil {
+ return err
+ }
+ projectImportWatchEventHandler, err := projectImportDependency.WatchEventHandler(log, k8sClient)
+ if err != nil {
+ return err
+ }
+
+ builder := ctrl.NewControllerManagedBy(mgr).
+ WithOptions(options).
+ Watches(&orcv1alpha1.Network{}, networkWatchEventHandler,
+ builder.WithPredicates(predicates.NewBecameAvailable(log, &orcv1alpha1.Network{})),
+ ).
+ Watches(&orcv1alpha1.Project{}, projectWatchEventHandler,
+ builder.WithPredicates(predicates.NewBecameAvailable(log, &orcv1alpha1.Project{})),
+ ).
+ // A second watch is necessary because we need a different handler that omits deletion guards
+ Watches(&orcv1alpha1.Project{}, projectImportWatchEventHandler,
+ builder.WithPredicates(predicates.NewBecameAvailable(log, &orcv1alpha1.Project{})),
+ ).
+ For(&orcv1alpha1.RBACPolicy{})
+
+ if err := errors.Join(
+ networkDependency.AddToManager(ctx, mgr),
+ projectDependency.AddToManager(ctx, mgr),
+ projectImportDependency.AddToManager(ctx, mgr),
+ credentialsDependency.AddToManager(ctx, mgr),
+ credentials.AddCredentialsWatch(log, mgr.GetClient(), builder, credentialsDependency),
+ ); err != nil {
+ return err
+ }
+
+ r := reconciler.NewController(controllerName, mgr.GetClient(), c.scopeFactory, rbacpolicyHelperFactory{}, rbacpolicyStatusWriter{}, c.defaultResyncPeriod)
+ return builder.Complete(&r)
+}
diff --git a/internal/controllers/rbacpolicy/status.go b/internal/controllers/rbacpolicy/status.go
new file mode 100644
index 000000000..0305f1fbb
--- /dev/null
+++ b/internal/controllers/rbacpolicy/status.go
@@ -0,0 +1,63 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package rbacpolicy
+
+import (
+ "github.com/go-logr/logr"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+ orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/controllers/generic/interfaces"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/controllers/generic/progress"
+ orcapplyconfigv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/applyconfiguration/api/v1alpha1"
+)
+
+type rbacpolicyStatusWriter struct{}
+
+type objectApplyT = orcapplyconfigv1alpha1.RBACPolicyApplyConfiguration
+type statusApplyT = orcapplyconfigv1alpha1.RBACPolicyStatusApplyConfiguration
+
+var _ interfaces.ResourceStatusWriter[*orcv1alpha1.RBACPolicy, *osResourceT, *objectApplyT, *statusApplyT] = rbacpolicyStatusWriter{}
+
+func (rbacpolicyStatusWriter) GetApplyConfig(name, namespace string) *objectApplyT {
+ return orcapplyconfigv1alpha1.RBACPolicy(name, namespace)
+}
+
+// RBAC policies have no provisioning state: a policy is available once it exists.
+func (rbacpolicyStatusWriter) ResourceAvailableStatus(orcObject *orcv1alpha1.RBACPolicy, osResource *osResourceT) (metav1.ConditionStatus, progress.ReconcileStatus) {
+ if osResource == nil {
+ if orcObject.Status.ID == nil {
+ return metav1.ConditionFalse, nil
+ } else {
+ return metav1.ConditionUnknown, nil
+ }
+ }
+ return metav1.ConditionTrue, nil
+}
+
+func (rbacpolicyStatusWriter) ApplyResourceStatus(log logr.Logger, osResource *osResourceT, statusApply *statusApplyT) {
+ resourceStatus := orcapplyconfigv1alpha1.RBACPolicyResourceStatus().
+ WithNetworkID(osResource.ObjectID).
+ WithAction(string(osResource.Action)).
+ WithTargetProjectID(osResource.TargetTenant)
+
+ if osResource.ProjectID != "" {
+ resourceStatus.WithProjectID(osResource.ProjectID)
+ }
+
+ statusApply.WithResource(resourceStatus)
+}
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/00-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/00-assert.yaml
new file mode 100644
index 000000000..9f3d6761b
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/00-assert.yaml
@@ -0,0 +1,36 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-create-full
+status:
+ resource:
+ action: access_as_external
+ conditions:
+ - type: Available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ status: "False"
+ reason: Success
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+resourceRefs:
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-create-full
+ ref: rbacpolicy
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: Network
+ name: rbacpolicy-create-full
+ ref: network
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: Project
+ name: rbacpolicy-create-full
+ ref: project
+assertAll:
+ - celExpr: "rbacpolicy.status.id != ''"
+ - celExpr: "rbacpolicy.status.resource.networkID == network.status.id"
+ - celExpr: "rbacpolicy.status.resource.targetProjectID == project.status.id"
+ - celExpr: "rbacpolicy.status.resource.projectID != ''"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/00-create-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/00-create-resource.yaml
new file mode 100644
index 000000000..775805a17
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/00-create-resource.yaml
@@ -0,0 +1,36 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Project
+metadata:
+ name: rbacpolicy-create-full
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack-admin
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-create-full
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-create-full
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack-admin
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-create-full
+ action: access_as_external
+ targetProjectRef: rbacpolicy-create-full
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/00-secret.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/00-secret.yaml
new file mode 100644
index 000000000..045711ee7
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/00-secret.yaml
@@ -0,0 +1,6 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/README.md b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/README.md
new file mode 100644
index 000000000..b3c153b3c
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-full/README.md
@@ -0,0 +1,13 @@
+# Create a RBACPolicy with all the options
+
+## Step 00
+
+Create an RBACPolicy using all the fields: the target project by reference (`targetProjectRef`,
+`create-minimal` uses `targetProjectID`) and the other `action`, `access_as_external`, which
+Neutron restricts to admins.
+
+Verify that the observed state corresponds to the spec.
+
+## Reference
+
+https://k-orc.cloud/development/writing-tests/#create-full
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/00-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/00-assert.yaml
new file mode 100644
index 000000000..a627802c0
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/00-assert.yaml
@@ -0,0 +1,32 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-create-minimal
+status:
+ resource:
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000011"
+ conditions:
+ - type: Available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ status: "False"
+ reason: Success
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+resourceRefs:
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-create-minimal
+ ref: rbacpolicy
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: Network
+ name: rbacpolicy-create-minimal
+ ref: network
+assertAll:
+ - celExpr: "rbacpolicy.status.id != ''"
+ - celExpr: "rbacpolicy.status.resource.networkID == network.status.id"
+ - celExpr: "rbacpolicy.status.resource.projectID != ''"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/00-create-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/00-create-resource.yaml
new file mode 100644
index 000000000..8558c1da8
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/00-create-resource.yaml
@@ -0,0 +1,25 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-create-minimal
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-create-minimal
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-create-minimal
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000011"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/00-secret.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/00-secret.yaml
new file mode 100644
index 000000000..045711ee7
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/00-secret.yaml
@@ -0,0 +1,6 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/01-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/01-assert.yaml
new file mode 100644
index 000000000..11cad0ebd
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/01-assert.yaml
@@ -0,0 +1,11 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+resourceRefs:
+ - apiVersion: v1
+ kind: Secret
+ name: openstack-clouds
+ ref: secret
+assertAll:
+ - celExpr: "secret.metadata.deletionTimestamp != 0"
+ - celExpr: "'openstack.k-orc.cloud/rbacpolicy' in secret.metadata.finalizers"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/01-delete-secret.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/01-delete-secret.yaml
new file mode 100644
index 000000000..1620791b9
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/01-delete-secret.yaml
@@ -0,0 +1,7 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ # We expect the deletion to hang due to the finalizer, so use --wait=false
+ - command: kubectl delete secret openstack-clouds --wait=false
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/README.md b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/README.md
new file mode 100644
index 000000000..7da89d8e5
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-create-minimal/README.md
@@ -0,0 +1,15 @@
+# Create a RBACPolicy with the minimum options
+
+## Step 00
+
+Create a minimal RBACPolicy, that sets only the required fields (RBACPolicy has no
+optional fields - networkRef, action and targetProjectID are all required), and
+verify that the observed state corresponds to the spec.
+
+## Step 01
+
+Try deleting the secret and ensure that it is not deleted thanks to the finalizer.
+
+## Reference
+
+https://k-orc.cloud/development/writing-tests/#create-minimal
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/00-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/00-assert.yaml
new file mode 100644
index 000000000..5fee30b2d
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/00-assert.yaml
@@ -0,0 +1,45 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-dependency-no-secret
+status:
+ conditions:
+ - type: Available
+ message: Waiting for Secret/rbacpolicy-dependency to be created
+ status: "False"
+ reason: Progressing
+ - type: Progressing
+ message: Waiting for Secret/rbacpolicy-dependency to be created
+ status: "True"
+ reason: Progressing
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-dependency-no-network
+status:
+ conditions:
+ - type: Available
+ message: Waiting for Network/rbacpolicy-dependency-pending to be created
+ status: "False"
+ reason: Progressing
+ - type: Progressing
+ message: Waiting for Network/rbacpolicy-dependency-pending to be created
+ status: "True"
+ reason: Progressing
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-dependency-no-project
+status:
+ conditions:
+ - type: Available
+ message: Waiting for Project/rbacpolicy-dependency to be created
+ status: "False"
+ reason: Progressing
+ - type: Progressing
+ message: Waiting for Project/rbacpolicy-dependency to be created
+ status: "True"
+ reason: Progressing
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/00-create-resources-missing-deps.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/00-create-resources-missing-deps.yaml
new file mode 100644
index 000000000..58d48cd69
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/00-create-resources-missing-deps.yaml
@@ -0,0 +1,53 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-dependency
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-dependency-no-network
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-dependency-pending
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000013"
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-dependency-no-secret
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: rbacpolicy-dependency
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-dependency
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000014"
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-dependency-no-project
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-dependency
+ action: access_as_shared
+ targetProjectRef: rbacpolicy-dependency
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/00-secret.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/00-secret.yaml
new file mode 100644
index 000000000..045711ee7
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/00-secret.yaml
@@ -0,0 +1,6 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/01-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/01-assert.yaml
new file mode 100644
index 000000000..adfa080a6
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/01-assert.yaml
@@ -0,0 +1,45 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-dependency-no-secret
+status:
+ conditions:
+ - type: Available
+ message: OpenStack resource is available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ message: OpenStack resource is up to date
+ status: "False"
+ reason: Success
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-dependency-no-network
+status:
+ conditions:
+ - type: Available
+ message: OpenStack resource is available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ message: OpenStack resource is up to date
+ status: "False"
+ reason: Success
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-dependency-no-project
+status:
+ conditions:
+ - type: Available
+ message: OpenStack resource is available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ message: OpenStack resource is up to date
+ status: "False"
+ reason: Success
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/01-create-dependencies.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/01-create-dependencies.yaml
new file mode 100644
index 000000000..0244a9a00
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/01-create-dependencies.yaml
@@ -0,0 +1,28 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ - command: kubectl create secret generic rbacpolicy-dependency --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
+ namespaced: true
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-dependency-pending
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Project
+metadata:
+ name: rbacpolicy-dependency
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack-admin
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/02-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/02-assert.yaml
new file mode 100644
index 000000000..ea9238055
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/02-assert.yaml
@@ -0,0 +1,23 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+resourceRefs:
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: Network
+ name: rbacpolicy-dependency
+ ref: network
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: Project
+ name: rbacpolicy-dependency
+ ref: project
+ - apiVersion: v1
+ kind: Secret
+ name: rbacpolicy-dependency
+ ref: secret
+assertAll:
+ - celExpr: "network.metadata.deletionTimestamp != 0"
+ - celExpr: "'openstack.k-orc.cloud/rbacpolicy' in network.metadata.finalizers"
+ - celExpr: "project.metadata.deletionTimestamp != 0"
+ - celExpr: "'openstack.k-orc.cloud/rbacpolicy' in project.metadata.finalizers"
+ - celExpr: "secret.metadata.deletionTimestamp != 0"
+ - celExpr: "'openstack.k-orc.cloud/rbacpolicy' in secret.metadata.finalizers"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/02-delete-dependencies.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/02-delete-dependencies.yaml
new file mode 100644
index 000000000..8065409dc
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/02-delete-dependencies.yaml
@@ -0,0 +1,11 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ # We expect the deletion to hang due to the finalizer, so use --wait=false
+ - command: kubectl delete network.openstack.k-orc.cloud rbacpolicy-dependency --wait=false
+ namespaced: true
+ - command: kubectl delete secret rbacpolicy-dependency --wait=false
+ namespaced: true
+ - command: kubectl delete project rbacpolicy-dependency --wait=false
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/03-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/03-assert.yaml
new file mode 100644
index 000000000..0ba56047d
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/03-assert.yaml
@@ -0,0 +1,11 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+commands:
+# Dependencies that were prevented deletion before should now be gone
+- script: "! kubectl get network.openstack.k-orc.cloud rbacpolicy-dependency --namespace $NAMESPACE"
+ skipLogOutput: true
+- script: "! kubectl get secret rbacpolicy-dependency --namespace $NAMESPACE"
+ skipLogOutput: true
+- script: "! kubectl get project rbacpolicy-dependency --namespace $NAMESPACE"
+ skipLogOutput: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/03-delete-resources.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/03-delete-resources.yaml
new file mode 100644
index 000000000..eac99b840
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/03-delete-resources.yaml
@@ -0,0 +1,13 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+delete:
+- apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-dependency-no-secret
+- apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-dependency-no-network
+- apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-dependency-no-project
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/README.md b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/README.md
new file mode 100644
index 000000000..2d21c0ff7
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-dependency/README.md
@@ -0,0 +1,21 @@
+# Creation and deletion dependencies
+
+## Step 00
+
+Create RBACPolicies referencing non-existing resources. Each RBACPolicy is dependent on other non-existing resource. Verify that the RBACPolicies are waiting for the needed resources to be created externally.
+
+## Step 01
+
+Create the missing dependencies and verify all the RBACPolicies are available.
+
+## Step 02
+
+Delete all the dependencies and check that ORC prevents deletion since there is still a resource that depends on them.
+
+## Step 03
+
+Delete the RBACPolicies and validate that all resources are gone.
+
+## Reference
+
+https://k-orc.cloud/development/writing-tests/#dependency
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/00-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/00-assert.yaml
new file mode 100644
index 000000000..a9151705b
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/00-assert.yaml
@@ -0,0 +1,15 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-dependency
+status:
+ conditions:
+ - type: Available
+ message: Waiting for Project/rbacpolicy-import-dependency to be ready
+ status: "False"
+ reason: Progressing
+ - type: Progressing
+ message: Waiting for Project/rbacpolicy-import-dependency to be ready
+ status: "True"
+ reason: Progressing
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/00-import-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/00-import-resource.yaml
new file mode 100644
index 000000000..a55b04b52
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/00-import-resource.yaml
@@ -0,0 +1,27 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Project
+metadata:
+ name: rbacpolicy-import-dependency
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack-admin
+ secretName: openstack-clouds
+ managementPolicy: unmanaged
+ import:
+ filter:
+ name: rbacpolicy-import-dependency-external
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-dependency
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: unmanaged
+ import:
+ filter:
+ action: access_as_shared
+ targetProjectRef: rbacpolicy-import-dependency
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/00-secret.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/00-secret.yaml
new file mode 100644
index 000000000..045711ee7
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/00-secret.yaml
@@ -0,0 +1,6 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/01-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/01-assert.yaml
new file mode 100644
index 000000000..8fec4f39e
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/01-assert.yaml
@@ -0,0 +1,30 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-dependency-not-this-one
+status:
+ conditions:
+ - type: Available
+ message: OpenStack resource is available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ message: OpenStack resource is up to date
+ status: "False"
+ reason: Success
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-dependency
+status:
+ conditions:
+ - type: Available
+ message: Waiting for Project/rbacpolicy-import-dependency to be ready
+ status: "False"
+ reason: Progressing
+ - type: Progressing
+ message: Waiting for Project/rbacpolicy-import-dependency to be ready
+ status: "True"
+ reason: Progressing
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/01-create-trap-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/01-create-trap-resource.yaml
new file mode 100644
index 000000000..d4c96acf3
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/01-create-trap-resource.yaml
@@ -0,0 +1,36 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Project
+metadata:
+ name: rbacpolicy-import-dependency-not-this-one
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack-admin
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-import-dependency-not-this-one
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-dependency-not-this-one
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-import-dependency-not-this-one
+ action: access_as_shared
+ targetProjectRef: rbacpolicy-import-dependency-not-this-one
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/02-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/02-assert.yaml
new file mode 100644
index 000000000..504a8ab79
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/02-assert.yaml
@@ -0,0 +1,34 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+resourceRefs:
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-import-dependency
+ ref: rbacpolicy1
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-import-dependency-not-this-one
+ ref: rbacpolicy2
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: Project
+ name: rbacpolicy-import-dependency
+ ref: project
+assertAll:
+ - celExpr: "rbacpolicy1.status.id != rbacpolicy2.status.id"
+ - celExpr: "rbacpolicy1.status.resource.targetProjectID == project.status.id"
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-dependency
+status:
+ conditions:
+ - type: Available
+ message: OpenStack resource is available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ message: OpenStack resource is up to date
+ status: "False"
+ reason: Success
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/02-create-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/02-create-resource.yaml
new file mode 100644
index 000000000..f3eca6d47
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/02-create-resource.yaml
@@ -0,0 +1,36 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Project
+metadata:
+ name: rbacpolicy-import-dependency-external
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack-admin
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-import-dependency-external
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-dependency-external
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-import-dependency-external
+ action: access_as_shared
+ targetProjectRef: rbacpolicy-import-dependency-external
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/03-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/03-assert.yaml
new file mode 100644
index 000000000..cc05292c0
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/03-assert.yaml
@@ -0,0 +1,6 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+commands:
+- script: "! kubectl get project rbacpolicy-import-dependency --namespace $NAMESPACE"
+ skipLogOutput: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/03-delete-import-dependencies.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/03-delete-import-dependencies.yaml
new file mode 100644
index 000000000..f1ddfab49
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/03-delete-import-dependencies.yaml
@@ -0,0 +1,6 @@
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ # We should be able to delete the project
+ - command: kubectl delete project rbacpolicy-import-dependency
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/04-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/04-assert.yaml
new file mode 100644
index 000000000..219794768
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/04-assert.yaml
@@ -0,0 +1,5 @@
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+commands:
+- script: "! kubectl get rbacpolicy rbacpolicy-import-dependency --namespace $NAMESPACE"
+ skipLogOutput: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/04-delete-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/04-delete-resource.yaml
new file mode 100644
index 000000000..f1db9ad95
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/04-delete-resource.yaml
@@ -0,0 +1,6 @@
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+delete:
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-import-dependency
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/README.md b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/README.md
new file mode 100644
index 000000000..53b31ea6c
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-dependency/README.md
@@ -0,0 +1,28 @@
+# Check dependency handling for imported RBAC policies
+
+## Step 00
+
+Import an RBAC policy whose filter references an imported project that has no matching resource yet.
+Verify the RBAC policy is waiting for the dependency to be ready.
+
+## Step 01
+
+Create an RBAC policy matching the import filter, except for the referenced project, and verify that it's not being imported.
+
+## Step 02
+
+Create the referenced project and an RBAC policy matching the import filter.
+
+Verify that the observed status on the imported RBAC policy corresponds to the spec of the created one.
+
+## Step 03
+
+Delete the referenced project and check that ORC does not prevent deletion.
+
+## Step 04
+
+Delete the RBAC policy and validate that all resources are gone.
+
+## Reference
+
+https://k-orc.cloud/development/writing-tests/#import-dependency
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/00-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/00-assert.yaml
new file mode 100644
index 000000000..1ad9aa176
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/00-assert.yaml
@@ -0,0 +1,30 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-error-external-1
+status:
+ conditions:
+ - type: Available
+ message: OpenStack resource is available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ message: OpenStack resource is up to date
+ status: "False"
+ reason: Success
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-error-external-2
+status:
+ conditions:
+ - type: Available
+ message: OpenStack resource is available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ message: OpenStack resource is up to date
+ status: "False"
+ reason: Success
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/00-create-resources.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/00-create-resources.yaml
new file mode 100644
index 000000000..0f1a8f754
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/00-create-resources.yaml
@@ -0,0 +1,55 @@
+---
+# Two distinct networks: Neutron rejects an exact duplicate RBAC policy (same
+# object_id+action+target_tenant, confirmed live against a real cloud), so to get
+# two OpenStack resources that both match the same (action, targetProjectID) import
+# filter - which doesn't look at the network at all, see rbacpolicy_types.go's
+# RBACPolicyFilter - they must point at different networks.
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-import-error-1
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-import-error-2
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-error-external-1
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-import-error-1
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000015"
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-error-external-2
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-import-error-2
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000015"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/00-secret.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/00-secret.yaml
new file mode 100644
index 000000000..045711ee7
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/00-secret.yaml
@@ -0,0 +1,6 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/01-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/01-assert.yaml
new file mode 100644
index 000000000..2bb7a44a8
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/01-assert.yaml
@@ -0,0 +1,15 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-error
+status:
+ conditions:
+ - type: Available
+ message: found more than one matching OpenStack resource during import
+ status: "False"
+ reason: InvalidConfiguration
+ - type: Progressing
+ message: found more than one matching OpenStack resource during import
+ status: "False"
+ reason: InvalidConfiguration
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/01-import-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/01-import-resource.yaml
new file mode 100644
index 000000000..d6f8a73e5
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/01-import-resource.yaml
@@ -0,0 +1,14 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-error
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: unmanaged
+ import:
+ filter:
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000015"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/README.md b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/README.md
new file mode 100644
index 000000000..92f33725c
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import-error/README.md
@@ -0,0 +1,16 @@
+# Import RBACPolicy with more than one matching resources
+
+## Step 00
+
+Create two RBACPolicies sharing the same action and targetProjectID (RBACPolicyFilter
+only matches on those two fields, not on the network), each attached to a different
+network since Neutron rejects an exact duplicate policy on the same network.
+
+## Step 01
+
+Ensure that an imported RBACPolicy with a filter matching both resources returns an
+error.
+
+## Reference
+
+https://k-orc.cloud/development/writing-tests/#import-error
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import/00-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/00-assert.yaml
new file mode 100644
index 000000000..fa73c1c49
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/00-assert.yaml
@@ -0,0 +1,15 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import
+status:
+ conditions:
+ - type: Available
+ message: Waiting for OpenStack resource to be created externally
+ status: "False"
+ reason: Progressing
+ - type: Progressing
+ message: Waiting for OpenStack resource to be created externally
+ status: "True"
+ reason: Progressing
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import/00-import-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/00-import-resource.yaml
new file mode 100644
index 000000000..b2b2a107a
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/00-import-resource.yaml
@@ -0,0 +1,14 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: unmanaged
+ import:
+ filter:
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000016"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import/00-secret.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/00-secret.yaml
new file mode 100644
index 000000000..045711ee7
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/00-secret.yaml
@@ -0,0 +1,6 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import/01-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/01-assert.yaml
new file mode 100644
index 000000000..de93801eb
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/01-assert.yaml
@@ -0,0 +1,30 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-not-this-one
+status:
+ conditions:
+ - type: Available
+ message: OpenStack resource is available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ message: OpenStack resource is up to date
+ status: "False"
+ reason: Success
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import
+status:
+ conditions:
+ - type: Available
+ message: Waiting for OpenStack resource to be created externally
+ status: "False"
+ reason: Progressing
+ - type: Progressing
+ message: Waiting for OpenStack resource to be created externally
+ status: "True"
+ reason: Progressing
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import/01-create-trap-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/01-create-trap-resource.yaml
new file mode 100644
index 000000000..7f713815d
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/01-create-trap-resource.yaml
@@ -0,0 +1,30 @@
+---
+# This `rbacpolicy-import-not-this-one` resource serves two purposes:
+# - ensure that we can successfully create another resource with a different
+# targetProjectID (i.e. it's not being adopted)
+# - ensure that importing a resource with the filter's targetProjectID will not
+# pick this one, since it was created with a different targetProjectID.
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-import-not-this-one
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-not-this-one
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-import-not-this-one
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000017"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import/02-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/02-assert.yaml
new file mode 100644
index 000000000..e2c98d42f
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/02-assert.yaml
@@ -0,0 +1,32 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+resourceRefs:
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-import-external
+ ref: rbacpolicy1
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-import-not-this-one
+ ref: rbacpolicy2
+assertAll:
+ - celExpr: "rbacpolicy1.status.id != rbacpolicy2.status.id"
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import
+status:
+ conditions:
+ - type: Available
+ message: OpenStack resource is available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ message: OpenStack resource is up to date
+ status: "False"
+ reason: Success
+ resource:
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000016"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import/02-create-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/02-create-resource.yaml
new file mode 100644
index 000000000..e2bc5af2d
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/02-create-resource.yaml
@@ -0,0 +1,25 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-import
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-import-external
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-import
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000016"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-import/README.md b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/README.md
new file mode 100644
index 000000000..4f373cee1
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-import/README.md
@@ -0,0 +1,23 @@
+# Import RBACPolicy
+
+## Step 00
+
+Import a RBACPolicy, matching all of the available filter's fields (action,
+targetProjectID), and verify it is waiting for the external resource to be
+created.
+
+## Step 01
+
+Create a RBACPolicy with a different targetProjectID than the one specified in
+the import filter, and verify that it's not being imported.
+
+## Step 02
+
+Create a RBACPolicy matching the filter and verify that the observed status on
+the imported RBACPolicy corresponds to the spec of the created RBACPolicy.
+Also verify that it didn't adopt the RBACPolicy with the different
+targetProjectID.
+
+## Reference
+
+https://k-orc.cloud/development/writing-tests/#import
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-update/00-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/00-assert.yaml
new file mode 100644
index 000000000..bc787a1db
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/00-assert.yaml
@@ -0,0 +1,25 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+resourceRefs:
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-update
+ ref: rbacpolicy
+assertAll:
+ - celExpr: "rbacpolicy.status.resource.targetProjectID == '3fac9d0b0e0e4b0e9b0e000000000018'"
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-update
+status:
+ resource:
+ action: access_as_shared
+ conditions:
+ - type: Available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ status: "False"
+ reason: Success
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-update/00-minimal-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/00-minimal-resource.yaml
new file mode 100644
index 000000000..fca35c91e
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/00-minimal-resource.yaml
@@ -0,0 +1,25 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: Network
+metadata:
+ name: rbacpolicy-update
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource: {}
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-update
+spec:
+ cloudCredentialsRef:
+ cloudName: openstack
+ secretName: openstack-clouds
+ managementPolicy: managed
+ resource:
+ networkRef: rbacpolicy-update
+ action: access_as_shared
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000018"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-update/00-secret.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/00-secret.yaml
new file mode 100644
index 000000000..045711ee7
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/00-secret.yaml
@@ -0,0 +1,6 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ - command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-update/01-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/01-assert.yaml
new file mode 100644
index 000000000..ad9e97478
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/01-assert.yaml
@@ -0,0 +1,25 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+resourceRefs:
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-update
+ ref: rbacpolicy
+assertAll:
+ - celExpr: "rbacpolicy.status.resource.targetProjectID == '3fac9d0b0e0e4b0e9b0e000000000019'"
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-update
+status:
+ resource:
+ action: access_as_shared
+ conditions:
+ - type: Available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ status: "False"
+ reason: Success
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-update/01-updated-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/01-updated-resource.yaml
new file mode 100644
index 000000000..a2684f96e
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/01-updated-resource.yaml
@@ -0,0 +1,8 @@
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-update
+spec:
+ resource:
+ targetProjectID: "3fac9d0b0e0e4b0e9b0e000000000019"
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-update/02-assert.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/02-assert.yaml
new file mode 100644
index 000000000..bc787a1db
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/02-assert.yaml
@@ -0,0 +1,25 @@
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestAssert
+resourceRefs:
+ - apiVersion: openstack.k-orc.cloud/v1alpha1
+ kind: RBACPolicy
+ name: rbacpolicy-update
+ ref: rbacpolicy
+assertAll:
+ - celExpr: "rbacpolicy.status.resource.targetProjectID == '3fac9d0b0e0e4b0e9b0e000000000018'"
+---
+apiVersion: openstack.k-orc.cloud/v1alpha1
+kind: RBACPolicy
+metadata:
+ name: rbacpolicy-update
+status:
+ resource:
+ action: access_as_shared
+ conditions:
+ - type: Available
+ status: "True"
+ reason: Success
+ - type: Progressing
+ status: "False"
+ reason: Success
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-update/02-reverted-resource.yaml b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/02-reverted-resource.yaml
new file mode 100644
index 000000000..2c6c253ff
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/02-reverted-resource.yaml
@@ -0,0 +1,7 @@
+# NOTE: kuttl only does patch updates, which means we can't delete a field.
+# We have to use a kubectl apply command instead.
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+commands:
+ - command: kubectl replace -f 00-minimal-resource.yaml
+ namespaced: true
diff --git a/internal/controllers/rbacpolicy/tests/rbacpolicy-update/README.md b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/README.md
new file mode 100644
index 000000000..71e26dbf9
--- /dev/null
+++ b/internal/controllers/rbacpolicy/tests/rbacpolicy-update/README.md
@@ -0,0 +1,20 @@
+# Update RBACPolicy
+
+## Step 00
+
+Create a RBACPolicy using only mandatory fields (RBACPolicy has no optional
+fields).
+
+## Step 01
+
+Update targetProjectID, the only field Neutron's RBAC policy API allows mutating
+(networkRef and action are immutable - see rbacpolicy_types.go).
+
+## Step 02
+
+Revert the resource to its original targetProjectID and verify that the
+resulting object matches its state when first created.
+
+## Reference
+
+https://k-orc.cloud/development/writing-tests/#update
diff --git a/internal/controllers/rbacpolicy/zz_generated.adapter.go b/internal/controllers/rbacpolicy/zz_generated.adapter.go
new file mode 100644
index 000000000..311bfc2dd
--- /dev/null
+++ b/internal/controllers/rbacpolicy/zz_generated.adapter.go
@@ -0,0 +1,88 @@
+// Code generated by resource-generator. DO NOT EDIT.
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package rbacpolicy
+
+import (
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+ orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ "github.com/k-orc/openstack-resource-controller/v3/internal/controllers/generic/interfaces"
+)
+
+// Fundamental types
+type (
+ orcObjectT = orcv1alpha1.RBACPolicy
+ orcObjectListT = orcv1alpha1.RBACPolicyList
+ resourceSpecT = orcv1alpha1.RBACPolicyResourceSpec
+ filterT = orcv1alpha1.RBACPolicyFilter
+)
+
+// Derived types
+type (
+ orcObjectPT = *orcObjectT
+ adapterI = interfaces.APIObjectAdapter[orcObjectPT, resourceSpecT, filterT]
+ adapterT = rbacpolicyAdapter
+)
+
+type rbacpolicyAdapter struct {
+ *orcv1alpha1.RBACPolicy
+}
+
+var _ adapterI = &adapterT{}
+
+func (f adapterT) GetObject() orcObjectPT {
+ return f.RBACPolicy
+}
+
+func (f adapterT) GetManagementPolicy() orcv1alpha1.ManagementPolicy {
+ return f.Spec.ManagementPolicy
+}
+
+func (f adapterT) GetManagedOptions() *orcv1alpha1.ManagedOptions {
+ return f.Spec.ManagedOptions
+}
+
+func (f adapterT) GetResyncPeriod() *metav1.Duration {
+ return f.Spec.ResyncPeriod
+}
+
+func (f adapterT) GetLastSyncTime() *metav1.Time {
+ return f.Status.LastSyncTime
+}
+
+func (f adapterT) GetStatusID() *string {
+ return f.Status.ID
+}
+
+func (f adapterT) GetResourceSpec() *resourceSpecT {
+ return f.Spec.Resource
+}
+
+func (f adapterT) GetImportID() *string {
+ if f.Spec.Import == nil {
+ return nil
+ }
+ return f.Spec.Import.ID
+}
+
+func (f adapterT) GetImportFilter() *filterT {
+ if f.Spec.Import == nil {
+ return nil
+ }
+ return f.Spec.Import.Filter
+}
diff --git a/internal/controllers/rbacpolicy/zz_generated.controller.go b/internal/controllers/rbacpolicy/zz_generated.controller.go
new file mode 100644
index 000000000..187e09310
--- /dev/null
+++ b/internal/controllers/rbacpolicy/zz_generated.controller.go
@@ -0,0 +1,45 @@
+// Code generated by resource-generator. DO NOT EDIT.
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package rbacpolicy
+
+import (
+ corev1 "k8s.io/api/core/v1"
+
+ "github.com/k-orc/openstack-resource-controller/v3/internal/util/dependency"
+ orcstrings "github.com/k-orc/openstack-resource-controller/v3/internal/util/strings"
+)
+
+var (
+ // NOTE: controllerName must be defined in any controller using this template
+
+ // finalizer is the string this controller adds to an object's Finalizers
+ finalizer = orcstrings.GetFinalizerName(controllerName)
+
+ // externalObjectFieldOwner is the field owner we use when using
+ // server-side-apply on objects we don't control
+ externalObjectFieldOwner = orcstrings.GetSSAFieldOwner(controllerName)
+
+ credentialsDependency = dependency.NewDeletionGuardDependency[*orcObjectListT, *corev1.Secret](
+ "spec.cloudCredentialsRef.secretName",
+ func(obj orcObjectPT) []string {
+ return []string{obj.Spec.CloudCredentialsRef.SecretName}
+ },
+ finalizer, externalObjectFieldOwner,
+ dependency.OverrideDependencyName("credentials"),
+ )
+)
diff --git a/internal/osclients/mock/networking.go b/internal/osclients/mock/networking.go
index 2f39a557b..3da1d4358 100644
--- a/internal/osclients/mock/networking.go
+++ b/internal/osclients/mock/networking.go
@@ -32,6 +32,7 @@ import (
attributestags "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/attributestags"
floatingips "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips"
routers "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers"
+ rbacpolicies "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/rbacpolicies"
groups "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups"
rules "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules"
trunks "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/trunks"
@@ -141,6 +142,21 @@ func (mr *MockNetworkClientMockRecorder) CreatePort(ctx, opts any) *gomock.Call
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePort", reflect.TypeOf((*MockNetworkClient)(nil).CreatePort), ctx, opts)
}
+// CreateRBACPolicy mocks base method.
+func (m *MockNetworkClient) CreateRBACPolicy(ctx context.Context, opts rbacpolicies.CreateOptsBuilder) (*rbacpolicies.RBACPolicy, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateRBACPolicy", ctx, opts)
+ ret0, _ := ret[0].(*rbacpolicies.RBACPolicy)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CreateRBACPolicy indicates an expected call of CreateRBACPolicy.
+func (mr *MockNetworkClientMockRecorder) CreateRBACPolicy(ctx, opts any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRBACPolicy", reflect.TypeOf((*MockNetworkClient)(nil).CreateRBACPolicy), ctx, opts)
+}
+
// CreateRouter mocks base method.
func (m *MockNetworkClient) CreateRouter(ctx context.Context, opts routers.CreateOptsBuilder) (*routers.Router, error) {
m.ctrl.T.Helper()
@@ -258,6 +274,20 @@ func (mr *MockNetworkClientMockRecorder) DeletePort(ctx, id any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePort", reflect.TypeOf((*MockNetworkClient)(nil).DeletePort), ctx, id)
}
+// DeleteRBACPolicy mocks base method.
+func (m *MockNetworkClient) DeleteRBACPolicy(ctx context.Context, id string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteRBACPolicy", ctx, id)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteRBACPolicy indicates an expected call of DeleteRBACPolicy.
+func (mr *MockNetworkClientMockRecorder) DeleteRBACPolicy(ctx, id any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRBACPolicy", reflect.TypeOf((*MockNetworkClient)(nil).DeleteRBACPolicy), ctx, id)
+}
+
// DeleteRouter mocks base method.
func (m *MockNetworkClient) DeleteRouter(ctx context.Context, id string) error {
m.ctrl.T.Helper()
@@ -373,6 +403,21 @@ func (mr *MockNetworkClientMockRecorder) GetPort(ctx, id any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPort", reflect.TypeOf((*MockNetworkClient)(nil).GetPort), ctx, id)
}
+// GetRBACPolicy mocks base method.
+func (m *MockNetworkClient) GetRBACPolicy(ctx context.Context, id string) (*rbacpolicies.RBACPolicy, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetRBACPolicy", ctx, id)
+ ret0, _ := ret[0].(*rbacpolicies.RBACPolicy)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetRBACPolicy indicates an expected call of GetRBACPolicy.
+func (mr *MockNetworkClientMockRecorder) GetRBACPolicy(ctx, id any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRBACPolicy", reflect.TypeOf((*MockNetworkClient)(nil).GetRBACPolicy), ctx, id)
+}
+
// GetRouter mocks base method.
func (m *MockNetworkClient) GetRouter(ctx context.Context, id string) (*routers.Router, error) {
m.ctrl.T.Helper()
@@ -490,6 +535,20 @@ func (mr *MockNetworkClientMockRecorder) ListPort(ctx, opts any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPort", reflect.TypeOf((*MockNetworkClient)(nil).ListPort), ctx, opts)
}
+// ListRBACPolicy mocks base method.
+func (m *MockNetworkClient) ListRBACPolicy(ctx context.Context, opts rbacpolicies.ListOptsBuilder) iter.Seq2[*rbacpolicies.RBACPolicy, error] {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListRBACPolicy", ctx, opts)
+ ret0, _ := ret[0].(iter.Seq2[*rbacpolicies.RBACPolicy, error])
+ return ret0
+}
+
+// ListRBACPolicy indicates an expected call of ListRBACPolicy.
+func (mr *MockNetworkClientMockRecorder) ListRBACPolicy(ctx, opts any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListRBACPolicy", reflect.TypeOf((*MockNetworkClient)(nil).ListRBACPolicy), ctx, opts)
+}
+
// ListRouter mocks base method.
func (m *MockNetworkClient) ListRouter(ctx context.Context, opts routers.ListOpts) iter.Seq2[*routers.Router, error] {
m.ctrl.T.Helper()
@@ -650,6 +709,21 @@ func (mr *MockNetworkClientMockRecorder) UpdatePort(ctx, id, opts any) *gomock.C
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatePort", reflect.TypeOf((*MockNetworkClient)(nil).UpdatePort), ctx, id, opts)
}
+// UpdateRBACPolicy mocks base method.
+func (m *MockNetworkClient) UpdateRBACPolicy(ctx context.Context, id string, opts rbacpolicies.UpdateOptsBuilder) (*rbacpolicies.RBACPolicy, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "UpdateRBACPolicy", ctx, id, opts)
+ ret0, _ := ret[0].(*rbacpolicies.RBACPolicy)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// UpdateRBACPolicy indicates an expected call of UpdateRBACPolicy.
+func (mr *MockNetworkClientMockRecorder) UpdateRBACPolicy(ctx, id, opts any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRBACPolicy", reflect.TypeOf((*MockNetworkClient)(nil).UpdateRBACPolicy), ctx, id, opts)
+}
+
// UpdateRouter mocks base method.
func (m *MockNetworkClient) UpdateRouter(ctx context.Context, id string, opts routers.UpdateOptsBuilder) (*routers.Router, error) {
m.ctrl.T.Helper()
diff --git a/internal/osclients/networking.go b/internal/osclients/networking.go
index 31ad31208..b29b84133 100644
--- a/internal/osclients/networking.go
+++ b/internal/osclients/networking.go
@@ -35,6 +35,7 @@ import (
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/portsecurity"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/portstrustedvif"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/provider"
+ "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/rbacpolicies"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/trunks"
@@ -149,6 +150,12 @@ type NetworkClient interface {
RemoveSubports(ctx context.Context, id string, opts trunks.RemoveSubportsOpts) error
ReplaceAllAttributesTags(ctx context.Context, resourceType string, resourceID string, opts attributestags.ReplaceAllOptsBuilder) ([]string, error)
+
+ ListRBACPolicy(ctx context.Context, opts rbacpolicies.ListOptsBuilder) iter.Seq2[*rbacpolicies.RBACPolicy, error]
+ CreateRBACPolicy(ctx context.Context, opts rbacpolicies.CreateOptsBuilder) (*rbacpolicies.RBACPolicy, error)
+ DeleteRBACPolicy(ctx context.Context, id string) error
+ GetRBACPolicy(ctx context.Context, id string) (*rbacpolicies.RBACPolicy, error)
+ UpdateRBACPolicy(ctx context.Context, id string, opts rbacpolicies.UpdateOptsBuilder) (*rbacpolicies.RBACPolicy, error)
}
type networkClient struct {
@@ -271,6 +278,27 @@ func (c networkClient) UpdateRouter(ctx context.Context, id string, opts routers
return routers.Update(ctx, c.serviceClient, id, opts).Extract()
}
+func (c networkClient) ListRBACPolicy(ctx context.Context, opts rbacpolicies.ListOptsBuilder) iter.Seq2[*rbacpolicies.RBACPolicy, error] {
+ pager := rbacpolicies.List(c.serviceClient, opts)
+ return listResources(ctx, pager, rbacpolicies.ExtractRBACPolicies)
+}
+
+func (c networkClient) CreateRBACPolicy(ctx context.Context, opts rbacpolicies.CreateOptsBuilder) (*rbacpolicies.RBACPolicy, error) {
+ return rbacpolicies.Create(ctx, c.serviceClient, opts).Extract()
+}
+
+func (c networkClient) DeleteRBACPolicy(ctx context.Context, id string) error {
+ return rbacpolicies.Delete(ctx, c.serviceClient, id).ExtractErr()
+}
+
+func (c networkClient) GetRBACPolicy(ctx context.Context, id string) (*rbacpolicies.RBACPolicy, error) {
+ return rbacpolicies.Get(ctx, c.serviceClient, id).Extract()
+}
+
+func (c networkClient) UpdateRBACPolicy(ctx context.Context, id string, opts rbacpolicies.UpdateOptsBuilder) (*rbacpolicies.RBACPolicy, error) {
+ return rbacpolicies.Update(ctx, c.serviceClient, id, opts).Extract()
+}
+
func (c networkClient) ListSecGroup(ctx context.Context, opts groups.ListOpts) iter.Seq2[*groups.SecGroup, error] {
pager := groups.List(c.serviceClient, opts)
return listResources(ctx, pager, groups.ExtractGroups)
diff --git a/kuttl-test.yaml b/kuttl-test.yaml
index f732d5878..8603616e1 100644
--- a/kuttl-test.yaml
+++ b/kuttl-test.yaml
@@ -16,6 +16,7 @@ testDirs:
- ./internal/controllers/network/tests/
- ./internal/controllers/port/tests/
- ./internal/controllers/project/tests/
+- ./internal/controllers/rbacpolicy/tests/
- ./internal/controllers/recordset/tests/
- ./internal/controllers/region/tests/
- ./internal/controllers/registeredlimit/tests/
diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicy.go b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicy.go
new file mode 100644
index 000000000..40ee72bcd
--- /dev/null
+++ b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicy.go
@@ -0,0 +1,281 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by applyconfiguration-gen. DO NOT EDIT.
+
+package v1alpha1
+
+import (
+ apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ internal "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/applyconfiguration/internal"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ types "k8s.io/apimachinery/pkg/types"
+ managedfields "k8s.io/apimachinery/pkg/util/managedfields"
+ v1 "k8s.io/client-go/applyconfigurations/meta/v1"
+)
+
+// RBACPolicyApplyConfiguration represents a declarative configuration of the RBACPolicy type for use
+// with apply.
+type RBACPolicyApplyConfiguration struct {
+ v1.TypeMetaApplyConfiguration `json:",inline"`
+ *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
+ Spec *RBACPolicySpecApplyConfiguration `json:"spec,omitempty"`
+ Status *RBACPolicyStatusApplyConfiguration `json:"status,omitempty"`
+}
+
+// RBACPolicy constructs a declarative configuration of the RBACPolicy type for use with
+// apply.
+func RBACPolicy(name, namespace string) *RBACPolicyApplyConfiguration {
+ b := &RBACPolicyApplyConfiguration{}
+ b.WithName(name)
+ b.WithNamespace(namespace)
+ b.WithKind("RBACPolicy")
+ b.WithAPIVersion("openstack.k-orc.cloud/v1alpha1")
+ return b
+}
+
+// ExtractRBACPolicy extracts the applied configuration owned by fieldManager from
+// rBACPolicy. If no managedFields are found in rBACPolicy for fieldManager, a
+// RBACPolicyApplyConfiguration is returned with only the Name, Namespace (if applicable),
+// APIVersion and Kind populated. It is possible that no managed fields were found for because other
+// field managers have taken ownership of all the fields previously owned by fieldManager, or because
+// the fieldManager never owned fields any fields.
+// rBACPolicy must be a unmodified RBACPolicy API object that was retrieved from the Kubernetes API.
+// ExtractRBACPolicy provides a way to perform a extract/modify-in-place/apply workflow.
+// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
+// applied if another fieldManager has updated or force applied any of the previously applied fields.
+// Experimental!
+func ExtractRBACPolicy(rBACPolicy *apiv1alpha1.RBACPolicy, fieldManager string) (*RBACPolicyApplyConfiguration, error) {
+ return extractRBACPolicy(rBACPolicy, fieldManager, "")
+}
+
+// ExtractRBACPolicyStatus is the same as ExtractRBACPolicy except
+// that it extracts the status subresource applied configuration.
+// Experimental!
+func ExtractRBACPolicyStatus(rBACPolicy *apiv1alpha1.RBACPolicy, fieldManager string) (*RBACPolicyApplyConfiguration, error) {
+ return extractRBACPolicy(rBACPolicy, fieldManager, "status")
+}
+
+func extractRBACPolicy(rBACPolicy *apiv1alpha1.RBACPolicy, fieldManager string, subresource string) (*RBACPolicyApplyConfiguration, error) {
+ b := &RBACPolicyApplyConfiguration{}
+ err := managedfields.ExtractInto(rBACPolicy, internal.Parser().Type("com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicy"), fieldManager, b, subresource)
+ if err != nil {
+ return nil, err
+ }
+ b.WithName(rBACPolicy.Name)
+ b.WithNamespace(rBACPolicy.Namespace)
+
+ b.WithKind("RBACPolicy")
+ b.WithAPIVersion("openstack.k-orc.cloud/v1alpha1")
+ return b, nil
+}
+func (b RBACPolicyApplyConfiguration) IsApplyConfiguration() {}
+
+// WithKind sets the Kind field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Kind field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithKind(value string) *RBACPolicyApplyConfiguration {
+ b.TypeMetaApplyConfiguration.Kind = &value
+ return b
+}
+
+// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the APIVersion field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithAPIVersion(value string) *RBACPolicyApplyConfiguration {
+ b.TypeMetaApplyConfiguration.APIVersion = &value
+ return b
+}
+
+// WithName sets the Name field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Name field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithName(value string) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ b.ObjectMetaApplyConfiguration.Name = &value
+ return b
+}
+
+// WithGenerateName sets the GenerateName field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the GenerateName field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithGenerateName(value string) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ b.ObjectMetaApplyConfiguration.GenerateName = &value
+ return b
+}
+
+// WithNamespace sets the Namespace field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Namespace field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithNamespace(value string) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ b.ObjectMetaApplyConfiguration.Namespace = &value
+ return b
+}
+
+// WithUID sets the UID field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the UID field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithUID(value types.UID) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ b.ObjectMetaApplyConfiguration.UID = &value
+ return b
+}
+
+// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the ResourceVersion field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithResourceVersion(value string) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ b.ObjectMetaApplyConfiguration.ResourceVersion = &value
+ return b
+}
+
+// WithGeneration sets the Generation field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Generation field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithGeneration(value int64) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ b.ObjectMetaApplyConfiguration.Generation = &value
+ return b
+}
+
+// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the CreationTimestamp field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithCreationTimestamp(value metav1.Time) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ b.ObjectMetaApplyConfiguration.CreationTimestamp = &value
+ return b
+}
+
+// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the DeletionTimestamp field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value
+ return b
+}
+
+// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value
+ return b
+}
+
+// WithLabels puts the entries into the Labels field in the declarative configuration
+// and returns the receiver, so that objects can be build by chaining "With" function invocations.
+// If called multiple times, the entries provided by each call will be put on the Labels field,
+// overwriting an existing map entries in Labels field with the same key.
+func (b *RBACPolicyApplyConfiguration) WithLabels(entries map[string]string) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 {
+ b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries))
+ }
+ for k, v := range entries {
+ b.ObjectMetaApplyConfiguration.Labels[k] = v
+ }
+ return b
+}
+
+// WithAnnotations puts the entries into the Annotations field in the declarative configuration
+// and returns the receiver, so that objects can be build by chaining "With" function invocations.
+// If called multiple times, the entries provided by each call will be put on the Annotations field,
+// overwriting an existing map entries in Annotations field with the same key.
+func (b *RBACPolicyApplyConfiguration) WithAnnotations(entries map[string]string) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 {
+ b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries))
+ }
+ for k, v := range entries {
+ b.ObjectMetaApplyConfiguration.Annotations[k] = v
+ }
+ return b
+}
+
+// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
+// and returns the receiver, so that objects can be build by chaining "With" function invocations.
+// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
+func (b *RBACPolicyApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ for i := range values {
+ if values[i] == nil {
+ panic("nil value passed to WithOwnerReferences")
+ }
+ b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i])
+ }
+ return b
+}
+
+// WithFinalizers adds the given value to the Finalizers field in the declarative configuration
+// and returns the receiver, so that objects can be build by chaining "With" function invocations.
+// If called multiple times, values provided by each call will be appended to the Finalizers field.
+func (b *RBACPolicyApplyConfiguration) WithFinalizers(values ...string) *RBACPolicyApplyConfiguration {
+ b.ensureObjectMetaApplyConfigurationExists()
+ for i := range values {
+ b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i])
+ }
+ return b
+}
+
+func (b *RBACPolicyApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
+ if b.ObjectMetaApplyConfiguration == nil {
+ b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
+ }
+}
+
+// WithSpec sets the Spec field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Spec field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithSpec(value *RBACPolicySpecApplyConfiguration) *RBACPolicyApplyConfiguration {
+ b.Spec = value
+ return b
+}
+
+// WithStatus sets the Status field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Status field is set to the value of the last call.
+func (b *RBACPolicyApplyConfiguration) WithStatus(value *RBACPolicyStatusApplyConfiguration) *RBACPolicyApplyConfiguration {
+ b.Status = value
+ return b
+}
+
+// GetKind retrieves the value of the Kind field in the declarative configuration.
+func (b *RBACPolicyApplyConfiguration) GetKind() *string {
+ return b.TypeMetaApplyConfiguration.Kind
+}
+
+// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration.
+func (b *RBACPolicyApplyConfiguration) GetAPIVersion() *string {
+ return b.TypeMetaApplyConfiguration.APIVersion
+}
+
+// GetName retrieves the value of the Name field in the declarative configuration.
+func (b *RBACPolicyApplyConfiguration) GetName() *string {
+ b.ensureObjectMetaApplyConfigurationExists()
+ return b.ObjectMetaApplyConfiguration.Name
+}
+
+// GetNamespace retrieves the value of the Namespace field in the declarative configuration.
+func (b *RBACPolicyApplyConfiguration) GetNamespace() *string {
+ b.ensureObjectMetaApplyConfigurationExists()
+ return b.ObjectMetaApplyConfiguration.Namespace
+}
diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyfilter.go b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyfilter.go
new file mode 100644
index 000000000..f07706400
--- /dev/null
+++ b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyfilter.go
@@ -0,0 +1,61 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by applyconfiguration-gen. DO NOT EDIT.
+
+package v1alpha1
+
+import (
+ apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+)
+
+// RBACPolicyFilterApplyConfiguration represents a declarative configuration of the RBACPolicyFilter type for use
+// with apply.
+type RBACPolicyFilterApplyConfiguration struct {
+ Action *apiv1alpha1.RBACPolicyAction `json:"action,omitempty"`
+ TargetProjectRef *apiv1alpha1.KubernetesNameRef `json:"targetProjectRef,omitempty"`
+ TargetProjectID *string `json:"targetProjectID,omitempty"`
+}
+
+// RBACPolicyFilterApplyConfiguration constructs a declarative configuration of the RBACPolicyFilter type for use with
+// apply.
+func RBACPolicyFilter() *RBACPolicyFilterApplyConfiguration {
+ return &RBACPolicyFilterApplyConfiguration{}
+}
+
+// WithAction sets the Action field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Action field is set to the value of the last call.
+func (b *RBACPolicyFilterApplyConfiguration) WithAction(value apiv1alpha1.RBACPolicyAction) *RBACPolicyFilterApplyConfiguration {
+ b.Action = &value
+ return b
+}
+
+// WithTargetProjectRef sets the TargetProjectRef field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the TargetProjectRef field is set to the value of the last call.
+func (b *RBACPolicyFilterApplyConfiguration) WithTargetProjectRef(value apiv1alpha1.KubernetesNameRef) *RBACPolicyFilterApplyConfiguration {
+ b.TargetProjectRef = &value
+ return b
+}
+
+// WithTargetProjectID sets the TargetProjectID field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the TargetProjectID field is set to the value of the last call.
+func (b *RBACPolicyFilterApplyConfiguration) WithTargetProjectID(value string) *RBACPolicyFilterApplyConfiguration {
+ b.TargetProjectID = &value
+ return b
+}
diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyimport.go b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyimport.go
new file mode 100644
index 000000000..e30f10680
--- /dev/null
+++ b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyimport.go
@@ -0,0 +1,48 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by applyconfiguration-gen. DO NOT EDIT.
+
+package v1alpha1
+
+// RBACPolicyImportApplyConfiguration represents a declarative configuration of the RBACPolicyImport type for use
+// with apply.
+type RBACPolicyImportApplyConfiguration struct {
+ ID *string `json:"id,omitempty"`
+ Filter *RBACPolicyFilterApplyConfiguration `json:"filter,omitempty"`
+}
+
+// RBACPolicyImportApplyConfiguration constructs a declarative configuration of the RBACPolicyImport type for use with
+// apply.
+func RBACPolicyImport() *RBACPolicyImportApplyConfiguration {
+ return &RBACPolicyImportApplyConfiguration{}
+}
+
+// WithID sets the ID field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the ID field is set to the value of the last call.
+func (b *RBACPolicyImportApplyConfiguration) WithID(value string) *RBACPolicyImportApplyConfiguration {
+ b.ID = &value
+ return b
+}
+
+// WithFilter sets the Filter field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Filter field is set to the value of the last call.
+func (b *RBACPolicyImportApplyConfiguration) WithFilter(value *RBACPolicyFilterApplyConfiguration) *RBACPolicyImportApplyConfiguration {
+ b.Filter = value
+ return b
+}
diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyresourcespec.go b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyresourcespec.go
new file mode 100644
index 000000000..674ffe7be
--- /dev/null
+++ b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyresourcespec.go
@@ -0,0 +1,70 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by applyconfiguration-gen. DO NOT EDIT.
+
+package v1alpha1
+
+import (
+ apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+)
+
+// RBACPolicyResourceSpecApplyConfiguration represents a declarative configuration of the RBACPolicyResourceSpec type for use
+// with apply.
+type RBACPolicyResourceSpecApplyConfiguration struct {
+ NetworkRef *apiv1alpha1.KubernetesNameRef `json:"networkRef,omitempty"`
+ Action *apiv1alpha1.RBACPolicyAction `json:"action,omitempty"`
+ TargetProjectRef *apiv1alpha1.KubernetesNameRef `json:"targetProjectRef,omitempty"`
+ TargetProjectID *string `json:"targetProjectID,omitempty"`
+}
+
+// RBACPolicyResourceSpecApplyConfiguration constructs a declarative configuration of the RBACPolicyResourceSpec type for use with
+// apply.
+func RBACPolicyResourceSpec() *RBACPolicyResourceSpecApplyConfiguration {
+ return &RBACPolicyResourceSpecApplyConfiguration{}
+}
+
+// WithNetworkRef sets the NetworkRef field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the NetworkRef field is set to the value of the last call.
+func (b *RBACPolicyResourceSpecApplyConfiguration) WithNetworkRef(value apiv1alpha1.KubernetesNameRef) *RBACPolicyResourceSpecApplyConfiguration {
+ b.NetworkRef = &value
+ return b
+}
+
+// WithAction sets the Action field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Action field is set to the value of the last call.
+func (b *RBACPolicyResourceSpecApplyConfiguration) WithAction(value apiv1alpha1.RBACPolicyAction) *RBACPolicyResourceSpecApplyConfiguration {
+ b.Action = &value
+ return b
+}
+
+// WithTargetProjectRef sets the TargetProjectRef field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the TargetProjectRef field is set to the value of the last call.
+func (b *RBACPolicyResourceSpecApplyConfiguration) WithTargetProjectRef(value apiv1alpha1.KubernetesNameRef) *RBACPolicyResourceSpecApplyConfiguration {
+ b.TargetProjectRef = &value
+ return b
+}
+
+// WithTargetProjectID sets the TargetProjectID field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the TargetProjectID field is set to the value of the last call.
+func (b *RBACPolicyResourceSpecApplyConfiguration) WithTargetProjectID(value string) *RBACPolicyResourceSpecApplyConfiguration {
+ b.TargetProjectID = &value
+ return b
+}
diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyresourcestatus.go b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyresourcestatus.go
new file mode 100644
index 000000000..8377f5c2d
--- /dev/null
+++ b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyresourcestatus.go
@@ -0,0 +1,66 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by applyconfiguration-gen. DO NOT EDIT.
+
+package v1alpha1
+
+// RBACPolicyResourceStatusApplyConfiguration represents a declarative configuration of the RBACPolicyResourceStatus type for use
+// with apply.
+type RBACPolicyResourceStatusApplyConfiguration struct {
+ NetworkID *string `json:"networkID,omitempty"`
+ Action *string `json:"action,omitempty"`
+ TargetProjectID *string `json:"targetProjectID,omitempty"`
+ ProjectID *string `json:"projectID,omitempty"`
+}
+
+// RBACPolicyResourceStatusApplyConfiguration constructs a declarative configuration of the RBACPolicyResourceStatus type for use with
+// apply.
+func RBACPolicyResourceStatus() *RBACPolicyResourceStatusApplyConfiguration {
+ return &RBACPolicyResourceStatusApplyConfiguration{}
+}
+
+// WithNetworkID sets the NetworkID field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the NetworkID field is set to the value of the last call.
+func (b *RBACPolicyResourceStatusApplyConfiguration) WithNetworkID(value string) *RBACPolicyResourceStatusApplyConfiguration {
+ b.NetworkID = &value
+ return b
+}
+
+// WithAction sets the Action field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Action field is set to the value of the last call.
+func (b *RBACPolicyResourceStatusApplyConfiguration) WithAction(value string) *RBACPolicyResourceStatusApplyConfiguration {
+ b.Action = &value
+ return b
+}
+
+// WithTargetProjectID sets the TargetProjectID field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the TargetProjectID field is set to the value of the last call.
+func (b *RBACPolicyResourceStatusApplyConfiguration) WithTargetProjectID(value string) *RBACPolicyResourceStatusApplyConfiguration {
+ b.TargetProjectID = &value
+ return b
+}
+
+// WithProjectID sets the ProjectID field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the ProjectID field is set to the value of the last call.
+func (b *RBACPolicyResourceStatusApplyConfiguration) WithProjectID(value string) *RBACPolicyResourceStatusApplyConfiguration {
+ b.ProjectID = &value
+ return b
+}
diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyspec.go b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyspec.go
new file mode 100644
index 000000000..eab9218bf
--- /dev/null
+++ b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicyspec.go
@@ -0,0 +1,89 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by applyconfiguration-gen. DO NOT EDIT.
+
+package v1alpha1
+
+import (
+ apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+)
+
+// RBACPolicySpecApplyConfiguration represents a declarative configuration of the RBACPolicySpec type for use
+// with apply.
+type RBACPolicySpecApplyConfiguration struct {
+ Import *RBACPolicyImportApplyConfiguration `json:"import,omitempty"`
+ Resource *RBACPolicyResourceSpecApplyConfiguration `json:"resource,omitempty"`
+ ManagementPolicy *apiv1alpha1.ManagementPolicy `json:"managementPolicy,omitempty"`
+ ManagedOptions *ManagedOptionsApplyConfiguration `json:"managedOptions,omitempty"`
+ ResyncPeriod *v1.Duration `json:"resyncPeriod,omitempty"`
+ CloudCredentialsRef *CloudCredentialsReferenceApplyConfiguration `json:"cloudCredentialsRef,omitempty"`
+}
+
+// RBACPolicySpecApplyConfiguration constructs a declarative configuration of the RBACPolicySpec type for use with
+// apply.
+func RBACPolicySpec() *RBACPolicySpecApplyConfiguration {
+ return &RBACPolicySpecApplyConfiguration{}
+}
+
+// WithImport sets the Import field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Import field is set to the value of the last call.
+func (b *RBACPolicySpecApplyConfiguration) WithImport(value *RBACPolicyImportApplyConfiguration) *RBACPolicySpecApplyConfiguration {
+ b.Import = value
+ return b
+}
+
+// WithResource sets the Resource field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Resource field is set to the value of the last call.
+func (b *RBACPolicySpecApplyConfiguration) WithResource(value *RBACPolicyResourceSpecApplyConfiguration) *RBACPolicySpecApplyConfiguration {
+ b.Resource = value
+ return b
+}
+
+// WithManagementPolicy sets the ManagementPolicy field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the ManagementPolicy field is set to the value of the last call.
+func (b *RBACPolicySpecApplyConfiguration) WithManagementPolicy(value apiv1alpha1.ManagementPolicy) *RBACPolicySpecApplyConfiguration {
+ b.ManagementPolicy = &value
+ return b
+}
+
+// WithManagedOptions sets the ManagedOptions field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the ManagedOptions field is set to the value of the last call.
+func (b *RBACPolicySpecApplyConfiguration) WithManagedOptions(value *ManagedOptionsApplyConfiguration) *RBACPolicySpecApplyConfiguration {
+ b.ManagedOptions = value
+ return b
+}
+
+// WithResyncPeriod sets the ResyncPeriod field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the ResyncPeriod field is set to the value of the last call.
+func (b *RBACPolicySpecApplyConfiguration) WithResyncPeriod(value v1.Duration) *RBACPolicySpecApplyConfiguration {
+ b.ResyncPeriod = &value
+ return b
+}
+
+// WithCloudCredentialsRef sets the CloudCredentialsRef field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the CloudCredentialsRef field is set to the value of the last call.
+func (b *RBACPolicySpecApplyConfiguration) WithCloudCredentialsRef(value *CloudCredentialsReferenceApplyConfiguration) *RBACPolicySpecApplyConfiguration {
+ b.CloudCredentialsRef = value
+ return b
+}
diff --git a/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicystatus.go b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicystatus.go
new file mode 100644
index 000000000..6588392d8
--- /dev/null
+++ b/pkg/clients/applyconfiguration/api/v1alpha1/rbacpolicystatus.go
@@ -0,0 +1,76 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by applyconfiguration-gen. DO NOT EDIT.
+
+package v1alpha1
+
+import (
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ v1 "k8s.io/client-go/applyconfigurations/meta/v1"
+)
+
+// RBACPolicyStatusApplyConfiguration represents a declarative configuration of the RBACPolicyStatus type for use
+// with apply.
+type RBACPolicyStatusApplyConfiguration struct {
+ Conditions []v1.ConditionApplyConfiguration `json:"conditions,omitempty"`
+ ID *string `json:"id,omitempty"`
+ Resource *RBACPolicyResourceStatusApplyConfiguration `json:"resource,omitempty"`
+ LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
+}
+
+// RBACPolicyStatusApplyConfiguration constructs a declarative configuration of the RBACPolicyStatus type for use with
+// apply.
+func RBACPolicyStatus() *RBACPolicyStatusApplyConfiguration {
+ return &RBACPolicyStatusApplyConfiguration{}
+}
+
+// WithConditions adds the given value to the Conditions field in the declarative configuration
+// and returns the receiver, so that objects can be build by chaining "With" function invocations.
+// If called multiple times, values provided by each call will be appended to the Conditions field.
+func (b *RBACPolicyStatusApplyConfiguration) WithConditions(values ...*v1.ConditionApplyConfiguration) *RBACPolicyStatusApplyConfiguration {
+ for i := range values {
+ if values[i] == nil {
+ panic("nil value passed to WithConditions")
+ }
+ b.Conditions = append(b.Conditions, *values[i])
+ }
+ return b
+}
+
+// WithID sets the ID field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the ID field is set to the value of the last call.
+func (b *RBACPolicyStatusApplyConfiguration) WithID(value string) *RBACPolicyStatusApplyConfiguration {
+ b.ID = &value
+ return b
+}
+
+// WithResource sets the Resource field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Resource field is set to the value of the last call.
+func (b *RBACPolicyStatusApplyConfiguration) WithResource(value *RBACPolicyResourceStatusApplyConfiguration) *RBACPolicyStatusApplyConfiguration {
+ b.Resource = value
+ return b
+}
+
+// WithLastSyncTime sets the LastSyncTime field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the LastSyncTime field is set to the value of the last call.
+func (b *RBACPolicyStatusApplyConfiguration) WithLastSyncTime(value metav1.Time) *RBACPolicyStatusApplyConfiguration {
+ b.LastSyncTime = &value
+ return b
+}
diff --git a/pkg/clients/applyconfiguration/internal/internal.go b/pkg/clients/applyconfiguration/internal/internal.go
index 66cac7a36..41a4b66cb 100644
--- a/pkg/clients/applyconfiguration/internal/internal.go
+++ b/pkg/clients/applyconfiguration/internal/internal.go
@@ -2503,6 +2503,120 @@ var schemaYAML = typed.YAMLObject(`types:
- name: segmentationID
type:
scalar: numeric
+- name: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicy
+ map:
+ fields:
+ - name: apiVersion
+ type:
+ scalar: string
+ - name: kind
+ type:
+ scalar: string
+ - name: metadata
+ type:
+ namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
+ default: {}
+ - name: spec
+ type:
+ namedType: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicySpec
+ default: {}
+ - name: status
+ type:
+ namedType: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyStatus
+ default: {}
+- name: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyFilter
+ map:
+ fields:
+ - name: action
+ type:
+ scalar: string
+ - name: targetProjectID
+ type:
+ scalar: string
+ - name: targetProjectRef
+ type:
+ scalar: string
+- name: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyImport
+ map:
+ fields:
+ - name: filter
+ type:
+ namedType: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyFilter
+ - name: id
+ type:
+ scalar: string
+- name: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyResourceSpec
+ map:
+ fields:
+ - name: action
+ type:
+ scalar: string
+ - name: networkRef
+ type:
+ scalar: string
+ - name: targetProjectID
+ type:
+ scalar: string
+ - name: targetProjectRef
+ type:
+ scalar: string
+- name: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyResourceStatus
+ map:
+ fields:
+ - name: action
+ type:
+ scalar: string
+ - name: networkID
+ type:
+ scalar: string
+ - name: projectID
+ type:
+ scalar: string
+ - name: targetProjectID
+ type:
+ scalar: string
+- name: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicySpec
+ map:
+ fields:
+ - name: cloudCredentialsRef
+ type:
+ namedType: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.CloudCredentialsReference
+ default: {}
+ - name: import
+ type:
+ namedType: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyImport
+ - name: managedOptions
+ type:
+ namedType: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.ManagedOptions
+ - name: managementPolicy
+ type:
+ scalar: string
+ - name: resource
+ type:
+ namedType: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyResourceSpec
+ - name: resyncPeriod
+ type:
+ namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Duration
+- name: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyStatus
+ map:
+ fields:
+ - name: conditions
+ type:
+ list:
+ elementType:
+ namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Condition
+ elementRelationship: associative
+ keys:
+ - type
+ - name: id
+ type:
+ scalar: string
+ - name: lastSyncTime
+ type:
+ namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time
+ - name: resource
+ type:
+ namedType: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RBACPolicyResourceStatus
- name: com.github.k-orc.openstack-resource-controller.v3.api.v1alpha1.RecordSet
map:
fields:
diff --git a/pkg/clients/applyconfiguration/utils.go b/pkg/clients/applyconfiguration/utils.go
index 3309db411..7ff8113b4 100644
--- a/pkg/clients/applyconfiguration/utils.go
+++ b/pkg/clients/applyconfiguration/utils.go
@@ -298,6 +298,20 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &apiv1alpha1.ProviderPropertiesStatusApplyConfiguration{}
case v1alpha1.SchemeGroupVersion.WithKind("ProviderSegmentSpec"):
return &apiv1alpha1.ProviderSegmentSpecApplyConfiguration{}
+ case v1alpha1.SchemeGroupVersion.WithKind("RBACPolicy"):
+ return &apiv1alpha1.RBACPolicyApplyConfiguration{}
+ case v1alpha1.SchemeGroupVersion.WithKind("RBACPolicyFilter"):
+ return &apiv1alpha1.RBACPolicyFilterApplyConfiguration{}
+ case v1alpha1.SchemeGroupVersion.WithKind("RBACPolicyImport"):
+ return &apiv1alpha1.RBACPolicyImportApplyConfiguration{}
+ case v1alpha1.SchemeGroupVersion.WithKind("RBACPolicyResourceSpec"):
+ return &apiv1alpha1.RBACPolicyResourceSpecApplyConfiguration{}
+ case v1alpha1.SchemeGroupVersion.WithKind("RBACPolicyResourceStatus"):
+ return &apiv1alpha1.RBACPolicyResourceStatusApplyConfiguration{}
+ case v1alpha1.SchemeGroupVersion.WithKind("RBACPolicySpec"):
+ return &apiv1alpha1.RBACPolicySpecApplyConfiguration{}
+ case v1alpha1.SchemeGroupVersion.WithKind("RBACPolicyStatus"):
+ return &apiv1alpha1.RBACPolicyStatusApplyConfiguration{}
case v1alpha1.SchemeGroupVersion.WithKind("RecordSet"):
return &apiv1alpha1.RecordSetApplyConfiguration{}
case v1alpha1.SchemeGroupVersion.WithKind("RecordSetFilter"):
diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/api_client.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/api_client.go
index 595e88fc0..739f5001a 100644
--- a/pkg/clients/clientset/clientset/typed/api/v1alpha1/api_client.go
+++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/api_client.go
@@ -42,6 +42,7 @@ type OpenstackV1alpha1Interface interface {
NetworksGetter
PortsGetter
ProjectsGetter
+ RBACPoliciesGetter
RecordSetsGetter
RegionsGetter
RegisteredLimitsGetter
@@ -123,6 +124,10 @@ func (c *OpenstackV1alpha1Client) Projects(namespace string) ProjectInterface {
return newProjects(c, namespace)
}
+func (c *OpenstackV1alpha1Client) RBACPolicies(namespace string) RBACPolicyInterface {
+ return newRBACPolicies(c, namespace)
+}
+
func (c *OpenstackV1alpha1Client) RecordSets(namespace string) RecordSetInterface {
return newRecordSets(c, namespace)
}
diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_api_client.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_api_client.go
index a6fb37761..e66657386 100644
--- a/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_api_client.go
+++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_api_client.go
@@ -84,6 +84,10 @@ func (c *FakeOpenstackV1alpha1) Projects(namespace string) v1alpha1.ProjectInter
return newFakeProjects(c, namespace)
}
+func (c *FakeOpenstackV1alpha1) RBACPolicies(namespace string) v1alpha1.RBACPolicyInterface {
+ return newFakeRBACPolicies(c, namespace)
+}
+
func (c *FakeOpenstackV1alpha1) RecordSets(namespace string) v1alpha1.RecordSetInterface {
return newFakeRecordSets(c, namespace)
}
diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_rbacpolicy.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_rbacpolicy.go
new file mode 100644
index 000000000..78ab98832
--- /dev/null
+++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/fake/fake_rbacpolicy.go
@@ -0,0 +1,51 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by client-gen. DO NOT EDIT.
+
+package fake
+
+import (
+ v1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/applyconfiguration/api/v1alpha1"
+ typedapiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/clientset/clientset/typed/api/v1alpha1"
+ gentype "k8s.io/client-go/gentype"
+)
+
+// fakeRBACPolicies implements RBACPolicyInterface
+type fakeRBACPolicies struct {
+ *gentype.FakeClientWithListAndApply[*v1alpha1.RBACPolicy, *v1alpha1.RBACPolicyList, *apiv1alpha1.RBACPolicyApplyConfiguration]
+ Fake *FakeOpenstackV1alpha1
+}
+
+func newFakeRBACPolicies(fake *FakeOpenstackV1alpha1, namespace string) typedapiv1alpha1.RBACPolicyInterface {
+ return &fakeRBACPolicies{
+ gentype.NewFakeClientWithListAndApply[*v1alpha1.RBACPolicy, *v1alpha1.RBACPolicyList, *apiv1alpha1.RBACPolicyApplyConfiguration](
+ fake.Fake,
+ namespace,
+ v1alpha1.SchemeGroupVersion.WithResource("rbacpolicies"),
+ v1alpha1.SchemeGroupVersion.WithKind("RBACPolicy"),
+ func() *v1alpha1.RBACPolicy { return &v1alpha1.RBACPolicy{} },
+ func() *v1alpha1.RBACPolicyList { return &v1alpha1.RBACPolicyList{} },
+ func(dst, src *v1alpha1.RBACPolicyList) { dst.ListMeta = src.ListMeta },
+ func(list *v1alpha1.RBACPolicyList) []*v1alpha1.RBACPolicy { return gentype.ToPointerSlice(list.Items) },
+ func(list *v1alpha1.RBACPolicyList, items []*v1alpha1.RBACPolicy) {
+ list.Items = gentype.FromPointerSlice(items)
+ },
+ ),
+ fake,
+ }
+}
diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/generated_expansion.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/generated_expansion.go
index c0df3192c..072cdbc7a 100644
--- a/pkg/clients/clientset/clientset/typed/api/v1alpha1/generated_expansion.go
+++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/generated_expansion.go
@@ -46,6 +46,8 @@ type PortExpansion interface{}
type ProjectExpansion interface{}
+type RBACPolicyExpansion interface{}
+
type RecordSetExpansion interface{}
type RegionExpansion interface{}
diff --git a/pkg/clients/clientset/clientset/typed/api/v1alpha1/rbacpolicy.go b/pkg/clients/clientset/clientset/typed/api/v1alpha1/rbacpolicy.go
new file mode 100644
index 000000000..a7ab7242e
--- /dev/null
+++ b/pkg/clients/clientset/clientset/typed/api/v1alpha1/rbacpolicy.go
@@ -0,0 +1,74 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by client-gen. DO NOT EDIT.
+
+package v1alpha1
+
+import (
+ context "context"
+
+ apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ applyconfigurationapiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/applyconfiguration/api/v1alpha1"
+ scheme "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/clientset/clientset/scheme"
+ v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ types "k8s.io/apimachinery/pkg/types"
+ watch "k8s.io/apimachinery/pkg/watch"
+ gentype "k8s.io/client-go/gentype"
+)
+
+// RBACPoliciesGetter has a method to return a RBACPolicyInterface.
+// A group's client should implement this interface.
+type RBACPoliciesGetter interface {
+ RBACPolicies(namespace string) RBACPolicyInterface
+}
+
+// RBACPolicyInterface has methods to work with RBACPolicy resources.
+type RBACPolicyInterface interface {
+ Create(ctx context.Context, rBACPolicy *apiv1alpha1.RBACPolicy, opts v1.CreateOptions) (*apiv1alpha1.RBACPolicy, error)
+ Update(ctx context.Context, rBACPolicy *apiv1alpha1.RBACPolicy, opts v1.UpdateOptions) (*apiv1alpha1.RBACPolicy, error)
+ // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
+ UpdateStatus(ctx context.Context, rBACPolicy *apiv1alpha1.RBACPolicy, opts v1.UpdateOptions) (*apiv1alpha1.RBACPolicy, error)
+ Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
+ DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
+ Get(ctx context.Context, name string, opts v1.GetOptions) (*apiv1alpha1.RBACPolicy, error)
+ List(ctx context.Context, opts v1.ListOptions) (*apiv1alpha1.RBACPolicyList, error)
+ Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
+ Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *apiv1alpha1.RBACPolicy, err error)
+ Apply(ctx context.Context, rBACPolicy *applyconfigurationapiv1alpha1.RBACPolicyApplyConfiguration, opts v1.ApplyOptions) (result *apiv1alpha1.RBACPolicy, err error)
+ // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
+ ApplyStatus(ctx context.Context, rBACPolicy *applyconfigurationapiv1alpha1.RBACPolicyApplyConfiguration, opts v1.ApplyOptions) (result *apiv1alpha1.RBACPolicy, err error)
+ RBACPolicyExpansion
+}
+
+// rBACPolicies implements RBACPolicyInterface
+type rBACPolicies struct {
+ *gentype.ClientWithListAndApply[*apiv1alpha1.RBACPolicy, *apiv1alpha1.RBACPolicyList, *applyconfigurationapiv1alpha1.RBACPolicyApplyConfiguration]
+}
+
+// newRBACPolicies returns a RBACPolicies
+func newRBACPolicies(c *OpenstackV1alpha1Client, namespace string) *rBACPolicies {
+ return &rBACPolicies{
+ gentype.NewClientWithListAndApply[*apiv1alpha1.RBACPolicy, *apiv1alpha1.RBACPolicyList, *applyconfigurationapiv1alpha1.RBACPolicyApplyConfiguration](
+ "rbacpolicies",
+ c.RESTClient(),
+ scheme.ParameterCodec,
+ namespace,
+ func() *apiv1alpha1.RBACPolicy { return &apiv1alpha1.RBACPolicy{} },
+ func() *apiv1alpha1.RBACPolicyList { return &apiv1alpha1.RBACPolicyList{} },
+ ),
+ }
+}
diff --git a/pkg/clients/informers/externalversions/api/v1alpha1/interface.go b/pkg/clients/informers/externalversions/api/v1alpha1/interface.go
index eafde09c9..02933e85a 100644
--- a/pkg/clients/informers/externalversions/api/v1alpha1/interface.go
+++ b/pkg/clients/informers/externalversions/api/v1alpha1/interface.go
@@ -52,6 +52,8 @@ type Interface interface {
Ports() PortInformer
// Projects returns a ProjectInformer.
Projects() ProjectInformer
+ // RBACPolicies returns a RBACPolicyInformer.
+ RBACPolicies() RBACPolicyInformer
// RecordSets returns a RecordSetInformer.
RecordSets() RecordSetInformer
// Regions returns a RegionInformer.
@@ -171,6 +173,11 @@ func (v *version) Projects() ProjectInformer {
return &projectInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
+// RBACPolicies returns a RBACPolicyInformer.
+func (v *version) RBACPolicies() RBACPolicyInformer {
+ return &rBACPolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
+}
+
// RecordSets returns a RecordSetInformer.
func (v *version) RecordSets() RecordSetInformer {
return &recordSetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
diff --git a/pkg/clients/informers/externalversions/api/v1alpha1/rbacpolicy.go b/pkg/clients/informers/externalversions/api/v1alpha1/rbacpolicy.go
new file mode 100644
index 000000000..09a2344ac
--- /dev/null
+++ b/pkg/clients/informers/externalversions/api/v1alpha1/rbacpolicy.go
@@ -0,0 +1,102 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by informer-gen. DO NOT EDIT.
+
+package v1alpha1
+
+import (
+ context "context"
+ time "time"
+
+ v3apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ clientset "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/clientset/clientset"
+ internalinterfaces "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/informers/externalversions/internalinterfaces"
+ apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/listers/api/v1alpha1"
+ v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ runtime "k8s.io/apimachinery/pkg/runtime"
+ watch "k8s.io/apimachinery/pkg/watch"
+ cache "k8s.io/client-go/tools/cache"
+)
+
+// RBACPolicyInformer provides access to a shared informer and lister for
+// RBACPolicies.
+type RBACPolicyInformer interface {
+ Informer() cache.SharedIndexInformer
+ Lister() apiv1alpha1.RBACPolicyLister
+}
+
+type rBACPolicyInformer struct {
+ factory internalinterfaces.SharedInformerFactory
+ tweakListOptions internalinterfaces.TweakListOptionsFunc
+ namespace string
+}
+
+// NewRBACPolicyInformer constructs a new informer for RBACPolicy type.
+// Always prefer using an informer factory to get a shared informer instead of getting an independent
+// one. This reduces memory footprint and number of connections to the server.
+func NewRBACPolicyInformer(client clientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
+ return NewFilteredRBACPolicyInformer(client, namespace, resyncPeriod, indexers, nil)
+}
+
+// NewFilteredRBACPolicyInformer constructs a new informer for RBACPolicy type.
+// Always prefer using an informer factory to get a shared informer instead of getting an independent
+// one. This reduces memory footprint and number of connections to the server.
+func NewFilteredRBACPolicyInformer(client clientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
+ return cache.NewSharedIndexInformer(
+ &cache.ListWatch{
+ ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
+ if tweakListOptions != nil {
+ tweakListOptions(&options)
+ }
+ return client.OpenstackV1alpha1().RBACPolicies(namespace).List(context.Background(), options)
+ },
+ WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
+ if tweakListOptions != nil {
+ tweakListOptions(&options)
+ }
+ return client.OpenstackV1alpha1().RBACPolicies(namespace).Watch(context.Background(), options)
+ },
+ ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) {
+ if tweakListOptions != nil {
+ tweakListOptions(&options)
+ }
+ return client.OpenstackV1alpha1().RBACPolicies(namespace).List(ctx, options)
+ },
+ WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) {
+ if tweakListOptions != nil {
+ tweakListOptions(&options)
+ }
+ return client.OpenstackV1alpha1().RBACPolicies(namespace).Watch(ctx, options)
+ },
+ },
+ &v3apiv1alpha1.RBACPolicy{},
+ resyncPeriod,
+ indexers,
+ )
+}
+
+func (f *rBACPolicyInformer) defaultInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
+ return NewFilteredRBACPolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
+}
+
+func (f *rBACPolicyInformer) Informer() cache.SharedIndexInformer {
+ return f.factory.InformerFor(&v3apiv1alpha1.RBACPolicy{}, f.defaultInformer)
+}
+
+func (f *rBACPolicyInformer) Lister() apiv1alpha1.RBACPolicyLister {
+ return apiv1alpha1.NewRBACPolicyLister(f.Informer().GetIndexer())
+}
diff --git a/pkg/clients/informers/externalversions/generic.go b/pkg/clients/informers/externalversions/generic.go
index 1abdbaa1c..1c047639a 100644
--- a/pkg/clients/informers/externalversions/generic.go
+++ b/pkg/clients/informers/externalversions/generic.go
@@ -81,6 +81,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
return &genericInformer{resource: resource.GroupResource(), informer: f.Openstack().V1alpha1().Ports().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("projects"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Openstack().V1alpha1().Projects().Informer()}, nil
+ case v1alpha1.SchemeGroupVersion.WithResource("rbacpolicies"):
+ return &genericInformer{resource: resource.GroupResource(), informer: f.Openstack().V1alpha1().RBACPolicies().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("recordsets"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Openstack().V1alpha1().RecordSets().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("regions"):
diff --git a/pkg/clients/listers/api/v1alpha1/expansion_generated.go b/pkg/clients/listers/api/v1alpha1/expansion_generated.go
index 4d91e5e73..19b54bc45 100644
--- a/pkg/clients/listers/api/v1alpha1/expansion_generated.go
+++ b/pkg/clients/listers/api/v1alpha1/expansion_generated.go
@@ -130,6 +130,14 @@ type ProjectListerExpansion interface{}
// ProjectNamespaceLister.
type ProjectNamespaceListerExpansion interface{}
+// RBACPolicyListerExpansion allows custom methods to be added to
+// RBACPolicyLister.
+type RBACPolicyListerExpansion interface{}
+
+// RBACPolicyNamespaceListerExpansion allows custom methods to be added to
+// RBACPolicyNamespaceLister.
+type RBACPolicyNamespaceListerExpansion interface{}
+
// RecordSetListerExpansion allows custom methods to be added to
// RecordSetLister.
type RecordSetListerExpansion interface{}
diff --git a/pkg/clients/listers/api/v1alpha1/rbacpolicy.go b/pkg/clients/listers/api/v1alpha1/rbacpolicy.go
new file mode 100644
index 000000000..84aa07f71
--- /dev/null
+++ b/pkg/clients/listers/api/v1alpha1/rbacpolicy.go
@@ -0,0 +1,70 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by lister-gen. DO NOT EDIT.
+
+package v1alpha1
+
+import (
+ apiv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ labels "k8s.io/apimachinery/pkg/labels"
+ listers "k8s.io/client-go/listers"
+ cache "k8s.io/client-go/tools/cache"
+)
+
+// RBACPolicyLister helps list RBACPolicies.
+// All objects returned here must be treated as read-only.
+type RBACPolicyLister interface {
+ // List lists all RBACPolicies in the indexer.
+ // Objects returned here must be treated as read-only.
+ List(selector labels.Selector) (ret []*apiv1alpha1.RBACPolicy, err error)
+ // RBACPolicies returns an object that can list and get RBACPolicies.
+ RBACPolicies(namespace string) RBACPolicyNamespaceLister
+ RBACPolicyListerExpansion
+}
+
+// rBACPolicyLister implements the RBACPolicyLister interface.
+type rBACPolicyLister struct {
+ listers.ResourceIndexer[*apiv1alpha1.RBACPolicy]
+}
+
+// NewRBACPolicyLister returns a new RBACPolicyLister.
+func NewRBACPolicyLister(indexer cache.Indexer) RBACPolicyLister {
+ return &rBACPolicyLister{listers.New[*apiv1alpha1.RBACPolicy](indexer, apiv1alpha1.Resource("rbacpolicy"))}
+}
+
+// RBACPolicies returns an object that can list and get RBACPolicies.
+func (s *rBACPolicyLister) RBACPolicies(namespace string) RBACPolicyNamespaceLister {
+ return rBACPolicyNamespaceLister{listers.NewNamespaced[*apiv1alpha1.RBACPolicy](s.ResourceIndexer, namespace)}
+}
+
+// RBACPolicyNamespaceLister helps list and get RBACPolicies.
+// All objects returned here must be treated as read-only.
+type RBACPolicyNamespaceLister interface {
+ // List lists all RBACPolicies in the indexer for a given namespace.
+ // Objects returned here must be treated as read-only.
+ List(selector labels.Selector) (ret []*apiv1alpha1.RBACPolicy, err error)
+ // Get retrieves the RBACPolicy from the indexer for a given namespace and name.
+ // Objects returned here must be treated as read-only.
+ Get(name string) (*apiv1alpha1.RBACPolicy, error)
+ RBACPolicyNamespaceListerExpansion
+}
+
+// rBACPolicyNamespaceLister implements the RBACPolicyNamespaceLister
+// interface.
+type rBACPolicyNamespaceLister struct {
+ listers.ResourceIndexer[*apiv1alpha1.RBACPolicy]
+}
diff --git a/test/apivalidations/rbacpolicy_test.go b/test/apivalidations/rbacpolicy_test.go
new file mode 100644
index 000000000..b68d05c5a
--- /dev/null
+++ b/test/apivalidations/rbacpolicy_test.go
@@ -0,0 +1,184 @@
+/*
+Copyright The ORC Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package apivalidations
+
+import (
+ "context"
+
+ . "github.com/onsi/ginkgo/v2"
+ . "github.com/onsi/gomega"
+ corev1 "k8s.io/api/core/v1"
+ "sigs.k8s.io/controller-runtime/pkg/client"
+
+ orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/api/v1alpha1"
+ applyconfigv1alpha1 "github.com/k-orc/openstack-resource-controller/v3/pkg/clients/applyconfiguration/api/v1alpha1"
+)
+
+const (
+ rbacpolicyName = "rbacpolicy"
+ rbacpolicyID = "265c9e4f-0f5a-46e4-9f3f-fb8de25ae120"
+)
+
+func rbacpolicyStub(namespace *corev1.Namespace) *orcv1alpha1.RBACPolicy {
+ obj := &orcv1alpha1.RBACPolicy{}
+ obj.Name = rbacpolicyName
+ obj.Namespace = namespace.Name
+ return obj
+}
+
+func testRBACPolicyResource() *applyconfigv1alpha1.RBACPolicyResourceSpecApplyConfiguration {
+ return applyconfigv1alpha1.RBACPolicyResourceSpec().
+ WithNetworkRef("network").
+ WithAction(orcv1alpha1.RBACPolicyActionAccessShared).
+ WithTargetProjectID("3fac9d0b0e0e4b0e9b0e000000000001")
+}
+
+func baseRBACPolicyPatch(obj client.Object) *applyconfigv1alpha1.RBACPolicyApplyConfiguration {
+ return applyconfigv1alpha1.RBACPolicy(obj.GetName(), obj.GetNamespace()).
+ WithSpec(applyconfigv1alpha1.RBACPolicySpec().
+ WithCloudCredentialsRef(testCredentials()))
+}
+
+func testRBACPolicyImport() *applyconfigv1alpha1.RBACPolicyImportApplyConfiguration {
+ return applyconfigv1alpha1.RBACPolicyImport().WithID(rbacpolicyID)
+}
+
+var _ = Describe("ORC RBACPolicy API validations", func() {
+ var namespace *corev1.Namespace
+ BeforeEach(func() {
+ namespace = createNamespace()
+ })
+
+ runManagementPolicyTests(func() *corev1.Namespace { return namespace }, managementPolicyTestArgs[*applyconfigv1alpha1.RBACPolicyApplyConfiguration]{
+ createObject: func(ns *corev1.Namespace) client.Object { return rbacpolicyStub(ns) },
+ basePatch: func(obj client.Object) *applyconfigv1alpha1.RBACPolicyApplyConfiguration {
+ return baseRBACPolicyPatch(obj)
+ },
+ applyResource: func(p *applyconfigv1alpha1.RBACPolicyApplyConfiguration) {
+ p.Spec.WithResource(testRBACPolicyResource())
+ },
+ applyImport: func(p *applyconfigv1alpha1.RBACPolicyApplyConfiguration) {
+ p.Spec.WithImport(testRBACPolicyImport())
+ },
+ applyEmptyImport: func(p *applyconfigv1alpha1.RBACPolicyApplyConfiguration) {
+ p.Spec.WithImport(applyconfigv1alpha1.RBACPolicyImport())
+ },
+ applyEmptyFilter: func(p *applyconfigv1alpha1.RBACPolicyApplyConfiguration) {
+ p.Spec.WithImport(applyconfigv1alpha1.RBACPolicyImport().WithFilter(applyconfigv1alpha1.RBACPolicyFilter()))
+ },
+ applyValidFilter: func(p *applyconfigv1alpha1.RBACPolicyApplyConfiguration) {
+ p.Spec.WithImport(applyconfigv1alpha1.RBACPolicyImport().WithFilter(applyconfigv1alpha1.RBACPolicyFilter().WithTargetProjectID("foo")))
+ },
+ applyManaged: func(p *applyconfigv1alpha1.RBACPolicyApplyConfiguration) {
+ p.Spec.WithManagementPolicy(orcv1alpha1.ManagementPolicyManaged)
+ },
+ applyUnmanaged: func(p *applyconfigv1alpha1.RBACPolicyApplyConfiguration) {
+ p.Spec.WithManagementPolicy(orcv1alpha1.ManagementPolicyUnmanaged)
+ },
+ applyManagedOptions: func(p *applyconfigv1alpha1.RBACPolicyApplyConfiguration) {
+ p.Spec.WithManagedOptions(applyconfigv1alpha1.ManagedOptions().WithOnDelete(orcv1alpha1.OnDeleteDetach))
+ },
+ getManagementPolicy: func(obj client.Object) orcv1alpha1.ManagementPolicy {
+ return obj.(*orcv1alpha1.RBACPolicy).Spec.ManagementPolicy
+ },
+ getOnDelete: func(obj client.Object) orcv1alpha1.OnDelete {
+ return obj.(*orcv1alpha1.RBACPolicy).Spec.ManagedOptions.OnDelete
+ },
+ })
+
+ It("should reject a rbacpolicy without required fields", func(ctx context.Context) {
+ obj := rbacpolicyStub(namespace)
+ patch := baseRBACPolicyPatch(obj)
+ patch.Spec.WithResource(applyconfigv1alpha1.RBACPolicyResourceSpec())
+ Expect(applyObj(ctx, obj, patch)).NotTo(Succeed())
+ })
+
+ It("should have immutable networkRef", func(ctx context.Context) {
+ obj := rbacpolicyStub(namespace)
+ patch := baseRBACPolicyPatch(obj)
+ patch.Spec.WithResource(testRBACPolicyResource().
+ WithNetworkRef("network-a"))
+ Expect(applyObj(ctx, obj, patch)).To(Succeed())
+
+ patch.Spec.WithResource(testRBACPolicyResource().
+ WithNetworkRef("network-b"))
+ Expect(applyObj(ctx, obj, patch)).To(MatchError(ContainSubstring("networkRef is immutable")))
+ })
+
+ It("should have immutable action", func(ctx context.Context) {
+ obj := rbacpolicyStub(namespace)
+ patch := baseRBACPolicyPatch(obj)
+ patch.Spec.WithResource(testRBACPolicyResource().
+ WithAction(orcv1alpha1.RBACPolicyActionAccessShared))
+ Expect(applyObj(ctx, obj, patch)).To(Succeed())
+
+ patch.Spec.WithResource(testRBACPolicyResource().
+ WithAction(orcv1alpha1.RBACPolicyActionAccessExternal))
+ Expect(applyObj(ctx, obj, patch)).To(MatchError(ContainSubstring("action is immutable")))
+ })
+
+ It("should reject an invalid action value", func(ctx context.Context) {
+ obj := rbacpolicyStub(namespace)
+ patch := baseRBACPolicyPatch(obj)
+ patch.Spec.WithResource(testRBACPolicyResource().
+ WithAction("not_a_real_action"))
+ Expect(applyObj(ctx, obj, patch)).NotTo(Succeed())
+ })
+
+ It("should allow mutating targetProjectID", func(ctx context.Context) {
+ obj := rbacpolicyStub(namespace)
+ patch := baseRBACPolicyPatch(obj)
+ patch.Spec.WithResource(testRBACPolicyResource().
+ WithTargetProjectID("3fac9d0b0e0e4b0e9b0e000000000001"))
+ Expect(applyObj(ctx, obj, patch)).To(Succeed())
+
+ patch.Spec.WithResource(testRBACPolicyResource().
+ WithTargetProjectID("4fac9d0b0e0e4b0e9b0e000000000002"))
+ Expect(applyObj(ctx, obj, patch)).To(Succeed())
+ })
+
+ It("should allow targetProjectRef instead of targetProjectID", func(ctx context.Context) {
+ obj := rbacpolicyStub(namespace)
+ patch := baseRBACPolicyPatch(obj)
+ patch.Spec.WithResource(applyconfigv1alpha1.RBACPolicyResourceSpec().
+ WithNetworkRef("network").
+ WithAction(orcv1alpha1.RBACPolicyActionAccessShared).
+ WithTargetProjectRef("project"))
+ Expect(applyObj(ctx, obj, patch)).To(Succeed())
+ })
+
+ It("should require one of targetProjectRef and targetProjectID", func(ctx context.Context) {
+ obj := rbacpolicyStub(namespace)
+ patch := baseRBACPolicyPatch(obj)
+ patch.Spec.WithResource(applyconfigv1alpha1.RBACPolicyResourceSpec().
+ WithNetworkRef("network").
+ WithAction(orcv1alpha1.RBACPolicyActionAccessShared))
+ Expect(applyObj(ctx, obj, patch)).To(MatchError(ContainSubstring("exactly one of targetProjectRef and targetProjectID must be set")))
+
+ patch.Spec.WithResource(testRBACPolicyResource().WithTargetProjectRef("project"))
+ Expect(applyObj(ctx, obj, patch)).To(MatchError(ContainSubstring("exactly one of targetProjectRef and targetProjectID must be set")))
+ })
+
+ It("should reject a filter with both targetProjectRef and targetProjectID", func(ctx context.Context) {
+ obj := rbacpolicyStub(namespace)
+ patch := baseRBACPolicyPatch(obj)
+ patch.Spec.WithManagementPolicy(orcv1alpha1.ManagementPolicyUnmanaged).
+ WithImport(applyconfigv1alpha1.RBACPolicyImport().WithFilter(applyconfigv1alpha1.RBACPolicyFilter().
+ WithTargetProjectID("foo").WithTargetProjectRef("project")))
+ Expect(applyObj(ctx, obj, patch)).To(MatchError(ContainSubstring("only one of targetProjectRef and targetProjectID can be set")))
+ })
+})
diff --git a/website/docs/crd-reference.md b/website/docs/crd-reference.md
index 1372241c8..879ea96a7 100644
--- a/website/docs/crd-reference.md
+++ b/website/docs/crd-reference.md
@@ -24,6 +24,7 @@ Package v1alpha1 contains API Schema definitions for the openstack v1alpha1 API
- [Network](#network)
- [Port](#port)
- [Project](#project)
+- [RBACPolicy](#rbacpolicy)
- [RecordSet](#recordset)
- [Region](#region)
- [RegisteredLimit](#registeredlimit)
@@ -529,6 +530,7 @@ _Appears in:_
- [NetworkSpec](#networkspec)
- [PortSpec](#portspec)
- [ProjectSpec](#projectspec)
+- [RBACPolicySpec](#rbacpolicyspec)
- [RecordSetSpec](#recordsetspec)
- [RegionSpec](#regionspec)
- [RegisteredLimitSpec](#registeredlimitspec)
@@ -2444,6 +2446,8 @@ _Appears in:_
- [PortResourceSpec](#portresourcespec)
- [ProjectFilter](#projectfilter)
- [ProjectResourceSpec](#projectresourcespec)
+- [RBACPolicyFilter](#rbacpolicyfilter)
+- [RBACPolicyResourceSpec](#rbacpolicyresourcespec)
- [RecordSetFilter](#recordsetfilter)
- [RecordSetResourceSpec](#recordsetresourcespec)
- [RegisteredLimitFilter](#registeredlimitfilter)
@@ -2675,6 +2679,7 @@ _Appears in:_
- [NetworkSpec](#networkspec)
- [PortSpec](#portspec)
- [ProjectSpec](#projectspec)
+- [RBACPolicySpec](#rbacpolicyspec)
- [RecordSetSpec](#recordsetspec)
- [RegionSpec](#regionspec)
- [RegisteredLimitSpec](#registeredlimitspec)
@@ -2722,6 +2727,7 @@ _Appears in:_
- [NetworkSpec](#networkspec)
- [PortSpec](#portspec)
- [ProjectSpec](#projectspec)
+- [RBACPolicySpec](#rbacpolicyspec)
- [RecordSetSpec](#recordsetspec)
- [RegionSpec](#regionspec)
- [RegisteredLimitSpec](#registeredlimitspec)
@@ -3564,6 +3570,162 @@ _Appears in:_
| `segmentationID` _integer_ | segmentationID is the ID of the isolated segment on the
physical network. The network_type attribute defines the
segmentation model. For example, if the network_type value is vlan,
this ID is a vlan identifier. If the network_type value is gre, this
ID is a gre key. | | Minimum: 0
Optional: \{\}
|
+#### RBACPolicy
+
+
+
+RBACPolicy is the Schema for an ORC resource.
+
+
+
+
+
+| Field | Description | Default | Validation |
+| --- | --- | --- | --- |
+| `apiVersion` _string_ | `openstack.k-orc.cloud/v1alpha1` | | |
+| `kind` _string_ | `RBACPolicy` | | |
+| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | Optional: \{\}
|
+| `spec` _[RBACPolicySpec](#rbacpolicyspec)_ | spec specifies the desired state of the resource. | | Required: \{\}
|
+| `status` _[RBACPolicyStatus](#rbacpolicystatus)_ | status defines the observed state of the resource. | | Optional: \{\}
|
+
+
+#### RBACPolicyAction
+
+_Underlying type:_ _string_
+
+RBACPolicyAction is the type of access being granted by an RBAC policy.
+
+_Validation:_
+- Enum: [access_as_shared access_as_external]
+
+_Appears in:_
+- [RBACPolicyFilter](#rbacpolicyfilter)
+- [RBACPolicyResourceSpec](#rbacpolicyresourcespec)
+
+| Field | Description |
+| --- | --- |
+| `access_as_shared` | RBACPolicyActionAccessShared grants the target project permission to attach ports to
(use) the network, without granting any ability to manage the network itself.
|
+| `access_as_external` | RBACPolicyActionAccessExternal grants the target project permission to use the network
as an external gateway.
|
+
+
+#### RBACPolicyFilter
+
+
+
+RBACPolicyFilter defines an existing resource by its properties
+
+_Validation:_
+- MinProperties: 1
+
+_Appears in:_
+- [RBACPolicyImport](#rbacpolicyimport)
+
+| Field | Description | Default | Validation |
+| --- | --- | --- | --- |
+| `action` _[RBACPolicyAction](#rbacpolicyaction)_ | action of the existing resource | | Enum: [access_as_shared access_as_external]
Optional: \{\}
|
+| `targetProjectRef` _[KubernetesNameRef](#kubernetesnameref)_ | targetProjectRef is a reference to the ORC Project of the existing resource's target | | MaxLength: 253
MinLength: 1
Optional: \{\}
|
+| `targetProjectID` _string_ | targetProjectID of the existing resource | | MaxLength: 64
MinLength: 1
Optional: \{\}
|
+
+
+#### RBACPolicyImport
+
+
+
+RBACPolicyImport specifies an existing resource which will be imported instead of
+creating a new one
+
+_Validation:_
+- MaxProperties: 1
+- MinProperties: 1
+
+_Appears in:_
+- [RBACPolicySpec](#rbacpolicyspec)
+
+| Field | Description | Default | Validation |
+| --- | --- | --- | --- |
+| `id` _string_ | id contains the unique identifier of an existing OpenStack resource. Note
that when specifying an import by ID, the resource MUST already exist.
The ORC object will enter an error state if the resource does not exist. | | Format: uuid
MaxLength: 36
Optional: \{\}
|
+| `filter` _[RBACPolicyFilter](#rbacpolicyfilter)_ | filter contains a resource query which is expected to return a single
result. The controller will continue to retry if filter returns no
results. If filter returns multiple results the controller will set an
error state and will not continue to retry. | | MinProperties: 1
Optional: \{\}
|
+
+
+#### RBACPolicyResourceSpec
+
+
+
+RBACPolicyResourceSpec contains the desired state of the resource. Only network policies
+are supported.
+
+
+
+_Appears in:_
+- [RBACPolicySpec](#rbacpolicyspec)
+
+| Field | Description | Default | Validation |
+| --- | --- | --- | --- |
+| `networkRef` _[KubernetesNameRef](#kubernetesnameref)_ | networkRef is a reference to the ORC Network this policy grants access to. | | MaxLength: 253
MinLength: 1
Required: \{\}
|
+| `action` _[RBACPolicyAction](#rbacpolicyaction)_ | action is the type of access being granted to the target project. | | Enum: [access_as_shared access_as_external]
Required: \{\}
|
+| `targetProjectRef` _[KubernetesNameRef](#kubernetesnameref)_ | targetProjectRef is a reference to the ORC Project to grant access to. | | MaxLength: 253
MinLength: 1
Optional: \{\}
|
+| `targetProjectID` _string_ | targetProjectID is the ID of the project to grant access to, for when it can't be
referenced: the target is another project, which the network owner's credentials usually
can't read, so it can't be imported with them. | | MaxLength: 64
MinLength: 1
Optional: \{\}
|
+
+
+#### RBACPolicyResourceStatus
+
+
+
+RBACPolicyResourceStatus represents the observed state of the resource.
+
+
+
+_Appears in:_
+- [RBACPolicyStatus](#rbacpolicystatus)
+
+| Field | Description | Default | Validation |
+| --- | --- | --- | --- |
+| `networkID` _string_ | networkID is the ID of the Network this policy applies to. | | MaxLength: 1024
Optional: \{\}
|
+| `action` _string_ | action is the type of access granted to targetProjectID. | | MaxLength: 1024
Optional: \{\}
|
+| `targetProjectID` _string_ | targetProjectID is the OpenStack project ID this policy grants access to. | | MaxLength: 1024
Optional: \{\}
|
+| `projectID` _string_ | projectID is the ID of the project that owns this policy. | | MaxLength: 1024
Optional: \{\}
|
+
+
+#### RBACPolicySpec
+
+
+
+RBACPolicySpec defines the desired state of an ORC object.
+
+
+
+_Appears in:_
+- [RBACPolicy](#rbacpolicy)
+
+| Field | Description | Default | Validation |
+| --- | --- | --- | --- |
+| `import` _[RBACPolicyImport](#rbacpolicyimport)_ | import refers to an existing OpenStack resource which will be imported instead of
creating a new one. | | MaxProperties: 1
MinProperties: 1
Optional: \{\}
|
+| `resource` _[RBACPolicyResourceSpec](#rbacpolicyresourcespec)_ | resource specifies the desired state of the resource.
resource may not be specified if the management policy is `unmanaged`.
resource must be specified if the management policy is `managed`. | | Optional: \{\}
|
+| `managementPolicy` _[ManagementPolicy](#managementpolicy)_ | managementPolicy defines how ORC will treat the object. Valid values are
`managed`: ORC will create, update, and delete the resource; `unmanaged`:
ORC will import an existing resource, and will not apply updates to it or
delete it. | managed | Enum: [managed unmanaged]
Optional: \{\}
|
+| `managedOptions` _[ManagedOptions](#managedoptions)_ | managedOptions specifies options which may be applied to managed objects. | | Optional: \{\}
|
+| `resyncPeriod` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#duration-v1-meta)_ | resyncPeriod defines how frequently the controller will re-reconcile
this resource even when no changes have been detected. This overrides
the global default resync period. The value must be a valid Go duration
string, e.g. "10m", "1h". Set to "0s" to disable periodic resync for
this resource. Very low values may cause excessive OpenStack API load. | | Optional: \{\}
|
+| `cloudCredentialsRef` _[CloudCredentialsReference](#cloudcredentialsreference)_ | cloudCredentialsRef points to a secret containing OpenStack credentials | | Required: \{\}
|
+
+
+#### RBACPolicyStatus
+
+
+
+RBACPolicyStatus defines the observed state of an ORC resource.
+
+
+
+_Appears in:_
+- [RBACPolicy](#rbacpolicy)
+
+| Field | Description | Default | Validation |
+| --- | --- | --- | --- |
+| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#condition-v1-meta) array_ | conditions represents the observed status of the object.
Known .status.conditions.type are: "Available", "Progressing"
Available represents the availability of the OpenStack resource. If it is
true then the resource is ready for use.
Progressing indicates whether the controller is still attempting to
reconcile the current state of the OpenStack resource to the desired
state. Progressing will be False either because the desired state has
been achieved, or because some terminal error prevents it from ever being
achieved and the controller is no longer attempting to reconcile. If
Progressing is True, an observer waiting on the resource should continue
to wait. | | MaxItems: 32
Optional: \{\}
|
+| `id` _string_ | id is the unique identifier of the OpenStack resource. | | MaxLength: 1024
Optional: \{\}
|
+| `resource` _[RBACPolicyResourceStatus](#rbacpolicyresourcestatus)_ | resource contains the observed state of the OpenStack resource. | | Optional: \{\}
|
+| `lastSyncTime` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#time-v1-meta)_ | lastSyncTime is the timestamp of the last successful reconciliation
that fetched state from OpenStack. It is updated each time the
controller successfully reads the resource state from the OpenStack
API. | | Optional: \{\}
|
+
+
#### RecordSet