-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new Chart Render functionality in console
The `_shims.render-manifest` will call `console.render` only once to generate all console resources. It's prelude for redpanda helm chart and de-flux controller.
- Loading branch information
1 parent
6a25b77
commit 151ff93
Showing
14 changed files
with
165 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to You under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// 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. | ||
// | ||
// +gotohelm:filename=_chart.go.tpl | ||
package console | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/redpanda-data/helm-charts/pkg/gotohelm" | ||
"github.com/redpanda-data/helm-charts/pkg/gotohelm/helmette" | ||
"github.com/redpanda-data/helm-charts/pkg/kube" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/client-go/kubernetes/scheme" | ||
) | ||
|
||
var ( | ||
// Scheme is a [runtime.Scheme] with the appropriate extensions to load all | ||
// objects produced by the redpanda chart. | ||
Scheme = runtime.NewScheme() | ||
|
||
//go:embed Chart.yaml | ||
chartYAML []byte | ||
|
||
//go:embed values.yaml | ||
defaultValuesYAML []byte | ||
|
||
// ChartLabel is the go version of the redpanda helm chart. | ||
Chart = gotohelm.MustLoad(chartYAML, defaultValuesYAML, render) | ||
) | ||
|
||
// +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 redpanda | ||
// 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{- /* Generated from "chart.go" */ -}} | ||
|
||
{{- define "console.render" -}} | ||
{{- $dot := (index .a 0) -}} | ||
{{- range $_ := (list 1) -}} | ||
{{- $_is_returning := false -}} | ||
{{- $manifests := (list (get (fromJson (include "console.ServiceAccount" (dict "a" (list $dot) ))) "r") (get (fromJson (include "console.Secret" (dict "a" (list $dot) ))) "r") (get (fromJson (include "console.ConfigMap" (dict "a" (list $dot) ))) "r") (get (fromJson (include "console.Service" (dict "a" (list $dot) ))) "r") (get (fromJson (include "console.Ingress" (dict "a" (list $dot) ))) "r") (get (fromJson (include "console.Deployment" (dict "a" (list $dot) ))) "r") (get (fromJson (include "console.HorizontalPodAutoscaler" (dict "a" (list $dot) ))) "r")) -}} | ||
{{- $_is_returning = true -}} | ||
{{- (dict "r" $manifests) | toJson -}} | ||
{{- break -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.