Skip to content

Commit

Permalink
Report version correctly (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Feb 1, 2023
1 parent 7af24d6 commit c64df2c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/hc-install/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"os"

"github.com/hashicorp/hc-install/internal/version"
"github.com/hashicorp/hc-install/version"

"github.com/hashicorp/logutils"
"github.com/mitchellh/cli"
Expand All @@ -28,7 +28,7 @@ func main() {
},
}

c := cli.NewCLI("hc-install", version.ModuleVersion())
c := cli.NewCLI("hc-install", version.Version().String())
c.Args = os.Args[1:]
c.Commands = map[string]cli.CommandFactory{
"install": func() (cli.Command, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/httpclient/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
"net/http"

"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/hc-install/internal/version"
"github.com/hashicorp/hc-install/version"
)

// NewHTTPClient provides a pre-configured http.Client
// e.g. with relevant User-Agent header
func NewHTTPClient() *http.Client {
client := cleanhttp.DefaultClient()

userAgent := fmt.Sprintf("hc-install/%s", version.ModuleVersion())
userAgent := fmt.Sprintf("hc-install/%s", version.Version())

cli := cleanhttp.DefaultPooledClient()
cli.Transport = &userAgentRoundTripper{
Expand Down
9 changes: 0 additions & 9 deletions internal/version/version.go

This file was deleted.

1 change: 1 addition & 0 deletions version/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.4.0-dev
20 changes: 20 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package version

import (
_ "embed"

"github.com/hashicorp/go-version"
)

//go:embed VERSION
var rawVersion string

// Version returns the version of the library
//
// Note: This is only exposed as public function/package
// due to hard-coded constraints in the release tooling.
// In general downstream should not implement version-specific
// logic and rely on this function to be present in future releases.
func Version() *version.Version {
return version.Must(version.NewVersion(rawVersion))
}

0 comments on commit c64df2c

Please sign in to comment.