diff options
Diffstat (limited to 'pkg/config/version')
-rw-r--r-- | pkg/config/version/genver/main.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pkg/config/version/genver/main.go b/pkg/config/version/genver/main.go index e0d80b0..d4b72d8 100644 --- a/pkg/config/version/genver/main.go +++ b/pkg/config/version/genver/main.go @@ -3,6 +3,7 @@ package main import ( "flag" "io" + "io/ioutil" "log" "os" "os/exec" @@ -43,7 +44,7 @@ func main() { vers, err := GitDescribe(dir) if err != nil { - log.Fatal(err) + vers = ReadVersionFile(dir) } vp := VersionPackage{ Name: *flPackageName, @@ -70,7 +71,7 @@ var packageLayout = `package {{.Name}} // AUTO-GENERATED. DO NOT EDIT // {{.Date}} -// {{.Variable}} is generated by git-describe from gen.go +// {{.Variable}} is generated by git-describe or static version file from gen.go var {{.Variable}} = "{{.Version}}" ` @@ -93,3 +94,12 @@ func GitDescribe(path string) (string, error) { return strings.TrimSpace(string(buf)), nil } + +func ReadVersionFile(path string) string { + versionFile := filepath.Join(path, "../../../version") + content, err := ioutil.ReadFile(versionFile) + if err != nil { + return "unknown" + } + return strings.Trim(string(content), "\n") +} |