|
| 1 | +/* |
| 2 | +Copyright 2021 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 v1alpha3 |
| 18 | + |
| 19 | +import ( |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | + clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" |
| 22 | +) |
| 23 | + |
| 24 | +const ( |
| 25 | + SecretIdentitySetFinalizer = "identity/infrastructure.cluster.x-k8s.io" |
| 26 | +) |
| 27 | + |
| 28 | +type VSphereClusterIdentitySpec struct { |
| 29 | + // SecretName references a Secret inside the controller namespace with the credentials to use |
| 30 | + // +kubebuilder:validation:MinLength=1 |
| 31 | + SecretName string `json:"secretName,omitempty"` |
| 32 | + |
| 33 | + // AllowedNamespaces is used to identify which namespaces are allowed to use this account. |
| 34 | + // Namespaces can be selected with a label selector. |
| 35 | + // If this object is nil, no namespaces will be allowed |
| 36 | + // +optional |
| 37 | + AllowedNamespaces *AllowedNamespaces `json:"allowedNamespaces,omitempty"` |
| 38 | +} |
| 39 | + |
| 40 | +type VSphereClusterIdentityStatus struct { |
| 41 | + // +optional |
| 42 | + Ready bool `json:"ready,omitempty"` |
| 43 | + |
| 44 | + // Conditions defines current service state of the VSphereCluster. |
| 45 | + // +optional |
| 46 | + Conditions clusterv1.Conditions `json:"conditions,omitempty"` |
| 47 | +} |
| 48 | + |
| 49 | +type AllowedNamespaces struct { |
| 50 | + // Selector is a standard Kubernetes LabelSelector. A label query over a set of resources. |
| 51 | + // +optional |
| 52 | + Selector metav1.LabelSelector `json:"selector"` |
| 53 | +} |
| 54 | + |
| 55 | +type VSphereIdentityKind string |
| 56 | + |
| 57 | +var ( |
| 58 | + VSphereClusterIdentityKind = VSphereIdentityKind("VSphereClusterIdentity") |
| 59 | + SecretKind = VSphereIdentityKind("Secret") |
| 60 | +) |
| 61 | + |
| 62 | +type VSphereIdentityReference struct { |
| 63 | + // Kind of the identity. Can either be VSphereClusterIdentity or Secret |
| 64 | + // +kubebuilder:validation:Enum=VSphereClusterIdentity;Secret |
| 65 | + Kind VSphereIdentityKind `json:"kind"` |
| 66 | + |
| 67 | + // Name of the identity. |
| 68 | + // +kubebuilder:validation:MinLength=1 |
| 69 | + Name string `json:"name"` |
| 70 | +} |
| 71 | + |
| 72 | +func (c *VSphereClusterIdentity) GetConditions() clusterv1.Conditions { |
| 73 | + return c.Status.Conditions |
| 74 | +} |
| 75 | + |
| 76 | +func (c *VSphereClusterIdentity) SetConditions(conditions clusterv1.Conditions) { |
| 77 | + c.Status.Conditions = conditions |
| 78 | +} |
| 79 | + |
| 80 | +// +kubebuilder:object:root=true |
| 81 | +// +kubebuilder:resource:path=vsphereclusteridentities,scope=Cluster,categories=cluster-api |
| 82 | +// +kubebuilder:storageversion |
| 83 | +// +kubebuilder:subresource:status |
| 84 | + |
| 85 | +// VSphereClusterIdentity defines the account to be used for reconciling clusters |
| 86 | +type VSphereClusterIdentity struct { |
| 87 | + metav1.TypeMeta `json:",inline"` |
| 88 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 89 | + |
| 90 | + Spec VSphereClusterIdentitySpec `json:"spec,omitempty"` |
| 91 | + Status VSphereClusterIdentityStatus `json:"status,omitempty"` |
| 92 | +} |
| 93 | + |
| 94 | +// +kubebuilder:object:root=true |
| 95 | +// VSphereClusterIdentityList contains a list of VSphereClusterIdentity |
| 96 | +type VSphereClusterIdentityList struct { |
| 97 | + metav1.TypeMeta `json:",inline"` |
| 98 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 99 | + Items []VSphereClusterIdentity `json:"items"` |
| 100 | +} |
| 101 | + |
| 102 | +func init() { |
| 103 | + SchemeBuilder.Register(&VSphereClusterIdentity{}, &VSphereClusterIdentityList{}) |
| 104 | +} |
0 commit comments