added local repository for restic

This commit is contained in:
jandre 2023-02-22 14:33:44 +01:00
parent 0c2d2d8f54
commit 5090b5fb1a
4 changed files with 13 additions and 11 deletions

View File

@ -24,6 +24,8 @@ import (
)
const (
RESTIC_REPO_VOLUME = "restic-volume"
RESTIC_REPO_PATH = "/restic-repo"
RESTIC_REPOSITORY = "RESTIC_REPOSITORY"
RESTIC_PASSWORD = "RESTIC_PASSWORD"
AWS_ACCESS_KEY_ID = "AWS_ACCESS_KEY_ID"
@ -38,7 +40,7 @@ type S3 struct {
}
type Local struct {
Path string `json:"path"`
corev1.VolumeSource `json:"source"`
}
type Backend struct {
@ -115,7 +117,7 @@ func (repo *Repo) GetResticEnv(backupConf BackupConfiguration) []corev1.EnvVar {
if repo.Spec.Backend.Local != nil {
env = append(env, corev1.EnvVar{
Name: RESTIC_REPOSITORY,
Value: repo.Spec.Backend.Local.Path,
Value: RESTIC_REPO_PATH,
})
}
env = append(env, corev1.EnvVar{

View File

@ -37,7 +37,7 @@ func (in *Backend) DeepCopyInto(out *Backend) {
if in.Local != nil {
in, out := &in.Local, &out.Local
*out = new(Local)
**out = **in
(*in).DeepCopyInto(*out)
}
}
@ -350,6 +350,7 @@ func (in *Keep) DeepCopy() *Keep {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Local) DeepCopyInto(out *Local) {
*out = *in
in.VolumeSource.DeepCopyInto(&out.VolumeSource)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Local.

View File

@ -187,7 +187,7 @@ func (r *BackupConfigurationReconciler) DeleteSidecar(backupConf formolv1alpha1.
if repo.Spec.Backend.Local != nil {
restoreVolumes := []corev1.Volume{}
for _, volume := range targetPodSpec.Volumes {
if volume.Name == "restic-local-repo" {
if volume.Name == formolv1alpha1.RESTIC_REPO_VOLUME {
continue
}
restoreVolumes = append(restoreVolumes, volume)
@ -310,14 +310,12 @@ func (r *BackupConfigurationReconciler) addOnlineSidecar(backupConf formolv1alph
})
if repo.Spec.Backend.Local != nil {
sidecar.VolumeMounts = append(vms, corev1.VolumeMount{
Name: "restic-local-repo",
MountPath: "/repo",
Name: formolv1alpha1.RESTIC_REPO_VOLUME,
MountPath: formolv1alpha1.RESTIC_REPO_PATH,
})
targetPodSpec.Volumes = append(targetPodSpec.Volumes, corev1.Volume{
Name: "restic-local-repo",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
Name: formolv1alpha1.RESTIC_REPO_VOLUME,
VolumeSource: repo.Spec.Backend.Local.VolumeSource,
})
} else {
sidecar.VolumeMounts = vms

View File

@ -79,7 +79,8 @@ metadata:
spec:
backend:
local:
path: /repo
source:
emptyDir:
repositorySecrets: secret-minio
---
apiVersion: formol.desmojim.fr/v1alpha1