Skip to content

Commit

Permalink
chore: fix generation for peering CRDs
Browse files Browse the repository at this point in the history
  • Loading branch information
DanStough committed Jan 27, 2023
1 parent 47049bf commit 55af66b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions hack/copy-crds-to-chart/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import (
"strings"
)

var (
// HACK IT!
requiresPeering = map[string]struct{}{
"consul.hashicorp.com_peeringacceptors.yaml": {},
"consul.hashicorp.com_peeringdialers.yaml": {},
}
)

func main() {
if len(os.Args) != 1 {
fmt.Println("Usage: go run ./...")
Expand Down Expand Up @@ -43,8 +51,13 @@ func realMain(helmPath string) error {
// Strip leading newline.
contents = strings.TrimPrefix(contents, "\n")

// Add {{- if .Values.connectInject.enabled }} {{- end }} wrapper.
contents = fmt.Sprintf("{{- if .Values.connectInject.enabled }}\n%s{{- end }}\n", contents)
if _, ok := requiresPeering[info.Name()]; ok {
// Add {{- if and .Values.connectInject.enabled .Values.global.peering.enabled }} {{- end }} wrapper.
contents = fmt.Sprintf("{{- if and .Values.connectInject.enabled .Values.global.peering.enabled }}\n%s{{- end }}\n", contents)
} else {
// Add {{- if .Values.connectInject.enabled }} {{- end }} wrapper.
contents = fmt.Sprintf("{{- if .Values.connectInject.enabled }}\n%s{{- end }}\n", contents)
}

// Add labels, this is hacky because we're relying on the line number
// but it means we don't need to regex or yaml parse.
Expand Down

0 comments on commit 55af66b

Please sign in to comment.