mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-14 10:37:00 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
111 lines
3.7 KiB
Go
111 lines
3.7 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
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.
|
|
//
|
|
// e.g. Vault/0.10.4 (+https://www.vaultproject.io/; go1.10.1)
|
|
func String() string {
|
|
return fmt.Sprintf("Vault/%s (+%s; %s)",
|
|
versionFunc(), projectURL, rt)
|
|
}
|
|
|
|
// AgentString returns the consistent user-agent string for Vault Agent.
|
|
//
|
|
// e.g. Vault Agent/0.10.4 (+https://www.vaultproject.io/; go1.10.1)
|
|
func AgentString() string {
|
|
return fmt.Sprintf("Vault Agent/%s (+%s; %s)",
|
|
versionFunc(), projectURL, rt)
|
|
}
|
|
|
|
// AgentTemplatingString returns the consistent user-agent string for Vault Agent Templating.
|
|
//
|
|
// e.g. Vault Agent Templating/0.10.4 (+https://www.vaultproject.io/; go1.10.1)
|
|
func AgentTemplatingString() string {
|
|
return fmt.Sprintf("Vault Agent Templating/%s (+%s; %s)",
|
|
versionFunc(), projectURL, rt)
|
|
}
|
|
|
|
// AgentProxyString returns the consistent user-agent string for Vault Agent API Proxying.
|
|
//
|
|
// e.g. Vault Agent API Proxy/0.10.4 (+https://www.vaultproject.io/; go1.10.1)
|
|
func AgentProxyString() string {
|
|
return fmt.Sprintf("Vault Agent API Proxy/%s (+%s; %s)",
|
|
versionFunc(), projectURL, rt)
|
|
}
|
|
|
|
// AgentProxyStringWithProxiedUserAgent returns the consistent user-agent
|
|
// string for Vault Agent API Proxying, keeping the User-Agent of the proxied
|
|
// client as an extension to this UserAgent
|
|
//
|
|
// e.g. Vault Agent API Proxy/0.10.4 (+https://www.vaultproject.io/; go1.10.1); proxiedUserAgent
|
|
func AgentProxyStringWithProxiedUserAgent(proxiedUserAgent string) string {
|
|
return fmt.Sprintf("Vault Agent API Proxy/%s (+%s; %s); %s",
|
|
versionFunc(), projectURL, rt, proxiedUserAgent)
|
|
}
|
|
|
|
// AgentAutoAuthString returns the consistent user-agent string for Vault Agent Auto-Auth.
|
|
//
|
|
// e.g. Vault Agent Auto-Auth/0.10.4 (+https://www.vaultproject.io/; go1.10.1)
|
|
func AgentAutoAuthString() string {
|
|
return fmt.Sprintf("Vault Agent Auto-Auth/%s (+%s; %s)",
|
|
versionFunc(), projectURL, rt)
|
|
}
|
|
|
|
// ProxyString returns the consistent user-agent string for Vault Proxy.
|
|
//
|
|
// e.g. Vault Proxy/0.10.4 (+https://www.vaultproject.io/; go1.10.1)
|
|
func ProxyString() string {
|
|
return fmt.Sprintf("Vault Proxy/%s (+%s; %s)",
|
|
versionFunc(), projectURL, rt)
|
|
}
|
|
|
|
// ProxyAPIProxyString returns the consistent user-agent string for Vault Proxy API Proxying.
|
|
//
|
|
// e.g. Vault Proxy API Proxy/0.10.4 (+https://www.vaultproject.io/; go1.10.1)
|
|
func ProxyAPIProxyString() string {
|
|
return fmt.Sprintf("Vault Proxy API Proxy/%s (+%s; %s)",
|
|
versionFunc(), projectURL, rt)
|
|
}
|
|
|
|
// ProxyStringWithProxiedUserAgent returns the consistent user-agent
|
|
// string for Vault Proxy API Proxying, keeping the User-Agent of the proxied
|
|
// client as an extension to this UserAgent
|
|
//
|
|
// e.g. Vault Proxy API Proxy/0.10.4 (+https://www.vaultproject.io/; go1.10.1); proxiedUserAgent
|
|
func ProxyStringWithProxiedUserAgent(proxiedUserAgent string) string {
|
|
return fmt.Sprintf("Vault Proxy API Proxy/%s (+%s; %s); %s",
|
|
versionFunc(), projectURL, rt, proxiedUserAgent)
|
|
}
|
|
|
|
// ProxyAutoAuthString returns the consistent user-agent string for Vault Agent Auto-Auth.
|
|
//
|
|
// e.g. Vault Proxy Auto-Auth/0.10.4 (+https://www.vaultproject.io/; go1.10.1)
|
|
func ProxyAutoAuthString() string {
|
|
return fmt.Sprintf("Vault Proxy Auto-Auth/%s (+%s; %s)",
|
|
versionFunc(), projectURL, rt)
|
|
}
|