|
| 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 v1beta1 |
| 18 | + |
| 19 | +import ( |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" |
| 22 | +) |
| 23 | + |
| 24 | +const ( |
| 25 | + // AzureASOManagedClusterKind is the kind for AzureASOManagedCluster. |
| 26 | + AzureASOManagedClusterKind = "AzureASOManagedCluster" |
| 27 | + |
| 28 | + // AzureASOManagedControlPlaneFinalizer is the finalizer added to AzureASOManagedControlPlanes. |
| 29 | + AzureASOManagedControlPlaneFinalizer = "azureasomanagedcontrolplane.infrastructure.cluster.x-k8s.io" |
| 30 | +) |
| 31 | + |
| 32 | +// AzureASOManagedClusterSpec defines the desired state of AzureASOManagedCluster. |
| 33 | +type AzureASOManagedClusterSpec struct { |
| 34 | + AzureASOManagedClusterTemplateResourceSpec `json:",inline"` |
| 35 | + |
| 36 | + // ControlPlaneEndpoint is the location of the API server within the control plane. CAPZ manages this field |
| 37 | + // and it should not be set by the user. It fulfills Cluster API's cluster infrastructure provider contract. |
| 38 | + // Because this field is programmatically set by CAPZ after resource creation, we define it as +optional |
| 39 | + // in the API schema to permit resource admission. |
| 40 | + //+optional |
| 41 | + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` |
| 42 | +} |
| 43 | + |
| 44 | +// AzureASOManagedClusterStatus defines the observed state of AzureASOManagedCluster. |
| 45 | +type AzureASOManagedClusterStatus struct { |
| 46 | + // Ready represents whether or not the cluster has been provisioned and is ready. It fulfills Cluster |
| 47 | + // API's cluster infrastructure provider contract. |
| 48 | + //+optional |
| 49 | + Ready bool `json:"ready"` |
| 50 | + |
| 51 | + //+optional |
| 52 | + Resources []ResourceStatus `json:"resources,omitempty"` |
| 53 | +} |
| 54 | + |
| 55 | +// ResourceStatus represents the status of a resource. |
| 56 | +type ResourceStatus struct { |
| 57 | + Resource StatusResource `json:"resource"` |
| 58 | + Ready bool `json:"ready"` |
| 59 | +} |
| 60 | + |
| 61 | +// StatusResource is a handle to a resource. |
| 62 | +type StatusResource struct { |
| 63 | + Group string `json:"group"` |
| 64 | + Version string `json:"version"` |
| 65 | + Kind string `json:"kind"` |
| 66 | + Name string `json:"name"` |
| 67 | +} |
| 68 | + |
| 69 | +// +kubebuilder:object:root=true |
| 70 | +// +kubebuilder:subresource:status |
| 71 | +// +kubebuilder:storageversion |
| 72 | + |
| 73 | +// AzureASOManagedCluster is the Schema for the azureasomanagedclusters API. |
| 74 | +type AzureASOManagedCluster struct { |
| 75 | + metav1.TypeMeta `json:",inline"` |
| 76 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 77 | + |
| 78 | + Spec AzureASOManagedClusterSpec `json:"spec,omitempty"` |
| 79 | + Status AzureASOManagedClusterStatus `json:"status,omitempty"` |
| 80 | +} |
| 81 | + |
| 82 | +// GetResourceStatuses returns the status of resources. |
| 83 | +func (a *AzureASOManagedCluster) GetResourceStatuses() []ResourceStatus { |
| 84 | + return a.Status.Resources |
| 85 | +} |
| 86 | + |
| 87 | +// SetResourceStatuses sets the status of resources. |
| 88 | +func (a *AzureASOManagedCluster) SetResourceStatuses(r []ResourceStatus) { |
| 89 | + a.Status.Resources = r |
| 90 | +} |
| 91 | + |
| 92 | +//+kubebuilder:object:root=true |
| 93 | + |
| 94 | +// AzureASOManagedClusterList contains a list of AzureASOManagedCluster. |
| 95 | +type AzureASOManagedClusterList struct { |
| 96 | + metav1.TypeMeta `json:",inline"` |
| 97 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 98 | + Items []AzureASOManagedCluster `json:"items"` |
| 99 | +} |
| 100 | + |
| 101 | +func init() { |
| 102 | + SchemeBuilder.Register(&AzureASOManagedCluster{}, &AzureASOManagedClusterList{}) |
| 103 | +} |
0 commit comments