Skip to content

Docs: Missing {{ end }} blocks in Go template for local Kind install guide #1754

Description

@mickotronic

Issue description

Section: "Configure external access to Redpanda"

Issue: The kubectl Go template command used to add /etc/hosts mappings is missing two {{end}} closing blocks, causing the command to fail.

The current (broken) command ends with:

...{{ end }}{{ end }}{{ end }}{{ end }}{{ end }}'

There used to be 7 closers, but now there are 5. It was changed as part of this PR:
https://github.com/redpanda-data/docs/pull/1304/changes#diff-81b46a7b72fbeb9d86aef902c2e6fbb8eae9908f015b683fab9734b816aedbb8L468

And running the command with the template as per the docs results in the following error:

template: output:1: unexpected EOF

This can be independently verified using Go text/template to parse:

cat > check_template.go << 'EOF'
package main
import (
    "os"
    "text/template"
)
func main() {
    b, _ := os.ReadFile(os.Args[1])
    _, err := template.New("t").Parse(string(b))
    if err != nil { println("INVALID:", err.Error()); os.Exit(1) }
    println("VALID")
}
EOF

cat > tmpl_broken.txt << 'EOF'
{{ range $_ := .items }}{{ if and (eq .kind "Endpoints") (eq .metadata.name "redpanda-external") }}{{ range $_ := (index .subsets 0).addresses }}{{ $nodeName := .nodeName }}{{ $podName := .targetRef.name }}{{ range $node := $.items }}{{ if and (eq .kind "Node") (eq .metadata.name $nodeName) }}{{ range $_ := .status.addresses }}{{ if eq .type "InternalIP" }}{{ .address }} {{ $podName }}.customredpandadomain.local{{ "\n" }}{{ end }}{{ end }}{{ end }}{{ end }}{{ end }}
EOF

cat > tmpl_fixed.txt << 'EOF'
{{ range $_ := .items }}{{ if and (eq .kind "Endpoints") (eq .metadata.name "redpanda-external") }}{{ range $_ := (index .subsets 0).addresses }}{{ $nodeName := .nodeName }}{{ $podName := .targetRef.name }}{{ range $node := $.items }}{{ if and (eq .kind "Node") (eq .metadata.name $nodeName) }}{{ range $_ := .status.addresses }}{{ if eq .type "InternalIP" }}{{ .address }} {{ $podName }}.customredpandadomain.local{{ "\n" }}{{ end }}{{ end }}{{ end }}{{ end }}{{ end }}{{ end }}{{ end }}
EOF

go run check_template.go tmpl_broken.txt
go run check_template.go tmpl_fixed.txt

You'll notice that the template with the additional closing {{ end }} blocks is parsed correctly.

Updates to existing documentation

https://docs.redpanda.com/streaming/current/deploy/redpanda/kubernetes/local-guide/

Link to Redpanda Slack conversation

No response

Checks

  • New feature
  • Content gap
  • Support Follow-up
  • Small fix (typos, links, copyedits, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions