Skip to content

Commit

Permalink
Fix Vault imports + package names
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhjp committed Mar 1, 2024
1 parent 9d289fd commit 5c76774
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 31 deletions.
4 changes: 2 additions & 2 deletions command/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/hashicorp/cli"
"github.com/hashicorp/vault/command/token"
"github.com/hashicorp/vault/api/tokenhelper"
)

func testAuthCommand(tb testing.TB) (*cli.MockUi, *AuthCommand) {
Expand All @@ -19,7 +19,7 @@ func testAuthCommand(tb testing.TB) (*cli.MockUi, *AuthCommand) {
UI: ui,

// Override to our own token helper
tokenHelper: token.NewTestingTokenHelper(),
tokenHelper: tokenhelper.NewTestingTokenHelper(),
},
}
}
Expand Down
11 changes: 6 additions & 5 deletions command/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
"github.com/hashicorp/cli"
hcpvlib "github.com/hashicorp/vault-hcp-lib"
"github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/api/cliconfig"
"github.com/hashicorp/vault/api/tokenhelper"
"github.com/hashicorp/vault/command/config"
"github.com/hashicorp/vault/command/token"
"github.com/hashicorp/vault/helper/namespace"
"github.com/mattn/go-isatty"
"github.com/pkg/errors"
Expand Down Expand Up @@ -72,7 +73,7 @@ type BaseCommand struct {

flagHeader map[string]string

tokenHelper token.TokenHelper
tokenHelper tokenhelper.TokenHelper
hcpTokenHelper hcpvlib.HCPTokenHelper

client *api.Client
Expand Down Expand Up @@ -248,17 +249,17 @@ func (c *BaseCommand) SetAddress(addr string) {
}

// SetTokenHelper sets the token helper on the command.
func (c *BaseCommand) SetTokenHelper(th token.TokenHelper) {
func (c *BaseCommand) SetTokenHelper(th tokenhelper.TokenHelper) {
c.tokenHelper = th
}

// TokenHelper returns the token helper attached to the command.
func (c *BaseCommand) TokenHelper() (token.TokenHelper, error) {
func (c *BaseCommand) TokenHelper() (tokenhelper.TokenHelper, error) {
if c.tokenHelper != nil {
return c.tokenHelper, nil
}

helper, err := DefaultTokenHelper()
helper, err := cliconfig.DefaultTokenHelper()
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion command/base_predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sync"

"github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/api/cliconfig"
"github.com/posener/complete"
)

Expand All @@ -28,7 +29,7 @@ func (p *Predict) Client() *api.Client {
client, _ := api.NewClient(nil)

if client.Token() == "" {
helper, err := DefaultTokenHelper()
helper, err := cliconfig.DefaultTokenHelper()
if err != nil {
return
}
Expand Down
20 changes: 10 additions & 10 deletions command/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package command

import (
"github.com/hashicorp/vault/command/config"
"github.com/hashicorp/vault/api/cliconfig"
)

const (
Expand All @@ -31,9 +31,9 @@ type DefaultConfig struct {
//
// Config just calls into config.Config for backwards compatibility purposes.
// Use config.Config instead.
func Config() (*DefaultConfig, error) {
conf, err := config.Config()
return (*DefaultConfig)(conf), err
func Config() (*cliconfig.DefaultConfig, error) {
conf, err := cliconfig.Config()
return (*cliconfig.DefaultConfig)(conf), err
}

// LoadConfig reads the configuration from the given path. If path is
Expand All @@ -42,16 +42,16 @@ func Config() (*DefaultConfig, error) {
//
// LoadConfig just calls into config.LoadConfig for backwards compatibility
// purposes. Use config.LoadConfig instead.
func LoadConfig(path string) (*DefaultConfig, error) {
conf, err := config.LoadConfig(path)
return (*DefaultConfig)(conf), err
func LoadConfig(path string) (*cliconfig.DefaultConfig, error) {
conf, err := cliconfig.LoadConfig(path)
return (*cliconfig.DefaultConfig)(conf), err
}

// ParseConfig parses the given configuration as a string.
//
// ParseConfig just calls into config.ParseConfig for backwards compatibility
// purposes. Use config.ParseConfig instead.
func ParseConfig(contents string) (*DefaultConfig, error) {
conf, err := config.ParseConfig(contents)
return (*DefaultConfig)(conf), err
func ParseConfig(contents string) (*cliconfig.DefaultConfig, error) {
conf, err := cliconfig.ParseConfig(contents)
return (*cliconfig.DefaultConfig)(conf), err
}
4 changes: 2 additions & 2 deletions command/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/hashicorp/cli"
"github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/api/tokenhelper"
credToken "github.com/hashicorp/vault/builtin/credential/token"
credUserpass "github.com/hashicorp/vault/builtin/credential/userpass"
"github.com/hashicorp/vault/command/token"
"github.com/hashicorp/vault/helper/testhelpers"
"github.com/hashicorp/vault/vault"
)
Expand All @@ -33,7 +33,7 @@ func testLoginCommand(tb testing.TB) (*cli.MockUi, *LoginCommand) {
UI: ui,

// Override to our own token helper
tokenHelper: token.NewTestingTokenHelper(),
tokenHelper: tokenhelper.NewTestingTokenHelper(),
},
Handlers: map[string]LoginHandler{
"token": &credToken.CLIHandler{},
Expand Down
4 changes: 2 additions & 2 deletions command/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/hashicorp/cli"
hcpvlib "github.com/hashicorp/vault-hcp-lib"
"github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/command/token"
"github.com/hashicorp/vault/api/tokenhelper"
"github.com/mattn/go-colorable"
)

Expand Down Expand Up @@ -135,7 +135,7 @@ func getGlobalFlagValue(arg string) string {
}

type RunOptions struct {
TokenHelper token.TokenHelper
TokenHelper tokenhelper.TokenHelper
HCPTokenHelper hcpvlib.HCPTokenHelper
Stdout io.Writer
Stderr io.Writer
Expand Down
4 changes: 2 additions & 2 deletions command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import (
"github.com/hashicorp/go-secure-stdlib/mlock"
"github.com/hashicorp/go-secure-stdlib/parseutil"
"github.com/hashicorp/go-secure-stdlib/reloadutil"
"github.com/hashicorp/vault/api/cliconfig"
"github.com/hashicorp/vault/audit"
config2 "github.com/hashicorp/vault/command/config"
"github.com/hashicorp/vault/command/server"
"github.com/hashicorp/vault/helper/builtinplugins"
"github.com/hashicorp/vault/helper/constants"
Expand Down Expand Up @@ -3293,7 +3293,7 @@ func startHttpServers(c *ServerCommand, core *vault.Core, config *server.Config,
return fmt.Errorf("Found nil listener config after parsing")
}

if err := config2.IsValidListener(ln.Config); err != nil {
if err := cliconfig.IsValidListener(ln.Config.TLSDisable); err != nil {
return err
}

Expand Down
8 changes: 4 additions & 4 deletions command/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
"github.com/hashicorp/cli"
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/command/config"
"github.com/hashicorp/vault/command/token"
"github.com/hashicorp/vault/api/cliconfig"
"github.com/hashicorp/vault/api/tokenhelper"
)

// DefaultTokenHelper returns the token helper that is configured for Vault.
// This helper should only be used for non-server CLI commands.
func DefaultTokenHelper() (token.TokenHelper, error) {
return config.DefaultTokenHelper()
func DefaultTokenHelper() (tokenhelper.TokenHelper, error) {
return cliconfig.DefaultTokenHelper()
}

// RawField extracts the raw field from the given data and returns it as a
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ require (
github.com/mitchellh/go-wordwrap v1.0.1
github.com/mitchellh/mapstructure v1.5.0
github.com/mitchellh/reflectwalk v1.0.2
github.com/natefinch/atomic v0.0.0-20150920032501-a62ce929ffcc
github.com/ncw/swift v1.0.47
github.com/oklog/run v1.1.0
github.com/okta/okta-sdk-golang/v2 v2.12.1
Expand Down Expand Up @@ -464,6 +463,7 @@ require (
github.com/montanaflynn/stats v0.7.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/natefinch/atomic v1.0.1 // indirect
github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 // indirect
github.com/nwaples/rardecode v1.1.2 // indirect
github.com/oklog/ulid v1.3.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2969,8 +2969,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/natefinch/atomic v0.0.0-20150920032501-a62ce929ffcc h1:7xGrl4tTpBQu5Zjll08WupHyq+Sp0Z/adtyf1cfk3Q8=
github.com/natefinch/atomic v0.0.0-20150920032501-a62ce929ffcc/go.mod h1:1rLVY/DWf3U6vSZgH16S7pymfrhK2lcUlXjgGglw/lY=
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM=
github.com/ncw/swift v1.0.47 h1:4DQRPj35Y41WogBxyhOXlrI37nzGlyEcsforeudyYPQ=
github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
github.com/networkplumbing/go-nft v0.2.0/go.mod h1:HnnM+tYvlGAsMU7yoYwXEVLLiDW9gdMmb5HoGcwpuQs=
Expand Down

0 comments on commit 5c76774

Please sign in to comment.