diff --git a/acceptance/go.sum b/acceptance/go.sum index 7cc7e3efd..5ffc1c784 100644 --- a/acceptance/go.sum +++ b/acceptance/go.sum @@ -720,6 +720,8 @@ github.com/redpanda-data/common-go/secrets v0.1.3 h1:VRo+OFS4Zgb2UMvwcIuUujdMhAP github.com/redpanda-data/common-go/secrets v0.1.3/go.mod h1:WjUU/5saSXwItZx6veFOGbQZUgPQz4MQ65z22y0Ky84= github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20 h1:+zsE3W1V86k2sjAGWOySIlF0xn5R1aXXQBaIdr80F48= github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20/go.mod h1:DC42/3+k5PefSo4IalYbDN3yRZrVFP0b69+gC/NwGd4= +github.com/redpanda-data/redpanda-operator/charts/console v0.0.0-20250718150737-e01f8476d560 h1:fhMikrIYgjTukRTS7zZHJ5sFQP4hotkfExEyFRWw6rI= +github.com/redpanda-data/redpanda-operator/charts/console v0.0.0-20250718150737-e01f8476d560/go.mod h1:aSiQU9wI3DcOv4tyvoJz5Gx2bUq71LHlLnPkQcGWpK4= github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0 h1:IV2Ic66JDKPtCnNU4Kn1naJlzZmhl0izRj17qgTCo20= github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0/go.mod h1:usCpPzzzhgtPrRTiUQOzFqGmukce8U0SrzEeX2ONDFE= github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20250716004441-6e1647296ad6 h1:SbcvWTYFEbH5+NQOl1To5jppEa8RCK1HAkRNfhdUGLg= diff --git a/charts/console/chart.go b/charts/console/chart.go deleted file mode 100644 index dba914902..000000000 --- a/charts/console/chart.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2025 Redpanda Data, Inc. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.md -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0 - -// +gotohelm:namespace=console -package console - -import ( - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/kubernetes/scheme" - - "github.com/redpanda-data/redpanda-operator/gotohelm/helmette" - "github.com/redpanda-data/redpanda-operator/pkg/kube" -) - -// Scheme is a [runtime.Scheme] with the appropriate extensions to load all -// objects produced by the console chart. -var Scheme = runtime.NewScheme() - -// +gotohelm:ignore=true -func init() { - must(scheme.AddToScheme(Scheme)) -} - -// +gotohelm:ignore=true -func must(err error) { - if err != nil { - panic(err) - } -} - -// render is the entrypoint to both the go and helm versions of the console -// helm chart. -// In helm, _shims.render-manifest is used to call and filter the output of -// this function. -// In go, this function should be call by executing [ChartLabel.Render], which will -// handle construction of [helmette.Dot], subcharting, and output filtering. -func Render(dot *helmette.Dot) []kube.Object { - manifests := []kube.Object{ - ServiceAccount(dot), - Secret(dot), - ConfigMap(dot), - Service(dot), - Ingress(dot), - Deployment(dot), - HorizontalPodAutoscaler(dot), - } - - // NB: This slice may contain nil interfaces! - // Filtering happens elsewhere, don't call this function directly if you - // can avoid it. - return manifests -} diff --git a/charts/console/chart/chart.go b/charts/console/chart/chart.go index fb4fc164d..4211efd55 100644 --- a/charts/console/chart/chart.go +++ b/charts/console/chart/chart.go @@ -11,6 +11,8 @@ package chart import ( "embed" + "fmt" + "strings" "github.com/redpanda-data/redpanda-operator/charts/console/v3" "github.com/redpanda-data/redpanda-operator/gotohelm" @@ -31,30 +33,118 @@ var ( //go:embed values.schema.json ValuesSchemaJSON []byte - // ChartLabel is the go version of the console helm chart. - Chart = gotohelm.MustLoad(chartFiles, render) + // Chart is the go version of the console helm chart. + Chart = gotohelm.MustLoad(chartFiles, Render) ) -type Values struct { - console.Values `json:",inline"` - - Enabled *bool `json:"enabled,omitempty"` - Tests Enableable `json:"tests"` -} - -type Enableable struct { - Enabled bool `json:"enabled"` -} - -// render is the entrypoint to both the go and helm versions of the console +// Render is the entrypoint to both the go and helm versions of the console // helm chart. // In helm, _shims.render-manifest is used to call and filter the output of // this function. // In go, this function should be call by executing [ChartLabel.Render], which will // handle construction of [helmette.Dot], subcharting, and output filtering. -func render(dot *helmette.Dot) []kube.Object { +func Render(dot *helmette.Dot) []kube.Object { + state := DotToState(dot) + // NB: This slice may contain nil interfaces! // Filtering happens elsewhere, don't call this function directly if you // can avoid it. - return console.Render(dot) + return console.Render(state) +} + +func DotToState(dot *helmette.Dot) *console.RenderState { + values := helmette.Unwrap[Values](dot.Values) + templater := &templater{Dot: dot, FauxDot: newFauxDot(dot)} + + return &console.RenderState{ + ReleaseName: dot.Release.Name, + Namespace: dot.Release.Namespace, + Values: values.RenderValues, + Template: templater.Template, + CommonLabels: map[string]string{ + "helm.sh/chart": ChartLabel(dot), + "app.kubernetes.io/managed-by": dot.Release.Service, + "app.kubernetes.io/version": dot.Chart.AppVersion, + }, + } +} + +// templater is a fairly hacky yet effective way to abstract out the global +// `tpl` function that's plagued our rendering packages. +// +// It works around a very niche issue in gotohelm/helm: +// 1. The inability to return a [helmette.Chart]. Helm's internal version +// of `Chart` has JSON tags. Returning it in gotohelm results in all +// fields being downcased and therefore inaccessible. To work around this, we +// construct a [FauxChart] which explicitly keeps the Chart fields upper cased. +// 2. The inability to return a `helmette.Values`. Values is a wrapper type +// around a map[string]any. It comes with an AsMap function that's used by +// gotohelm. We hack in interoperability by assigning a shallow clone of the +// values to itself in the AsMap key. +type templater struct { + // Dot is present purely to satisfy the go requirements of helmette.Tpl. DO + // NOT REFERENCE IT IN HELM IT WILL NOT WORK. + Dot *helmette.Dot + FauxDot *FauxDot +} + +func (t *templater) Template(tpl string) string { + return helmette.Tpl(t.Dot, tpl, t.FauxDot) +} + +type FauxChart struct { + Name string + Version string + AppVersion string +} + +type FauxDot struct { + Values map[string]any + Chart FauxChart + Release helmette.Release + Template helmette.Template +} + +func newFauxDot(dot *helmette.Dot) *FauxDot { + clone := map[string]any{} + for key, value := range dot.Values.AsMap() { + clone[key] = value + } + // NB: A shallow clone MUST be used here. If there's any recursion, the + // JSON serialization in sprig "gives up" and returns an empty string. + clone["AsMap"] = dot.Values.AsMap() + return &FauxDot{ + Values: clone, + Release: dot.Release, + Template: dot.Template, + Chart: FauxChart{ + Name: dot.Chart.Name, + AppVersion: dot.Chart.AppVersion, + Version: dot.Chart.Version, + }, + } +} + +// Functions below this line are included for backwards compatibility purposes. +// They're re-namespaced in compat.tpl + +func Name(dot *helmette.Dot) string { + return DotToState(dot).ChartName() +} + +// Create a default fully qualified app name. +// We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +// If release name contains chart name it will be used as a full name. +func Fullname(dot *helmette.Dot) string { + return DotToState(dot).FullName() +} + +// Create chart name and version as used by the chart label. +func ChartLabel(dot *helmette.Dot) string { + chart := fmt.Sprintf("%s-%s", dot.Chart.Name, dot.Chart.Version) + return cleanForK8s(strings.ReplaceAll(chart, "+", "_")) +} + +func cleanForK8s(s string) string { + return helmette.TrimSuffix("-", helmette.Trunc(63, s)) } diff --git a/charts/console/chart/chart_test.go b/charts/console/chart/chart_test.go index 2e2d2695d..905c0d8cf 100644 --- a/charts/console/chart/chart_test.go +++ b/charts/console/chart/chart_test.go @@ -39,16 +39,19 @@ import ( "github.com/redpanda-data/redpanda-operator/pkg/testutil" ) -func TestArtifactHubImages(t *testing.T) { +func TestChartYAML(t *testing.T) { var images []map[string]any require.NoError(t, yaml.Unmarshal([]byte(Chart.Metadata().Annotations["artifacthub.io/images"]), &images)) - require.Equal(t, []map[string]any{ + assert.Equal(t, []map[string]any{ { "name": "console", "image": "docker.redpanda.com/redpandadata/console:" + Chart.Metadata().AppVersion, }, }, images) + + assert.Equal(t, console.ChartName, Chart.Metadata().Name) + assert.Equal(t, console.AppVersion, Chart.Metadata().AppVersion) } // TestValues asserts that the chart's values.yaml file can be losslessly @@ -206,7 +209,7 @@ func TestGoHelmEquivalence(t *testing.T) { Tests: &PartialEnableable{ Enabled: ptr.To(false), }, - PartialValues: console.PartialValues{ + PartialRenderValues: console.PartialRenderValues{ Secret: &console.PartialSecretConfig{ Authentication: &console.PartialAuthenticationSecrets{ JWTSigningKey: ptr.To("SECRET"), @@ -259,7 +262,7 @@ func TestGoHelmEquivalence(t *testing.T) { func TestSecrets(t *testing.T) { values := PartialValues{ - PartialValues: console.PartialValues{ + PartialRenderValues: console.PartialRenderValues{ Secret: &console.PartialSecretConfig{ Create: ptr.To(true), Kafka: &console.PartialKafkaSecrets{ @@ -357,7 +360,7 @@ func TestIntegrationChart(t *testing.T) { env := h.Namespaced(t) partial := PartialValues{ - PartialValues: console.PartialValues{ + PartialRenderValues: console.PartialRenderValues{ Image: &console.PartialImage{ Repository: ptr.To("redpandadata/console-unstable"), Tag: ptr.To("master-a4cf9be"), diff --git a/charts/console/notes.go b/charts/console/chart/notes.go similarity index 99% rename from charts/console/notes.go rename to charts/console/chart/notes.go index f0ae8df5f..c9c9c4e9b 100644 --- a/charts/console/notes.go +++ b/charts/console/chart/notes.go @@ -7,7 +7,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0 -package console +package chart import ( "fmt" diff --git a/charts/console/chart/templates/NOTES.txt b/charts/console/chart/templates/NOTES.txt index 7541881fc..e7d2fcd67 100644 --- a/charts/console/chart/templates/NOTES.txt +++ b/charts/console/chart/templates/NOTES.txt @@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */}} -{{- $notes := (get ((include "console.Notes" (dict "a" (list .))) | fromJson) "r") -}} +{{- $notes := (get ((include "chart.Notes" (dict "a" (list .))) | fromJson) "r") -}} {{- range $_, $note := $notes }} {{ $note }} {{- end }} diff --git a/charts/console/chart/templates/_chart.chart.tpl b/charts/console/chart/templates/_chart.chart.tpl index 5a3a1c83b..4a61fa970 100644 --- a/charts/console/chart/templates/_chart.chart.tpl +++ b/charts/console/chart/templates/_chart.chart.tpl @@ -1,12 +1,95 @@ {{- /* GENERATED FILE DO NOT EDIT */ -}} {{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/chart/chart.go" */ -}} -{{- define "chart.render" -}} +{{- define "chart.Render" -}} {{- $dot := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} +{{- $state := (get (fromJson (include "chart.DotToState" (dict "a" (list $dot)))) "r") -}} {{- $_is_returning = true -}} -{{- (dict "r" (get (fromJson (include "console.Render" (dict "a" (list $dot)))) "r")) | toJson -}} +{{- (dict "r" (get (fromJson (include "console.Render" (dict "a" (list $state)))) "r")) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "chart.DotToState" -}} +{{- $dot := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $values := $dot.Values.AsMap -}} +{{- $templater := (mustMergeOverwrite (dict "Dot" (coalesce nil) "FauxDot" (coalesce nil)) (dict "Dot" $dot "FauxDot" (get (fromJson (include "chart.newFauxDot" (dict "a" (list $dot)))) "r"))) -}} +{{- $_is_returning = true -}} +{{- (dict "r" (mustMergeOverwrite (dict "ReleaseName" "" "Namespace" "" "Template" (coalesce nil) "CommonLabels" (coalesce nil) "Values" (dict "replicaCount" 0 "nameOverride" "" "commonLabels" (coalesce nil) "fullnameOverride" "" "image" (dict "registry" "" "repository" "" "pullPolicy" "" "tag" "") "imagePullSecrets" (coalesce nil) "automountServiceAccountToken" false "serviceAccount" (dict "create" false "automountServiceAccountToken" false "annotations" (coalesce nil) "name" "") "annotations" (coalesce nil) "podAnnotations" (coalesce nil) "podLabels" (coalesce nil) "podSecurityContext" (dict) "securityContext" (dict) "service" (dict "type" "" "port" 0 "annotations" (coalesce nil)) "ingress" (dict "enabled" false "annotations" (coalesce nil) "hosts" (coalesce nil) "tls" (coalesce nil)) "resources" (dict) "autoscaling" (dict "enabled" false "minReplicas" 0 "maxReplicas" 0 "targetCPUUtilizationPercentage" (coalesce nil)) "nodeSelector" (coalesce nil) "tolerations" (coalesce nil) "affinity" (dict) "topologySpreadConstraints" (coalesce nil) "priorityClassName" "" "config" (coalesce nil) "extraEnv" (coalesce nil) "extraEnvFrom" (coalesce nil) "extraVolumes" (coalesce nil) "extraVolumeMounts" (coalesce nil) "extraContainers" (coalesce nil) "initContainers" (dict "extraInitContainers" (coalesce nil)) "secretMounts" (coalesce nil) "secret" (dict "create" false "kafka" (dict) "authentication" (dict "jwtSigningKey" "" "oidc" (dict)) "license" "" "redpanda" (dict "adminApi" (dict)) "serde" (dict) "schemaRegistry" (dict)) "livenessProbe" (dict) "readinessProbe" (dict) "configmap" (dict "create" false) "deployment" (dict "create" false) "strategy" (dict))) (dict "ReleaseName" $dot.Release.Name "Namespace" $dot.Release.Namespace "Values" $values "Template" (list "chart.templater.Template" $templater) "CommonLabels" (dict "helm.sh/chart" (get (fromJson (include "chart.ChartLabel" (dict "a" (list $dot)))) "r") "app.kubernetes.io/managed-by" $dot.Release.Service "app.kubernetes.io/version" $dot.Chart.AppVersion)))) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "chart.templater.Template" -}} +{{- $t := (index .a 0) -}} +{{- $tpl := (index .a 1) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $_is_returning = true -}} +{{- (dict "r" (tpl $tpl $t.FauxDot)) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "chart.newFauxDot" -}} +{{- $dot := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $clone := (dict) -}} +{{- range $key, $value := $dot.Values.AsMap -}} +{{- $_ := (set $clone $key $value) -}} +{{- end -}} +{{- if $_is_returning -}} +{{- break -}} +{{- end -}} +{{- $_ := (set $clone "AsMap" $dot.Values.AsMap) -}} +{{- $_is_returning = true -}} +{{- (dict "r" (mustMergeOverwrite (dict "Values" (coalesce nil) "Chart" (dict "Name" "" "Version" "" "AppVersion" "") "Release" (dict "Name" "" "Namespace" "" "Service" "" "IsUpgrade" false "IsInstall" false) "Template" (dict "Name" "" "BasePath" "")) (dict "Values" $clone "Release" $dot.Release "Template" $dot.Template "Chart" (mustMergeOverwrite (dict "Name" "" "Version" "" "AppVersion" "") (dict "Name" $dot.Chart.Name "AppVersion" $dot.Chart.AppVersion "Version" $dot.Chart.Version))))) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "chart.Name" -}} +{{- $dot := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $_is_returning = true -}} +{{- (dict "r" (get (fromJson (include "console.RenderState.ChartName" (dict "a" (list (get (fromJson (include "chart.DotToState" (dict "a" (list $dot)))) "r"))))) "r")) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "chart.Fullname" -}} +{{- $dot := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $_is_returning = true -}} +{{- (dict "r" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list (get (fromJson (include "chart.DotToState" (dict "a" (list $dot)))) "r"))))) "r")) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "chart.ChartLabel" -}} +{{- $dot := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $chart := (printf "%s-%s" $dot.Chart.Name $dot.Chart.Version) -}} +{{- $_is_returning = true -}} +{{- (dict "r" (get (fromJson (include "chart.cleanForK8s" (dict "a" (list (replace "+" "_" $chart))))) "r")) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "chart.cleanForK8s" -}} +{{- $s := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $_is_returning = true -}} +{{- (dict "r" (trimSuffix "-" (trunc (63 | int) $s))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} diff --git a/charts/console/chart/templates/_console.notes.tpl b/charts/console/chart/templates/_chart.notes.tpl similarity index 63% rename from charts/console/chart/templates/_console.notes.tpl rename to charts/console/chart/templates/_chart.notes.tpl index 50cd5626f..b1b113e48 100644 --- a/charts/console/chart/templates/_console.notes.tpl +++ b/charts/console/chart/templates/_chart.notes.tpl @@ -1,7 +1,7 @@ {{- /* GENERATED FILE DO NOT EDIT */ -}} -{{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/notes.go" */ -}} +{{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/chart/notes.go" */ -}} -{{- define "console.Notes" -}} +{{- define "chart.Notes" -}} {{- $dot := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} @@ -24,11 +24,11 @@ {{- break -}} {{- end -}} {{- else -}}{{- if (contains "NodePort" (toString $values.service.type)) -}} -{{- $commands = (concat (default (list) $commands) (list (printf ` export NODE_PORT=$(kubectl get --namespace %s -o jsonpath="{.spec.ports[0].nodePort}" services %s)` $dot.Release.Namespace (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r")) (printf ` export NODE_IP=$(kubectl get nodes --namespace %s -o jsonpath="{.items[0].status.addresses[0].address}")` $dot.Release.Namespace) " echo http://$NODE_IP:$NODE_PORT")) -}} +{{- $commands = (concat (default (list) $commands) (list (printf ` export NODE_PORT=$(kubectl get --namespace %s -o jsonpath="{.spec.ports[0].nodePort}" services %s)` $dot.Release.Namespace (get (fromJson (include "chart.Fullname" (dict "a" (list $dot)))) "r")) (printf ` export NODE_IP=$(kubectl get nodes --namespace %s -o jsonpath="{.items[0].status.addresses[0].address}")` $dot.Release.Namespace) " echo http://$NODE_IP:$NODE_PORT")) -}} {{- else -}}{{- if (contains "NodePort" (toString $values.service.type)) -}} -{{- $commands = (concat (default (list) $commands) (list ` NOTE: It may take a few minutes for the LoadBalancer IP to be available.` (printf ` You can watch the status of by running 'kubectl get --namespace %s svc -w %s'` $dot.Release.Namespace (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r")) (printf ` export SERVICE_IP=$(kubectl get svc --namespace %s %s --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")` $dot.Release.Namespace (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r")) (printf ` echo http://$SERVICE_IP:%d` ($values.service.port | int)))) -}} +{{- $commands = (concat (default (list) $commands) (list ` NOTE: It may take a few minutes for the LoadBalancer IP to be available.` (printf ` You can watch the status of by running 'kubectl get --namespace %s svc -w %s'` $dot.Release.Namespace (get (fromJson (include "chart.Fullname" (dict "a" (list $dot)))) "r")) (printf ` export SERVICE_IP=$(kubectl get svc --namespace %s %s --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")` $dot.Release.Namespace (get (fromJson (include "chart.Fullname" (dict "a" (list $dot)))) "r")) (printf ` echo http://$SERVICE_IP:%d` ($values.service.port | int)))) -}} {{- else -}}{{- if (contains "ClusterIP" (toString $values.service.type)) -}} -{{- $commands = (concat (default (list) $commands) (list (printf ` export POD_NAME=$(kubectl get pods --namespace %s -l "app.kubernetes.io/name=%s,app.kubernetes.io/instance=%s" -o jsonpath="{.items[0].metadata.name}")` $dot.Release.Namespace (get (fromJson (include "console.Name" (dict "a" (list $dot)))) "r") $dot.Release.Name) (printf ` export CONTAINER_PORT=$(kubectl get pod --namespace %s $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")` $dot.Release.Namespace) ` echo "Visit http://127.0.0.1:8080 to use your application"` (printf ` kubectl --namespace %s port-forward $POD_NAME 8080:$CONTAINER_PORT` $dot.Release.Namespace))) -}} +{{- $commands = (concat (default (list) $commands) (list (printf ` export POD_NAME=$(kubectl get pods --namespace %s -l "app.kubernetes.io/name=%s,app.kubernetes.io/instance=%s" -o jsonpath="{.items[0].metadata.name}")` $dot.Release.Namespace (get (fromJson (include "chart.Name" (dict "a" (list $dot)))) "r") $dot.Release.Name) (printf ` export CONTAINER_PORT=$(kubectl get pod --namespace %s $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")` $dot.Release.Namespace) ` echo "Visit http://127.0.0.1:8080 to use your application"` (printf ` kubectl --namespace %s port-forward $POD_NAME 8080:$CONTAINER_PORT` $dot.Release.Namespace))) -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/console/chart/templates/_compat.tpl b/charts/console/chart/templates/_compat.tpl new file mode 100644 index 000000000..2ed95df8d --- /dev/null +++ b/charts/console/chart/templates/_compat.tpl @@ -0,0 +1,8 @@ +{{- define "console.Name" -}} +{{- (dict "r" (get (fromJson (include "chart.Name" .)) "r")) | toJson -}} +{{- end -}} + +{{- define "console.Fullname" -}} +{{- (dict "r" (get (fromJson (include "chart.Fullname" .)) "r")) | toJson -}} +{{- end -}} + diff --git a/charts/console/chart/templates/_console.configmap.tpl b/charts/console/chart/templates/_console.configmap.tpl index 494d6b73b..f9ffdcdef 100644 --- a/charts/console/chart/templates/_console.configmap.tpl +++ b/charts/console/chart/templates/_console.configmap.tpl @@ -2,18 +2,17 @@ {{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/configmap.go" */ -}} {{- define "console.ConfigMap" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- if (not $values.configmap.create) -}} +{{- if (not $state.Values.configmap.create) -}} {{- $_is_returning = true -}} {{- (dict "r" (coalesce nil)) | toJson -}} {{- break -}} {{- end -}} -{{- $data := (dict "config.yaml" (printf "# from .Values.config\n%s\n" (tpl (toYaml $values.config) $dot))) -}} +{{- $data := (dict "config.yaml" (printf "# from .Values.config\n%s\n" (get (fromJson (include (first $state.Template) (dict "a" (concat (rest $state.Template) (list (toYaml $state.Values.config)))))) "r"))) -}} {{- $_is_returning = true -}} -{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil))) (mustMergeOverwrite (dict) (dict "apiVersion" "v1" "kind" "ConfigMap")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "labels" (get (fromJson (include "console.Labels" (dict "a" (list $dot)))) "r") "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r") "namespace" $dot.Release.Namespace)) "data" $data))) | toJson -}} +{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil))) (mustMergeOverwrite (dict) (dict "apiVersion" "v1" "kind" "ConfigMap")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "labels" (get (fromJson (include "console.RenderState.Labels" (dict "a" (list $state (coalesce nil))))) "r") "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r") "namespace" $state.Namespace)) "data" $data))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} diff --git a/charts/console/chart/templates/_console.deployment.tpl b/charts/console/chart/templates/_console.deployment.tpl index 1ef455efa..cf0c4edde 100644 --- a/charts/console/chart/templates/_console.deployment.tpl +++ b/charts/console/chart/templates/_console.deployment.tpl @@ -2,18 +2,17 @@ {{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/deployment.go" */ -}} {{- define "console.ContainerPort" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} {{- $listenPort := ((8080 | int) | int) -}} -{{- if (ne (toJson $values.service.targetPort) "null") -}} -{{- $listenPort = $values.service.targetPort -}} +{{- if (ne (toJson $state.Values.service.targetPort) "null") -}} +{{- $listenPort = $state.Values.service.targetPort -}} {{- end -}} -{{- $configListenPort := (dig "server" "listenPort" (coalesce nil) $values.config) -}} -{{- $_36_asInt_1_ok_2 := (get (fromJson (include "_shims.asintegral" (dict "a" (list $configListenPort)))) "r") -}} -{{- $asInt_1 := ((index $_36_asInt_1_ok_2 0) | int) -}} -{{- $ok_2 := (index $_36_asInt_1_ok_2 1) -}} +{{- $configListenPort := (dig "server" "listenPort" (coalesce nil) $state.Values.config) -}} +{{- $_34_asInt_1_ok_2 := (get (fromJson (include "_shims.asintegral" (dict "a" (list $configListenPort)))) "r") -}} +{{- $asInt_1 := ((index $_34_asInt_1_ok_2 0) | int) -}} +{{- $ok_2 := (index $_34_asInt_1_ok_2 1) -}} {{- if $ok_2 -}} {{- $_is_returning = true -}} {{- (dict "r" ($asInt_1 | int)) | toJson -}} @@ -26,53 +25,51 @@ {{- end -}} {{- define "console.Deployment" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- if (not $values.deployment.create) -}} +{{- if (not $state.Values.deployment.create) -}} {{- $_is_returning = true -}} {{- (dict "r" (coalesce nil)) | toJson -}} {{- break -}} {{- end -}} {{- $replicas := (coalesce nil) -}} -{{- if (not $values.autoscaling.enabled) -}} -{{- $replicas = ($values.replicaCount | int) -}} +{{- if (not $state.Values.autoscaling.enabled) -}} +{{- $replicas = ($state.Values.replicaCount | int) -}} {{- end -}} {{- $initContainers := (coalesce nil) -}} -{{- if (not (empty $values.initContainers.extraInitContainers)) -}} -{{- $initContainers = (fromYamlArray (tpl $values.initContainers.extraInitContainers $dot)) -}} +{{- if (not (empty $state.Values.initContainers.extraInitContainers)) -}} +{{- $initContainers = (fromYamlArray (get (fromJson (include (first $state.Template) (dict "a" (concat (rest $state.Template) (list $state.Values.initContainers.extraInitContainers))))) "r")) -}} {{- end -}} {{- $volumeMounts := (list (mustMergeOverwrite (dict "name" "" "mountPath" "") (dict "name" "configs" "mountPath" "/etc/console/configs" "readOnly" true))) -}} -{{- if $values.secret.create -}} +{{- if $state.Values.secret.create -}} {{- $volumeMounts = (concat (default (list) $volumeMounts) (list (mustMergeOverwrite (dict "name" "" "mountPath" "") (dict "name" "secrets" "mountPath" "/etc/console/secrets" "readOnly" true)))) -}} {{- end -}} -{{- range $_, $mount := $values.secretMounts -}} +{{- range $_, $mount := $state.Values.secretMounts -}} {{- $volumeMounts = (concat (default (list) $volumeMounts) (list (mustMergeOverwrite (dict "name" "" "mountPath" "") (dict "name" $mount.name "mountPath" $mount.path "subPath" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $mount.subPath "")))) "r"))))) -}} {{- end -}} {{- if $_is_returning -}} {{- break -}} {{- end -}} -{{- $volumeMounts = (concat (default (list) $volumeMounts) (default (list) $values.extraVolumeMounts)) -}} +{{- $volumeMounts = (concat (default (list) $volumeMounts) (default (list) $state.Values.extraVolumeMounts)) -}} {{- $_is_returning = true -}} -{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "selector" (coalesce nil) "template" (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "containers" (coalesce nil))) "strategy" (dict)) "status" (dict)) (mustMergeOverwrite (dict) (dict "apiVersion" "apps/v1" "kind" "Deployment")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r") "labels" (get (fromJson (include "console.Labels" (dict "a" (list $dot)))) "r") "namespace" $dot.Release.Namespace "annotations" $values.annotations)) "spec" (mustMergeOverwrite (dict "selector" (coalesce nil) "template" (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "containers" (coalesce nil))) "strategy" (dict)) (dict "replicas" $replicas "selector" (mustMergeOverwrite (dict) (dict "matchLabels" (get (fromJson (include "console.SelectorLabels" (dict "a" (list $dot)))) "r"))) "strategy" $values.strategy "template" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "containers" (coalesce nil))) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "annotations" (merge (dict) (dict "checksum/config" (sha256sum (toYaml (get (fromJson (include "console.ConfigMap" (dict "a" (list $dot)))) "r").data))) $values.podAnnotations) "labels" (merge (dict) (get (fromJson (include "console.SelectorLabels" (dict "a" (list $dot)))) "r") $values.podLabels))) "spec" (mustMergeOverwrite (dict "containers" (coalesce nil)) (dict "imagePullSecrets" $values.imagePullSecrets "serviceAccountName" (get (fromJson (include "console.ServiceAccountName" (dict "a" (list $dot)))) "r") "automountServiceAccountToken" $values.automountServiceAccountToken "securityContext" $values.podSecurityContext "nodeSelector" $values.nodeSelector "affinity" $values.affinity "topologySpreadConstraints" $values.topologySpreadConstraints "priorityClassName" $values.priorityClassName "tolerations" $values.tolerations "volumes" (get (fromJson (include "console.consolePodVolumes" (dict "a" (list $dot)))) "r") "initContainers" $initContainers "containers" (concat (default (list) (list (mustMergeOverwrite (dict "name" "" "resources" (dict)) (dict "name" $dot.Chart.Name "command" $values.deployment.command "args" (concat (default (list) (list "--config.filepath=/etc/console/configs/config.yaml")) (default (list) $values.deployment.extraArgs)) "securityContext" $values.securityContext "image" (get (fromJson (include "console.containerImage" (dict "a" (list $dot)))) "r") "imagePullPolicy" $values.image.pullPolicy "ports" (list (mustMergeOverwrite (dict "containerPort" 0) (dict "name" "http" "containerPort" ((get (fromJson (include "console.ContainerPort" (dict "a" (list $dot)))) "r") | int) "protocol" "TCP"))) "volumeMounts" $volumeMounts "livenessProbe" (mustMergeOverwrite (dict) (mustMergeOverwrite (dict) (dict "httpGet" (mustMergeOverwrite (dict "port" 0) (dict "path" "/admin/health" "port" "http")))) (dict "initialDelaySeconds" ($values.livenessProbe.initialDelaySeconds | int) "periodSeconds" ($values.livenessProbe.periodSeconds | int) "timeoutSeconds" ($values.livenessProbe.timeoutSeconds | int) "successThreshold" ($values.livenessProbe.successThreshold | int) "failureThreshold" ($values.livenessProbe.failureThreshold | int))) "readinessProbe" (mustMergeOverwrite (dict) (mustMergeOverwrite (dict) (dict "httpGet" (mustMergeOverwrite (dict "port" 0) (dict "path" "/admin/health" "port" "http")))) (dict "initialDelaySeconds" ($values.readinessProbe.initialDelaySeconds | int) "periodSeconds" ($values.readinessProbe.periodSeconds | int) "timeoutSeconds" ($values.readinessProbe.timeoutSeconds | int) "successThreshold" ($values.readinessProbe.successThreshold | int) "failureThreshold" ($values.readinessProbe.failureThreshold | int))) "resources" $values.resources "env" (get (fromJson (include "console.consoleContainerEnv" (dict "a" (list $dot)))) "r") "envFrom" $values.extraEnvFrom)))) (default (list) $values.extraContainers))))))))))) | toJson -}} +{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "selector" (coalesce nil) "template" (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "containers" (coalesce nil))) "strategy" (dict)) "status" (dict)) (mustMergeOverwrite (dict) (dict "apiVersion" "apps/v1" "kind" "Deployment")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r") "labels" (get (fromJson (include "console.RenderState.Labels" (dict "a" (list $state (coalesce nil))))) "r") "namespace" $state.Namespace "annotations" $state.Values.annotations)) "spec" (mustMergeOverwrite (dict "selector" (coalesce nil) "template" (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "containers" (coalesce nil))) "strategy" (dict)) (dict "replicas" $replicas "selector" (mustMergeOverwrite (dict) (dict "matchLabels" (get (fromJson (include "console.RenderState.SelectorLabels" (dict "a" (list $state)))) "r"))) "strategy" $state.Values.strategy "template" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "containers" (coalesce nil))) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "annotations" (merge (dict) (dict "checksum/config" (sha256sum (toYaml (get (fromJson (include "console.ConfigMap" (dict "a" (list $state)))) "r").data))) $state.Values.podAnnotations) "labels" (merge (dict) (get (fromJson (include "console.RenderState.SelectorLabels" (dict "a" (list $state)))) "r") $state.Values.podLabels))) "spec" (mustMergeOverwrite (dict "containers" (coalesce nil)) (dict "imagePullSecrets" $state.Values.imagePullSecrets "serviceAccountName" (get (fromJson (include "console.ServiceAccountName" (dict "a" (list $state)))) "r") "automountServiceAccountToken" $state.Values.automountServiceAccountToken "securityContext" $state.Values.podSecurityContext "nodeSelector" $state.Values.nodeSelector "affinity" $state.Values.affinity "topologySpreadConstraints" $state.Values.topologySpreadConstraints "priorityClassName" $state.Values.priorityClassName "tolerations" $state.Values.tolerations "volumes" (get (fromJson (include "console.consolePodVolumes" (dict "a" (list $state)))) "r") "initContainers" $initContainers "containers" (concat (default (list) (list (mustMergeOverwrite (dict "name" "" "resources" (dict)) (dict "name" "console" "command" $state.Values.deployment.command "args" (concat (default (list) (list "--config.filepath=/etc/console/configs/config.yaml")) (default (list) $state.Values.deployment.extraArgs)) "securityContext" $state.Values.securityContext "image" (get (fromJson (include "console.containerImage" (dict "a" (list $state)))) "r") "imagePullPolicy" $state.Values.image.pullPolicy "ports" (list (mustMergeOverwrite (dict "containerPort" 0) (dict "name" "http" "containerPort" ((get (fromJson (include "console.ContainerPort" (dict "a" (list $state)))) "r") | int) "protocol" "TCP"))) "volumeMounts" $volumeMounts "livenessProbe" (mustMergeOverwrite (dict) (mustMergeOverwrite (dict) (dict "httpGet" (mustMergeOverwrite (dict "port" 0) (dict "path" "/admin/health" "port" "http")))) (dict "initialDelaySeconds" ($state.Values.livenessProbe.initialDelaySeconds | int) "periodSeconds" ($state.Values.livenessProbe.periodSeconds | int) "timeoutSeconds" ($state.Values.livenessProbe.timeoutSeconds | int) "successThreshold" ($state.Values.livenessProbe.successThreshold | int) "failureThreshold" ($state.Values.livenessProbe.failureThreshold | int))) "readinessProbe" (mustMergeOverwrite (dict) (mustMergeOverwrite (dict) (dict "httpGet" (mustMergeOverwrite (dict "port" 0) (dict "path" "/admin/health" "port" "http")))) (dict "initialDelaySeconds" ($state.Values.readinessProbe.initialDelaySeconds | int) "periodSeconds" ($state.Values.readinessProbe.periodSeconds | int) "timeoutSeconds" ($state.Values.readinessProbe.timeoutSeconds | int) "successThreshold" ($state.Values.readinessProbe.successThreshold | int) "failureThreshold" ($state.Values.readinessProbe.failureThreshold | int))) "resources" $state.Values.resources "env" (get (fromJson (include "console.consoleContainerEnv" (dict "a" (list $state)))) "r") "envFrom" $state.Values.extraEnvFrom)))) (default (list) $state.Values.extraContainers))))))))))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} {{- define "console.containerImage" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- $tag := $dot.Chart.AppVersion -}} -{{- if (not (empty $values.image.tag)) -}} -{{- $tag = $values.image.tag -}} +{{- $tag := $state.Values.image.tag -}} +{{- if (eq $tag "") -}} +{{- $tag = "v3.1.0" -}} {{- end -}} -{{- $image := (printf "%s:%s" $values.image.repository $tag) -}} -{{- if (not (empty $values.image.registry)) -}} +{{- $image := (printf "%s:%s" $state.Values.image.repository $tag) -}} +{{- if (not (empty $state.Values.image.registry)) -}} {{- $_is_returning = true -}} -{{- (dict "r" (printf "%s/%s" $values.image.registry $image)) | toJson -}} +{{- (dict "r" (printf "%s/%s" $state.Values.image.registry $image)) | toJson -}} {{- break -}} {{- end -}} {{- $_is_returning = true -}} @@ -82,21 +79,20 @@ {{- end -}} {{- define "console.consoleContainerEnv" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- if (not $values.secret.create) -}} -{{- $vars := $values.extraEnv -}} -{{- if (and (ne (toJson $values.licenseSecretRef) "null") (not (empty $values.licenseSecretRef.name))) -}} -{{- $vars = (concat (default (list) $values.extraEnv) (list (mustMergeOverwrite (dict "name" "") (dict "name" "LICENSE" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" $values.licenseSecretRef.name)) (dict "key" (default "enterprise-license" $values.licenseSecretRef.key))))))))) -}} +{{- if (not $state.Values.secret.create) -}} +{{- $vars := $state.Values.extraEnv -}} +{{- if (and (ne (toJson $state.Values.licenseSecretRef) "null") (not (empty $state.Values.licenseSecretRef.name))) -}} +{{- $vars = (concat (default (list) $state.Values.extraEnv) (list (mustMergeOverwrite (dict "name" "") (dict "name" "LICENSE" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" $state.Values.licenseSecretRef.name)) (dict "key" (default "enterprise-license" $state.Values.licenseSecretRef.key))))))))) -}} {{- end -}} {{- $_is_returning = true -}} {{- (dict "r" $vars) | toJson -}} {{- break -}} {{- end -}} -{{- $possibleVars := (list (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.kafka.saslPassword "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_SASL_PASSWORD" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) (dict "key" "kafka-sasl-password")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.serde.protobufGitBasicAuthPassword "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SERDE_PROTOBUF_GIT_BASICAUTH_PASSWORD" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) (dict "key" "serde-protobuf-git-basicauth-password")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.kafka.awsMskIamSecretKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_SASL_AWSMSKIAM_SECRETKEY" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) (dict "key" "kafka-sasl-aws-msk-iam-secret-key")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.kafka.tlsCa "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_TLS_CAFILEPATH" "value" "/etc/console/secrets/kafka-tls-ca")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.kafka.tlsCert "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_TLS_CERTFILEPATH" "value" "/etc/console/secrets/kafka-tls-cert")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.kafka.tlsKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_TLS_KEYFILEPATH" "value" "/etc/console/secrets/kafka-tls-key")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.schemaRegistry.tlsCa "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_TLS_CAFILEPATH" "value" "/etc/console/secrets/schemaregistry-tls-ca")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.schemaRegistry.tlsCert "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_TLS_CERTFILEPATH" "value" "/etc/console/secrets/schemaregistry-tls-cert")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.schemaRegistry.tlsKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_TLS_KEYFILEPATH" "value" "/etc/console/secrets/schemaregistry-tls-key")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.schemaRegistry.password "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_AUTHENTICATION_BASIC_PASSWORD" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) (dict "key" "schema-registry-password")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.schemaRegistry.bearerToken "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_AUTHENTICATION_BEARERTOKEN" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) (dict "key" "schema-registry-bearertoken")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.authentication.jwtSigningKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "AUTHENTICATION_JWTSIGNINGKEY" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) (dict "key" "authentication-jwt-signingkey")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.license "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "LICENSE" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) (dict "key" "license")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.redpanda.adminApi.password "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "REDPANDA_ADMINAPI_PASSWORD" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) (dict "key" "redpanda-admin-api-password")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.redpanda.adminApi.tlsCa "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "REDPANDA_ADMINAPI_TLS_CAFILEPATH" "value" "/etc/console/secrets/redpanda-admin-api-tls-ca")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.redpanda.adminApi.tlsKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "REDPANDA_ADMINAPI_TLS_KEYFILEPATH" "value" "/etc/console/secrets/redpanda-admin-api-tls-key")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $values.secret.redpanda.adminApi.tlsCert "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "REDPANDA_ADMINAPI_TLS_CERTFILEPATH" "value" "/etc/console/secrets/redpanda-admin-api-tls-cert"))))) -}} -{{- $vars := $values.extraEnv -}} +{{- $possibleVars := (list (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.kafka.saslPassword "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_SASL_PASSWORD" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) (dict "key" "kafka-sasl-password")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.serde.protobufGitBasicAuthPassword "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SERDE_PROTOBUF_GIT_BASICAUTH_PASSWORD" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) (dict "key" "serde-protobuf-git-basicauth-password")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.kafka.awsMskIamSecretKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_SASL_AWSMSKIAM_SECRETKEY" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) (dict "key" "kafka-sasl-aws-msk-iam-secret-key")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.kafka.tlsCa "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_TLS_CAFILEPATH" "value" "/etc/console/secrets/kafka-tls-ca")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.kafka.tlsCert "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_TLS_CERTFILEPATH" "value" "/etc/console/secrets/kafka-tls-cert")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.kafka.tlsKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "KAFKA_TLS_KEYFILEPATH" "value" "/etc/console/secrets/kafka-tls-key")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.schemaRegistry.tlsCa "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_TLS_CAFILEPATH" "value" "/etc/console/secrets/schemaregistry-tls-ca")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.schemaRegistry.tlsCert "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_TLS_CERTFILEPATH" "value" "/etc/console/secrets/schemaregistry-tls-cert")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.schemaRegistry.tlsKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_TLS_KEYFILEPATH" "value" "/etc/console/secrets/schemaregistry-tls-key")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.schemaRegistry.password "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_AUTHENTICATION_BASIC_PASSWORD" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) (dict "key" "schema-registry-password")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.schemaRegistry.bearerToken "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "SCHEMAREGISTRY_AUTHENTICATION_BEARERTOKEN" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) (dict "key" "schema-registry-bearertoken")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.authentication.jwtSigningKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "AUTHENTICATION_JWTSIGNINGKEY" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) (dict "key" "authentication-jwt-signingkey")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.license "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "LICENSE" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) (dict "key" "license")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.redpanda.adminApi.password "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "REDPANDA_ADMINAPI_PASSWORD" "valueFrom" (mustMergeOverwrite (dict) (dict "secretKeyRef" (mustMergeOverwrite (dict "key" "") (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) (dict "key" "redpanda-admin-api-password")))))))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.redpanda.adminApi.tlsCa "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "REDPANDA_ADMINAPI_TLS_CAFILEPATH" "value" "/etc/console/secrets/redpanda-admin-api-tls-ca")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.redpanda.adminApi.tlsKey "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "REDPANDA_ADMINAPI_TLS_KEYFILEPATH" "value" "/etc/console/secrets/redpanda-admin-api-tls-key")))) (mustMergeOverwrite (dict "Value" (coalesce nil) "EnvVar" (dict "name" "")) (dict "Value" $state.Values.secret.redpanda.adminApi.tlsCert "EnvVar" (mustMergeOverwrite (dict "name" "") (dict "name" "REDPANDA_ADMINAPI_TLS_CERTFILEPATH" "value" "/etc/console/secrets/redpanda-admin-api-tls-cert"))))) -}} +{{- $vars := $state.Values.extraEnv -}} {{- range $_, $possible := $possibleVars -}} {{- if (not (empty $possible.Value)) -}} {{- $vars = (concat (default (list) $vars) (list $possible.EnvVar)) -}} @@ -112,22 +108,21 @@ {{- end -}} {{- define "console.consolePodVolumes" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- $volumes := (list (mustMergeOverwrite (dict "name" "") (mustMergeOverwrite (dict) (dict "configMap" (mustMergeOverwrite (dict) (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) (dict)))) (dict "name" "configs"))) -}} -{{- if $values.secret.create -}} -{{- $volumes = (concat (default (list) $volumes) (list (mustMergeOverwrite (dict "name" "") (mustMergeOverwrite (dict) (dict "secret" (mustMergeOverwrite (dict) (dict "secretName" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))))) (dict "name" "secrets")))) -}} +{{- $volumes := (list (mustMergeOverwrite (dict "name" "") (mustMergeOverwrite (dict) (dict "configMap" (mustMergeOverwrite (dict) (mustMergeOverwrite (dict) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) (dict)))) (dict "name" "configs"))) -}} +{{- if $state.Values.secret.create -}} +{{- $volumes = (concat (default (list) $volumes) (list (mustMergeOverwrite (dict "name" "") (mustMergeOverwrite (dict) (dict "secret" (mustMergeOverwrite (dict) (dict "secretName" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))))) (dict "name" "secrets")))) -}} {{- end -}} -{{- range $_, $mount := $values.secretMounts -}} +{{- range $_, $mount := $state.Values.secretMounts -}} {{- $volumes = (concat (default (list) $volumes) (list (mustMergeOverwrite (dict "name" "") (mustMergeOverwrite (dict) (dict "secret" (mustMergeOverwrite (dict) (dict "secretName" $mount.secretName "defaultMode" $mount.defaultMode)))) (dict "name" $mount.name)))) -}} {{- end -}} {{- if $_is_returning -}} {{- break -}} {{- end -}} {{- $_is_returning = true -}} -{{- (dict "r" (concat (default (list) $volumes) (default (list) $values.extraVolumes))) | toJson -}} +{{- (dict "r" (concat (default (list) $volumes) (default (list) $state.Values.extraVolumes))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} diff --git a/charts/console/chart/templates/_console.helpers.tpl b/charts/console/chart/templates/_console.helpers.tpl deleted file mode 100644 index a7df3d287..000000000 --- a/charts/console/chart/templates/_console.helpers.tpl +++ /dev/null @@ -1,83 +0,0 @@ -{{- /* GENERATED FILE DO NOT EDIT */ -}} -{{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/helpers.go" */ -}} - -{{- define "console.Name" -}} -{{- $dot := (index .a 0) -}} -{{- range $_ := (list 1) -}} -{{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- $name := (default $dot.Chart.Name $values.nameOverride) -}} -{{- $_is_returning = true -}} -{{- (dict "r" (get (fromJson (include "console.cleanForK8s" (dict "a" (list $name)))) "r")) | toJson -}} -{{- break -}} -{{- end -}} -{{- end -}} - -{{- define "console.Fullname" -}} -{{- $dot := (index .a 0) -}} -{{- range $_ := (list 1) -}} -{{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- if (ne $values.fullnameOverride "") -}} -{{- $_is_returning = true -}} -{{- (dict "r" (get (fromJson (include "console.cleanForK8s" (dict "a" (list $values.fullnameOverride)))) "r")) | toJson -}} -{{- break -}} -{{- end -}} -{{- $name := (default $dot.Chart.Name $values.nameOverride) -}} -{{- if (contains $name $dot.Release.Name) -}} -{{- $_is_returning = true -}} -{{- (dict "r" (get (fromJson (include "console.cleanForK8s" (dict "a" (list $dot.Release.Name)))) "r")) | toJson -}} -{{- break -}} -{{- end -}} -{{- $_is_returning = true -}} -{{- (dict "r" (get (fromJson (include "console.cleanForK8s" (dict "a" (list (printf "%s-%s" $dot.Release.Name $name))))) "r")) | toJson -}} -{{- break -}} -{{- end -}} -{{- end -}} - -{{- define "console.ChartLabel" -}} -{{- $dot := (index .a 0) -}} -{{- range $_ := (list 1) -}} -{{- $_is_returning := false -}} -{{- $chart := (printf "%s-%s" $dot.Chart.Name $dot.Chart.Version) -}} -{{- $_is_returning = true -}} -{{- (dict "r" (get (fromJson (include "console.cleanForK8s" (dict "a" (list (replace "+" "_" $chart))))) "r")) | toJson -}} -{{- break -}} -{{- end -}} -{{- end -}} - -{{- define "console.Labels" -}} -{{- $dot := (index .a 0) -}} -{{- range $_ := (list 1) -}} -{{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- $labels := (dict "helm.sh/chart" (get (fromJson (include "console.ChartLabel" (dict "a" (list $dot)))) "r") "app.kubernetes.io/managed-by" $dot.Release.Service) -}} -{{- if (ne $dot.Chart.AppVersion "") -}} -{{- $_ := (set $labels "app.kubernetes.io/version" $dot.Chart.AppVersion) -}} -{{- end -}} -{{- $_is_returning = true -}} -{{- (dict "r" (merge (dict) $labels (get (fromJson (include "console.SelectorLabels" (dict "a" (list $dot)))) "r") $values.commonLabels)) | toJson -}} -{{- break -}} -{{- end -}} -{{- end -}} - -{{- define "console.SelectorLabels" -}} -{{- $dot := (index .a 0) -}} -{{- range $_ := (list 1) -}} -{{- $_is_returning := false -}} -{{- $_is_returning = true -}} -{{- (dict "r" (dict "app.kubernetes.io/name" (get (fromJson (include "console.Name" (dict "a" (list $dot)))) "r") "app.kubernetes.io/instance" $dot.Release.Name)) | toJson -}} -{{- break -}} -{{- end -}} -{{- end -}} - -{{- define "console.cleanForK8s" -}} -{{- $s := (index .a 0) -}} -{{- range $_ := (list 1) -}} -{{- $_is_returning := false -}} -{{- $_is_returning = true -}} -{{- (dict "r" (trimSuffix "-" (trunc (63 | int) $s))) | toJson -}} -{{- break -}} -{{- end -}} -{{- end -}} - diff --git a/charts/console/chart/templates/_console.hpa.tpl b/charts/console/chart/templates/_console.hpa.tpl index b6becfc91..d6c2a771b 100644 --- a/charts/console/chart/templates/_console.hpa.tpl +++ b/charts/console/chart/templates/_console.hpa.tpl @@ -2,24 +2,23 @@ {{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/hpa.go" */ -}} {{- define "console.HorizontalPodAutoscaler" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- if (not $values.autoscaling.enabled) -}} +{{- if (not $state.Values.autoscaling.enabled) -}} {{- $_is_returning = true -}} {{- (dict "r" (coalesce nil)) | toJson -}} {{- break -}} {{- end -}} {{- $metrics := (list) -}} -{{- if (ne (toJson $values.autoscaling.targetCPUUtilizationPercentage) "null") -}} -{{- $metrics = (concat (default (list) $metrics) (list (mustMergeOverwrite (dict "type" "") (dict "type" "Resource" "resource" (mustMergeOverwrite (dict "name" "" "target" (dict "type" "")) (dict "name" "cpu" "target" (mustMergeOverwrite (dict "type" "") (dict "type" "Utilization" "averageUtilization" $values.autoscaling.targetCPUUtilizationPercentage)))))))) -}} +{{- if (ne (toJson $state.Values.autoscaling.targetCPUUtilizationPercentage) "null") -}} +{{- $metrics = (concat (default (list) $metrics) (list (mustMergeOverwrite (dict "type" "") (dict "type" "Resource" "resource" (mustMergeOverwrite (dict "name" "" "target" (dict "type" "")) (dict "name" "cpu" "target" (mustMergeOverwrite (dict "type" "") (dict "type" "Utilization" "averageUtilization" $state.Values.autoscaling.targetCPUUtilizationPercentage)))))))) -}} {{- end -}} -{{- if (ne (toJson $values.autoscaling.targetMemoryUtilizationPercentage) "null") -}} -{{- $metrics = (concat (default (list) $metrics) (list (mustMergeOverwrite (dict "type" "") (dict "type" "Resource" "resource" (mustMergeOverwrite (dict "name" "" "target" (dict "type" "")) (dict "name" "memory" "target" (mustMergeOverwrite (dict "type" "") (dict "type" "Utilization" "averageUtilization" $values.autoscaling.targetMemoryUtilizationPercentage)))))))) -}} +{{- if (ne (toJson $state.Values.autoscaling.targetMemoryUtilizationPercentage) "null") -}} +{{- $metrics = (concat (default (list) $metrics) (list (mustMergeOverwrite (dict "type" "") (dict "type" "Resource" "resource" (mustMergeOverwrite (dict "name" "" "target" (dict "type" "")) (dict "name" "memory" "target" (mustMergeOverwrite (dict "type" "") (dict "type" "Utilization" "averageUtilization" $state.Values.autoscaling.targetMemoryUtilizationPercentage)))))))) -}} {{- end -}} {{- $_is_returning = true -}} -{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "scaleTargetRef" (dict "kind" "" "name" "") "maxReplicas" 0) "status" (dict "desiredReplicas" 0 "currentMetrics" (coalesce nil))) (mustMergeOverwrite (dict) (dict "apiVersion" "autoscaling/v2" "kind" "HorizontalPodAutoscaler")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "labels" (get (fromJson (include "console.Labels" (dict "a" (list $dot)))) "r") "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r") "namespace" $dot.Release.Namespace)) "spec" (mustMergeOverwrite (dict "scaleTargetRef" (dict "kind" "" "name" "") "maxReplicas" 0) (dict "scaleTargetRef" (mustMergeOverwrite (dict "kind" "" "name" "") (dict "apiVersion" "apps/v1" "kind" "Deployment" "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r"))) "minReplicas" ($values.autoscaling.minReplicas | int) "maxReplicas" ($values.autoscaling.maxReplicas | int) "metrics" $metrics))))) | toJson -}} +{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict "scaleTargetRef" (dict "kind" "" "name" "") "maxReplicas" 0) "status" (dict "desiredReplicas" 0 "currentMetrics" (coalesce nil))) (mustMergeOverwrite (dict) (dict "apiVersion" "autoscaling/v2" "kind" "HorizontalPodAutoscaler")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "labels" (get (fromJson (include "console.RenderState.Labels" (dict "a" (list $state (coalesce nil))))) "r") "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r") "namespace" $state.Namespace)) "spec" (mustMergeOverwrite (dict "scaleTargetRef" (dict "kind" "" "name" "") "maxReplicas" 0) (dict "scaleTargetRef" (mustMergeOverwrite (dict "kind" "" "name" "") (dict "apiVersion" "apps/v1" "kind" "Deployment" "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r"))) "minReplicas" ($state.Values.autoscaling.minReplicas | int) "maxReplicas" ($state.Values.autoscaling.maxReplicas | int) "metrics" $metrics))))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} diff --git a/charts/console/chart/templates/_console.ingress.tpl b/charts/console/chart/templates/_console.ingress.tpl index b241e9491..15b63757b 100644 --- a/charts/console/chart/templates/_console.ingress.tpl +++ b/charts/console/chart/templates/_console.ingress.tpl @@ -2,20 +2,19 @@ {{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/ingress.go" */ -}} {{- define "console.Ingress" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- if (not $values.ingress.enabled) -}} +{{- if (not $state.Values.ingress.enabled) -}} {{- $_is_returning = true -}} {{- (dict "r" (coalesce nil)) | toJson -}} {{- break -}} {{- end -}} {{- $tls := (coalesce nil) -}} -{{- range $_, $t := $values.ingress.tls -}} +{{- range $_, $t := $state.Values.ingress.tls -}} {{- $hosts := (coalesce nil) -}} {{- range $_, $host := $t.hosts -}} -{{- $hosts = (concat (default (list) $hosts) (list (tpl $host $dot))) -}} +{{- $hosts = (concat (default (list) $hosts) (list (get (fromJson (include (first $state.Template) (dict "a" (concat (rest $state.Template) (list $host))))) "r"))) -}} {{- end -}} {{- if $_is_returning -}} {{- break -}} @@ -26,21 +25,21 @@ {{- break -}} {{- end -}} {{- $rules := (coalesce nil) -}} -{{- range $_, $host := $values.ingress.hosts -}} +{{- range $_, $host := $state.Values.ingress.hosts -}} {{- $paths := (coalesce nil) -}} {{- range $_, $path := $host.paths -}} -{{- $paths = (concat (default (list) $paths) (list (mustMergeOverwrite (dict "pathType" (coalesce nil) "backend" (dict)) (dict "path" $path.path "pathType" $path.pathType "backend" (mustMergeOverwrite (dict) (dict "service" (mustMergeOverwrite (dict "name" "" "port" (dict)) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r") "port" (mustMergeOverwrite (dict) (dict "number" ($values.service.port | int))))))))))) -}} +{{- $paths = (concat (default (list) $paths) (list (mustMergeOverwrite (dict "pathType" (coalesce nil) "backend" (dict)) (dict "path" $path.path "pathType" $path.pathType "backend" (mustMergeOverwrite (dict) (dict "service" (mustMergeOverwrite (dict "name" "" "port" (dict)) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r") "port" (mustMergeOverwrite (dict) (dict "number" ($state.Values.service.port | int))))))))))) -}} {{- end -}} {{- if $_is_returning -}} {{- break -}} {{- end -}} -{{- $rules = (concat (default (list) $rules) (list (mustMergeOverwrite (dict) (mustMergeOverwrite (dict) (dict "http" (mustMergeOverwrite (dict "paths" (coalesce nil)) (dict "paths" $paths)))) (dict "host" (tpl $host.host $dot))))) -}} +{{- $rules = (concat (default (list) $rules) (list (mustMergeOverwrite (dict) (mustMergeOverwrite (dict) (dict "http" (mustMergeOverwrite (dict "paths" (coalesce nil)) (dict "paths" $paths)))) (dict "host" (get (fromJson (include (first $state.Template) (dict "a" (concat (rest $state.Template) (list $host.host))))) "r"))))) -}} {{- end -}} {{- if $_is_returning -}} {{- break -}} {{- end -}} {{- $_is_returning = true -}} -{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict) "status" (dict "loadBalancer" (dict))) (mustMergeOverwrite (dict) (dict "kind" "Ingress" "apiVersion" "networking.k8s.io/v1")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r") "labels" (get (fromJson (include "console.Labels" (dict "a" (list $dot)))) "r") "namespace" $dot.Release.Namespace "annotations" $values.ingress.annotations)) "spec" (mustMergeOverwrite (dict) (dict "ingressClassName" $values.ingress.className "tls" $tls "rules" $rules))))) | toJson -}} +{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict) "status" (dict "loadBalancer" (dict))) (mustMergeOverwrite (dict) (dict "kind" "Ingress" "apiVersion" "networking.k8s.io/v1")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r") "labels" (get (fromJson (include "console.RenderState.Labels" (dict "a" (list $state (coalesce nil))))) "r") "namespace" $state.Namespace "annotations" $state.Values.ingress.annotations)) "spec" (mustMergeOverwrite (dict) (dict "ingressClassName" $state.Values.ingress.className "tls" $tls "rules" $rules))))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} diff --git a/charts/console/chart/templates/_console.render.tpl b/charts/console/chart/templates/_console.render.tpl new file mode 100644 index 000000000..4c0077969 --- /dev/null +++ b/charts/console/chart/templates/_console.render.tpl @@ -0,0 +1,99 @@ +{{- /* GENERATED FILE DO NOT EDIT */ -}} +{{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/render.go" */ -}} + +{{- define "console.RenderState.ChartName" -}} +{{- $s := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $name := "console" -}} +{{- if (ne $s.Values.nameOverride "") -}} +{{- $name = $s.Values.nameOverride -}} +{{- end -}} +{{- $_is_returning = true -}} +{{- (dict "r" (get (fromJson (include "console.cleanForK8s" (dict "a" (list $name)))) "r")) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "console.RenderState.FullName" -}} +{{- $s := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- if (ne $s.Values.fullnameOverride "") -}} +{{- $_is_returning = true -}} +{{- (dict "r" (get (fromJson (include "console.cleanForK8s" (dict "a" (list $s.Values.fullnameOverride)))) "r")) | toJson -}} +{{- break -}} +{{- end -}} +{{- $name := (get (fromJson (include "console.RenderState.ChartName" (dict "a" (list $s)))) "r") -}} +{{- if (not (contains $s.ReleaseName $name)) -}} +{{- $name = (printf "%s-%s" $s.ReleaseName $name) -}} +{{- end -}} +{{- $_is_returning = true -}} +{{- (dict "r" (get (fromJson (include "console.cleanForK8s" (dict "a" (list $name)))) "r")) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "console.RenderState.SelectorLabels" -}} +{{- $s := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $_is_returning = true -}} +{{- (dict "r" (dict "app.kubernetes.io/name" (get (fromJson (include "console.RenderState.ChartName" (dict "a" (list $s)))) "r") "app.kubernetes.io/instance" $s.ReleaseName)) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "console.RenderState.Labels" -}} +{{- $s := (index .a 0) -}} +{{- $labels := (index .a 1) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- if (eq (toJson $labels) "null") -}} +{{- $labels = (dict) -}} +{{- end -}} +{{- range $key, $value := (get (fromJson (include "console.RenderState.SelectorLabels" (dict "a" (list $s)))) "r") -}} +{{- $_ := (set $labels $key $value) -}} +{{- end -}} +{{- if $_is_returning -}} +{{- break -}} +{{- end -}} +{{- range $key, $value := $s.CommonLabels -}} +{{- $_ := (set $labels $key $value) -}} +{{- end -}} +{{- if $_is_returning -}} +{{- break -}} +{{- end -}} +{{- range $key, $value := $s.Values.commonLabels -}} +{{- $_ := (set $labels $key $value) -}} +{{- end -}} +{{- if $_is_returning -}} +{{- break -}} +{{- end -}} +{{- $_is_returning = true -}} +{{- (dict "r" $labels) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "console.Render" -}} +{{- $state := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $manifests := (list (get (fromJson (include "console.ServiceAccount" (dict "a" (list $state)))) "r") (get (fromJson (include "console.Secret" (dict "a" (list $state)))) "r") (get (fromJson (include "console.ConfigMap" (dict "a" (list $state)))) "r") (get (fromJson (include "console.Service" (dict "a" (list $state)))) "r") (get (fromJson (include "console.Ingress" (dict "a" (list $state)))) "r") (get (fromJson (include "console.Deployment" (dict "a" (list $state)))) "r") (get (fromJson (include "console.HorizontalPodAutoscaler" (dict "a" (list $state)))) "r")) -}} +{{- $_is_returning = true -}} +{{- (dict "r" $manifests) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + +{{- define "console.cleanForK8s" -}} +{{- $s := (index .a 0) -}} +{{- range $_ := (list 1) -}} +{{- $_is_returning := false -}} +{{- $_is_returning = true -}} +{{- (dict "r" (trimSuffix "-" (trunc (63 | int) $s))) | toJson -}} +{{- break -}} +{{- end -}} +{{- end -}} + diff --git a/charts/console/chart/templates/_console.secret.tpl b/charts/console/chart/templates/_console.secret.tpl index dfb6f5c20..fa387f159 100644 --- a/charts/console/chart/templates/_console.secret.tpl +++ b/charts/console/chart/templates/_console.secret.tpl @@ -2,21 +2,20 @@ {{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/secret.go" */ -}} {{- define "console.Secret" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- if (not $values.secret.create) -}} +{{- if (not $state.Values.secret.create) -}} {{- $_is_returning = true -}} {{- (dict "r" (coalesce nil)) | toJson -}} {{- break -}} {{- end -}} -{{- $jwtSigningKey := $values.secret.authentication.jwtSigningKey -}} +{{- $jwtSigningKey := $state.Values.secret.authentication.jwtSigningKey -}} {{- if (eq $jwtSigningKey "") -}} {{- $jwtSigningKey = (randAlphaNum (32 | int)) -}} {{- end -}} {{- $_is_returning = true -}} -{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil))) (mustMergeOverwrite (dict) (dict "apiVersion" "v1" "kind" "Secret")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r") "labels" (get (fromJson (include "console.Labels" (dict "a" (list $dot)))) "r") "namespace" $dot.Release.Namespace)) "type" "Opaque" "stringData" (dict "kafka-sasl-password" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.kafka.saslPassword "")))) "r") "kafka-sasl-aws-msk-iam-secret-key" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.kafka.awsMskIamSecretKey "")))) "r") "kafka-tls-ca" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.kafka.tlsCa "")))) "r") "kafka-tls-cert" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.kafka.tlsCert "")))) "r") "kafka-tls-key" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.kafka.tlsKey "")))) "r") "schema-registry-bearertoken" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.schemaRegistry.bearerToken "")))) "r") "schema-registry-password" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.schemaRegistry.password "")))) "r") "schemaregistry-tls-ca" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.schemaRegistry.tlsCa "")))) "r") "schemaregistry-tls-cert" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.schemaRegistry.tlsCert "")))) "r") "schemaregistry-tls-key" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.schemaRegistry.tlsKey "")))) "r") "authentication-jwt-signingkey" $jwtSigningKey "authentication-oidc-client-secret" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.authentication.oidc.clientSecret "")))) "r") "license" $values.secret.license "redpanda-admin-api-password" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.redpanda.adminApi.password "")))) "r") "redpanda-admin-api-tls-ca" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.redpanda.adminApi.tlsCa "")))) "r") "redpanda-admin-api-tls-cert" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.redpanda.adminApi.tlsCert "")))) "r") "redpanda-admin-api-tls-key" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.redpanda.adminApi.tlsKey "")))) "r") "serde-protobuf-git-basicauth-password" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $values.secret.serde.protobufGitBasicAuthPassword "")))) "r"))))) | toJson -}} +{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil))) (mustMergeOverwrite (dict) (dict "apiVersion" "v1" "kind" "Secret")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r") "labels" (get (fromJson (include "console.RenderState.Labels" (dict "a" (list $state (coalesce nil))))) "r") "namespace" $state.Namespace)) "type" "Opaque" "stringData" (dict "kafka-sasl-password" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.kafka.saslPassword "")))) "r") "kafka-sasl-aws-msk-iam-secret-key" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.kafka.awsMskIamSecretKey "")))) "r") "kafka-tls-ca" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.kafka.tlsCa "")))) "r") "kafka-tls-cert" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.kafka.tlsCert "")))) "r") "kafka-tls-key" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.kafka.tlsKey "")))) "r") "schema-registry-bearertoken" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.schemaRegistry.bearerToken "")))) "r") "schema-registry-password" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.schemaRegistry.password "")))) "r") "schemaregistry-tls-ca" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.schemaRegistry.tlsCa "")))) "r") "schemaregistry-tls-cert" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.schemaRegistry.tlsCert "")))) "r") "schemaregistry-tls-key" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.schemaRegistry.tlsKey "")))) "r") "authentication-jwt-signingkey" $jwtSigningKey "authentication-oidc-client-secret" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.authentication.oidc.clientSecret "")))) "r") "license" $state.Values.secret.license "redpanda-admin-api-password" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.redpanda.adminApi.password "")))) "r") "redpanda-admin-api-tls-ca" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.redpanda.adminApi.tlsCa "")))) "r") "redpanda-admin-api-tls-cert" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.redpanda.adminApi.tlsCert "")))) "r") "redpanda-admin-api-tls-key" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.redpanda.adminApi.tlsKey "")))) "r") "serde-protobuf-git-basicauth-password" (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.secret.serde.protobufGitBasicAuthPassword "")))) "r"))))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} diff --git a/charts/console/chart/templates/_console.service.tpl b/charts/console/chart/templates/_console.service.tpl index 9efb66e46..2131821ce 100644 --- a/charts/console/chart/templates/_console.service.tpl +++ b/charts/console/chart/templates/_console.service.tpl @@ -2,19 +2,18 @@ {{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/service.go" */ -}} {{- define "console.Service" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- $port := (mustMergeOverwrite (dict "port" 0 "targetPort" 0) (dict "name" "http" "port" (($values.service.port | int) | int) "protocol" "TCP")) -}} -{{- if (ne (toJson $values.service.targetPort) "null") -}} -{{- $_ := (set $port "targetPort" $values.service.targetPort) -}} +{{- $port := (mustMergeOverwrite (dict "port" 0 "targetPort" 0) (dict "name" "http" "port" (($state.Values.service.port | int) | int) "protocol" "TCP")) -}} +{{- if (ne (toJson $state.Values.service.targetPort) "null") -}} +{{- $_ := (set $port "targetPort" $state.Values.service.targetPort) -}} {{- end -}} -{{- if (and (contains "NodePort" (toString $values.service.type)) (ne (toJson $values.service.nodePort) "null")) -}} -{{- $_ := (set $port "nodePort" $values.service.nodePort) -}} +{{- if (and (contains "NodePort" (toString $state.Values.service.type)) (ne (toJson $state.Values.service.nodePort) "null")) -}} +{{- $_ := (set $port "nodePort" $state.Values.service.nodePort) -}} {{- end -}} {{- $_is_returning = true -}} -{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict) "status" (dict "loadBalancer" (dict))) (mustMergeOverwrite (dict) (dict "apiVersion" "v1" "kind" "Service")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r") "namespace" $dot.Release.Namespace "labels" (get (fromJson (include "console.Labels" (dict "a" (list $dot)))) "r") "annotations" $values.service.annotations)) "spec" (mustMergeOverwrite (dict) (dict "type" $values.service.type "selector" (get (fromJson (include "console.SelectorLabels" (dict "a" (list $dot)))) "r") "ports" (list $port)))))) | toJson -}} +{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil)) "spec" (dict) "status" (dict "loadBalancer" (dict))) (mustMergeOverwrite (dict) (dict "apiVersion" "v1" "kind" "Service")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r") "namespace" $state.Namespace "labels" (get (fromJson (include "console.RenderState.Labels" (dict "a" (list $state (coalesce nil))))) "r") "annotations" $state.Values.service.annotations)) "spec" (mustMergeOverwrite (dict) (dict "type" $state.Values.service.type "selector" (get (fromJson (include "console.RenderState.SelectorLabels" (dict "a" (list $state)))) "r") "ports" (list $port)))))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} diff --git a/charts/console/chart/templates/_console.serviceaccount.tpl b/charts/console/chart/templates/_console.serviceaccount.tpl index 304d1ee3e..2dea7bd29 100644 --- a/charts/console/chart/templates/_console.serviceaccount.tpl +++ b/charts/console/chart/templates/_console.serviceaccount.tpl @@ -2,38 +2,36 @@ {{- /* Transpiled by gotohelm from "github.com/redpanda-data/redpanda-operator/charts/console/v3/serviceaccount.go" */ -}} {{- define "console.ServiceAccountName" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- if $values.serviceAccount.create -}} -{{- if (ne $values.serviceAccount.name "") -}} +{{- if $state.Values.serviceAccount.create -}} +{{- if (ne $state.Values.serviceAccount.name "") -}} {{- $_is_returning = true -}} -{{- (dict "r" $values.serviceAccount.name) | toJson -}} +{{- (dict "r" $state.Values.serviceAccount.name) | toJson -}} {{- break -}} {{- end -}} {{- $_is_returning = true -}} -{{- (dict "r" (get (fromJson (include "console.Fullname" (dict "a" (list $dot)))) "r")) | toJson -}} +{{- (dict "r" (get (fromJson (include "console.RenderState.FullName" (dict "a" (list $state)))) "r")) | toJson -}} {{- break -}} {{- end -}} {{- $_is_returning = true -}} -{{- (dict "r" (default "default" $values.serviceAccount.name)) | toJson -}} +{{- (dict "r" (default "default" $state.Values.serviceAccount.name)) | toJson -}} {{- break -}} {{- end -}} {{- end -}} {{- define "console.ServiceAccount" -}} -{{- $dot := (index .a 0) -}} +{{- $state := (index .a 0) -}} {{- range $_ := (list 1) -}} {{- $_is_returning := false -}} -{{- $values := $dot.Values.AsMap -}} -{{- if (not $values.serviceAccount.create) -}} +{{- if (not $state.Values.serviceAccount.create) -}} {{- $_is_returning = true -}} {{- (dict "r" (coalesce nil)) | toJson -}} {{- break -}} {{- end -}} {{- $_is_returning = true -}} -{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil))) (mustMergeOverwrite (dict) (dict "kind" "ServiceAccount" "apiVersion" "v1")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.ServiceAccountName" (dict "a" (list $dot)))) "r") "labels" (get (fromJson (include "console.Labels" (dict "a" (list $dot)))) "r") "namespace" $dot.Release.Namespace "annotations" $values.serviceAccount.annotations)) "automountServiceAccountToken" $values.serviceAccount.automountServiceAccountToken))) | toJson -}} +{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil))) (mustMergeOverwrite (dict) (dict "kind" "ServiceAccount" "apiVersion" "v1")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" (get (fromJson (include "console.ServiceAccountName" (dict "a" (list $state)))) "r") "labels" (get (fromJson (include "console.RenderState.Labels" (dict "a" (list $state (coalesce nil))))) "r") "namespace" $state.Namespace "annotations" $state.Values.serviceAccount.annotations)) "automountServiceAccountToken" $state.Values.serviceAccount.automountServiceAccountToken))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} diff --git a/charts/console/chart/templates/entry-point.yaml b/charts/console/chart/templates/entry-point.yaml index 925a960f0..16e646361 100644 --- a/charts/console/chart/templates/entry-point.yaml +++ b/charts/console/chart/templates/entry-point.yaml @@ -14,4 +14,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */}} -{{- include "_shims.render-manifest" (list "chart.render" .) -}} +{{- include "_shims.render-manifest" (list "chart.Render" .) -}} diff --git a/charts/console/chart/values.go b/charts/console/chart/values.go new file mode 100644 index 000000000..23e9eaba7 --- /dev/null +++ b/charts/console/chart/values.go @@ -0,0 +1,30 @@ +// Copyright 2025 Redpanda Data, Inc. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.md +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0 + +// +gotohelm:ignore=true +package chart + +import ( + "github.com/redpanda-data/redpanda-operator/charts/console/v3" +) + +type Values struct { + console.RenderValues `json:",inline"` + + Globals map[string]any `json:"global,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + CommonLabels map[string]string `json:"commonLabels"` + NameOverride string `json:"nameOverride"` + FullnameOverride string `json:"fullnameOverride"` + Tests Enableable `json:"tests"` +} + +type Enableable struct { + Enabled bool `json:"enabled"` +} diff --git a/charts/console/chart/values_partial.gen.go b/charts/console/chart/values_partial.gen.go index 61652efe0..1be79f6a1 100644 --- a/charts/console/chart/values_partial.gen.go +++ b/charts/console/chart/values_partial.gen.go @@ -18,9 +18,13 @@ import ( ) type PartialValues struct { - console.PartialValues "json:\",inline,omitempty\"" - Enabled *bool "json:\"enabled,omitempty\"" - Tests *PartialEnableable "json:\"tests,omitempty\"" + console.PartialRenderValues "json:\",inline,omitempty\"" + Globals map[string]any "json:\"global,omitempty\"" + Enabled *bool "json:\"enabled,omitempty\"" + CommonLabels map[string]string "json:\"commonLabels,omitempty\"" + NameOverride *string "json:\"nameOverride,omitempty\"" + FullnameOverride *string "json:\"fullnameOverride,omitempty\"" + Tests *PartialEnableable "json:\"tests,omitempty\"" } type PartialEnableable struct { diff --git a/charts/console/configmap.go b/charts/console/configmap.go index 6e46b9b30..cebf93dae 100644 --- a/charts/console/configmap.go +++ b/charts/console/configmap.go @@ -18,15 +18,13 @@ import ( "github.com/redpanda-data/redpanda-operator/gotohelm/helmette" ) -func ConfigMap(dot *helmette.Dot) *corev1.ConfigMap { - values := helmette.Unwrap[Values](dot.Values) - - if !values.ConfigMap.Create { +func ConfigMap(state *RenderState) *corev1.ConfigMap { + if !state.Values.ConfigMap.Create { return nil } data := map[string]string{ - "config.yaml": fmt.Sprintf("# from .Values.config\n%s\n", helmette.Tpl(dot, helmette.ToYaml(values.Config), dot)), + "config.yaml": fmt.Sprintf("# from .Values.config\n%s\n", state.Template(helmette.ToYaml(state.Values.Config))), } return &corev1.ConfigMap{ @@ -35,9 +33,9 @@ func ConfigMap(dot *helmette.Dot) *corev1.ConfigMap { Kind: "ConfigMap", }, ObjectMeta: metav1.ObjectMeta{ - Labels: Labels(dot), - Name: Fullname(dot), - Namespace: dot.Release.Namespace, + Labels: state.Labels(nil), + Name: state.FullName(), + Namespace: state.Namespace, }, Data: data, } diff --git a/charts/console/deployment.go b/charts/console/deployment.go index a78ea465a..58b28b4e8 100644 --- a/charts/console/deployment.go +++ b/charts/console/deployment.go @@ -24,15 +24,13 @@ import ( // Console's HTTP server Port. // The port is defined from the provided config but can be overridden // by setting service.targetPort and if that is missing defaults to 8080. -func ContainerPort(dot *helmette.Dot) int32 { - values := helmette.Unwrap[Values](dot.Values) - +func ContainerPort(state *RenderState) int32 { listenPort := int32(8080) - if values.Service.TargetPort != nil { - listenPort = *values.Service.TargetPort + if state.Values.Service.TargetPort != nil { + listenPort = *state.Values.Service.TargetPort } - configListenPort := helmette.Dig(values.Config, nil, "server", "listenPort") + configListenPort := helmette.Dig(state.Values.Config, nil, "server", "listenPort") if asInt, ok := helmette.AsIntegral[int](configListenPort); ok { return int32(asInt) } @@ -40,21 +38,19 @@ func ContainerPort(dot *helmette.Dot) int32 { return listenPort } -func Deployment(dot *helmette.Dot) *appsv1.Deployment { - values := helmette.Unwrap[Values](dot.Values) - - if !values.Deployment.Create { +func Deployment(state *RenderState) *appsv1.Deployment { + if !state.Values.Deployment.Create { return nil } var replicas *int32 - if !values.Autoscaling.Enabled { - replicas = ptr.To(values.ReplicaCount) + if !state.Values.Autoscaling.Enabled { + replicas = ptr.To(state.Values.ReplicaCount) } var initContainers []corev1.Container - if !helmette.Empty(values.InitContainers.ExtraInitContainers) { - initContainers = helmette.UnmarshalYamlArray[corev1.Container](helmette.Tpl(dot, *values.InitContainers.ExtraInitContainers, dot)) + if !helmette.Empty(state.Values.InitContainers.ExtraInitContainers) { + initContainers = helmette.UnmarshalYamlArray[corev1.Container](state.Template(*state.Values.InitContainers.ExtraInitContainers)) } volumeMounts := []corev1.VolumeMount{ @@ -65,7 +61,7 @@ func Deployment(dot *helmette.Dot) *appsv1.Deployment { }, } - if values.Secret.Create { + if state.Values.Secret.Create { volumeMounts = append(volumeMounts, corev1.VolumeMount{ Name: "secrets", MountPath: "/etc/console/secrets", @@ -73,7 +69,7 @@ func Deployment(dot *helmette.Dot) *appsv1.Deployment { }) } - for _, mount := range values.SecretMounts { + for _, mount := range state.Values.SecretMounts { volumeMounts = append(volumeMounts, corev1.VolumeMount{ Name: mount.Name, MountPath: mount.Path, @@ -81,7 +77,7 @@ func Deployment(dot *helmette.Dot) *appsv1.Deployment { }) } - volumeMounts = append(volumeMounts, values.ExtraVolumeMounts...) + volumeMounts = append(volumeMounts, state.Values.ExtraVolumeMounts...) return &appsv1.Deployment{ TypeMeta: metav1.TypeMeta{ @@ -89,60 +85,60 @@ func Deployment(dot *helmette.Dot) *appsv1.Deployment { Kind: "Deployment", }, ObjectMeta: metav1.ObjectMeta{ - Name: Fullname(dot), - Labels: Labels(dot), - Namespace: dot.Release.Namespace, - Annotations: values.Annotations, + Name: state.FullName(), + Labels: state.Labels(nil), + Namespace: state.Namespace, + Annotations: state.Values.Annotations, }, Spec: appsv1.DeploymentSpec{ Replicas: replicas, Selector: &metav1.LabelSelector{ - MatchLabels: SelectorLabels(dot), + MatchLabels: state.SelectorLabels(), }, - Strategy: values.Strategy, + Strategy: state.Values.Strategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Annotations: helmette.Merge(map[string]string{ - "checksum/config": helmette.Sha256Sum(helmette.ToYaml(ConfigMap(dot).Data)), - }, values.PodAnnotations), - Labels: helmette.Merge(SelectorLabels(dot), values.PodLabels), + "checksum/config": helmette.Sha256Sum(helmette.ToYaml(ConfigMap(state).Data)), + }, state.Values.PodAnnotations), + Labels: helmette.Merge(state.SelectorLabels(), state.Values.PodLabels), }, Spec: corev1.PodSpec{ - ImagePullSecrets: values.ImagePullSecrets, - ServiceAccountName: ServiceAccountName(dot), - AutomountServiceAccountToken: &values.AutomountServiceAccountToken, - SecurityContext: &values.PodSecurityContext, - NodeSelector: values.NodeSelector, - Affinity: &values.Affinity, - TopologySpreadConstraints: values.TopologySpreadConstraints, - PriorityClassName: values.PriorityClassName, - Tolerations: values.Tolerations, - Volumes: consolePodVolumes(dot), + ImagePullSecrets: state.Values.ImagePullSecrets, + ServiceAccountName: ServiceAccountName(state), + AutomountServiceAccountToken: &state.Values.AutomountServiceAccountToken, + SecurityContext: &state.Values.PodSecurityContext, + NodeSelector: state.Values.NodeSelector, + Affinity: &state.Values.Affinity, + TopologySpreadConstraints: state.Values.TopologySpreadConstraints, + PriorityClassName: state.Values.PriorityClassName, + Tolerations: state.Values.Tolerations, + Volumes: consolePodVolumes(state), InitContainers: initContainers, Containers: append([]corev1.Container{ { - Name: dot.Chart.Name, - Command: values.Deployment.Command, + Name: ConsoleContainerName, + Command: state.Values.Deployment.Command, Args: append([]string{ "--config.filepath=/etc/console/configs/config.yaml", - }, values.Deployment.ExtraArgs...), - SecurityContext: &values.SecurityContext, - Image: containerImage(dot), - ImagePullPolicy: values.Image.PullPolicy, + }, state.Values.Deployment.ExtraArgs...), + SecurityContext: &state.Values.SecurityContext, + Image: containerImage(state), + ImagePullPolicy: state.Values.Image.PullPolicy, Ports: []corev1.ContainerPort{ { Name: "http", - ContainerPort: ContainerPort(dot), + ContainerPort: ContainerPort(state), Protocol: corev1.ProtocolTCP, }, }, VolumeMounts: volumeMounts, LivenessProbe: &corev1.Probe{ - InitialDelaySeconds: values.LivenessProbe.InitialDelaySeconds, // TODO what to do with this?? - PeriodSeconds: values.LivenessProbe.PeriodSeconds, - TimeoutSeconds: values.LivenessProbe.TimeoutSeconds, - SuccessThreshold: values.LivenessProbe.SuccessThreshold, - FailureThreshold: values.LivenessProbe.FailureThreshold, + InitialDelaySeconds: state.Values.LivenessProbe.InitialDelaySeconds, // TODO what to do with this?? + PeriodSeconds: state.Values.LivenessProbe.PeriodSeconds, + TimeoutSeconds: state.Values.LivenessProbe.TimeoutSeconds, + SuccessThreshold: state.Values.LivenessProbe.SuccessThreshold, + FailureThreshold: state.Values.LivenessProbe.FailureThreshold, ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ Path: "/admin/health", @@ -151,11 +147,11 @@ func Deployment(dot *helmette.Dot) *appsv1.Deployment { }, }, ReadinessProbe: &corev1.Probe{ - InitialDelaySeconds: values.ReadinessProbe.InitialDelaySeconds, - PeriodSeconds: values.ReadinessProbe.PeriodSeconds, - TimeoutSeconds: values.ReadinessProbe.TimeoutSeconds, - SuccessThreshold: values.ReadinessProbe.SuccessThreshold, - FailureThreshold: values.ReadinessProbe.FailureThreshold, + InitialDelaySeconds: state.Values.ReadinessProbe.InitialDelaySeconds, + PeriodSeconds: state.Values.ReadinessProbe.PeriodSeconds, + TimeoutSeconds: state.Values.ReadinessProbe.TimeoutSeconds, + SuccessThreshold: state.Values.ReadinessProbe.SuccessThreshold, + FailureThreshold: state.Values.ReadinessProbe.FailureThreshold, ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ Path: "/admin/health", @@ -163,11 +159,11 @@ func Deployment(dot *helmette.Dot) *appsv1.Deployment { }, }, }, - Resources: values.Resources, - Env: consoleContainerEnv(dot), - EnvFrom: values.ExtraEnvFrom, + Resources: state.Values.Resources, + Env: consoleContainerEnv(state), + EnvFrom: state.Values.ExtraEnvFrom, }, - }, values.ExtraContainers...), + }, state.Values.ExtraContainers...), }, }, }, @@ -175,18 +171,17 @@ func Deployment(dot *helmette.Dot) *appsv1.Deployment { } // ConsoleImage -func containerImage(dot *helmette.Dot) string { - values := helmette.Unwrap[Values](dot.Values) - - tag := dot.Chart.AppVersion - if !helmette.Empty(values.Image.Tag) { - tag = *values.Image.Tag +func containerImage(state *RenderState) string { + // Use a default if tag is not set + tag := state.Values.Image.Tag + if tag == "" { + tag = AppVersion } - image := fmt.Sprintf("%s:%s", values.Image.Repository, tag) + image := fmt.Sprintf("%s:%s", state.Values.Image.Repository, tag) - if !helmette.Empty(values.Image.Registry) { - return fmt.Sprintf("%s/%s", values.Image.Registry, image) + if !helmette.Empty(state.Values.Image.Registry) { + return fmt.Sprintf("%s/%s", state.Values.Image.Registry, image) } return image @@ -197,21 +192,19 @@ type PossibleEnvVar struct { EnvVar corev1.EnvVar } -func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { - values := helmette.Unwrap[Values](dot.Values) +func consoleContainerEnv(state *RenderState) []corev1.EnvVar { + if !state.Values.Secret.Create { + vars := state.Values.ExtraEnv - if !values.Secret.Create { - vars := values.ExtraEnv - - if values.LicenseSecretRef != nil && !helmette.Empty(values.LicenseSecretRef.Name) { - vars = append(values.ExtraEnv, corev1.EnvVar{ + if state.Values.LicenseSecretRef != nil && !helmette.Empty(state.Values.LicenseSecretRef.Name) { + vars = append(state.Values.ExtraEnv, corev1.EnvVar{ Name: "LICENSE", ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ - Name: values.LicenseSecretRef.Name, + Name: state.Values.LicenseSecretRef.Name, }, - Key: helmette.Default("enterprise-license", values.LicenseSecretRef.Key), + Key: helmette.Default("enterprise-license", state.Values.LicenseSecretRef.Key), }, }, }) @@ -222,13 +215,13 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { possibleVars := []PossibleEnvVar{ { - Value: values.Secret.Kafka.SASLPassword, + Value: state.Values.Secret.Kafka.SASLPassword, EnvVar: corev1.EnvVar{ Name: "KAFKA_SASL_PASSWORD", ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ - Name: Fullname(dot), + Name: state.FullName(), }, Key: "kafka-sasl-password", }, @@ -236,13 +229,13 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { }, }, { - Value: values.Secret.Serde.ProtobufGitBasicAuthPassword, + Value: state.Values.Secret.Serde.ProtobufGitBasicAuthPassword, EnvVar: corev1.EnvVar{ Name: "SERDE_PROTOBUF_GIT_BASICAUTH_PASSWORD", ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ - Name: Fullname(dot), + Name: state.FullName(), }, Key: "serde-protobuf-git-basicauth-password", }, @@ -250,13 +243,13 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { }, }, { - Value: values.Secret.Kafka.AWSMSKIAMSecretKey, + Value: state.Values.Secret.Kafka.AWSMSKIAMSecretKey, EnvVar: corev1.EnvVar{ Name: "KAFKA_SASL_AWSMSKIAM_SECRETKEY", ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ - Name: Fullname(dot), + Name: state.FullName(), }, Key: "kafka-sasl-aws-msk-iam-secret-key", }, @@ -264,55 +257,55 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { }, }, { - Value: values.Secret.Kafka.TLSCA, + Value: state.Values.Secret.Kafka.TLSCA, EnvVar: corev1.EnvVar{ Name: "KAFKA_TLS_CAFILEPATH", Value: "/etc/console/secrets/kafka-tls-ca", }, }, { - Value: values.Secret.Kafka.TLSCert, + Value: state.Values.Secret.Kafka.TLSCert, EnvVar: corev1.EnvVar{ Name: "KAFKA_TLS_CERTFILEPATH", Value: "/etc/console/secrets/kafka-tls-cert", }, }, { - Value: values.Secret.Kafka.TLSKey, + Value: state.Values.Secret.Kafka.TLSKey, EnvVar: corev1.EnvVar{ Name: "KAFKA_TLS_KEYFILEPATH", Value: "/etc/console/secrets/kafka-tls-key", }, }, { - Value: values.Secret.SchemaRegistry.TLSCA, + Value: state.Values.Secret.SchemaRegistry.TLSCA, EnvVar: corev1.EnvVar{ Name: "SCHEMAREGISTRY_TLS_CAFILEPATH", Value: "/etc/console/secrets/schemaregistry-tls-ca", }, }, { - Value: values.Secret.SchemaRegistry.TLSCert, + Value: state.Values.Secret.SchemaRegistry.TLSCert, EnvVar: corev1.EnvVar{ Name: "SCHEMAREGISTRY_TLS_CERTFILEPATH", Value: "/etc/console/secrets/schemaregistry-tls-cert", }, }, { - Value: values.Secret.SchemaRegistry.TLSKey, + Value: state.Values.Secret.SchemaRegistry.TLSKey, EnvVar: corev1.EnvVar{ Name: "SCHEMAREGISTRY_TLS_KEYFILEPATH", Value: "/etc/console/secrets/schemaregistry-tls-key", }, }, { - Value: values.Secret.SchemaRegistry.Password, + Value: state.Values.Secret.SchemaRegistry.Password, EnvVar: corev1.EnvVar{ Name: "SCHEMAREGISTRY_AUTHENTICATION_BASIC_PASSWORD", ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ - Name: Fullname(dot), + Name: state.FullName(), }, Key: "schema-registry-password", }, @@ -320,13 +313,13 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { }, }, { - Value: values.Secret.SchemaRegistry.BearerToken, + Value: state.Values.Secret.SchemaRegistry.BearerToken, EnvVar: corev1.EnvVar{ Name: "SCHEMAREGISTRY_AUTHENTICATION_BEARERTOKEN", ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ - Name: Fullname(dot), + Name: state.FullName(), }, Key: "schema-registry-bearertoken", }, @@ -334,13 +327,13 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { }, }, { - Value: values.Secret.Authentication.JWTSigningKey, + Value: state.Values.Secret.Authentication.JWTSigningKey, EnvVar: corev1.EnvVar{ Name: "AUTHENTICATION_JWTSIGNINGKEY", ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ - Name: Fullname(dot), + Name: state.FullName(), }, Key: "authentication-jwt-signingkey", }, @@ -348,13 +341,13 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { }, }, { - Value: values.Secret.License, + Value: state.Values.Secret.License, EnvVar: corev1.EnvVar{ Name: "LICENSE", ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ - Name: Fullname(dot), + Name: state.FullName(), }, Key: "license", }, @@ -362,13 +355,13 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { }, }, { - Value: values.Secret.Redpanda.AdminAPI.Password, + Value: state.Values.Secret.Redpanda.AdminAPI.Password, EnvVar: corev1.EnvVar{ Name: "REDPANDA_ADMINAPI_PASSWORD", ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ - Name: Fullname(dot), + Name: state.FullName(), }, Key: "redpanda-admin-api-password", }, @@ -376,21 +369,21 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { }, }, { - Value: values.Secret.Redpanda.AdminAPI.TLSCA, + Value: state.Values.Secret.Redpanda.AdminAPI.TLSCA, EnvVar: corev1.EnvVar{ Name: "REDPANDA_ADMINAPI_TLS_CAFILEPATH", Value: "/etc/console/secrets/redpanda-admin-api-tls-ca", }, }, { - Value: values.Secret.Redpanda.AdminAPI.TLSKey, + Value: state.Values.Secret.Redpanda.AdminAPI.TLSKey, EnvVar: corev1.EnvVar{ Name: "REDPANDA_ADMINAPI_TLS_KEYFILEPATH", Value: "/etc/console/secrets/redpanda-admin-api-tls-key", }, }, { - Value: values.Secret.Redpanda.AdminAPI.TLSCert, + Value: state.Values.Secret.Redpanda.AdminAPI.TLSCert, EnvVar: corev1.EnvVar{ Name: "REDPANDA_ADMINAPI_TLS_CERTFILEPATH", Value: "/etc/console/secrets/redpanda-admin-api-tls-cert", @@ -398,7 +391,7 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { }, } - vars := values.ExtraEnv + vars := state.Values.ExtraEnv for _, possible := range possibleVars { if !helmette.Empty(possible.Value) { vars = append(vars, possible.EnvVar) @@ -408,34 +401,32 @@ func consoleContainerEnv(dot *helmette.Dot) []corev1.EnvVar { return vars } -func consolePodVolumes(dot *helmette.Dot) []corev1.Volume { - values := helmette.Unwrap[Values](dot.Values) - +func consolePodVolumes(state *RenderState) []corev1.Volume { volumes := []corev1.Volume{ { Name: "configs", VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ - Name: Fullname(dot), + Name: state.FullName(), }, }, }, }, } - if values.Secret.Create { + if state.Values.Secret.Create { volumes = append(volumes, corev1.Volume{ Name: "secrets", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: Fullname(dot), + SecretName: state.FullName(), }, }, }) } - for _, mount := range values.SecretMounts { + for _, mount := range state.Values.SecretMounts { volumes = append(volumes, corev1.Volume{ Name: mount.Name, VolumeSource: corev1.VolumeSource{ @@ -447,5 +438,5 @@ func consolePodVolumes(dot *helmette.Dot) []corev1.Volume { }) } - return append(volumes, values.ExtraVolumes...) + return append(volumes, state.Values.ExtraVolumes...) } diff --git a/charts/console/helpers.go b/charts/console/helpers.go deleted file mode 100644 index ff2352660..000000000 --- a/charts/console/helpers.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2025 Redpanda Data, Inc. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.md -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0 - -package console - -import ( - "fmt" - "strings" - - "github.com/redpanda-data/redpanda-operator/gotohelm/helmette" -) - -// Expand the name of the chart. -func Name(dot *helmette.Dot) string { - values := helmette.Unwrap[Values](dot.Values) - - name := helmette.Default(dot.Chart.Name, values.NameOverride) - return cleanForK8s(name) -} - -// Create a default fully qualified app name. -// We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -// If release name contains chart name it will be used as a full name. -func Fullname(dot *helmette.Dot) string { - values := helmette.Unwrap[Values](dot.Values) - - if values.FullnameOverride != "" { - return cleanForK8s(values.FullnameOverride) - } - - name := helmette.Default(dot.Chart.Name, values.NameOverride) - - if helmette.Contains(name, dot.Release.Name) { - return cleanForK8s(dot.Release.Name) - } - - return cleanForK8s(fmt.Sprintf("%s-%s", dot.Release.Name, name)) -} - -// Create chart name and version as used by the chart label. -func ChartLabel(dot *helmette.Dot) string { - chart := fmt.Sprintf("%s-%s", dot.Chart.Name, dot.Chart.Version) - return cleanForK8s(strings.ReplaceAll(chart, "+", "_")) -} - -// Common labels -func Labels(dot *helmette.Dot) map[string]string { - values := helmette.Unwrap[Values](dot.Values) - - labels := map[string]string{ - "helm.sh/chart": ChartLabel(dot), - "app.kubernetes.io/managed-by": dot.Release.Service, - } - - if dot.Chart.AppVersion != "" { - labels["app.kubernetes.io/version"] = dot.Chart.AppVersion - } - - return helmette.Merge(labels, SelectorLabels(dot), values.CommonLabels) -} - -func SelectorLabels(dot *helmette.Dot) map[string]string { - return map[string]string{ - "app.kubernetes.io/name": Name(dot), - "app.kubernetes.io/instance": dot.Release.Name, - } -} - -func cleanForK8s(s string) string { - return helmette.TrimSuffix("-", helmette.Trunc(63, s)) -} diff --git a/charts/console/hpa.go b/charts/console/hpa.go index 03281ed53..e47d50d93 100644 --- a/charts/console/hpa.go +++ b/charts/console/hpa.go @@ -14,40 +14,36 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" - - "github.com/redpanda-data/redpanda-operator/gotohelm/helmette" ) -func HorizontalPodAutoscaler(dot *helmette.Dot) *autoscalingv2.HorizontalPodAutoscaler { - values := helmette.Unwrap[Values](dot.Values) - - if !values.Autoscaling.Enabled { +func HorizontalPodAutoscaler(state *RenderState) *autoscalingv2.HorizontalPodAutoscaler { + if !state.Values.Autoscaling.Enabled { return nil } metrics := []autoscalingv2.MetricSpec{} - if values.Autoscaling.TargetCPUUtilizationPercentage != nil { + if state.Values.Autoscaling.TargetCPUUtilizationPercentage != nil { metrics = append(metrics, autoscalingv2.MetricSpec{ Type: "Resource", Resource: &autoscalingv2.ResourceMetricSource{ Name: corev1.ResourceCPU, Target: autoscalingv2.MetricTarget{ Type: autoscalingv2.UtilizationMetricType, - AverageUtilization: values.Autoscaling.TargetCPUUtilizationPercentage, + AverageUtilization: state.Values.Autoscaling.TargetCPUUtilizationPercentage, }, }, }) } - if values.Autoscaling.TargetMemoryUtilizationPercentage != nil { + if state.Values.Autoscaling.TargetMemoryUtilizationPercentage != nil { metrics = append(metrics, autoscalingv2.MetricSpec{ Type: "Resource", Resource: &autoscalingv2.ResourceMetricSource{ Name: corev1.ResourceMemory, Target: autoscalingv2.MetricTarget{ Type: autoscalingv2.UtilizationMetricType, - AverageUtilization: values.Autoscaling.TargetMemoryUtilizationPercentage, + AverageUtilization: state.Values.Autoscaling.TargetMemoryUtilizationPercentage, }, }, }) @@ -59,18 +55,18 @@ func HorizontalPodAutoscaler(dot *helmette.Dot) *autoscalingv2.HorizontalPodAuto Kind: "HorizontalPodAutoscaler", }, ObjectMeta: metav1.ObjectMeta{ - Labels: Labels(dot), - Name: Fullname(dot), - Namespace: dot.Release.Namespace, + Labels: state.Labels(nil), + Name: state.FullName(), + Namespace: state.Namespace, }, Spec: autoscalingv2.HorizontalPodAutoscalerSpec{ ScaleTargetRef: autoscalingv2.CrossVersionObjectReference{ APIVersion: "apps/v1", Kind: "Deployment", - Name: Fullname(dot), + Name: state.FullName(), }, - MinReplicas: ptr.To(values.Autoscaling.MinReplicas), - MaxReplicas: values.Autoscaling.MaxReplicas, + MinReplicas: ptr.To(state.Values.Autoscaling.MinReplicas), + MaxReplicas: state.Values.Autoscaling.MaxReplicas, Metrics: metrics, }, } diff --git a/charts/console/ingress.go b/charts/console/ingress.go index 1e13183ba..eec45e476 100644 --- a/charts/console/ingress.go +++ b/charts/console/ingress.go @@ -12,22 +12,18 @@ package console import ( networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/redpanda-data/redpanda-operator/gotohelm/helmette" ) -func Ingress(dot *helmette.Dot) *networkingv1.Ingress { - values := helmette.Unwrap[Values](dot.Values) - - if !values.Ingress.Enabled { +func Ingress(state *RenderState) *networkingv1.Ingress { + if !state.Values.Ingress.Enabled { return nil } var tls []networkingv1.IngressTLS - for _, t := range values.Ingress.TLS { + for _, t := range state.Values.Ingress.TLS { var hosts []string for _, host := range t.Hosts { - hosts = append(hosts, helmette.Tpl(dot, host, dot)) + hosts = append(hosts, state.Template(host)) } tls = append(tls, networkingv1.IngressTLS{ SecretName: t.SecretName, @@ -36,7 +32,7 @@ func Ingress(dot *helmette.Dot) *networkingv1.Ingress { } var rules []networkingv1.IngressRule - for _, host := range values.Ingress.Hosts { + for _, host := range state.Values.Ingress.Hosts { var paths []networkingv1.HTTPIngressPath for _, path := range host.Paths { paths = append(paths, networkingv1.HTTPIngressPath{ @@ -44,9 +40,9 @@ func Ingress(dot *helmette.Dot) *networkingv1.Ingress { PathType: path.PathType, Backend: networkingv1.IngressBackend{ Service: &networkingv1.IngressServiceBackend{ - Name: Fullname(dot), + Name: state.FullName(), Port: networkingv1.ServiceBackendPort{ - Number: values.Service.Port, + Number: state.Values.Service.Port, }, }, }, @@ -54,7 +50,7 @@ func Ingress(dot *helmette.Dot) *networkingv1.Ingress { } rules = append(rules, networkingv1.IngressRule{ - Host: helmette.Tpl(dot, host.Host, dot), + Host: state.Template(host.Host), IngressRuleValue: networkingv1.IngressRuleValue{ HTTP: &networkingv1.HTTPIngressRuleValue{ Paths: paths, @@ -69,13 +65,13 @@ func Ingress(dot *helmette.Dot) *networkingv1.Ingress { APIVersion: "networking.k8s.io/v1", }, ObjectMeta: metav1.ObjectMeta{ - Name: Fullname(dot), - Labels: Labels(dot), - Namespace: dot.Release.Namespace, - Annotations: values.Ingress.Annotations, + Name: state.FullName(), + Labels: state.Labels(nil), + Namespace: state.Namespace, + Annotations: state.Values.Ingress.Annotations, }, Spec: networkingv1.IngressSpec{ - IngressClassName: values.Ingress.ClassName, + IngressClassName: state.Values.Ingress.ClassName, TLS: tls, Rules: rules, }, diff --git a/charts/console/render.go b/charts/console/render.go new file mode 100644 index 000000000..6e8d43149 --- /dev/null +++ b/charts/console/render.go @@ -0,0 +1,137 @@ +// Copyright 2025 Redpanda Data, Inc. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.md +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0 + +// +gotohelm:namespace=console +package console + +import ( + "fmt" + "strings" + + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/kubernetes/scheme" + + "github.com/redpanda-data/redpanda-operator/gotohelm/helmette" + "github.com/redpanda-data/redpanda-operator/pkg/kube" +) + +// Scheme is a [runtime.Scheme] with the appropriate extensions to load all +// objects produced by the console chart. +var Scheme = runtime.NewScheme() + +const ( + AppVersion = "v3.1.0" + ChartName = "console" + ConsoleContainerName = "console" +) + +// +gotohelm:ignore=true +func init() { + must(scheme.AddToScheme(Scheme)) +} + +// +gotohelm:ignore=true +func must(err error) { + if err != nil { + panic(err) + } +} + +type RenderState struct { + ReleaseName string + Namespace string + Template func(string) string + CommonLabels map[string]string + Values RenderValues +} + +// ChartName returns the name of this "chart", respecting any overrides. +// +// Previously known as "console.Name" +func (s *RenderState) ChartName() string { + name := ChartName + if s.Values.NameOverride != "" { + name = s.Values.NameOverride + } + return cleanForK8s(name) +} + +// FullName returns the fully qualified name of this installation, respecting +// any overrides. e.g. "release-console" +// +// Previously known as "console.Fullname" +func (s *RenderState) FullName() string { + if s.Values.FullnameOverride != "" { + return cleanForK8s(s.Values.FullnameOverride) + } + + name := s.ChartName() + + if !strings.Contains(name, s.ReleaseName) { + name = fmt.Sprintf("%s-%s", s.ReleaseName, name) + } + + return cleanForK8s(name) +} + +func (s *RenderState) SelectorLabels() map[string]string { + return map[string]string{ + "app.kubernetes.io/name": s.ChartName(), + "app.kubernetes.io/instance": s.ReleaseName, + } +} + +// Labels returns labels updated with any chart or used imposed common labels. +// Keys in labels will be overridden if there is a conflict. +func (s *RenderState) Labels(labels map[string]string) map[string]string { + if labels == nil { + labels = map[string]string{} + } + + for key, value := range s.SelectorLabels() { + labels[key] = value + } + + for key, value := range s.CommonLabels { + labels[key] = value + } + + for key, value := range s.Values.CommonLabels { + labels[key] = value + } + + return labels +} + +// render is the entrypoint to both the go and helm versions of the console +// helm chart. +// In helm, _shims.render-manifest is used to call and filter the output of +// this function. +// In go, this function should be call by executing [ChartLabel.Render], which will +// handle construction of [helmette.Dot], subcharting, and output filtering. +func Render(state *RenderState) []kube.Object { + manifests := []kube.Object{ + ServiceAccount(state), + Secret(state), + ConfigMap(state), + Service(state), + Ingress(state), + Deployment(state), + HorizontalPodAutoscaler(state), + } + + // NB: This slice may contain nil interfaces! + // Filtering happens elsewhere, don't call this function directly if you + // can avoid it. + return manifests +} + +func cleanForK8s(s string) string { + return helmette.TrimSuffix("-", helmette.Trunc(63, s)) +} diff --git a/charts/console/values.go b/charts/console/rendervalues.go similarity index 98% rename from charts/console/values.go rename to charts/console/rendervalues.go index 8394608a6..baf5baad2 100644 --- a/charts/console/values.go +++ b/charts/console/rendervalues.go @@ -16,16 +16,15 @@ import ( networkingv1 "k8s.io/api/networking/v1" ) -type Values struct { - Globals map[string]any `json:"global,omitempty"` +type RenderValues struct { ReplicaCount int32 `json:"replicaCount"` - Image Image `json:"image"` - ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets"` NameOverride string `json:"nameOverride"` + CommonLabels map[string]string `json:"commonLabels"` FullnameOverride string `json:"fullnameOverride"` + Image Image `json:"image"` + ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets"` AutomountServiceAccountToken bool `json:"automountServiceAccountToken"` ServiceAccount ServiceAccountConfig `json:"serviceAccount"` - CommonLabels map[string]string `json:"commonLabels"` Annotations map[string]string `json:"annotations"` PodAnnotations map[string]string `json:"podAnnotations"` PodLabels map[string]string `json:"podLabels"` @@ -180,5 +179,5 @@ type Image struct { Registry string `json:"registry"` Repository string `json:"repository"` PullPolicy corev1.PullPolicy `json:"pullPolicy"` - Tag *string `json:"tag"` + Tag string `json:"tag"` } diff --git a/charts/console/values_partial.gen.go b/charts/console/rendervalues_partial.gen.go similarity index 98% rename from charts/console/values_partial.gen.go rename to charts/console/rendervalues_partial.gen.go index 03903293a..03d6fbd37 100644 --- a/charts/console/values_partial.gen.go +++ b/charts/console/rendervalues_partial.gen.go @@ -19,16 +19,15 @@ import ( networkingv1 "k8s.io/api/networking/v1" ) -type PartialValues struct { - Globals map[string]any "json:\"global,omitempty\"" +type PartialRenderValues struct { ReplicaCount *int32 "json:\"replicaCount,omitempty\"" - Image *PartialImage "json:\"image,omitempty\"" - ImagePullSecrets []corev1.LocalObjectReference "json:\"imagePullSecrets,omitempty\"" NameOverride *string "json:\"nameOverride,omitempty\"" + CommonLabels map[string]string "json:\"commonLabels,omitempty\"" FullnameOverride *string "json:\"fullnameOverride,omitempty\"" + Image *PartialImage "json:\"image,omitempty\"" + ImagePullSecrets []corev1.LocalObjectReference "json:\"imagePullSecrets,omitempty\"" AutomountServiceAccountToken *bool "json:\"automountServiceAccountToken,omitempty\"" ServiceAccount *PartialServiceAccountConfig "json:\"serviceAccount,omitempty\"" - CommonLabels map[string]string "json:\"commonLabels,omitempty\"" Annotations map[string]string "json:\"annotations,omitempty\"" PodAnnotations map[string]string "json:\"podAnnotations,omitempty\"" PodLabels map[string]string "json:\"podLabels,omitempty\"" diff --git a/charts/console/secret.go b/charts/console/secret.go index bfc91402f..6a24be436 100644 --- a/charts/console/secret.go +++ b/charts/console/secret.go @@ -17,14 +17,12 @@ import ( "github.com/redpanda-data/redpanda-operator/gotohelm/helmette" ) -func Secret(dot *helmette.Dot) *corev1.Secret { - values := helmette.Unwrap[Values](dot.Values) - - if !values.Secret.Create { +func Secret(state *RenderState) *corev1.Secret { + if !state.Values.Secret.Create { return nil } - jwtSigningKey := values.Secret.Authentication.JWTSigningKey + jwtSigningKey := state.Values.Secret.Authentication.JWTSigningKey if jwtSigningKey == "" { jwtSigningKey = helmette.RandAlphaNum(32) } @@ -35,9 +33,9 @@ func Secret(dot *helmette.Dot) *corev1.Secret { Kind: "Secret", }, ObjectMeta: metav1.ObjectMeta{ - Name: Fullname(dot), - Labels: Labels(dot), - Namespace: dot.Release.Namespace, + Name: state.FullName(), + Labels: state.Labels(nil), + Namespace: state.Namespace, }, Type: corev1.SecretTypeOpaque, StringData: map[string]string{ @@ -45,34 +43,34 @@ func Secret(dot *helmette.Dot) *corev1.Secret { // For this reason we can't use `with` to change the scope. // Kafka - "kafka-sasl-password": ptr.Deref(values.Secret.Kafka.SASLPassword, ""), - "kafka-sasl-aws-msk-iam-secret-key": ptr.Deref(values.Secret.Kafka.AWSMSKIAMSecretKey, ""), - "kafka-tls-ca": ptr.Deref(values.Secret.Kafka.TLSCA, ""), - "kafka-tls-cert": ptr.Deref(values.Secret.Kafka.TLSCert, ""), - "kafka-tls-key": ptr.Deref(values.Secret.Kafka.TLSKey, ""), + "kafka-sasl-password": ptr.Deref(state.Values.Secret.Kafka.SASLPassword, ""), + "kafka-sasl-aws-msk-iam-secret-key": ptr.Deref(state.Values.Secret.Kafka.AWSMSKIAMSecretKey, ""), + "kafka-tls-ca": ptr.Deref(state.Values.Secret.Kafka.TLSCA, ""), + "kafka-tls-cert": ptr.Deref(state.Values.Secret.Kafka.TLSCert, ""), + "kafka-tls-key": ptr.Deref(state.Values.Secret.Kafka.TLSKey, ""), // schema registry - "schema-registry-bearertoken": ptr.Deref(values.Secret.SchemaRegistry.BearerToken, ""), - "schema-registry-password": ptr.Deref(values.Secret.SchemaRegistry.Password, ""), - "schemaregistry-tls-ca": ptr.Deref(values.Secret.SchemaRegistry.TLSCA, ""), - "schemaregistry-tls-cert": ptr.Deref(values.Secret.SchemaRegistry.TLSCert, ""), - "schemaregistry-tls-key": ptr.Deref(values.Secret.SchemaRegistry.TLSKey, ""), + "schema-registry-bearertoken": ptr.Deref(state.Values.Secret.SchemaRegistry.BearerToken, ""), + "schema-registry-password": ptr.Deref(state.Values.Secret.SchemaRegistry.Password, ""), + "schemaregistry-tls-ca": ptr.Deref(state.Values.Secret.SchemaRegistry.TLSCA, ""), + "schemaregistry-tls-cert": ptr.Deref(state.Values.Secret.SchemaRegistry.TLSCert, ""), + "schemaregistry-tls-key": ptr.Deref(state.Values.Secret.SchemaRegistry.TLSKey, ""), // Authentication "authentication-jwt-signingkey": jwtSigningKey, - "authentication-oidc-client-secret": ptr.Deref(values.Secret.Authentication.OIDC.ClientSecret, ""), + "authentication-oidc-client-secret": ptr.Deref(state.Values.Secret.Authentication.OIDC.ClientSecret, ""), // License - "license": values.Secret.License, + "license": state.Values.Secret.License, // Redpanda - "redpanda-admin-api-password": ptr.Deref(values.Secret.Redpanda.AdminAPI.Password, ""), - "redpanda-admin-api-tls-ca": ptr.Deref(values.Secret.Redpanda.AdminAPI.TLSCA, ""), - "redpanda-admin-api-tls-cert": ptr.Deref(values.Secret.Redpanda.AdminAPI.TLSCert, ""), - "redpanda-admin-api-tls-key": ptr.Deref(values.Secret.Redpanda.AdminAPI.TLSKey, ""), + "redpanda-admin-api-password": ptr.Deref(state.Values.Secret.Redpanda.AdminAPI.Password, ""), + "redpanda-admin-api-tls-ca": ptr.Deref(state.Values.Secret.Redpanda.AdminAPI.TLSCA, ""), + "redpanda-admin-api-tls-cert": ptr.Deref(state.Values.Secret.Redpanda.AdminAPI.TLSCert, ""), + "redpanda-admin-api-tls-key": ptr.Deref(state.Values.Secret.Redpanda.AdminAPI.TLSKey, ""), // Serde - "serde-protobuf-git-basicauth-password": ptr.Deref(values.Secret.Serde.ProtobufGitBasicAuthPassword, ""), + "serde-protobuf-git-basicauth-password": ptr.Deref(state.Values.Secret.Serde.ProtobufGitBasicAuthPassword, ""), }, } } diff --git a/charts/console/service.go b/charts/console/service.go index 684f0d20a..dc8abbd96 100644 --- a/charts/console/service.go +++ b/charts/console/service.go @@ -17,21 +17,19 @@ import ( "github.com/redpanda-data/redpanda-operator/gotohelm/helmette" ) -func Service(dot *helmette.Dot) *corev1.Service { - values := helmette.Unwrap[Values](dot.Values) - +func Service(state *RenderState) *corev1.Service { port := corev1.ServicePort{ Name: "http", - Port: int32(values.Service.Port), + Port: int32(state.Values.Service.Port), Protocol: corev1.ProtocolTCP, } - if values.Service.TargetPort != nil { - port.TargetPort = intstr.FromInt32(*values.Service.TargetPort) + if state.Values.Service.TargetPort != nil { + port.TargetPort = intstr.FromInt32(*state.Values.Service.TargetPort) } - if helmette.Contains("NodePort", string(values.Service.Type)) && values.Service.NodePort != nil { - port.NodePort = *values.Service.NodePort + if helmette.Contains("NodePort", string(state.Values.Service.Type)) && state.Values.Service.NodePort != nil { + port.NodePort = *state.Values.Service.NodePort } return &corev1.Service{ @@ -40,14 +38,14 @@ func Service(dot *helmette.Dot) *corev1.Service { Kind: "Service", }, ObjectMeta: metav1.ObjectMeta{ - Name: Fullname(dot), - Namespace: dot.Release.Namespace, - Labels: Labels(dot), - Annotations: values.Service.Annotations, + Name: state.FullName(), + Namespace: state.Namespace, + Labels: state.Labels(nil), + Annotations: state.Values.Service.Annotations, }, Spec: corev1.ServiceSpec{ - Type: values.Service.Type, - Selector: SelectorLabels(dot), + Type: state.Values.Service.Type, + Selector: state.SelectorLabels(), Ports: []corev1.ServicePort{port}, }, } diff --git a/charts/console/serviceaccount.go b/charts/console/serviceaccount.go index d21dda938..74d43e367 100644 --- a/charts/console/serviceaccount.go +++ b/charts/console/serviceaccount.go @@ -18,23 +18,19 @@ import ( ) // Create the name of the service account to use -func ServiceAccountName(dot *helmette.Dot) string { - values := helmette.Unwrap[Values](dot.Values) - - if values.ServiceAccount.Create { - if values.ServiceAccount.Name != "" { - return values.ServiceAccount.Name +func ServiceAccountName(state *RenderState) string { + if state.Values.ServiceAccount.Create { + if state.Values.ServiceAccount.Name != "" { + return state.Values.ServiceAccount.Name } - return Fullname(dot) + return state.FullName() } - return helmette.Default("default", values.ServiceAccount.Name) + return helmette.Default("default", state.Values.ServiceAccount.Name) } -func ServiceAccount(dot *helmette.Dot) *corev1.ServiceAccount { - values := helmette.Unwrap[Values](dot.Values) - - if !values.ServiceAccount.Create { +func ServiceAccount(state *RenderState) *corev1.ServiceAccount { + if !state.Values.ServiceAccount.Create { return nil } @@ -44,11 +40,11 @@ func ServiceAccount(dot *helmette.Dot) *corev1.ServiceAccount { APIVersion: "v1", }, ObjectMeta: metav1.ObjectMeta{ - Name: ServiceAccountName(dot), - Labels: Labels(dot), - Namespace: dot.Release.Namespace, - Annotations: values.ServiceAccount.Annotations, + Name: ServiceAccountName(state), + Labels: state.Labels(nil), + Namespace: state.Namespace, + Annotations: state.Values.ServiceAccount.Annotations, }, - AutomountServiceAccountToken: ptr.To(values.ServiceAccount.AutomountServiceAccountToken), + AutomountServiceAccountToken: ptr.To(state.Values.ServiceAccount.AutomountServiceAccountToken), } } diff --git a/charts/redpanda/chart/templates/_console.go.tpl b/charts/redpanda/chart/templates/_console.go.tpl index 8d1091334..72f49d876 100644 --- a/charts/redpanda/chart/templates/_console.go.tpl +++ b/charts/redpanda/chart/templates/_console.go.tpl @@ -10,42 +10,36 @@ {{- (dict "r" (coalesce nil)) | toJson -}} {{- break -}} {{- end -}} -{{- $consoleDot := (index $state.Dot.Subcharts "console") -}} -{{- $loadedValues := $consoleDot.Values -}} -{{- $consoleValue := $consoleDot.Values -}} +{{- $consoleState := (get (fromJson (include "chart.DotToState" (dict "a" (list (index $state.Dot.Subcharts "console"))))) "r") -}} {{- $license_1 := $state.Values.enterprise.license -}} {{- if (and (ne $license_1 "") (not (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.console.secret.create false)))) "r"))) -}} -{{- $_ := (set $consoleValue.secret "create" true) -}} -{{- $_ := (set $consoleValue.secret "license" $license_1) -}} +{{- $_ := (set $consoleState.Values.secret "create" true) -}} +{{- $_ := (set $consoleState.Values.secret "license" $license_1) -}} {{- end -}} {{- if (not (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.console.configmap.create false)))) "r")) -}} -{{- $_ := (set $consoleValue.configmap "create" true) -}} -{{- $_ := (set $consoleValue "config" (get (fromJson (include "redpanda.ConsoleConfig" (dict "a" (list $state)))) "r")) -}} +{{- $_ := (set $consoleState.Values.configmap "create" true) -}} +{{- $_ := (set $consoleState.Values "config" (get (fromJson (include "redpanda.ConsoleConfig" (dict "a" (list $state)))) "r")) -}} {{- end -}} {{- if (not (get (fromJson (include "_shims.ptr_Deref" (dict "a" (list $state.Values.console.deployment.create false)))) "r")) -}} -{{- $_ := (set $consoleValue.deployment "create" true) -}} +{{- $_ := (set $consoleState.Values.deployment "create" true) -}} {{- if (get (fromJson (include "redpanda.Auth.IsSASLEnabled" (dict "a" (list $state.Values.auth)))) "r") -}} {{- $command := (list "sh" "-c" (printf "%s%s" (printf "%s%s" (printf "%s%s" (printf "%s%s" (printf "%s%s" (printf "%s%s" (printf "%s%s" "set -e; IFS=':' read -r KAFKA_SASL_USERNAME KAFKA_SASL_PASSWORD KAFKA_SASL_MECHANISM < <(grep \"\" $(find /mnt/users/* -print));" (printf " KAFKA_SASL_MECHANISM=${KAFKA_SASL_MECHANISM:-%s};" (get (fromJson (include "redpanda.GetSASLMechanism" (dict "a" (list $state)))) "r"))) " export KAFKA_SASL_USERNAME KAFKA_SASL_PASSWORD KAFKA_SASL_MECHANISM;") " export KAFKA_SCHEMAREGISTRY_USERNAME=$KAFKA_SASL_USERNAME;") " export KAFKA_SCHEMAREGISTRY_PASSWORD=$KAFKA_SASL_PASSWORD;") " export REDPANDA_ADMINAPI_USERNAME=$KAFKA_SASL_USERNAME;") " export REDPANDA_ADMINAPI_PASSWORD=$KAFKA_SASL_PASSWORD;") " /app/console $@") " --") -}} -{{- $_ := (set $consoleValue.deployment "command" $command) -}} +{{- $_ := (set $consoleState.Values.deployment "command" $command) -}} {{- end -}} {{- $secret_2 := $state.Values.enterprise.licenseSecretRef -}} {{- if (ne (toJson $secret_2) "null") -}} -{{- $_ := (set $consoleValue "licenseSecretRef" $secret_2) -}} +{{- $_ := (set $consoleState.Values "licenseSecretRef" $secret_2) -}} {{- end -}} -{{- $_ := (set $consoleValue "extraVolumes" (get (fromJson (include "redpanda.consoleTLSVolumes" (dict "a" (list $state)))) "r")) -}} -{{- $_ := (set $consoleValue "extraVolumeMounts" (get (fromJson (include "redpanda.consoleTLSVolumesMounts" (dict "a" (list $state)))) "r")) -}} -{{- $_ := (set $consoleDot "Values" $consoleValue) -}} -{{- $cfg := (get (fromJson (include "console.ConfigMap" (dict "a" (list $consoleDot)))) "r") -}} -{{- if (eq (toJson $consoleValue.podAnnotations) "null") -}} -{{- $_ := (set $consoleValue "podAnnotations" (dict)) -}} +{{- $_ := (set $consoleState.Values "extraVolumes" (get (fromJson (include "redpanda.consoleTLSVolumes" (dict "a" (list $state)))) "r")) -}} +{{- $_ := (set $consoleState.Values "extraVolumeMounts" (get (fromJson (include "redpanda.consoleTLSVolumesMounts" (dict "a" (list $state)))) "r")) -}} +{{- if (eq (toJson $consoleState.Values.podAnnotations) "null") -}} +{{- $_ := (set $consoleState.Values "podAnnotations" (dict)) -}} {{- end -}} -{{- $_ := (set $consoleValue.podAnnotations "checksum-redpanda-chart/config" (sha256sum (toYaml $cfg))) -}} +{{- $cfg := (get (fromJson (include "console.ConfigMap" (dict "a" (list $consoleState)))) "r") -}} +{{- $_ := (set $consoleState.Values.podAnnotations "checksum-redpanda-chart/config" (sha256sum (toYaml $cfg))) -}} {{- end -}} -{{- $_ := (set $consoleDot "Values" $consoleValue) -}} -{{- $manifests := (list (get (fromJson (include "console.Secret" (dict "a" (list $consoleDot)))) "r") (get (fromJson (include "console.ConfigMap" (dict "a" (list $consoleDot)))) "r") (get (fromJson (include "console.Deployment" (dict "a" (list $consoleDot)))) "r")) -}} -{{- $_ := (set $consoleDot "Values" $loadedValues) -}} {{- $_is_returning = true -}} -{{- (dict "r" $manifests) | toJson -}} +{{- (dict "r" (list (get (fromJson (include "console.Secret" (dict "a" (list $consoleState)))) "r") (get (fromJson (include "console.ConfigMap" (dict "a" (list $consoleState)))) "r") (get (fromJson (include "console.Deployment" (dict "a" (list $consoleState)))) "r"))) | toJson -}} {{- break -}} {{- end -}} {{- end -}} @@ -64,9 +58,9 @@ {{- end -}} {{- $visitedCert := (dict) -}} {{- range $_, $tlsCfg := (list $state.Values.listeners.kafka.tls $state.Values.listeners.schemaRegistry.tls $state.Values.listeners.admin.tls) -}} -{{- $_127___visited := (get (fromJson (include "_shims.dicttest" (dict "a" (list $visitedCert $tlsCfg.cert false)))) "r") -}} -{{- $_ := (index $_127___visited 0) -}} -{{- $visited := (index $_127___visited 1) -}} +{{- $_119___visited := (get (fromJson (include "_shims.dicttest" (dict "a" (list $visitedCert $tlsCfg.cert false)))) "r") -}} +{{- $_ := (index $_119___visited 0) -}} +{{- $visited := (index $_119___visited 1) -}} {{- if (or (not (get (fromJson (include "redpanda.InternalTLS.IsEnabled" (dict "a" (list $tlsCfg $state.Values.tls)))) "r")) $visited) -}} {{- continue -}} {{- end -}} @@ -97,9 +91,9 @@ {{- end -}} {{- $visitedCert := (dict) -}} {{- range $_, $tlsCfg := (list $state.Values.listeners.kafka.tls $state.Values.listeners.schemaRegistry.tls $state.Values.listeners.admin.tls) -}} -{{- $_166___visited := (get (fromJson (include "_shims.dicttest" (dict "a" (list $visitedCert $tlsCfg.cert false)))) "r") -}} -{{- $_ := (index $_166___visited 0) -}} -{{- $visited := (index $_166___visited 1) -}} +{{- $_158___visited := (get (fromJson (include "_shims.dicttest" (dict "a" (list $visitedCert $tlsCfg.cert false)))) "r") -}} +{{- $_ := (index $_158___visited 0) -}} +{{- $visited := (index $_158___visited 1) -}} {{- if (or (not (get (fromJson (include "redpanda.InternalTLS.IsEnabled" (dict "a" (list $tlsCfg $state.Values.tls)))) "r")) $visited) -}} {{- continue -}} {{- end -}} diff --git a/charts/redpanda/chart_test.go b/charts/redpanda/chart_test.go index ee6a6133a..05e4acbff 100644 --- a/charts/redpanda/chart_test.go +++ b/charts/redpanda/chart_test.go @@ -1099,7 +1099,7 @@ func TestGoHelmEquivalence(t *testing.T) { values.Console = &consolechart.PartialValues{ Enabled: ptr.To(true), Tests: &consolechart.PartialEnableable{Enabled: ptr.To(false)}, - PartialValues: console.PartialValues{ + PartialRenderValues: console.PartialRenderValues{ Ingress: &console.PartialIngressConfig{ Enabled: ptr.To(true), }, diff --git a/charts/redpanda/console.tpl.go b/charts/redpanda/console.tpl.go index 0002a7901..54c645d2c 100644 --- a/charts/redpanda/console.tpl.go +++ b/charts/redpanda/console.tpl.go @@ -17,6 +17,7 @@ import ( "k8s.io/utils/ptr" "github.com/redpanda-data/redpanda-operator/charts/console/v3" + consolechart "github.com/redpanda-data/redpanda-operator/charts/console/v3/chart" "github.com/redpanda-data/redpanda-operator/gotohelm/helmette" "github.com/redpanda-data/redpanda-operator/pkg/kube" ) @@ -29,24 +30,22 @@ func consoleChartIntegration(state *RenderState) []kube.Object { return nil } - consoleDot := state.Dot.Subcharts["console"] - loadedValues := consoleDot.Values + consoleState := consolechart.DotToState(state.Dot.Subcharts["console"]) - consoleValue := helmette.UnmarshalInto[console.Values](consoleDot.Values) // Pass the same Redpanda License to Console if license := state.Values.Enterprise.License; license != "" && !ptr.Deref(state.Values.Console.Secret.Create, false) { - consoleValue.Secret.Create = true - consoleValue.Secret.License = license + consoleState.Values.Secret.Create = true + consoleState.Values.Secret.License = license } // Create console configuration based on Redpanda helm chart state.Values. if !ptr.Deref(state.Values.Console.ConfigMap.Create, false) { - consoleValue.ConfigMap.Create = true - consoleValue.Config = ConsoleConfig(state) + consoleState.Values.ConfigMap.Create = true + consoleState.Values.Config = ConsoleConfig(state) } if !ptr.Deref(state.Values.Console.Deployment.Create, false) { - consoleValue.Deployment.Create = true + consoleState.Values.Deployment.Create = true // Adopt Console entry point to use SASL user in Kafka, // Schema Registry and Redpanda Admin API connection @@ -64,39 +63,33 @@ func consoleChartIntegration(state *RenderState) []kube.Object { " /app/console $@", " --", } - consoleValue.Deployment.Command = command + consoleState.Values.Deployment.Command = command } // Create License reference for Console if secret := state.Values.Enterprise.LicenseSecretRef; secret != nil { - consoleValue.LicenseSecretRef = secret + consoleState.Values.LicenseSecretRef = secret } - consoleValue.ExtraVolumes = consoleTLSVolumes(state) - consoleValue.ExtraVolumeMounts = consoleTLSVolumesMounts(state) + consoleState.Values.ExtraVolumes = consoleTLSVolumes(state) + consoleState.Values.ExtraVolumeMounts = consoleTLSVolumesMounts(state) - consoleDot.Values = helmette.UnmarshalInto[helmette.Values](consoleValue) - cfg := console.ConfigMap(consoleDot) - if consoleValue.PodAnnotations == nil { - consoleValue.PodAnnotations = map[string]string{} + if consoleState.Values.PodAnnotations == nil { + consoleState.Values.PodAnnotations = map[string]string{} } - consoleValue.PodAnnotations["checksum-redpanda-chart/config"] = helmette.Sha256Sum(helmette.ToYaml(cfg)) - } - - consoleDot.Values = helmette.UnmarshalInto[helmette.Values](consoleValue) - manifests := []kube.Object{ - console.Secret(consoleDot), - console.ConfigMap(consoleDot), - console.Deployment(consoleDot), + cfg := console.ConfigMap(consoleState) + consoleState.Values.PodAnnotations["checksum-redpanda-chart/config"] = helmette.Sha256Sum(helmette.ToYaml(cfg)) } - consoleDot.Values = loadedValues - // NB: This slice may contain nil interfaces! // Filtering happens elsewhere, don't call this function directly if you // can avoid it. - return manifests + return []kube.Object{ + console.Secret(consoleState), + console.ConfigMap(consoleState), + console.Deployment(consoleState), + } } func consoleTLSVolumesMounts(state *RenderState) []corev1.VolumeMount { diff --git a/gotohelm/helmette/helm.go b/gotohelm/helmette/helm.go index 335c487fe..3ba4ae54c 100644 --- a/gotohelm/helmette/helm.go +++ b/gotohelm/helmette/helm.go @@ -33,6 +33,7 @@ type Dot struct { Chart Chart Subcharts map[string]*Dot Files Files + Template Template // Capabilities // KubeConfig is a hacked in value to allow `Lookup` to not rely on global @@ -50,6 +51,15 @@ type Dot struct { Templates fs.FS `json:"-"` } +// Template is not technically a struct but it acts like one and is always +// present in the helm execution context[1]. Specially, it's referenced by the +// `tpl` function. +// [^1]: https://github.com/helm/helm/blob/618b14a7723589887e02cd482dcd5a85768583cc/pkg/engine/engine.go#L315 +type Template struct { + Name string + BasePath string +} + // Files is a re-implementation of helm's `.Files` construct. // https://helm.sh/docs/chart_template_guide/accessing_files/ type Files struct { diff --git a/gotohelm/transpiler.go b/gotohelm/transpiler.go index 7a3b71294..6c5466dc3 100644 --- a/gotohelm/transpiler.go +++ b/gotohelm/transpiler.go @@ -1233,6 +1233,8 @@ func (t *Transpiler) transpileCallExpr(n *ast.CallExpr) Node { switch id { case "sort.Strings": return &BuiltInCall{Func: Literal("sortAlpha"), Arguments: args} + case "strings.Contains": + return &BuiltInCall{Func: Literal("contains"), Arguments: []Node{args[1], args[0]}} case "strings.TrimSuffix": return &BuiltInCall{Func: Literal("trimSuffix"), Arguments: []Node{args[1], args[0]}} case "strings.TrimPrefix": diff --git a/operator/api/redpanda/v1alpha2/redpanda_types_test.go b/operator/api/redpanda/v1alpha2/redpanda_types_test.go index 736472428..2f5b51b5e 100644 --- a/operator/api/redpanda/v1alpha2/redpanda_types_test.go +++ b/operator/api/redpanda/v1alpha2/redpanda_types_test.go @@ -31,7 +31,7 @@ import ( "pgregory.net/rapid" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/redpanda-data/redpanda-operator/charts/console/v3" + "github.com/redpanda-data/redpanda-operator/charts/console" "github.com/redpanda-data/redpanda-operator/charts/redpanda/v25" "github.com/redpanda-data/redpanda-operator/operator/api/apiutil" redpandav1alpha2 "github.com/redpanda-data/redpanda-operator/operator/api/redpanda/v1alpha2" diff --git a/operator/go.mod b/operator/go.mod index 0b30e7389..a204b0154 100644 --- a/operator/go.mod +++ b/operator/go.mod @@ -28,7 +28,7 @@ require ( github.com/redpanda-data/common-go/rpadmin v0.1.14 github.com/redpanda-data/common-go/secrets v0.1.3 github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20 - github.com/redpanda-data/redpanda-operator/charts/console/v3 v3.1.0 + github.com/redpanda-data/redpanda-operator/charts/console v0.0.0-20250718150737-e01f8476d560 github.com/redpanda-data/redpanda-operator/charts/redpanda/v25 v25.0.0 github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0 github.com/redpanda-data/redpanda-operator/pkg v0.0.0-20250528175436-e8cca0053dc6 @@ -246,6 +246,7 @@ require ( github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/procfs v0.16.1 // indirect github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect + github.com/redpanda-data/redpanda-operator/charts/console/v3 v3.1.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.13.1 // indirect github.com/rubenv/sql-migrate v1.8.0 // indirect diff --git a/operator/go.sum b/operator/go.sum index 1d0972d37..7efd11639 100644 --- a/operator/go.sum +++ b/operator/go.sum @@ -707,6 +707,8 @@ github.com/redpanda-data/common-go/secrets v0.1.3 h1:VRo+OFS4Zgb2UMvwcIuUujdMhAP github.com/redpanda-data/common-go/secrets v0.1.3/go.mod h1:WjUU/5saSXwItZx6veFOGbQZUgPQz4MQ65z22y0Ky84= github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20 h1:+zsE3W1V86k2sjAGWOySIlF0xn5R1aXXQBaIdr80F48= github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20/go.mod h1:DC42/3+k5PefSo4IalYbDN3yRZrVFP0b69+gC/NwGd4= +github.com/redpanda-data/redpanda-operator/charts/console v0.0.0-20250718150737-e01f8476d560 h1:fhMikrIYgjTukRTS7zZHJ5sFQP4hotkfExEyFRWw6rI= +github.com/redpanda-data/redpanda-operator/charts/console v0.0.0-20250718150737-e01f8476d560/go.mod h1:aSiQU9wI3DcOv4tyvoJz5Gx2bUq71LHlLnPkQcGWpK4= github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0 h1:IV2Ic66JDKPtCnNU4Kn1naJlzZmhl0izRj17qgTCo20= github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0/go.mod h1:usCpPzzzhgtPrRTiUQOzFqGmukce8U0SrzEeX2ONDFE= github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20250716004441-6e1647296ad6 h1:SbcvWTYFEbH5+NQOl1To5jppEa8RCK1HAkRNfhdUGLg= diff --git a/taskfiles/charts.yml b/taskfiles/charts.yml index 10a949997..86ea88d0a 100644 --- a/taskfiles/charts.yml +++ b/taskfiles/charts.yml @@ -15,7 +15,7 @@ tasks: desc: "Generate files for the console Helm chart" cmds: - task: genpartial - vars: { CHART: console } + vars: { CHART: console, STRUCT: RenderValues } - task: genpartial vars: { CHART: console/chart } - task: genschema