Skip to content

Commit 8c01f0f

Browse files
armruleonardoce
authored andcommitted
feat(spike): restore
Signed-off-by: Armando Ruocco <[email protected]>
1 parent 44986ab commit 8c01f0f

File tree

32 files changed

+1533
-277
lines changed

32 files changed

+1533
-277
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Image URL to use all building/pushing image targets
2-
IMG ?= controller:latest
2+
IMG ?= plugin-barman-cloud:latest
33
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
44
ENVTEST_K8S_VERSION = 1.31.0
55

cmd/manager/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package main is the entrypoint for the plugin
2+
package main

cmd/manager/main.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
8+
"github.com/cloudnative-pg/machinery/pkg/log"
9+
"github.com/spf13/cobra"
10+
11+
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cmd/instance"
12+
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cmd/operator"
13+
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cmd/restore"
14+
)
15+
16+
func main() {
17+
cobra.EnableTraverseRunHooks = true
18+
19+
logFlags := &log.Flags{}
20+
rootCmd := &cobra.Command{
21+
Use: "manager [cmd]",
22+
PersistentPreRunE: func(_ *cobra.Command, _ []string) error {
23+
logFlags.ConfigureLogging()
24+
return nil
25+
},
26+
}
27+
28+
logFlags.AddFlags(rootCmd.PersistentFlags())
29+
30+
rootCmd.AddCommand(instance.NewCmd())
31+
rootCmd.AddCommand(operator.NewCmd())
32+
rootCmd.AddCommand(restore.NewCmd())
33+
34+
if err := rootCmd.Execute(); err != nil {
35+
fmt.Println(err)
36+
os.Exit(1)
37+
}
38+
}

cmd/operator/main.go

Lines changed: 0 additions & 98 deletions
This file was deleted.

config/rbac/role.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ rules:
4040
- get
4141
- patch
4242
- update
43+
- apiGroups:
44+
- postgresql.cnpg.io
45+
resources:
46+
- backups
47+
verbs:
48+
- get
49+
- list
50+
- watch
4351
- apiGroups:
4452
- rbac.authorization.k8s.io
4553
resources:

containers/Dockerfile.plugin

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ COPY ../go.sum go.sum
1212
RUN go mod download
1313

1414
# Copy the go source
15-
COPY ../cmd/operator/main.go cmd/operator/main.go
16-
COPY ../api api/
17-
COPY ../internal internal/
15+
COPY ../cmd/manager/main.go cmd/manager/main.go
16+
COPY ../api/ api/
17+
COPY ../internal/ internal/
1818

1919
# Build
2020
# the GOARCH has not a default value to allow the binary be built according to the host where the command
2121
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
2222
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2323
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
2424
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
25-
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/operator/main.go
25+
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/manager/main.go
2626

2727
# Use distroless as minimal base image to package the manager binary
2828
# Refer to https://github.com/GoogleContainerTools/distroless for more details
@@ -45,4 +45,4 @@ WORKDIR /
4545
COPY --from=builder /workspace/manager .
4646
USER 65532:65532
4747

48-
ENTRYPOINT ["/manager"]
48+
ENTRYPOINT ["/manager"]

docs/examples/cluster-example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: cluster-example
55
spec:
66
instances: 3
7-
7+
imagePullPolicy: IfNotPresent
88
plugins:
99
- name: barman-cloud.cloudnative-pg.io
1010
parameters:

docs/examples/cluster-restore.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: postgresql.cnpg.io/v1
2+
kind: Cluster
3+
metadata:
4+
name: cluster-restore
5+
spec:
6+
instances: 3
7+
imagePullPolicy: IfNotPresent
8+
9+
bootstrap:
10+
recovery:
11+
backup:
12+
name: backup-example
13+
usePlugin: true
14+
15+
plugins:
16+
- name: barman-cloud.cloudnative-pg.io
17+
# parameters:
18+
# barmanObjectName: minio-store
19+
20+
storage:
21+
size: 1Gi

