Merge pull request #1140 from anderbubble/sprig-substr
Replace slice in templates with sprig substr
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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 -}}
|
||||
|
||||
@@ -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 -}}
|
||||
|
||||
@@ -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 -}}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user