/
batch_types.go
74 lines (63 loc) · 2.67 KB
/
batch_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
package v2alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)
// BatchSpec defines the desired state of Batch
type BatchSpec struct {
// Infinispan cluster name
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Cluster Name",xDescriptors="urn:alm:descriptor:io.kubernetes:infinispan.org:v1:Infinispan"
Cluster string `json:"cluster"`
// Batch string to be executed
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Config Command"
Config *string `json:"config,omitempty"`
// Name of the ConfigMap containing the batch and resource files to be executed
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="ConfigMap Name"
ConfigMap *string `json:"configMap,omitempty"`
}
type BatchPhase string
const (
// BatchInitializing means the request has been accepted by the system, but the underlying resources are still
// being initialized.
BatchInitializing BatchPhase = "Initializing"
// BatchInitialized means that all required resources have been initialized
BatchInitialized BatchPhase = "Initialized"
// BatchRunning means that the Batch job has been created and the Batch process initiated on the infinispan server.
BatchRunning BatchPhase = "Running"
// BatchSucceeded means that the Batch job has completed successfully.
BatchSucceeded BatchPhase = "Succeeded"
// BatchFailed means that the Batch has failed.
BatchFailed BatchPhase = "Failed"
)
// BatchStatus defines the observed state of Batch
type BatchStatus struct {
// Current phase of the batch operation
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Phase"
Phase BatchPhase `json:"phase"`
// The reason for any batch related failures
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Reason"
Reason string `json:"reason,omitempty"`
// The UUID of the Infinispan instance that the Batch is associated with
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Cluster UUID"
ClusterUID *types.UID `json:"clusterUID,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=batches,scope=Namespaced
// Batch is the Schema for the batches API
type Batch struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec BatchSpec `json:"spec,omitempty"`
Status BatchStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// BatchList contains a list of Batch
type BatchList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Batch `json:"items"`
}
func init() {
SchemeBuilder.Register(&Batch{}, &BatchList{})
}