package meta import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/k8s/v1alpha1" v1 "k8s.io/api/core/v1" ) // These constants define Condition reasons for K8s Config Connector resources // https://cloud.google.com/config-connector/docs/how-to/monitoring-your-resources const ( // Occurs when a resource's underlying resource is being updated. UpdatingReason string = "Updating" // Occurs when a resource's reconciliation has succeeded. UpToDateReason string = "UpToDate" // Occurs when a resource's reconciliation has failed. UpdateFailedReason string = "UpdateFailed" // Occurs when a referenced resource is not ready. DependencyNotReadyReason string = "DependencyNotReady" // Occurs when a referenced resource or Kubernetes Secret is not found. DependencyNotFoundReason string = "DependencyNotFound" // Occurs when a reference is invalid. // For example, suppose a resource that references a Kubernetes Secret. If the Secret exists, but if it does not contain the key that is being referenced, then the reference is said to be invalid. DependencyInvalidReason string = "DependencyInvalid" // Occurs when a resource is being deleted from the Kubernetes API Server. DeletingReason string = "Deleting" // Occurs when a resource has successfully been deleted from the Kubernetes API Server. DeletedReason string = "Deleted" // Occurs when a resource has failed to be deleted from the Kubernetes API Server. DeleteFailedReason string = "DeleteFailed" // Occurs when a resource fails to take ownership of the underlying resource. ManagementConflictReason string = "ManagementConflict" // Occurs when a resource fails to perform pre-actuation transformations. This event type likely means that the resource configuration is invalid. PreActuationTransformFailedReason string = "PreActuationTransformFailed" // Occurs when a resource fails to perform post-actuation transformations. PostActuationTransformFailedReason string = "PostActuationTransformFailed" ) // IsReady determines if a GCP resource is Ready. func IsReady(conditions []v1alpha1.Condition) (bool, string) { return IsCondition(conditions, "Ready", v1.ConditionTrue) } // IsCondition generically determines if the provided conditions contains // a condition of the provided type with the provided status func IsCondition(conditions []v1alpha1.Condition, conditionType string, conditionStatus v1.ConditionStatus) (bool, string) { reason := "" for _, condition := range conditions { if condition.Type == conditionType { return condition.Status == conditionStatus, condition.Reason } } return false, reason }