Skip to content

Commit

Permalink
Merge pull request #916 from l0wl3vel/azure-path
Browse files Browse the repository at this point in the history
Add option to use a custom path inside an Azure Blob Storage Container
  • Loading branch information
Kidswiss authored Dec 19, 2023
2 parents 608c1d1 + 665aad6 commit 8978cb3
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 2 deletions.
10 changes: 8 additions & 2 deletions api/v1/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ func (in *GCSSpec) String() string {

type AzureSpec struct {
Container string `json:"container,omitempty"`
Path string `json:"path,omitempty"`
AccountNameSecretRef *corev1.SecretKeySelector `json:"accountNameSecretRef,omitempty"`
AccountKeySecretRef *corev1.SecretKeySelector `json:"accountKeySecretRef,omitempty"`
}
Expand All @@ -215,9 +216,14 @@ func (in *AzureSpec) EnvVars(vars map[string]*corev1.EnvVarSource) map[string]*c
return vars
}

// String returns "azure:container:/"
// String returns "azure:container:path"
// If Path is empty, the default value "/" will be used as path
func (in *AzureSpec) String() string {
return fmt.Sprintf("azure:%s:/", in.Container)
path := "/"
if in.Path != "" {
path = in.Path
}
return fmt.Sprintf("azure:%s:%s", in.Container, path)
}

type SwiftSpec struct {
Expand Down
15 changes: 15 additions & 0 deletions api/v1/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ var tests = map[string]struct {
},
expectedRepositoryString: "azure:container:/",
},
"GivenAzureBackendAndPath_ThenExpectAzureContainerWithCustomPath": {
givenBackend: &Backend{
Azure: &AzureSpec{
Container: "container",
Path: "foo",
AccountNameSecretRef: newSecretRef("name"),
AccountKeySecretRef: newSecretRef("key"),
},
},
expectedVars: map[string]*corev1.EnvVarSource{
cfg.AzureAccountEnvName: {SecretKeyRef: newSecretRef("name")},
cfg.AzureAccountKeyEnvName: {SecretKeyRef: newSecretRef("key")},
},
expectedRepositoryString: "azure:container:foo",
},
"GivenB2Backend_ThenExpectB2BucketAndPath": {
givenBackend: &Backend{
B2: &B2Spec{
Expand Down
2 changes: 2 additions & 0 deletions config/crd/apiextensions.k8s.io/v1/k8up.io_archives.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/apiextensions.k8s.io/v1/k8up.io_backups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/apiextensions.k8s.io/v1/k8up.io_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/apiextensions.k8s.io/v1/k8up.io_prunes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/apiextensions.k8s.io/v1/k8up.io_restores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down
12 changes: 12 additions & 0 deletions config/crd/apiextensions.k8s.io/v1/k8up.io_schedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down Expand Up @@ -693,6 +695,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down Expand Up @@ -998,6 +1002,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down Expand Up @@ -1549,6 +1555,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down Expand Up @@ -2262,6 +2270,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down Expand Up @@ -2859,6 +2869,8 @@ spec:
x-kubernetes-map-type: atomic
container:
type: string
path:
type: string
type: object
b2:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ Settings:
Settings:

* `container`: name of the container that should be used
* `path`: path inside the container, will default to "/" if omitted
* `accountNameSecretRef`: Kubernetes secret reference containing the account name
* `accountKeySecretRef`: Kubernetes secret reference containing the account key

Expand Down

0 comments on commit 8978cb3

Please sign in to comment.