package status import "fmt" const ( // Registered is the status returned when the cluster is not bootstrapped // and Edge Manifests have not been applied. Registered = "Registered" // Ready is the status returned when the cluster is bootstrapped, // kustomization is ready, shipment is ready, and bucket is ready. Ready = "Ready" // Installing is the status returned when the cluster is bootstrapped, // but no Ready status condition exists for either the kustomization, shipment, or/and bucket // and no error exists for either too. Installing = "Installing" // Error is the status returned when the cluster is bootstrapped, // but the Ready status condition is False for either the kustomization, shipment, or/and bucket // or/and an error exists for any. Error = "Error" // AwaitingInstallation is the status returned when the terminal's activation code is not consumed. AwaitingInstallation = "Awaiting Installation" // Disconnected is the status returned when the terminal's node status is Unknown. Disconnected = "Disconnected" // NotAvailable is the status returned when the resource's status is not available. NotAvailable = "N/A" // Running is the status returned when the helm pod is working without error Running = "Running" // RegisteredMessage is the status message returned when the status is Registered. RegisteredMessage = "Registered but Edge is not installed" // ReadyMessage is the status message returned when the status is Ready. ReadyMessage = "Cluster is ready" // InstallingMessage is the status message returned when the status is Installing. InstallingMessage = "Waiting for installation to complete" // NotReportedFormat is the status message format for missing or not reported statuses. NotReportedFormat = "Waiting for" // UnusedActivationCodeMessage is the status message returned when the status is Awaiting Installation. UnusedActivationCodeMessage = "Activation code not consumed" // DisconnectedMessage is the status message returned when the status is Disconnected. DisconnectedMessage = "Node is disconnected or turned off" // NodeReadyMessage is the status message returned when the status is Ready. NodeReadyMessage = "Node Ready" // NotAvailableMessage is the status message returned when the status is N/A. NotAvailableMessage = "Status for node missing" // Unknown to support Kubernetes Node Unknown status returned in some cases. Unknown = "UNKNOWN" // IsReady ready status string for a resource. IsReady = "True" // NotReady not ready status string for a resource. NotReady = "False" // KindReadyMessage ready status message for individual kind resource. KindReadyMessage = "%s is ready" // NotAvailableStatusMessage is the status message returned when the status is N/A. NotAvailableStatusMessage = "Status not available" // Deleting status string for when a workload is marked as deleted Deleting = "Deleting" // DeletingStatusMessage is the status message returned when a workload is pending deletion by the clusterctl. DeletingStatusMessage = "Workload is being deleted" // Updating Updating = "Updating" // UpdatingStatusMessage UpdatingStatusMessage = "Workload is updating" // InstallingStatusMessage InstallingStatusMessage = "Workload is installing" // WorkloadReadyStatusMessage WorkloadReadyStatusMessage = "Workload is installed and healthy" // Supported denotes that the cluster's version (infra or edge os) is supported Supported = "VersionSupported" // ErrGettingVersion returns an error if there is no active fleet version or terminal versions associated with the cluster ErrGettingVersion = "ErrGettingVersion" // ClusterInfraOutOfSupport indicates that a cluster's infra version is out of support ClusterOutOfSupport = "OutOfSupport" // ClusterInfraNearingEndOfSupport indicates that a cluster's infra version will be out of support in the next release ClusterNearingEndOfSupport = "NearingEndOfSupport" // NoActiveVersion indicates that a cluster does not have an associated active Edge Infra version NoActiveVersion = "Cluster has no active version" // NoTerminalVersion indicates that a cluster registered as dsds does not have any EdgeOS versions associated with it NoTerminalVersion = "Cluster is registered as dsds but has no terminal versions associated with it" // NotDeployedStatusMessage is the status message returned when a workload has // not been deployed and is not in the process of being deployed. NotDeployedStatusMessage = "Workload not deployed" ) // IsNotReported checks to see if the kind exists and if the status is not reported. func IsNotReported(kind string, notReportedElem map[string]bool) bool { notReportedValue, exists := notReportedElem[kind] return exists && notReportedValue } // MergeErrorMessages merges a slice of status error messages into a comma separated list. func MergeErrorMessages(errors []string) string { errMessage := "" for idx, err := range errors { switch { case idx == 0: errMessage = err case idx < len(errors)-1: errMessage = fmt.Sprintf("%s, %s", errMessage, err) case idx == len(errors)-1: conjunction := ", and" if len(errors) == 2 { conjunction = " and" } errMessage = fmt.Sprintf("%s%s %s", errMessage, conjunction, err) } } return errMessage }