|
| 1 | +/* |
| 2 | +Copyright 2025 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | +) |
| 22 | + |
| 23 | +// OpenStackCredentialSecretReference references a Secret containing OpenStack credentials. |
| 24 | +type OpenStackCredentialSecretReference struct { |
| 25 | + // Name of the Secret which contains a `clouds.yaml` key (and optionally `cacert`). |
| 26 | + // +kubebuilder:validation:Required |
| 27 | + Name string `json:"name"` |
| 28 | + |
| 29 | + // Namespace where the Secret resides. |
| 30 | + // +kubebuilder:validation:Required |
| 31 | + Namespace string `json:"namespace"` |
| 32 | +} |
| 33 | + |
| 34 | +// OpenStackClusterIdentitySpec defines the desired state for an OpenStackClusterIdentity. |
| 35 | +type OpenStackClusterIdentitySpec struct { |
| 36 | + // SecretRef references the credentials Secret containing a `clouds.yaml` file. |
| 37 | + // +kubebuilder:validation:Required |
| 38 | + SecretRef OpenStackCredentialSecretReference `json:"secretRef"` |
| 39 | + |
| 40 | + // NamespaceSelector limits which namespaces may use this identity. If nil, all namespaces are allowed. |
| 41 | + // +optional |
| 42 | + NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"` |
| 43 | +} |
| 44 | + |
| 45 | +// +genclient |
| 46 | +// +kubebuilder:object:root=true |
| 47 | +// +kubebuilder:resource:path=openstackclusteridentities,scope=Cluster,categories=cluster-api,shortName=osci |
| 48 | + |
| 49 | +// OpenStackClusterIdentity is a cluster-scoped identity that centralizes OpenStack credentials. |
| 50 | +type OpenStackClusterIdentity struct { |
| 51 | + metav1.TypeMeta `json:",inline"` |
| 52 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 53 | + |
| 54 | + Spec OpenStackClusterIdentitySpec `json:"spec,omitempty"` |
| 55 | +} |
| 56 | + |
| 57 | +// +kubebuilder:object:root=true |
| 58 | + |
| 59 | +// OpenStackClusterIdentityList contains a list of OpenStackClusterIdentity. |
| 60 | +type OpenStackClusterIdentityList struct { |
| 61 | + metav1.TypeMeta `json:",inline"` |
| 62 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 63 | + Items []OpenStackClusterIdentity `json:"items"` |
| 64 | +} |
| 65 | + |
| 66 | +func init() { |
| 67 | + SchemeBuilder.Register(&OpenStackClusterIdentity{}, &OpenStackClusterIdentityList{}) |
| 68 | +} |
0 commit comments