From 718217bb03d49c9fea619f6787569c8d61b4cd63 Mon Sep 17 00:00:00 2001 From: Alessio Dionisi Date: Tue, 29 Oct 2024 18:08:07 +0100 Subject: [PATCH] fix: add checks to DR cron templates (#285) --- templates/distribution/manifests/dr/kustomization.yaml.tpl | 6 ++++-- .../manifests/dr/patches/velero-schedule-full.yml.tpl | 6 ++++-- .../manifests/dr/patches/velero-schedule-manifests.yml.tpl | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/templates/distribution/manifests/dr/kustomization.yaml.tpl b/templates/distribution/manifests/dr/kustomization.yaml.tpl index fa13dbd12..f2cd569a7 100644 --- a/templates/distribution/manifests/dr/kustomization.yaml.tpl +++ b/templates/distribution/manifests/dr/kustomization.yaml.tpl @@ -33,12 +33,14 @@ patchesStrategicMerge: {{- if eq .spec.distribution.common.provider.type "eks" }} - patches/eks-velero.yml {{- end }} -{{- if and (.spec.distribution.modules.dr.velero.schedules.install) (ne .spec.distribution.modules.dr.velero.schedules.cron.manifests "") }} +{{- if .spec.distribution.modules.dr.velero.schedules.install }} +{{- if or (index .spec.distribution.modules.dr.velero.schedules "ttl") (and (index .spec.distribution.modules.dr.velero.schedules "cron") (index .spec.distribution.modules.dr.velero.schedules.cron "manifests")) }} - patches/velero-schedule-manifests.yml {{- end }} -{{- if and (.spec.distribution.modules.dr.velero.schedules.install) (ne .spec.distribution.modules.dr.velero.schedules.cron.full "") }} +{{- if or (index .spec.distribution.modules.dr.velero.schedules "ttl") (and (index .spec.distribution.modules.dr.velero.schedules "cron") (index .spec.distribution.modules.dr.velero.schedules.cron "full")) }} - patches/velero-schedule-full.yml {{- end }} +{{- end }} {{- if eq .spec.distribution.common.provider.type "none" }} {{- if eq .spec.distribution.modules.dr.velero.backend "externalEndpoint" }} diff --git a/templates/distribution/manifests/dr/patches/velero-schedule-full.yml.tpl b/templates/distribution/manifests/dr/patches/velero-schedule-full.yml.tpl index 31307f71a..5bf3de289 100644 --- a/templates/distribution/manifests/dr/patches/velero-schedule-full.yml.tpl +++ b/templates/distribution/manifests/dr/patches/velero-schedule-full.yml.tpl @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +{{- if or (index .spec.distribution.modules.dr.velero.schedules "ttl") (and (index .spec.distribution.modules.dr.velero.schedules "cron") (index .spec.distribution.modules.dr.velero.schedules.cron "full")) }} --- apiVersion: velero.io/v1 kind: Schedule @@ -12,7 +13,8 @@ spec: {{- if and (index .spec.distribution.modules.dr.velero.schedules "cron") (index .spec.distribution.modules.dr.velero.schedules.cron "full") }} schedule: {{ .spec.distribution.modules.dr.velero.schedules.cron.full }} {{- end }} + {{- if index .spec.distribution.modules.dr.velero.schedules "ttl" }} template: - {{- if index .spec.distribution.modules.dr.velero.schedules "ttl" }} ttl: {{ .spec.distribution.modules.dr.velero.schedules.ttl }} - {{- end }} + {{- end }} +{{- end }} diff --git a/templates/distribution/manifests/dr/patches/velero-schedule-manifests.yml.tpl b/templates/distribution/manifests/dr/patches/velero-schedule-manifests.yml.tpl index db585789f..c08006331 100644 --- a/templates/distribution/manifests/dr/patches/velero-schedule-manifests.yml.tpl +++ b/templates/distribution/manifests/dr/patches/velero-schedule-manifests.yml.tpl @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +{{- if or (index .spec.distribution.modules.dr.velero.schedules "ttl") (and (index .spec.distribution.modules.dr.velero.schedules "cron") (index .spec.distribution.modules.dr.velero.schedules.cron "manifests")) }} --- apiVersion: velero.io/v1 kind: Schedule @@ -12,7 +13,8 @@ spec: {{- if and (index .spec.distribution.modules.dr.velero.schedules "cron") (index .spec.distribution.modules.dr.velero.schedules.cron "manifests") }} schedule: {{ .spec.distribution.modules.dr.velero.schedules.cron.manifests }} {{- end }} + {{- if index .spec.distribution.modules.dr.velero.schedules "ttl" }} template: - {{- if index .spec.distribution.modules.dr.velero.schedules "ttl" }} ttl: {{ .spec.distribution.modules.dr.velero.schedules.ttl }} - {{- end }} + {{- end }} +{{- end }}