Skip to content

Commit

Permalink
Remove the last vestiges of sdk/version. (#19068)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncabatoff committed Feb 8, 2023
1 parent aaa50f1 commit e0d726a
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 127 deletions.
3 changes: 3 additions & 0 deletions changelog/19068.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:change
sdk: Remove version package, make useragent.String versionless.
```
2 changes: 1 addition & 1 deletion internal/go118_sha1_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
_ "unsafe" // for go:linkname

goversion "github.com/hashicorp/go-version"
"github.com/hashicorp/vault/sdk/version"
"github.com/hashicorp/vault/version"
)

const sha1PatchVersionsBefore = "1.12.0"
Expand Down
28 changes: 11 additions & 17 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,34 +14,29 @@ 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.
// Deprecated: use PluginString instead.
//
// e.g. Vault/0.10.4 (+https://www.vaultproject.io/; go1.10.1)
// Example output:
//
// Given comments will be appended to the semicolon-delimited comment section.
// Vault (+https://www.vaultproject.io/; go1.19.5)
//
// e.g. Vault/0.10.4 (+https://www.vaultproject.io/; go1.10.1; comment-0; comment-1)
// Given comments will be appended to the semicolon-delimited comment section:
//
// Vault (+https://www.vaultproject.io/; go1.19.5; 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
// version hardcoded into the vault/sdk/version/ package. This worked 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 of that Vault binary. It did 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.
// contents of the external plugin's go.mod. We've kept the String method around
// to avoid breaking builds, but you should be using PluginString.
func String(comments ...string) string {
c := append([]string{"+" + projectURL, rt}, comments...)
return fmt.Sprintf("Vault/%s (%s)", versionFunc(), strings.Join(c, "; "))
return fmt.Sprintf("Vault (%s)", strings.Join(c, "; "))
}

// PluginString is usable by plugins to return a user-agent string reflecting
Expand Down
7 changes: 3 additions & 4 deletions sdk/helper/useragent/useragent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
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
Expand All @@ -22,21 +21,21 @@ func TestUserAgent(t *testing.T) {
{
name: "User agent",
args: args{},
want: "Vault/1.2.3 (+https://vault-test.com; go5.0)",
want: "Vault (+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)",
want: "Vault (+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)",
want: "Vault (+https://vault-test.com; go5.0; pid-abcdefg; cloud-provider)",
},
}
for _, tt := range tests {
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.

2 changes: 1 addition & 1 deletion vault/hcp_link/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
linkConfig "github.com/hashicorp/hcp-link/pkg/config"
scada "github.com/hashicorp/hcp-scada-provider"
"github.com/hashicorp/vault/internalshared/configutil"
vaultVersion "github.com/hashicorp/vault/sdk/version"
"github.com/hashicorp/vault/vault"
"github.com/hashicorp/vault/vault/hcp_link/capabilities"
"github.com/hashicorp/vault/vault/hcp_link/capabilities/api_capability"
"github.com/hashicorp/vault/vault/hcp_link/capabilities/link_control"
"github.com/hashicorp/vault/vault/hcp_link/capabilities/meta"
"github.com/hashicorp/vault/vault/hcp_link/capabilities/node_status"
"github.com/hashicorp/vault/vault/hcp_link/internal"
vaultVersion "github.com/hashicorp/vault/version"
)

const (
Expand Down

0 comments on commit e0d726a

Please sign in to comment.