|
| 1 | +// Copyright 2025 StreamNative |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package v1alpha1 |
| 16 | + |
| 17 | +import ( |
| 18 | + corev1 "k8s.io/api/core/v1" |
| 19 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 20 | +) |
| 21 | + |
| 22 | +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! |
| 23 | +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. |
| 24 | + |
| 25 | +// RoleBindingSpec defines the desired state of RoleBinding |
| 26 | +type RoleBindingSpec struct { |
| 27 | + // APIServerRef is the reference to the StreamNativeCloudConnection |
| 28 | + // +required |
| 29 | + APIServerRef corev1.LocalObjectReference `json:"apiServerRef"` |
| 30 | + |
| 31 | + // Users is a list of Users that will be granted the role |
| 32 | + // +optional |
| 33 | + Users []string `json:"users"` |
| 34 | + |
| 35 | + // IdentityPools is a list of IdentityPools that will be granted the role |
| 36 | + // +optional |
| 37 | + IdentityPools []string `json:"identityPools,omitempty"` |
| 38 | + |
| 39 | + // ServiceAccounts is a list of ServiceAccounts that will be granted the role |
| 40 | + // +optional |
| 41 | + ServiceAccounts []string `json:"serviceAccounts,omitempty"` |
| 42 | + |
| 43 | + // ClusterRole is the reference to the role that will be granted |
| 44 | + // +required |
| 45 | + ClusterRole string `json:"clusterRole"` |
| 46 | + |
| 47 | + // CEL is an optional CEL expression for the role binding |
| 48 | + // +optional |
| 49 | + CEL *string `json:"cel,omitempty"` |
| 50 | + |
| 51 | + // SRNOrganization is the organization of the SRN |
| 52 | + // +optional |
| 53 | + SRNOrganization []string `json:"srnOrganization,omitempty"` |
| 54 | + |
| 55 | + // SRNInstance is the pulsar instance of the SRN |
| 56 | + // +optional |
| 57 | + SRNInstance []string `json:"srnInstance,omitempty"` |
| 58 | + |
| 59 | + // SRNCluster is the cluster of the SRN |
| 60 | + // +optional |
| 61 | + SRNCluster []string `json:"srnCluster,omitempty"` |
| 62 | + |
| 63 | + // SRNTenant is the tenant of the SRN |
| 64 | + // +optional |
| 65 | + SRNTenant []string `json:"srnTenant,omitempty"` |
| 66 | + |
| 67 | + // SRNNamespace is the namespace of the SRN |
| 68 | + // +optional |
| 69 | + SRNNamespace []string `json:"srnNamespace,omitempty"` |
| 70 | + |
| 71 | + // SRNTopicDomain is the topic domain of the SRN |
| 72 | + // +optional |
| 73 | + SRNTopicDomain []string `json:"srnTopicDomain,omitempty"` |
| 74 | + |
| 75 | + // SRNTopicName is the topic of the SRN |
| 76 | + // +optional |
| 77 | + SRNTopicName []string `json:"srnTopicName,omitempty"` |
| 78 | + |
| 79 | + // SRNSubscription is the subscription of the SRN |
| 80 | + // +optional |
| 81 | + SRNSubscription []string `json:"srnSubscription,omitempty"` |
| 82 | + |
| 83 | + // SRNServiceAccount is the service account of the SRN |
| 84 | + // +optional |
| 85 | + SRNServiceAccount []string `json:"srnServiceAccount,omitempty"` |
| 86 | + |
| 87 | + // SRNSecret is the secret of the SRN |
| 88 | + // +optional |
| 89 | + SRNSecret []string `json:"srnSecret,omitempty"` |
| 90 | +} |
| 91 | + |
| 92 | +// RoleBindingStatus defines the observed state of RoleBinding |
| 93 | +type RoleBindingStatus struct { |
| 94 | + // Conditions represent the latest available observations of an object's state |
| 95 | + // +optional |
| 96 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 97 | + |
| 98 | + // ObservedGeneration is the last observed generation |
| 99 | + // +optional |
| 100 | + ObservedGeneration int64 `json:"observedGeneration,omitempty"` |
| 101 | + |
| 102 | + // FailedClusters is a list of clusters where the role binding failed |
| 103 | + // +optional |
| 104 | + FailedClusters []string `json:"failedClusters,omitempty"` |
| 105 | + |
| 106 | + // SyncedClusters is a map of clusters where the role binding is synced |
| 107 | + // +optional |
| 108 | + SyncedClusters map[string]string `json:"syncedClusters,omitempty"` |
| 109 | +} |
| 110 | + |
| 111 | +//+kubebuilder:object:root=true |
| 112 | +//+kubebuilder:subresource:status |
| 113 | +//+kubebuilder:resource:scope=Namespaced,categories={streamnative,all} |
| 114 | +//+kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" |
| 115 | +//+kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status" |
| 116 | +//+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 117 | + |
| 118 | +// RoleBinding is the Schema for the RoleBindings API |
| 119 | +type RoleBinding struct { |
| 120 | + metav1.TypeMeta `json:",inline"` |
| 121 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 122 | + |
| 123 | + Spec RoleBindingSpec `json:"spec,omitempty"` |
| 124 | + Status RoleBindingStatus `json:"status,omitempty"` |
| 125 | +} |
| 126 | + |
| 127 | +//+kubebuilder:object:root=true |
| 128 | + |
| 129 | +// RoleBindingList contains a list of RoleBinding |
| 130 | +type RoleBindingList struct { |
| 131 | + metav1.TypeMeta `json:",inline"` |
| 132 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 133 | + Items []RoleBinding `json:"items"` |
| 134 | +} |
| 135 | + |
| 136 | +func init() { |
| 137 | + SchemeBuilder.Register(&RoleBinding{}, &RoleBindingList{}) |
| 138 | +} |
0 commit comments