-
Notifications
You must be signed in to change notification settings - Fork 128
/
promotion_types.go
84 lines (74 loc) · 2.96 KB
/
promotion_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
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type PromotionPhase string
const (
PromotionPhasePending PromotionPhase = "Pending"
PromotionPhaseInProgress PromotionPhase = "Promoting"
PromotionPhaseComplete PromotionPhase = "Completed"
PromotionPhaseFailed PromotionPhase = "Failed"
)
//+kubebuilder:resource:shortName={promo,promos}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name=Environment,type=string,JSONPath=`.spec.environment`
//+kubebuilder:printcolumn:name=State,type=string,JSONPath=`.spec.state`
//+kubebuilder:printcolumn:name=Phase,type=string,JSONPath=`.status.phase`
//+kubebuilder:printcolumn:name=Age,type=date,JSONPath=`.metadata.creationTimestamp`
// Promotion represents a request to transition a particular Environment into a
// particular state.
type Promotion struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec describes the desired transition of a specific Environment into a
// specific EnvironmentState.
//
//+kubebuilder:validation:Required
Spec *PromotionSpec `json:"spec"`
// Status describes the current state of the transition represented by this
// Promotion.
Status PromotionStatus `json:"status,omitempty"`
}
// PromotionSpec describes the desired transition of a specific Environment into
// a specific EnvironmentState.
type PromotionSpec struct {
// Environment specifies the name of the Environment to which this Promotion
// applies. The Environment referenced by this field MUST be in the same
// namespace as the Promotion.
//
// TODO: Use a webhook to make this immutable
//
//+kubebuilder:validation:MinLength=1
//+kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
Environment string `json:"environment"`
// State specifies the specific EnvironmentState into which the Environment
// referenced by the Environment field should be transitioned. The State MUST
// be among the Environment's Status.AvailableStates or the Promotion will
// ultimately fail.
//
// TODO: Use a webhook to make this immutable
//
//+kubebuilder:validation:MinLength=1
State string `json:"state"`
}
// PromotionStatus describes the current state of the transition represented by
// a Promotion.
type PromotionStatus struct {
// Phase describes where the Promotion currently is in its lifecycle.
Phase PromotionPhase `json:"phase,omitempty"`
// Error describes any errors that are preventing the Promotion controller
// from executing this Promotion. i.e. If the Phase field has a value of
// Failed, this field can be expected to explain why.
Error string `json:"error,omitempty"`
}
//+kubebuilder:object:root=true
// PromotionList contains a list of Promotion
type PromotionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Promotion `json:"items"`
}
func init() {
SchemeBuilder.Register(&Promotion{}, &PromotionList{})
}