@@ -27,20 +27,83 @@ Default image name for a given product
2727{ {- printf " ghcr.io/loft-sh/loft:%s" .Chart.Version -} }
2828{ {- end -} }
2929
30+ { {/*
31+ Populate image ref for a given product
32+ */} }
33+ { {- define " loft.imageRef" -} }
34+ { {- $registry := default " ghcr.io" .Values.imageRef.registry -} }
35+ { {- $repository := coalesce .Values.imageRef.repository .repo " loft-sh/vcluster-platform" -} }
36+ { {- $tag := default .Chart.Version .Values.imageRef.tag -} }
37+ { {- printf " %s/%s:%s" $registry $repository $tag -} }
38+ { {- end -} }
39+
3040{ {- define " loft.image" -} }
3141 { {- if .Values.product -} }
3242 { {- if eq .Values.product " vcluster-pro" -} }
33- { {- printf " ghcr.io/loft-sh/vcluster-platform:%s" .Chart.Version -} }
34- { {- else if eq .Values.product " devpod-pro" -} }
35- { {- printf " ghcr.io/loft-sh/devpod-pro:%s" .Chart.Version -} }
43+ { {- if .Values.imageRef -} }
44+ { { include " loft.imageRef" $ } }
45+ { {- else -} }
46+ { {- printf " ghcr.io/loft-sh/vcluster-platform:%s" .Chart.Version -} }
47+ { {- end -} }
3648 { {- else -} }
37- { { include " loft.defaultImage" . } }
49+ { {- if .Values.imageRef -} }
50+ { { include " loft.imageRef" (merge (dict " repo" " loft-sh/loft" ) $) } }
51+ { {- else -} }
52+ { { coalesce .Values.image (include " loft.defaultImage" .) } }
53+ { {- end -} }
3854 { {- end -} }
3955 { {- else -} }
40- { { include " loft.defaultImage" . } }
56+ { {- if .Values.imageRef -} }
57+ { { include " loft.imageRef" (merge (dict " repo" " loft-sh/loft" ) $) } }
58+ { {- else -} }
59+ { { coalesce .Values.image (include " loft.defaultImage" .) } }
60+ { {- end -} }
4161 { {- end -} }
4262{ {- end -} }
4363
64+
65+ { {/*
66+ Populate audit image ref
67+ */} }
68+ { {- define " loft.auditImageRef" -} }
69+ { {- $registry := default " docker.io" .Values.audit.imageRef.registry -} }
70+ { {- $repository := default " library/alpine" .Values.audit.imageRef.repository -} }
71+ { {- $tag := default " 3.13.1" .Values.audit.imageRef.tag -} }
72+ { {- printf " %s/%s:%s" $registry $repository $tag -} }
73+ { {- end -} }
74+
75+ { {- define " loft.auditImage" -} }
76+ { {- if .Values.audit.imageRef -} }
77+ { { include " loft.auditImageRef" . } }
78+ { {- else -} }
79+ { { default " library/alpine:3.13.1" .Values.audit.image } }
80+ { {- end -} }
81+ { {- end -} }
82+
83+ { {/*
84+ True when multiRegion is set and enabled (safe when .Values.multiRegion is nil).
85+ Output is truthy when enabled, empty otherwise; use in {{ if include " loft.multiRegionEnabled" . } }.
86+ */}}
87+ { {- define " loft.multiRegionEnabled" -} }
88+ { {- if and .Values.multiRegion .Values.multiRegion.enabled } }{ { true } }{ { end -} }
89+ { {- end -} }
90+
91+ { {/*
92+ True when config.database is set and enabled (safe when .Values.config or .Values.config.database is nil).
93+ Output is truthy when enabled, empty otherwise; use in {{ if include " loft.configDatabaseEnabled" . } }.
94+ */}}
95+ { {- define " loft.configDatabaseEnabled" -} }
96+ { {- if and .Values.config .Values.config.database .Values.config.database.enabled } }{ { true } }{ { end -} }
97+ { {- end -} }
98+
99+ { {/*
100+ True when env.LOFT_EMBEDDED_K8S is set to " true" (safe when .Values.env is nil).
101+ Output is truthy when enabled, empty otherwise; use in {{ if include " loft.envEmbeddedK8sEnabled" . } }.
102+ */}}
103+ { {- define " loft.envEmbeddedK8sEnabled" -} }
104+ { {- if eq (.Values.env.LOFT_EMBEDDED_K8S | toString) " true" } }{ { true } }{ { end -} }
105+ { {- end -} }
106+
44107{ {- define " loft.strategyType" -} }
45108 { {- if and .Values.strategy .Values.strategy.type -} }
46109 { {- .Values.strategy.type -} }
@@ -66,3 +129,29 @@ rollingUpdate:
66129 { {- end } }
67130{ {- end -} }
68131{ {- end -} }
132+
133+ { {- define " loft.leastPrivilegeModeValues" -} }
134+ { {- $defaultValues := dict
135+ " enabled" false
136+ " clusterAccess" (dict " enabled" true )
137+ " projectQuotas" (dict " enabled" true )
138+ " secrets" (dict " enabled" true )
139+ " sleepMode" (dict " enabled" true )
140+ " role" (dict " enabled" true " extraRules" (list) " overwriteRules" (list))
141+ " clusterRole" (dict " enabled" true " extraRules" (list) " overwriteRules" (list))
142+ " namespaceAdminRole" (dict " enabled" true " extraRules" (list) " overwriteRules" (list)) -} }
143+ { {- if .Values.leastPrivilegeMode -} }
144+ { { mergeOverwrite $defaultValues .Values.leastPrivilegeMode | toJson } }
145+ { {- else -} }
146+ { { $defaultValues | toJson } }
147+ { {- end -} }
148+ { {- end -} }
149+
150+ { {- define " loft.isLeastPrivilegeModeEnabled" -} }
151+ { {- if .Values.leastPrivilegeMode -} }
152+ { {- if eq true .Values.leastPrivilegeMode.enabled -} }
153+ { { true } }
154+ { {- end -} }
155+ { {- end -} }
156+ { {- end -} }
157+
0 commit comments