Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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$
Expand Down
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ kubectl delete -f $ORC_RELEASE
| network | | ◐ | ◐ |
| port | | ◐ | ◐ |
| project | | ◐ | ◐ |
| rbac policy | | | ◐ |
| region | | | ◐ |
| registered limits | | | ◐ |
| role | | ✔ | ✔ |
Expand Down
103 changes: 103 additions & 0 deletions api/v1alpha1/rbacpolicy_types.go
Original file line number Diff line number Diff line change
@@ -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"`
}
226 changes: 226 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading