Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report version correctly #97

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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))
}