-
Notifications
You must be signed in to change notification settings - Fork 66
/
atlasbackupschedule_types.go
125 lines (100 loc) · 4.85 KB
/
atlasbackupschedule_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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
Copyright (C) MongoDB, Inc. 2020-present.
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/v1/status"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/v1/common"
)
// AtlasBackupScheduleSpec defines the desired state of AtlasBackupSchedule
type AtlasBackupScheduleSpec struct {
// Specify true to enable automatic export of cloud backup snapshots to the AWS bucket. You must also define the export policy using export. If omitted, defaults to false.
// +optional
// +kubebuilder:default:=false
AutoExportEnabled bool `json:"autoExportEnabled,omitempty"`
// Export policy for automatically exporting cloud backup snapshots to AWS bucket.
// +optional
Export *AtlasBackupExportSpec `json:"export,omitempty"`
// A reference (name & namespace) for backup policy in the desired updated backup policy.
PolicyRef common.ResourceRefNamespaced `json:"policy"`
// UTC Hour of day between 0 and 23, inclusive, representing which hour of the day that Atlas takes snapshots for backup policy items
// +kubebuilder:validation:Minimum:=0
// +kubebuilder:validation:Maximum:=23
// +optional
ReferenceHourOfDay int64 `json:"referenceHourOfDay,omitempty"`
// UTC Minutes after ReferenceHourOfDay that Atlas takes snapshots for backup policy items. Must be between 0 and 59, inclusive.
// +kubebuilder:validation:Minimum:=0
// +kubebuilder:validation:Maximum:=59
// +optional
ReferenceMinuteOfHour int64 `json:"referenceMinuteOfHour,omitempty"`
// Number of days back in time you can restore to with Continuous Cloud Backup accuracy. Must be a positive, non-zero integer. Applies to continuous cloud backups only.
// +optional
// +kubebuilder:default:=1
RestoreWindowDays int64 `json:"restoreWindowDays,omitempty"`
// Specify true to apply the retention changes in the updated backup policy to snapshots that Atlas took previously.
// +optional
UpdateSnapshots bool `json:"updateSnapshots,omitempty"`
// Specify true to use organization and project names instead of organization and project UUIDs in the path for the metadata files that Atlas uploads to your S3 bucket after it finishes exporting the snapshots
// +optional
UseOrgAndGroupNamesInExportPrefix bool `json:"useOrgAndGroupNamesInExportPrefix,omitempty"`
// Copy backups to other regions for increased resiliency and faster restores.
// +optional
CopySettings []CopySetting `json:"copySettings,omitempty"`
}
type AtlasBackupExportSpec struct {
// Unique Atlas identifier of the AWS bucket which was granted access to export backup snapshot
ExportBucketID string `json:"exportBucketId"`
// +kubebuilder:validation:Enum:=monthly
// +kubebuilder:default:=monthly
FrequencyType string `json:"frequencyType"`
}
type CopySetting struct {
// Identifies the cloud provider that stores the snapshot copy.
// +kubebuilder:validation:Enum:=AWS;GCP;AZURE
// +kubebuilder:default:=AWS
CloudProvider *string `json:"cloudProvider,omitempty"`
// Target region to copy snapshots belonging to replicationSpecId to.
RegionName *string `json:"regionName,omitempty"`
// Unique identifier that identifies the replication object for a zone in a cluster.
ReplicationSpecID *string `json:"replicationSpecId,omitempty"`
// Flag that indicates whether to copy the oplogs to the target region.
ShouldCopyOplogs *bool `json:"shouldCopyOplogs,omitempty"`
// List that describes which types of snapshots to copy.
// +kubebuilder:validation:MinItems=1
Frequencies []string `json:"frequencies,omitempty"`
}
// AtlasBackupSchedule is the Schema for the atlasbackupschedules API
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
type AtlasBackupSchedule struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec AtlasBackupScheduleSpec `json:"spec,omitempty"`
Status status.BackupScheduleStatus `json:"status,omitempty"`
}
func (in *AtlasBackupSchedule) GetStatus() status.Status {
return in.Status
}
func (in *AtlasBackupSchedule) UpdateStatus(conditions []status.Condition, options ...status.Option) {
in.Status.Conditions = conditions
in.Status.ObservedGeneration = in.ObjectMeta.Generation
for _, o := range options {
// This will fail if the Option passed is incorrect - which is expected
v := o.(status.AtlasBackupScheduleStatusOption)
v(&in.Status)
}
}
//+kubebuilder:object:root=true
// AtlasBackupScheduleList contains a list of AtlasBackupSchedule
type AtlasBackupScheduleList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AtlasBackupSchedule `json:"items"`
}
func init() {
SchemeBuilder.Register(&AtlasBackupSchedule{}, &AtlasBackupScheduleList{})
}