open-vault/helper/useragent/useragent.go
Seth Vargo b5e4db975e Add useragent helper (#3991)
* Add useragent package

This helper provides a consistent user-agent header for Vault, taking into account different versions.

* Add user-agent headers to spanner and gcs
2018-02-15 18:30:31 -05:00

30 lines
680 B
Go

package useragent
import (
"fmt"
"runtime"
"github.com/hashicorp/vault/version"
)
var (
// projectURL is the project URL.
projectURL = "https://www.vaultproject.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.GetVersion().VersionNumber()
}
)
// String returns the consistent user-agent string for Vault.
func String() string {
return fmt.Sprintf("Vault/%s (+%s; %s)",
versionFunc(), projectURL, rt)
}