Fix .chezmoi.yaml.tmpl: handle missing ID_LIKE on debian-stable
debian-stable's /etc/os-release has no ID_LIKE field. Template crashed with 'map has no entry for key idLike' when chezmoi init ran on rye. Two fixes: 1. hasKey() guard around .chezmoi.osRelease.idLike so missing key doesn't error out 2. Flip contains() arg order: sprig's signature is contains(substr, str), not contains(str, substr). Was checking backwards. Tested against: - miche (ID=debian-derivative with ID_LIKE=arch) -> os_family=arch - empty ID_LIKE fallback (debian-stable) -> falls through to .id=debian -> os_family=debian
This commit is contained in:
parent
ef9b7dcd2a
commit
0cc12f050a
1 changed files with 8 additions and 4 deletions
|
|
@ -1,7 +1,11 @@
|
|||
{{- $osFamily := "unknown" -}}
|
||||
{{- if eq .chezmoi.osRelease.idLike "arch" -}}
|
||||
{{- $idLike := "" -}}
|
||||
{{- if hasKey .chezmoi.osRelease "idLike" -}}
|
||||
{{- $idLike = .chezmoi.osRelease.idLike -}}
|
||||
{{- end -}}
|
||||
{{- if or (eq .chezmoi.osRelease.id "arch") (contains "arch" $idLike) -}}
|
||||
{{- $osFamily = "arch" -}}
|
||||
{{- else if or (eq .chezmoi.osRelease.id "debian") (eq .chezmoi.osRelease.idLike "debian") -}}
|
||||
{{- else if or (eq .chezmoi.osRelease.id "debian") (contains "debian" $idLike) -}}
|
||||
{{- $osFamily = "debian" -}}
|
||||
{{- end -}}
|
||||
encryption: "age"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue