Replace slice in templates with sprig substr

sprig replaces slice with a function that only operates on sprig lists.
substr is required for use with strings.

- Fixes: #1139

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-03-16 12:43:17 -06:00
parent 41d30332d2
commit 7099b08db5
6 changed files with 7 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`/sys/firmware/devicetree/base/serial-number`
- Fix `wwctl profile list -a` format when kernerargs are set
- Fix a rendering bug in the documentation for GRUB boot support. #1132
- Replace slice in templates with sprig substr. #1093
## [4.5.0] 2024-02-08

View File

@@ -67,7 +67,7 @@ gateway={{ $netdev.Gateway }}
method=manual
{{- $dns := "" }}
{{range $tk, $tv := $netdev.Tags -}}
{{ $prefix := slice $tk 0 3 -}}
{{ $prefix := substr 0 3 $tk -}}
{{ if eq $prefix "DNS" -}}
{{ $dns = print $dns $tv ";" -}}
{{ end -}}

View File

@@ -7,7 +7,7 @@
# Source: {{ $source }}
{{range $devname, $netdev := .NetDevs -}}
{{range $tk, $tv := $netdev.Tags -}}
{{ $prefix := slice $tk 0 3 -}}
{{ $prefix := substr 0 3 $tk -}}
{{ if eq $prefix "DNS" -}}
nameserver {{ $tv }}
{{ end -}}

View File

@@ -38,7 +38,7 @@ IPV6_FAILURE_FATAL=no
IPV6ADDR="{{ $netdev.Ipaddr6 }}"
{{ end -}}
{{range $tk, $tv := $netdev.Tags -}}
{{ $prefix := slice $tk 0 3 -}}
{{ $prefix := substr 0 3 $tk -}}
{{ if eq $prefix "DNS" -}}
{{ $tk }}={{ $tv }}
{{ end -}}

View File

@@ -13,14 +13,14 @@ Requisite=ignition-ww4-disks.service
{{- $prefix := $fsdevice }}
{{- $prefix = replace "-" "\\x2d" $fsdevice }}
{{- $prefix = replace "/" "-" $prefix }}
{{- $prefix = slice $prefix 1 }}{{ $suffix := "mount" }}
{{- $prefix = substr 1 -1 $prefix }}{{ $suffix := "mount" }}
{{- if eq $fs.Format "swap"}}
{{- $prefix = replace "/dev/disk/by-partlabel/" "dev-disk-by\\x2dpartlabel-" $fsdevice }}{{ $suffix = "swap"}}
{{- else }}
{{- if ne $fs.Path "" }}
{{- $prefix = replace "-" "\\x2d" $fs.Path }}
{{- $prefix = replace "/" "-" $prefix }}
{{- $prefix = slice $prefix 1 }}
{{- $prefix = substr 1 -1 $prefix }}
{{- end }}
{{- end }}
Wants={{ print $prefix "." $suffix }}

View File

@@ -4,7 +4,7 @@
{{- range $fsdevice,$fs := .FileSystems }}
{{- $prefix := replace "-" "\\x2d" $fs.Path }}
{{- $prefix = replace "/" "-" $prefix }}
{{- $prefix = slice $prefix 1 }}
{{- $prefix = substr 1 -1 $prefix }}
{{ $suffix := "mount"}}
{{- if $fs.Label }}{{ $prefix = $fs.Label }}{{ end }}
{{- if eq $fs.Format "swap" }}{{ $prefix = replace "/dev/disk/by-partlabel/" "dev-disk-by\\x2dpartlabel-" $fsdevice }}{{ $suffix = "swap" }}{{ end }}