sigs.k8s.io/cluster-api-provider-azure@v1.17.0/api/v1alpha1/azureasomanagedcluster_types.go (about)

     1  /*
     2  Copyright 2024 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  	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  
    72  // AzureASOManagedCluster is the Schema for the azureasomanagedclusters API.
    73  type AzureASOManagedCluster struct {
    74  	metav1.TypeMeta   `json:",inline"`
    75  	metav1.ObjectMeta `json:"metadata,omitempty"`
    76  
    77  	Spec   AzureASOManagedClusterSpec   `json:"spec,omitempty"`
    78  	Status AzureASOManagedClusterStatus `json:"status,omitempty"`
    79  }
    80  
    81  // GetResourceStatuses returns the status of resources.
    82  func (a *AzureASOManagedCluster) GetResourceStatuses() []ResourceStatus {
    83  	return a.Status.Resources
    84  }
    85  
    86  // SetResourceStatuses sets the status of resources.
    87  func (a *AzureASOManagedCluster) SetResourceStatuses(r []ResourceStatus) {
    88  	a.Status.Resources = r
    89  }
    90  
    91  //+kubebuilder:object:root=true
    92  
    93  // AzureASOManagedClusterList contains a list of AzureASOManagedCluster.
    94  type AzureASOManagedClusterList struct {
    95  	metav1.TypeMeta `json:",inline"`
    96  	metav1.ListMeta `json:"metadata,omitempty"`
    97  	Items           []AzureASOManagedCluster `json:"items"`
    98  }
    99  
   100  func init() {
   101  	SchemeBuilder.Register(&AzureASOManagedCluster{}, &AzureASOManagedClusterList{})
   102  }