2023-03-28 22:48:58 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 22:48:58 +00:00
|
|
|
|
2018-04-05 02:13:54 +00:00
|
|
|
package lib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/version"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// projectURL is the project URL.
|
|
|
|
projectURL = "https://www.consul.io/"
|
|
|
|
|
|
|
|
// rt is the runtime - variable for tests.
|
|
|
|
rt = runtime.Version()
|
|
|
|
|
|
|
|
// versionFunc is the func that returns the current version. This is a
|
|
|
|
// function to take into account the different build processes and distinguish
|
|
|
|
// between enterprise and oss builds.
|
|
|
|
versionFunc = func() string {
|
|
|
|
return version.GetHumanVersion()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// UserAgent returns the consistent user-agent string for Consul.
|
|
|
|
func UserAgent() string {
|
|
|
|
return fmt.Sprintf("Consul/%s (+%s; %s)",
|
|
|
|
versionFunc(), projectURL, rt)
|
|
|
|
}
|