Skip to content

Commit

Permalink
Rip off the bandaid and drop sdk/version altogether.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncabatoff committed Dec 1, 2022
1 parent 79d2ee2 commit 019638b
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 175 deletions.
4 changes: 4 additions & 0 deletions changelog/14229.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:change
core: Vault version has been moved out of sdk and into main vault module.
Plugins using sdk/useragent.String must instead use sdk/useragent.PluginString.
```
29 changes: 0 additions & 29 deletions sdk/helper/useragent/useragent.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"github.com/hashicorp/vault/sdk/logical"
"github.com/hashicorp/vault/sdk/version"
)

var (
Expand All @@ -15,36 +14,8 @@ var (

// 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)
//
// Given comments will be appended to the semicolon-delimited comment section.
//
// e.g. Vault/0.10.4 (+https://www.vaultproject.io/; go1.10.1; comment-0; comment-1)
//
// Deprecated: use PluginString instead.
// At one point the user-agent string returned contained the Vault
// version hardcoded into the vault/sdk/version/ package. This works for builtin
// plugins that are compiled into the `vault` binary, in that it correctly described
// the version of that Vault binary. It does not work for external plugins: for them,
// the version will be based on the version stored in the sdk based on the
// contents of the external plugin's go.mod. Now that we're no longer updating
// the version in vault/sdk/version/, it is even less meaningful than ever.
func String(comments ...string) string {
c := append([]string{"+" + projectURL, rt}, comments...)
return fmt.Sprintf("Vault/%s (%s)", versionFunc(), strings.Join(c, "; "))
}

// PluginString is usable by plugins to return a user-agent string reflecting
// the running Vault version and an optional plugin name.
//
Expand Down
42 changes: 0 additions & 42 deletions sdk/helper/useragent/useragent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,6 @@ import (
"github.com/hashicorp/vault/sdk/logical"
)

func TestUserAgent(t *testing.T) {
projectURL = "https://vault-test.com"
rt = "go5.0"
versionFunc = func() string { return "1.2.3" }

type args struct {
comments []string
}
tests := []struct {
name string
args args
want string
}{
{
name: "User agent",
args: args{},
want: "Vault/1.2.3 (+https://vault-test.com; go5.0)",
},
{
name: "User agent with additional comment",
args: args{
comments: []string{"pid-abcdefg"},
},
want: "Vault/1.2.3 (+https://vault-test.com; go5.0; pid-abcdefg)",
},
{
name: "User agent with additional comments",
args: args{
comments: []string{"pid-abcdefg", "cloud-provider"},
},
want: "Vault/1.2.3 (+https://vault-test.com; go5.0; pid-abcdefg; cloud-provider)",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := String(tt.args.comments...); got != tt.want {
t.Errorf("String() = %v, want %v", got, tt.want)
}
})
}
}

func TestUserAgentPlugin(t *testing.T) {
projectURL = "https://vault-test.com"
rt = "go5.0"
Expand Down
7 changes: 0 additions & 7 deletions sdk/version/cgo.go

This file was deleted.

80 changes: 0 additions & 80 deletions sdk/version/version.go

This file was deleted.

17 changes: 0 additions & 17 deletions sdk/version/version_base.go

This file was deleted.

0 comments on commit 019638b

Please sign in to comment.