k8s_cluster_api/v1beta1/cluster/phase.rs
1use std::fmt;
2
3use super::*;
4
5/// ClusterPhase is a string representation of a Cluster Phase.
6///
7/// This type is a high-level indicator of the status of the Cluster as it is provisioned,
8/// from the API user’s perspective.
9///
10/// The value should not be interpreted by any software components as a reliable indication
11/// of the actual state of the Cluster, and controllers should not use the Cluster Phase field
12/// value when making decisions about what action to take.
13///
14/// Controllers should always look at the actual state of the Cluster’s fields to make those decisions.
15///
16
17#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
18pub enum ClusterPhase {
19 /// ClusterPhasePending is the first state a Cluster is assigned by
20 /// Cluster API Cluster controller after being created.
21 Pending,
22
23 /// Provisioning is the state when the Cluster has a provider infrastructure
24 /// object associated and can start provisioning.
25 Provisioning,
26
27 /// Provisioned is the state when its
28 /// infrastructure has been created and configured.
29 Provisioned,
30
31 /// Deleting is the Cluster state when a delete
32 /// request has been sent to the API Server,
33 /// but its infrastructure has not yet been fully deleted.
34 Deleting,
35
36 /// Failed is the Cluster state when the system
37 /// might require user intervention.
38 Failed,
39
40 /// Unknown is returned if the Cluster state cannot be determined.
41 Unknown,
42}
43
44impl Default for ClusterPhase {
45 fn default() -> Self {
46 Self::Unknown
47 }
48}
49
50impl ClusterPhase {
51 pub fn to_str(&self) -> &'static str {
52 match self {
53 Self::Pending => "Pending",
54 Self::Provisioning => "Provisioning",
55 Self::Provisioned => "Provisioned",
56 Self::Deleting => "Deleting",
57 Self::Failed => "Failed",
58 Self::Unknown => "Unknown",
59 }
60 }
61}
62
63impl fmt::Display for ClusterPhase {
64 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
65 self.to_str().fmt(f)
66 }
67}