-
Notifications
You must be signed in to change notification settings - Fork 50
/
drpolicy_types.go
97 lines (77 loc) · 3.35 KB
/
drpolicy_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
/*
Copyright 2021 The RamenDR authors.
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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Managed cluster information
type ManagedCluster struct {
// Name of this managed cluster as configured in OCM/ACM
Name string `json:"name"`
// S3 profile name (in Ramen config) to use as a source to restore PV
// related cluster state during recovery or relocate actions of applications
// to this managed cluster; hence, this S3 profile should be available to
// successfully move the workload to this managed cluster. For applications
// that are active on this managed cluster, their PV related cluster state
// is stored to S3 profiles of all other managed clusters in the same
// DRPolicy to enable recovery or relocate actions on those managed clusters.
S3ProfileName string `json:"s3ProfileName"`
}
// DRPolicySpec defines the desired state of DRPolicy
type DRPolicySpec struct {
// Important: Run "make" to regenerate code after modifying this file
// scheduling Interval for replicating Persistent Volume
// data to a peer cluster. Interval is typically in the
// form <num><m,h,d>. Here <num> is a number, 'm' means
// minutes, 'h' means hours and 'd' stands for days.
SchedulingInterval string `json:"schedulingInterval"`
// Label selector to identify all the VolumeReplicationClasses.
// This selector is assumed to be the same for all subscriptions that
// need DR protection. It will be passed in to the VRG when it is created
//+optional
ReplicationClassSelector metav1.LabelSelector `json:"replicationClassSelector,omitempty"`
// The set of managed clusters governed by this policy, which have
// replication relationship enabled between them.
DRClusterSet []ManagedCluster `json:"drClusterSet"`
}
// DRPolicyStatus defines the observed state of DRPolicy
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
type DRPolicyStatus struct{}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// DRPolicy is the Schema for the drpolicies API
type DRPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec DRPolicySpec `json:"spec,omitempty"`
Status *DRPolicyStatus `json:"status,omitempty"`
}
func (drpolicy *DRPolicy) ClusterNames() []string {
clusterNames := make([]string, len(drpolicy.Spec.DRClusterSet))
for i := range drpolicy.Spec.DRClusterSet {
clusterNames[i] = drpolicy.Spec.DRClusterSet[i].Name
}
return clusterNames
}
// +kubebuilder:object:root=true
// DRPolicyList contains a list of DRPolicy
type DRPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []DRPolicy `json:"items"`
}
func init() {
SchemeBuilder.Register(&DRPolicy{}, &DRPolicyList{})
}