diff --git a/api/v1/backend.go b/api/v1/backend.go index ca0de3be7..dd74912fb 100644 --- a/api/v1/backend.go +++ b/api/v1/backend.go @@ -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"` } @@ -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 { diff --git a/api/v1/backend_test.go b/api/v1/backend_test.go index 498140ab4..5424eaffb 100644 --- a/api/v1/backend_test.go +++ b/api/v1/backend_test.go @@ -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{ diff --git a/config/crd/apiextensions.k8s.io/v1/k8up.io_archives.yaml b/config/crd/apiextensions.k8s.io/v1/k8up.io_archives.yaml index db2842c58..78919c600 100644 --- a/config/crd/apiextensions.k8s.io/v1/k8up.io_archives.yaml +++ b/config/crd/apiextensions.k8s.io/v1/k8up.io_archives.yaml @@ -100,6 +100,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: diff --git a/config/crd/apiextensions.k8s.io/v1/k8up.io_backups.yaml b/config/crd/apiextensions.k8s.io/v1/k8up.io_backups.yaml index ff068e366..992c13041 100644 --- a/config/crd/apiextensions.k8s.io/v1/k8up.io_backups.yaml +++ b/config/crd/apiextensions.k8s.io/v1/k8up.io_backups.yaml @@ -107,6 +107,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: diff --git a/config/crd/apiextensions.k8s.io/v1/k8up.io_checks.yaml b/config/crd/apiextensions.k8s.io/v1/k8up.io_checks.yaml index 7ac97eabc..b55642725 100644 --- a/config/crd/apiextensions.k8s.io/v1/k8up.io_checks.yaml +++ b/config/crd/apiextensions.k8s.io/v1/k8up.io_checks.yaml @@ -101,6 +101,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: diff --git a/config/crd/apiextensions.k8s.io/v1/k8up.io_prunes.yaml b/config/crd/apiextensions.k8s.io/v1/k8up.io_prunes.yaml index 8fb06ce0d..086aa92c8 100644 --- a/config/crd/apiextensions.k8s.io/v1/k8up.io_prunes.yaml +++ b/config/crd/apiextensions.k8s.io/v1/k8up.io_prunes.yaml @@ -101,6 +101,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: diff --git a/config/crd/apiextensions.k8s.io/v1/k8up.io_restores.yaml b/config/crd/apiextensions.k8s.io/v1/k8up.io_restores.yaml index 8e8fe6bd2..ab7cde027 100644 --- a/config/crd/apiextensions.k8s.io/v1/k8up.io_restores.yaml +++ b/config/crd/apiextensions.k8s.io/v1/k8up.io_restores.yaml @@ -101,6 +101,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: diff --git a/config/crd/apiextensions.k8s.io/v1/k8up.io_schedules.yaml b/config/crd/apiextensions.k8s.io/v1/k8up.io_schedules.yaml index 9dc0832a0..e77453f8d 100644 --- a/config/crd/apiextensions.k8s.io/v1/k8up.io_schedules.yaml +++ b/config/crd/apiextensions.k8s.io/v1/k8up.io_schedules.yaml @@ -93,6 +93,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: @@ -693,6 +695,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: @@ -998,6 +1002,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: @@ -1549,6 +1555,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: @@ -2262,6 +2270,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: @@ -2859,6 +2869,8 @@ spec: x-kubernetes-map-type: atomic container: type: string + path: + type: string type: object b2: properties: diff --git a/docs/modules/ROOT/pages/references/object-specifications.adoc b/docs/modules/ROOT/pages/references/object-specifications.adoc index c7a6c0ca3..f5154f512 100644 --- a/docs/modules/ROOT/pages/references/object-specifications.adoc +++ b/docs/modules/ROOT/pages/references/object-specifications.adoc @@ -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