Skip to content

Commit 7038da8

Browse files
author
Archit Sharma
authored
Velero analyzer (#1366)
* feat: add velero analyzer (#806) * updated schema * analyzer without collector * tests * covers deprecated Restic repository type * velero version from deployment image to check deprecated type * read for both velero pod kinds (velero*, node-agent*) --------- Signed-off-by: Archit Sharma <[email protected]>
1 parent a7bb9ea commit 7038da8

17 files changed

+1987
-37
lines changed

config/crds/troubleshoot.sh_analyzers.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,19 @@ spec:
14891489
required:
14901490
- outcomes
14911491
type: object
1492+
velero:
1493+
properties:
1494+
annotations:
1495+
additionalProperties:
1496+
type: string
1497+
type: object
1498+
checkName:
1499+
type: string
1500+
exclude:
1501+
type: BoolString
1502+
strict:
1503+
type: BoolString
1504+
type: object
14921505
weaveReport:
14931506
properties:
14941507
annotations:

config/crds/troubleshoot.sh_preflights.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,19 @@ spec:
14891489
required:
14901490
- outcomes
14911491
type: object
1492+
velero:
1493+
properties:
1494+
annotations:
1495+
additionalProperties:
1496+
type: string
1497+
type: object
1498+
checkName:
1499+
type: string
1500+
exclude:
1501+
type: BoolString
1502+
strict:
1503+
type: BoolString
1504+
type: object
14921505
weaveReport:
14931506
properties:
14941507
annotations:

config/crds/troubleshoot.sh_supportbundles.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,19 @@ spec:
15201520
required:
15211521
- outcomes
15221522
type: object
1523+
velero:
1524+
properties:
1525+
annotations:
1526+
additionalProperties:
1527+
type: string
1528+
type: object
1529+
checkName:
1530+
type: string
1531+
exclude:
1532+
type: BoolString
1533+
strict:
1534+
type: BoolString
1535+
type: object
15231536
weaveReport:
15241537
properties:
15251538
annotations:

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ require (
3535
github.com/spf13/viper v1.17.0
3636
github.com/stretchr/testify v1.8.4
3737
github.com/tj/go-spin v1.1.0
38+
github.com/vmware-tanzu/velero v1.12.0
3839
go.opentelemetry.io/otel v1.19.0
3940
go.opentelemetry.io/otel/sdk v1.19.0
4041
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
42+
golang.org/x/mod v0.12.0
4143
golang.org/x/sync v0.4.0
4244
gopkg.in/yaml.v2 v2.4.0
4345
k8s.io/api v0.28.2
@@ -86,7 +88,6 @@ require (
8688
github.com/mistifyio/go-zfs/v3 v3.0.0 // indirect
8789
github.com/mitchellh/copystructure v1.2.0 // indirect
8890
github.com/mitchellh/reflectwalk v1.0.2 // indirect
89-
github.com/onsi/ginkgo v1.14.0 // indirect
9091
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
9192
github.com/rubenv/sql-migrate v1.3.1 // indirect
9293
github.com/russross/blackfriday/v2 v2.1.0 // indirect
@@ -105,7 +106,6 @@ require (
105106
go.opentelemetry.io/otel/metric v1.19.0 // indirect
106107
go.opentelemetry.io/otel/trace v1.19.0 // indirect
107108
go.uber.org/multierr v1.11.0 // indirect
108-
golang.org/x/mod v0.12.0 // indirect
109109
golang.org/x/tools v0.13.0 // indirect
110110
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
111111
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect
@@ -123,7 +123,7 @@ require (
123123
github.com/Microsoft/go-winio v0.6.0 // indirect
124124
github.com/Microsoft/hcsshim v0.10.0-rc.7 // indirect
125125
github.com/andybalholm/brotli v1.0.1 // indirect
126-
github.com/aws/aws-sdk-go v1.44.198 // indirect
126+
github.com/aws/aws-sdk-go v1.44.253 // indirect
127127
github.com/beorn7/perks v1.0.1 // indirect
128128
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
129129
github.com/c9s/goprocinfo v0.0.0-20170724085704-0010a05ce49f // indirect

go.sum

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
192192
github.com/14rcole/gopopulate v0.0.0-20180821133914-b175b219e774 h1:SCbEWT58NSt7d2mcFdvxC9uyrdcTfvBbPLThhkDmXzg=
193193
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic=
194194
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1/go.mod h1:VzwV+t+dZ9j/H867F1M2ziD+yLHtB46oM35FxxMJ4d0=
195-
github.com/Azure/azure-sdk-for-go v56.3.0+incompatible h1:DmhwMrUIvpeoTDiWRDtNHqelNUd3Og8JCkrLHQK795c=
195+
github.com/Azure/azure-sdk-for-go v67.2.0+incompatible h1:Uu/Ww6ernvPTrpq31kITVTIm/I5jlJ1wjtEH/bmSB2k=
196196
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 h1:/iHxaJhsFr0+xVFfbMr5vxz848jyiWuIEDhYq3y5odY=
197197
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg=
198198
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
@@ -244,8 +244,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
244244
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
245245
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
246246
github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
247-
github.com/aws/aws-sdk-go v1.44.198 h1:kgnvxQv4/kP5M0nbxBx0Ac0so9ndr9f8Ti0g+NmPQF8=
248-
github.com/aws/aws-sdk-go v1.44.198/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
247+
github.com/aws/aws-sdk-go v1.44.253 h1:iqDd0okcH4ShfFexz2zzf4VmeDFf6NOMm07pHnEb8iY=
248+
github.com/aws/aws-sdk-go v1.44.253/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
249249
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
250250
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
251251
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -800,19 +800,14 @@ github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE
800800
github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
801801
github.com/nwaples/rardecode v1.1.2 h1:Cj0yZY6T1Zx1R7AhTbyGSALm44/Mmq+BAPc4B/p/d3M=
802802
github.com/nwaples/rardecode v1.1.2/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
803-
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
804-
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
803+
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
805804
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
806805
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
807806
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
808807
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
809-
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
810-
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
811-
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
808+
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
812809
github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU=
813810
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
814-
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
815-
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
816811
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
817812
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
818813
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
@@ -1001,6 +996,8 @@ github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYp
1001996
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
1002997
github.com/vladimirvivien/gexe v0.2.0 h1:nbdAQ6vbZ+ZNsolCgSVb9Fno60kzSuvtzVh6Ytqi/xY=
1003998
github.com/vladimirvivien/gexe v0.2.0/go.mod h1:LHQL00w/7gDUKIak24n801ABp8C+ni6eBht9vGVst8w=
999+
github.com/vmware-tanzu/velero v1.12.0 h1:gN8PbQMYOAMv8OYE3RkIvxr6s6IoMS0Daxc+IQN0X5U=
1000+
github.com/vmware-tanzu/velero v1.12.0/go.mod h1:rY2UfdC2K9je9jtjnSBsZr8Zmg8hzePjG2W00Oe/CT4=
10041001
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
10051002
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
10061003
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
@@ -1149,7 +1146,6 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/
11491146
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
11501147
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
11511148
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
1152-
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
11531149
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
11541150
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
11551151
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
@@ -1246,14 +1242,12 @@ golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7w
12461242
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12471243
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12481244
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1249-
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12501245
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12511246
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12521247
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12531248
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12541249
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12551250
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1256-
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12571251
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12581252
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12591253
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1268,7 +1262,6 @@ golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7w
12681262
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12691263
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12701264
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1271-
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12721265
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12731266
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12741267
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

pkg/analyze/analyzer.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
package analyzer
22

33
import (
4+
"bufio"
5+
"bytes"
46
"context"
57
"encoding/json"
68
"fmt"
79
"reflect"
810
"strconv"
11+
"strings"
912

1013
"github.com/pkg/errors"
1114
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
1215
"github.com/replicatedhq/troubleshoot/pkg/constants"
1316
"github.com/replicatedhq/troubleshoot/pkg/multitype"
17+
"github.com/replicatedhq/troubleshoot/pkg/redact"
1418
"go.opentelemetry.io/otel"
1519
"go.opentelemetry.io/otel/attribute"
1620
"go.opentelemetry.io/otel/codes"
@@ -226,6 +230,8 @@ func getAnalyzer(analyzer *troubleshootv1beta2.Analyze) Analyzer {
226230
return &AnalyzeRedis{analyzer: analyzer.Redis}
227231
case analyzer.CephStatus != nil:
228232
return &AnalyzeCephStatus{analyzer: analyzer.CephStatus}
233+
case analyzer.Velero != nil:
234+
return &AnalyzeVelero{analyzer: analyzer.Velero}
229235
case analyzer.Longhorn != nil:
230236
return &AnalyzeLonghorn{analyzer: analyzer.Longhorn}
231237
case analyzer.RegistryImages != nil:
@@ -265,3 +271,18 @@ func DedupAnalyzers(allAnalyzers []*troubleshootv1beta2.Analyze) []*troubleshoot
265271
}
266272
return finalAnalyzers
267273
}
274+
275+
func stripRedactedLines(yaml []byte) []byte {
276+
buf := bytes.NewBuffer(yaml)
277+
scanner := bufio.NewScanner(buf)
278+
279+
out := []byte{}
280+
281+
for scanner.Scan() {
282+
line := strings.ReplaceAll(scanner.Text(), redact.MASK_TEXT, "HIDDEN")
283+
out = append(out, []byte(line)...)
284+
out = append(out, '\n')
285+
}
286+
287+
return out
288+
}

pkg/analyze/longhorn.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
package analyzer
22

33
import (
4-
"bufio"
5-
"bytes"
64
"fmt"
75
"path/filepath"
86
"reflect"
9-
"strings"
107

118
"github.com/pkg/errors"
129
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
1310
"github.com/replicatedhq/troubleshoot/pkg/collect"
1411
longhornv1beta1 "github.com/replicatedhq/troubleshoot/pkg/longhorn/apis/longhorn/v1beta1"
1512
longhorntypes "github.com/replicatedhq/troubleshoot/pkg/longhorn/types"
16-
"github.com/replicatedhq/troubleshoot/pkg/redact"
1713
"gopkg.in/yaml.v2"
1814
)
1915

@@ -241,21 +237,6 @@ func analyzeLonghornEngine(engine *longhornv1beta1.Engine) *AnalyzeResult {
241237
return result
242238
}
243239

244-
func stripRedactedLines(yaml []byte) []byte {
245-
buf := bytes.NewBuffer(yaml)
246-
scanner := bufio.NewScanner(buf)
247-
248-
out := []byte{}
249-
250-
for scanner.Scan() {
251-
line := strings.ReplaceAll(scanner.Text(), redact.MASK_TEXT, "HIDDEN")
252-
out = append(out, []byte(line)...)
253-
out = append(out, '\n')
254-
}
255-
256-
return out
257-
}
258-
259240
func analyzeLonghornReplicaChecksums(volumeName string, checksums []map[string]string) *AnalyzeResult {
260241
result := &AnalyzeResult{
261242
Title: fmt.Sprintf("Longhorn Volume Replica Corruption: %s", volumeName),

pkg/analyze/types/restic_types.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package analyzer
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
// ResticRepositorySpec is the specification for a ResticRepository.
8+
type ResticRepositorySpec struct {
9+
// VolumeNamespace is the namespace this restic repository contains
10+
// pod volume backups for.
11+
VolumeNamespace string `json:"volumeNamespace"`
12+
13+
// BackupStorageLocation is the name of the BackupStorageLocation
14+
// that should contain this repository.
15+
BackupStorageLocation string `json:"backupStorageLocation"`
16+
17+
// ResticIdentifier is the full restic-compatible string for identifying
18+
// this repository.
19+
ResticIdentifier string `json:"resticIdentifier"`
20+
21+
// MaintenanceFrequency is how often maintenance should be run.
22+
MaintenanceFrequency metav1.Duration `json:"maintenanceFrequency"`
23+
}
24+
25+
// ResticRepositoryPhase represents the lifecycle phase of a ResticRepository.
26+
// +kubebuilder:validation:Enum=New;Ready;NotReady
27+
type ResticRepositoryPhase string
28+
29+
const (
30+
ResticRepositoryPhaseNew ResticRepositoryPhase = "New"
31+
ResticRepositoryPhaseReady ResticRepositoryPhase = "Ready"
32+
ResticRepositoryPhaseNotReady ResticRepositoryPhase = "NotReady"
33+
)
34+
35+
// ResticRepositoryStatus is the current status of a ResticRepository.
36+
type ResticRepositoryStatus struct {
37+
// Phase is the current state of the ResticRepository.
38+
// +optional
39+
Phase ResticRepositoryPhase `json:"phase,omitempty"`
40+
41+
// Message is a message about the current status of the ResticRepository.
42+
// +optional
43+
Message string `json:"message,omitempty"`
44+
45+
// LastMaintenanceTime is the last time maintenance was run.
46+
// +optional
47+
// +nullable
48+
LastMaintenanceTime *metav1.Time `json:"lastMaintenanceTime,omitempty"`
49+
}
50+
51+
type ResticRepository struct {
52+
metav1.TypeMeta `json:",inline"`
53+
54+
// +optional
55+
metav1.ObjectMeta `json:"metadata,omitempty"`
56+
57+
// +optional
58+
Spec ResticRepositorySpec `json:"spec,omitempty"`
59+
60+
// +optional
61+
Status ResticRepositoryStatus `json:"status,omitempty"`
62+
}

0 commit comments

Comments
 (0)