util/useragent: use more verbose version
This commit is contained in:
parent
4e5a2d1646
commit
6b4e33a483
@ -4,19 +4,19 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// CertManagerUserAgent is the user agent that http clients in this codebase should use
|
||||
var CertManagerUserAgent = "jetstack-cert-manager/" + version()
|
||||
|
||||
// UserAgentRoundTripper implements the http.RoundTripper interface and adds a User-Agent
|
||||
// header.
|
||||
type userAgentRoundTripper struct {
|
||||
inner http.RoundTripper
|
||||
}
|
||||
|
||||
// CertManagerUserAgent is the user agent that http clients in this codebase should use
|
||||
const CertManagerUserAgent = "jetstack-cert-manager/" + AppVersion
|
||||
|
||||
// UserAgentRoundTripper returns a RoundTripper that functions identically to
|
||||
// the provided 'inner' round tripper, other than also setting a user agent.
|
||||
func UserAgentRoundTripper(inner http.RoundTripper) http.RoundTripper {
|
||||
return UserAgentRoundTripper{
|
||||
return userAgentRoundTripper{
|
||||
inner: inner,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,20 @@
|
||||
package util
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
AppGitState = ""
|
||||
AppGitCommit = ""
|
||||
AppVersion = "canary"
|
||||
)
|
||||
|
||||
func version() string {
|
||||
v := AppVersion
|
||||
if AppGitCommit != "" {
|
||||
v += "-" + AppGitCommit
|
||||
}
|
||||
if AppGitState != "" {
|
||||
v += fmt.Sprintf(" (%v)", AppGitState)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user