Skip to content

Commit 65c2c32

Browse files
fix(init): conditionally set version in /etc/os-release (#97)
1 parent 63a0728 commit 65c2c32

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

initramfs/.conform.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ tasks:
6868
-o /{{ .Docker.CurrentStage }}-darwin-amd64
6969
{{ else }}
7070
RUN GOOS=linux GOARCH=amd64 go build -a \
71-
-ldflags "-s -w -X {{ index .Variables "versionPath" }}.Name=Client -X {{ index .Variables "versionPath" }}.Tag=none -X {{ index .Variables "versionPath" }}.SH={{ .Git.SHA }}" \
71+
-ldflags "-s -w -X {{ index .Variables "versionPath" }}.Name=Client -X {{ index .Variables "versionPath" }}.Tag=none -X {{ index .Variables "versionPath" }}.SHA={{ .Git.SHA }}" \
7272
-o /{{ .Docker.CurrentStage }}-linux-amd64
7373
RUN GOOS=darwin GOARCH=amd64 go build -a \
74-
-ldflags "-s -w -X {{ index .Variables "versionPath" }}.Name=Client -X {{ index .Variables "versionPath" }}.Tag=none -X {{ index .Variables "versionPath" }}.SH={{ .Git.SHA }}" \
74+
-ldflags "-s -w -X {{ index .Variables "versionPath" }}.Name=Client -X {{ index .Variables "versionPath" }}.Tag=none -X {{ index .Variables "versionPath" }}.SHA={{ .Git.SHA }}" \
7575
-o /{{ .Docker.CurrentStage }}-darwin-amd64
7676
{{ end }}
7777
RUN chmod +x /{{ .Docker.CurrentStage }}-linux-amd64

initramfs/cmd/init/pkg/rootfs/etc/etc.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,21 @@ func ResolvConf(s string) (err error) {
7373
// OSRelease renders a valid /etc/os-release file and writes it to disk. The
7474
// node's OS Image field is reported by the node from /etc/os-release.
7575
func OSRelease(s string) (err error) {
76+
var v string
77+
switch version.Tag {
78+
case "none":
79+
v = version.SHA
80+
default:
81+
v = version.Tag
82+
}
7683
data := struct {
7784
Name string
7885
ID string
7986
Version string
8087
}{
8188
Name: version.Name,
8289
ID: strings.ToLower(version.Name),
83-
Version: version.Tag,
90+
Version: v,
8491
}
8592

8693
tmpl, err := template.New("").Parse(osReleaseTemplate)

0 commit comments

Comments
 (0)