mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 08:29:18 -03:00
some optimization
This commit is contained in:
@@ -16,12 +16,11 @@ objectData:
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- $volsyncData := .volsyncData }}
|
||||
|
||||
---
|
||||
apiVersion: volsync.backube/v1alpha1
|
||||
kind: replicationdestination
|
||||
kind: ReplicationDestination
|
||||
metadata:
|
||||
name: {{ $objectData.name }}-{{ $volsyncData.name }}-dest
|
||||
name: {{ printf "%s-%s-dest" $objectData.name $volsyncData.name }}
|
||||
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "replicationdestination") }}
|
||||
{{- $labels := (mustMerge ($volsyncData.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
|
||||
@@ -22,25 +22,21 @@ objectData:
|
||||
{{- $schedule = $volsyncData.src.trigger.schedule -}}
|
||||
{{- end }}
|
||||
|
||||
{{- $hourly := 24 -}}
|
||||
{{- $daily := 7 -}}
|
||||
{{- $weekly := 5 -}}
|
||||
{{- if and $volsyncData.src.retain -}}
|
||||
{{- with $volsyncData.src.retain.hourly -}}
|
||||
{{- $hourly = . }}
|
||||
{{- end -}}
|
||||
{{- with $volsyncData.src.retain.daily -}}
|
||||
{{- $daily = . }}
|
||||
{{- end -}}
|
||||
{{- with $volsyncData.src.retain.weekly -}}
|
||||
{{- $weekly = . }}
|
||||
{{- $retain := dict "hourly" 24 "daily" 7 "weekly" 5 -}}
|
||||
{{- $items := list "hourly" "daily" "weekly" -}}
|
||||
|
||||
{{- if $volsyncData.src.retain -}}
|
||||
{{- range $item := $items -}}
|
||||
{{- with get $volsyncData.src.retain $item -}}
|
||||
{{- $_ := set $retain $item . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: volsync.backube/v1alpha1
|
||||
kind: ReplicationSource
|
||||
metadata:
|
||||
name: {{ $objectData.name }}-{{ $volsyncData.name }}
|
||||
name: {{ printf "%s-%s" $objectData.name $volsyncData.name }}
|
||||
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "replicationsource") }}
|
||||
{{- $labels := (mustMerge ($volsyncData.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
@@ -66,7 +62,7 @@ spec:
|
||||
{{- include "tc.v1.common.lib.volsync.moversecuritycontext" (dict "rootCtx" $rootCtx "objectData" $objectData "volsyncData" $volsyncData "target" "src") | trim | nindent 4 }}
|
||||
|
||||
retain:
|
||||
hourly: {{ $hourly }}
|
||||
daily: {{ $daily }}
|
||||
weekly: {{ $weekly }}
|
||||
hourly: {{ $retain.hourly }}
|
||||
daily: {{ $retain.daily }}
|
||||
weekly: {{ $retain.weekly }}
|
||||
{{- end }}
|
||||
|
||||
@@ -6,24 +6,23 @@
|
||||
{{- $volsyncData := .volsyncData -}}
|
||||
{{- $target := get $volsyncData .target -}}
|
||||
|
||||
{{- $runAsUser := $rootCtx.Values.securityContext.container.runAsUser -}}
|
||||
{{- $runAsGroup := $rootCtx.Values.securityContext.container.runAsGroup -}}
|
||||
{{- $fsGroup := $rootCtx.Values.securityContext.pod.fsGroup -}}
|
||||
{{- $sec := dict
|
||||
"runAsUser" $rootCtx.Values.securityContext.container.runAsUser
|
||||
"runAsGroup" $rootCtx.Values.securityContext.container.runAsGroup
|
||||
"fsGroup" $rootCtx.Values.securityContext.pod.fsGroup
|
||||
-}}
|
||||
|
||||
{{- $items := list "runAsUser" "runAsGroup" "fsGroup" -}}
|
||||
{{- if $target.moverSecurityContext -}}
|
||||
{{- with $target.moverSecurityContext.runAsUser -}} {{/* TODO: Handle 0 here */}}
|
||||
{{- $runAsUser = . | default $runAsUser -}}
|
||||
{{- end -}}
|
||||
{{- with $target.moverSecurityContext.runAsGroup -}} {{/* TODO: Handle 0 here */}}
|
||||
{{- $runAsGroup = . | default $runAsGroup -}}
|
||||
{{- end -}}
|
||||
{{- with $target.moverSecurityContext.fsGroup -}} {{/* TODO: Handle 0 here */}}
|
||||
{{- $fsGroup = . | default $fsGroup -}}
|
||||
{{- range $item := $items -}}
|
||||
{{- if hasKey $target.moverSecurityContext $item -}}
|
||||
{{- $_ := set $sec $item (get $target.moverSecurityContext $item) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
moverSecurityContext:
|
||||
runAsUser: {{ $runAsUser }}
|
||||
runAsGroup: {{ $runAsGroup }}
|
||||
fsGroup: {{ $fsGroup }}
|
||||
runAsUser: {{ $sec.runAsUser }}
|
||||
runAsGroup: {{ $sec.runAsGroup }}
|
||||
fsGroup: {{ $sec.fsGroup }}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user