Skip to content

Commit 406d305

Browse files
authored
Adding commit sha to version information (#65)
* Adding commit sha to information displayed when binary executed with -version flag * Removed version descriptor from information returned from passing -version flag
1 parent 66d2616 commit 406d305

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

cmd/tfplugingen-openapi/main.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,28 @@ package main
66
import (
77
"io"
88
"os"
9+
"runtime/debug"
910

10-
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/cmd"
11+
"github.com/mattn/go-colorable"
1112
"github.com/mitchellh/cli"
1213

13-
"github.com/mattn/go-colorable"
14+
"github.com/hashicorp/terraform-plugin-codegen-openapi/internal/cmd"
1415
)
1516

17+
// version will be set by goreleaser via ldflags
18+
// https://goreleaser.com/cookbooks/using-main.version/
1619
func main() {
1720
name := "tfplugingen-openapi"
18-
version := name + " Version " + version
19-
if commit != "" {
20-
version += " from commit " + commit
21-
}
21+
version := name + " commit: " + func() string {
22+
if info, ok := debug.ReadBuildInfo(); ok {
23+
for _, setting := range info.Settings {
24+
if setting.Key == "vcs.revision" {
25+
return setting.Value
26+
}
27+
}
28+
}
29+
return "local"
30+
}()
2231

2332
os.Exit(runCLI(
2433
name,

cmd/tfplugingen-openapi/version.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)