Skip to content

Commit

Permalink
Merge pull request #28 from hashicorp/f-source-channel
Browse files Browse the repository at this point in the history
Set source channel for CLI
  • Loading branch information
dadgar authored Mar 13, 2024
2 parents dbe7bf4 + 9bc0414 commit efb1fcc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 12 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/hashicorp/hcp/internal/pkg/format"
"github.com/hashicorp/hcp/internal/pkg/iostreams"
"github.com/hashicorp/hcp/internal/pkg/profile"
"github.com/hashicorp/hcp/version"
"github.com/mitchellh/cli"
"github.com/posener/complete"
)
Expand Down Expand Up @@ -104,7 +105,12 @@ func realMain() int {
return 1
}

hcpClient, err := httpclient.New(httpclient.Config{HCPConfig: hcpCfg})
hconfig := httpclient.Config{
HCPConfig: hcpCfg,
SourceChannel: getSourceChannel(),
}

hcpClient, err := httpclient.New(hconfig)
if err != nil {
fmt.Fprintf(io.Err(), "failed to create HCP API client: %v\n", err)
return 1
Expand Down Expand Up @@ -143,3 +149,8 @@ func realMain() int {

return status
}

// getSourceChannel returns the source channel for the CLI
func getSourceChannel() string {
return fmt.Sprintf("hcp-cli/%s", version.FullVersion())
}
7 changes: 6 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (
//go:embed VERSION
fullVersion string

Version, VersionPrerelease, _ = strings.Cut(strings.TrimSpace(fullVersion), "-")
Version, VersionPrerelease, _ = strings.Cut(FullVersion(), "-")
VersionMetadata = ""
)

Expand Down Expand Up @@ -52,3 +52,8 @@ func GetHumanVersion() string {

return version
}

// FullVersion returns the full version string including any prerelease tags.
func FullVersion() string {
return strings.TrimSpace(fullVersion)
}

0 comments on commit efb1fcc

Please sign in to comment.