/
volumesnapshotschedule.go
76 lines (63 loc) · 2.93 KB
/
volumesnapshotschedule.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
package v1alpha1
import (
snapv1 "github.com/kubernetes-incubator/external-storage/snapshot/pkg/apis/crd/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
// VolumeSnapshotScheduleResourceName is name for "volumesnapshotschedule" resource
VolumeSnapshotScheduleResourceName = "volumesnapshotschedule"
// VolumeSnapshotScheduleResourcePlural is plural for "volumesnapshotschedule" resource
VolumeSnapshotScheduleResourcePlural = "volumesnapshotschedules"
)
// VolumeSnapshotScheduleSpec is the spec used to schedule volumesnapshots
type VolumeSnapshotScheduleSpec struct {
Template VolumeSnapshotTemplateSpec `json:"template"`
SchedulePolicyName string `json:"schedulePolicyName"`
Suspend *bool `json:"suspend"`
ReclaimPolicy ReclaimPolicyType `json:"reclaimPolicy"`
PreExecRule string `json:"preExecRule"`
PostExecRule string `json:"postExecRule"`
}
// VolumeSnapshotTemplateSpec describes the data a VolumeSnapshot should have when created
// from a template
type VolumeSnapshotTemplateSpec struct {
Spec snapv1.VolumeSnapshotSpec `json:"spec"`
}
// ReclaimPolicyType is the type of reclaim policy
type ReclaimPolicyType string
const (
// ReclaimPolicyInvalid is an invalid schedule policy
ReclaimPolicyInvalid ReclaimPolicyType = "Invalid"
// ReclaimPolicyDelete is to specify that an object should be deleted
ReclaimPolicyDelete ReclaimPolicyType = "Delete"
// ReclaimPolicyRetain is to specify that an object should be retained
ReclaimPolicyRetain ReclaimPolicyType = "Retain"
)
// VolumeSnapshotScheduleStatus is the status of a volumesnapshot schedule
type VolumeSnapshotScheduleStatus struct {
Items map[SchedulePolicyType][]*ScheduledVolumeSnapshotStatus `json:"items"`
}
// ScheduledVolumeSnapshotStatus keeps track of the volumesnapshot that was triggered by a
// scheduled policy
type ScheduledVolumeSnapshotStatus struct {
Name string `json:"name"`
CreationTimestamp meta.Time `json:"creationTimestamp"`
FinishTimestamp meta.Time `json:"finishTimestamp"`
Status snapv1.VolumeSnapshotConditionType `json:"status"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// VolumeSnapshotSchedule represents a scheduled volumesnapshot object
type VolumeSnapshotSchedule struct {
meta.TypeMeta `json:",inline"`
meta.ObjectMeta `json:"metadata,omitempty"`
Spec VolumeSnapshotScheduleSpec `json:"spec"`
Status VolumeSnapshotScheduleStatus `json:"status"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// VolumeSnapshotScheduleList is a list of VolumeSnapshotSchedules
type VolumeSnapshotScheduleList struct {
meta.TypeMeta `json:",inline"`
meta.ListMeta `json:"metadata,omitempty"`
Items []VolumeSnapshotSchedule `json:"items"`
}