Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
EVEREST-539 Fix editing of backup storage (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
recharte authored Feb 2, 2024
1 parent 74d7782 commit 6b296b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion api/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,13 @@ func validateUpdateBackupStorageRequest(ctx echo.Context, bs *everestv1alpha1.Ba
return nil, err
}

url := &bs.Spec.EndpointURL
if params.Url != nil {
if ok := validateURL(*params.Url); !ok {
err := ErrInvalidURL("url")
return nil, err
}
url = params.Url
}
accessKey := string(secret.Data["AWS_ACCESS_KEY_ID"])
if params.AccessKey != nil {
Expand All @@ -279,12 +281,16 @@ func validateUpdateBackupStorageRequest(ctx echo.Context, bs *everestv1alpha1.Ba
if params.BucketName != nil {
bucketName = *params.BucketName
}
region := bs.Spec.Region
if params.Region != nil {
region = *params.Region
}
switch string(bs.Spec.Type) {
case string(BackupStorageTypeS3):
if params.Region != nil && *params.Region == "" {
return nil, errors.New("region is required when using S3 storage type")
}
if err := s3Access(l, &bs.Spec.EndpointURL, accessKey, secretKey, bucketName, bs.Spec.Region); err != nil {
if err := s3Access(l, url, accessKey, secretKey, bucketName, region); err != nil {
return nil, err
}
case string(BackupStorageTypeAzure):
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/labstack/echo/v4 v4.11.3
github.com/oapi-codegen/echo-middleware v1.0.1
github.com/oapi-codegen/runtime v1.1.0
github.com/percona/everest-operator v0.6.0-dev1.0.20240125162053-e43000fbf0b8
github.com/percona/everest-operator v0.6.0-dev1.0.20240201153051-79f428e0c869
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.26.0
golang.org/x/crypto v0.17.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8P
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
github.com/percona/everest-operator v0.6.0-dev1.0.20240125162053-e43000fbf0b8 h1:nXu+L8fCl+vb9i24zqBCA5AjOMeeEGBn6M/KqWlmrCM=
github.com/percona/everest-operator v0.6.0-dev1.0.20240125162053-e43000fbf0b8/go.mod h1:o84NcJlAImYMpKK9+PIjS4V8SSREt1uZOqNhHt5qXMg=
github.com/percona/everest-operator v0.6.0-dev1.0.20240201153051-79f428e0c869 h1:lJlpwTRpRWJ9H6LuEUNHBO5K6oI0h8oghtp5pXIcXG0=
github.com/percona/everest-operator v0.6.0-dev1.0.20240201153051-79f428e0c869/go.mod h1:o84NcJlAImYMpKK9+PIjS4V8SSREt1uZOqNhHt5qXMg=
github.com/percona/percona-backup-mongodb v1.8.1-0.20230920143330-3b1c2e263901 h1:BDgsZRCjEuxl2/z4yWBqB0s8d20shuIDks7/RVdZiLs=
github.com/percona/percona-backup-mongodb v1.8.1-0.20230920143330-3b1c2e263901/go.mod h1:fZRCMpUqkWlLVdRKqqaj001LoVP2eo6F0ZhoMPeXDng=
github.com/percona/percona-postgresql-operator v0.0.0-20231220140959-ad5eef722609 h1:+UOK4gcHrRgqjo4smgfwT7/0apF6PhAJdQIdAV4ub/M=
Expand Down

0 comments on commit 6b296b2

Please sign in to comment.