go.mod

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
module github.com/cloudnative-pg/plugin-barman-cloud
22

3-
go 1.22.0
3+
go 1.23
4+
5+
toolchain go1.23.1
46

57
require (
68
github.com/cloudnative-pg/barman-cloud v0.0.0-20240924124724-92831d48562a
7-
github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241001084914-829808376542
8-
github.com/cloudnative-pg/cnpg-i v0.0.0-20240924030516-c5636170f248
9-
github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241002070940-e5495e9c5ed6
10-
github.com/cloudnative-pg/machinery v0.0.0-20241007093555-1e197af1f392
9+
github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241017151552-20297270038b
10+
github.com/cloudnative-pg/cnpg-i v0.0.0-20241018104538-7f169c24d7a8
11+
github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241017094517-76870f5660ef
12+
github.com/cloudnative-pg/machinery v0.0.0-20241010122207-5ac7af31ef72
1113
github.com/onsi/ginkgo/v2 v2.20.2
1214
github.com/onsi/gomega v1.34.2
1315
github.com/spf13/cobra v1.8.1
@@ -16,6 +18,7 @@ require (
1618
k8s.io/api v0.31.1
1719
k8s.io/apimachinery v0.31.1
1820
k8s.io/client-go v0.31.1
21+
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6
1922
sigs.k8s.io/controller-runtime v0.19.0
2023
)
2124

@@ -27,6 +30,7 @@ require (
2730
github.com/blang/semver/v4 v4.0.0 // indirect
2831
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
2932
github.com/cespare/xxhash/v2 v2.3.0 // indirect
33+
github.com/cloudnative-pg/api v0.0.0-20241004125129-98baa9f4957b // indirect
3034
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3135
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
3236
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
@@ -70,8 +74,8 @@ require (
7074
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
7175
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
7276
github.com/pkg/errors v0.9.1 // indirect
73-
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.75.2 // indirect
74-
github.com/prometheus/client_golang v1.20.3 // indirect
77+
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.77.1 // indirect
78+
github.com/prometheus/client_golang v1.20.4 // indirect
7579
github.com/prometheus/client_model v0.6.1 // indirect
7680
github.com/prometheus/common v0.59.1 // indirect
7781
github.com/prometheus/procfs v0.15.1 // indirect
@@ -109,7 +113,7 @@ require (
109113
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
110114
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
111115
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
112-
google.golang.org/protobuf v1.34.2 // indirect
116+
google.golang.org/protobuf v1.35.1 // indirect
113117
gopkg.in/inf.v0 v0.9.1 // indirect
114118
gopkg.in/ini.v1 v1.67.0 // indirect
115119
gopkg.in/yaml.v2 v2.4.0 // indirect
@@ -119,7 +123,6 @@ require (
119123
k8s.io/component-base v0.31.1 // indirect
120124
k8s.io/klog/v2 v2.130.1 // indirect
121125
k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38 // indirect
122-
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 // indirect
123126
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect
124127
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
125128
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect

go.sum

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
1414
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
1515
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
1616
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
17+
github.com/cloudnative-pg/api v0.0.0-20241004125129-98baa9f4957b h1:LZ9tIgKmWb8ZvyLg/J8ExXtmBtEWP2dr3Y4TU4nCq/w=
18+
github.com/cloudnative-pg/api v0.0.0-20241004125129-98baa9f4957b/go.mod h1:mzd1EvoLYy16jJdne6/4nwhoj7t4IZ0MqJMEH4mla8Q=
1719
github.com/cloudnative-pg/barman-cloud v0.0.0-20240924124724-92831d48562a h1:0v1ML9Eibfq3helbT9GtU0EstqFtG91k/MPO9azY5ME=
1820
github.com/cloudnative-pg/barman-cloud v0.0.0-20240924124724-92831d48562a/go.mod h1:Jm0tOp5oB7utpt8wz6RfSv31h1mThOtffjfyxVupriE=
19-
github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241001084914-829808376542 h1:IXf5lj+m4CBqzckQ9L/9hJ01JUoVw5N0FuPex0sVdVo=
20-
github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241001084914-829808376542/go.mod h1:L8M+kTGpz/eaLZj46+4sARvO/vDYlo/m1xOigI/ghBA=
21-
github.com/cloudnative-pg/cnpg-i v0.0.0-20240924030516-c5636170f248 h1:eUGzb7YNjVLilwhgZoe4hDOO70fci3oqb/ZzQFbN3xg=
22-
github.com/cloudnative-pg/cnpg-i v0.0.0-20240924030516-c5636170f248/go.mod h1:K9/4eAT3rh2bKIWyujoN8BIPRXa4d1Ls+eBY8PE8y6w=
23-
github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241002070940-e5495e9c5ed6 h1:C4CU5fBTYTiJBPDqcgHpXSc5IvRTy+5KTaFZzdKHfAQ=
24-
github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241002070940-e5495e9c5ed6/go.mod h1:mHEVy/Guae+rij1qlgwHg+lyFKDX48qjTL4lAqE7OJs=
25-
github.com/cloudnative-pg/machinery v0.0.0-20241007093555-1e197af1f392 h1:DHaSe0PoLnIQFWIpRqB9RiBlNzbdLuVbiCtc9tN+FL0=
26-
github.com/cloudnative-pg/machinery v0.0.0-20241007093555-1e197af1f392/go.mod h1:bWp1Es5zlxElg4Z/c5f0RKOkDcyNvDHdYIvNcPQU4WM=
21+
github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241017151552-20297270038b h1:47OKNQRgSs9XWvIt2bm8B1Yo7TA5oxBGjQPqF0j+Llw=
22+
github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241017151552-20297270038b/go.mod h1:0grklCuA9WSA5lazBeTgDqLHjxP13fqAhqlveDx7hPg=
23+
github.com/cloudnative-pg/cnpg-i v0.0.0-20241018104538-7f169c24d7a8 h1:8m2Xcobj9tcwjDHgeJ7OJpySx908P1gqLeGMVZ7pMJU=
24+
github.com/cloudnative-pg/cnpg-i v0.0.0-20241018104538-7f169c24d7a8/go.mod h1:fAU7ySVzjpt/RZntxWZiWJCjaBJayzIxEnd0NuO7oQc=
25+
github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241017094517-76870f5660ef h1:Og/btbliFYkJ2sz899T+b832GaFQU4ai52k98zZr0xA=
26+
github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241017094517-76870f5660ef/go.mod h1:X6r1fRuUEIAv4+5SSBY2RmQ201K6GcptOXgnmaX/8tY=
27+
github.com/cloudnative-pg/machinery v0.0.0-20241010122207-5ac7af31ef72 h1:3pgtSYhv3RDd+51bnlqICNrcVpWQQvriCOvkxtbZpaE=
28+
github.com/cloudnative-pg/machinery v0.0.0-20241010122207-5ac7af31ef72/go.mod h1:bWp1Es5zlxElg4Z/c5f0RKOkDcyNvDHdYIvNcPQU4WM=
2729
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2830
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2931
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -138,10 +140,10 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
138140
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
139141
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
140142
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
141-
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.75.2 h1:6UsAv+jAevuGO2yZFU/BukV4o9NKnFMOuoouSA4G0ns=
142-
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.75.2/go.mod h1:XYrdZw5dW12Cjkt4ndbeNZZTBp4UCHtW0ccR9+sTtPU=
143-
github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4=
144-
github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
143+
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.77.1 h1:XGoEXT6WTTihO+MD8MAao+YaQIH905HbK0WK2lyo28k=
144+
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.77.1/go.mod h1:D0KY8md81DQKdaR/cXwnhoWB3MYYyc/UjvqE8GFkIvA=
145+
github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
146+
github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
145147
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
146148
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
147149
github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0=
@@ -266,8 +268,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:
266268
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
267269
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
268270
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
269-
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
270-
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
271+
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
272+
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
271273
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
272274
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
273275
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

0 commit comments

Comments
 (0)