This repository has been archived by the owner on Oct 10, 2023. It is now read-only.
/
readiness_types.go
96 lines (74 loc) · 2.86 KB
/
readiness_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2023 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package v1alpha2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ReadinessCheckType defines the current state of the provider
type ReadinessCheckType string
const (
// BasicReadinessCheck depends directly on the ReadinessProviders to be ready
BasicReadinessCheck = ReadinessCheckType("basic")
// CompositeReadinessCheck depends on other basic checks to be ready
CompositeReadinessCheck = ReadinessCheckType("composite")
)
// ReadinessSpec defines the desired state of Readiness
type ReadinessSpec struct {
// Checks is the set of checks that are required to mark the readiness
Checks []Check `json:"checks"`
}
type Check struct {
// Name is the name of the check
Name string `json:"name"`
// Type is the type of the check. Type can be either basic or composite.
// The basic checks depend on its providers to be ready.
// The composite checks depend on the basic checks for their readiness.
// +kubebuilder:validation:Enum=basic;composite
Type ReadinessCheckType `json:"type"`
// Category is the category of the check. Examples of categories are availability and security.
Category string `json:"category"`
}
// ReadinessStatus defines the observed state of Readiness
type ReadinessStatus struct {
// CheckStatus presents the status of check defined in the spec
CheckStatus []CheckStatus `json:"checkStatus"`
// Ready is the flag that denotes if the defined readiness is ready.
// The readiness is marked ready if all the checks are satisfied.
Ready bool `json:"ready"`
}
type CheckStatus struct {
// Name is the name of the check
Name string `json:"name"`
// Ready is the boolean flag indicating if the check is ready
Ready bool `json:"status"`
// Providers is the list of providers available for the given check
Providers []Provider `json:"providers"`
}
type Provider struct {
// Name is the name of the provider
Name string `json:"name"`
// IsActive is the boolean flag indicating if the provider is active
IsActive bool `json:"isActive"`
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster
//+kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
//+kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// Readiness is the Schema for the readinesses API
type Readiness struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ReadinessSpec `json:"spec,omitempty"`
Status ReadinessStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// ReadinessList contains a list of Readiness
type ReadinessList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Readiness `json:"items"`
}
func init() {
SchemeBuilder.Register(&Readiness{}, &ReadinessList{})
}