-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathbackup_status.go
108 lines (93 loc) · 3.15 KB
/
backup_status.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
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
//
// 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package v1
import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1"
)
// ArangoBackupStatus contains the status part of
// an ArangoBackup.
type ArangoBackupStatus struct {
ArangoBackupState `json:",inline"`
// Backup ArangoBackup details
Backup *ArangoBackupDetails `json:"backup,omitempty"`
// Available Determines if we can restore from ArangoBackup
Available bool `json:"available"`
// Backoff shows current backoff status
Backoff *ArangoBackupStatusBackOff `json:"backoff,omitempty"`
}
func (a *ArangoBackupStatus) Equal(b *ArangoBackupStatus) bool {
if a == b {
return true
}
if a == nil && b != nil || a != nil && b == nil {
return false
}
return a.ArangoBackupState.Equal(&b.ArangoBackupState) &&
a.Backup.Equal(b.Backup) &&
a.Available == b.Available
}
type ArangoBackupDetails struct {
ID string `json:"id"`
Version string `json:"version"`
PotentiallyInconsistent *bool `json:"potentiallyInconsistent,omitempty"`
// SizeInBytes Size of the Backup in ArangoDB.
SizeInBytes uint64 `json:"sizeInBytes,omitempty"`
// NumberOfDBServers Cluster size of the Backup in ArangoDB
NumberOfDBServers uint `json:"numberOfDBServers,omitempty"`
// Uploaded Determines if ArangoBackup has been uploaded
Uploaded *bool `json:"uploaded,omitempty"`
// Downloaded Determines if ArangoBackup has been downloaded.
Downloaded *bool `json:"downloaded,omitempty"`
Imported *bool `json:"imported,omitempty"`
// CreationTimestamp ArangoBackup Custom Resource creation time in UTC
CreationTimestamp meta.Time `json:"createdAt"`
Keys sharedApi.HashList `json:"keys,omitempty"`
}
func (a *ArangoBackupDetails) Equal(b *ArangoBackupDetails) bool {
if a == b {
return true
}
if a == nil && b != nil || a != nil && b == nil {
return false
}
return a.ID == b.ID &&
a.Version == b.Version &&
a.SizeInBytes == b.SizeInBytes &&
a.NumberOfDBServers == b.NumberOfDBServers &&
a.CreationTimestamp.Equal(&b.CreationTimestamp) &&
compareBoolPointer(a.PotentiallyInconsistent, b.PotentiallyInconsistent) &&
compareBoolPointer(a.Uploaded, b.Uploaded) &&
compareBoolPointer(a.Downloaded, b.Downloaded) &&
compareBoolPointer(a.Imported, b.Imported) &&
a.Keys.Equal(b.Keys)
}
func compareBoolPointer(a, b *bool) bool {
if a == nil && b != nil || a != nil && b == nil {
return false
}
if a == b {
return true
}
if *a == *b {
return true
}
return false
}