From 5c767744961273e7eb641009b2374146c1aff006 Mon Sep 17 00:00:00 2001 From: Tom Proctor <tomhjp@users.noreply.github.com> Date: Fri, 1 Mar 2024 14:44:01 +0000 Subject: [PATCH] Fix Vault imports + package names --- command/auth_test.go | 4 ++-- command/base.go | 11 ++++++----- command/base_predict.go | 3 ++- command/config.go | 20 ++++++++++---------- command/login_test.go | 4 ++-- command/main.go | 4 ++-- command/server.go | 4 ++-- command/util.go | 8 ++++---- go.mod | 2 +- go.sum | 4 ++-- 10 files changed, 33 insertions(+), 31 deletions(-) diff --git a/command/auth_test.go b/command/auth_test.go index e6c895df8fe1..615bc46aecab 100644 --- a/command/auth_test.go +++ b/command/auth_test.go @@ -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) { @@ -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(), }, } } diff --git a/command/base.go b/command/base.go index 5acd2227fa4f..ed9c76b82689 100644 --- a/command/base.go +++ b/command/base.go @@ -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" @@ -72,7 +73,7 @@ type BaseCommand struct { flagHeader map[string]string - tokenHelper token.TokenHelper + tokenHelper tokenhelper.TokenHelper hcpTokenHelper hcpvlib.HCPTokenHelper client *api.Client @@ -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 } diff --git a/command/base_predict.go b/command/base_predict.go index 72ba402fe97f..ed3edfa30f91 100644 --- a/command/base_predict.go +++ b/command/base_predict.go @@ -10,6 +10,7 @@ import ( "sync" "github.com/hashicorp/vault/api" + "github.com/hashicorp/vault/api/cliconfig" "github.com/posener/complete" ) @@ -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 } diff --git a/command/config.go b/command/config.go index 9a5ee7ac5700..11b7e863692f 100644 --- a/command/config.go +++ b/command/config.go @@ -4,7 +4,7 @@ package command import ( - "github.com/hashicorp/vault/command/config" + "github.com/hashicorp/vault/api/cliconfig" ) const ( @@ -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 @@ -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 } diff --git a/command/login_test.go b/command/login_test.go index 3f7c01d3c86e..238f93a4e481 100644 --- a/command/login_test.go +++ b/command/login_test.go @@ -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" ) @@ -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{}, diff --git a/command/main.go b/command/main.go index d6fad4b6c9ae..465ec5e6e864 100644 --- a/command/main.go +++ b/command/main.go @@ -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" ) @@ -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 diff --git a/command/server.go b/command/server.go index 6b79e405861f..28079258c716 100644 --- a/command/server.go +++ b/command/server.go @@ -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" @@ -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 } diff --git a/command/util.go b/command/util.go index 717191025d24..26fd38000b42 100644 --- a/command/util.go +++ b/command/util.go @@ -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 diff --git a/go.mod b/go.mod index 24b1790990f9..cf91ee14f4b4 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go.sum b/go.sum index d00da7b5adcc..af80468fb531 100644 --- a/go.sum +++ b/go.sum @@ -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=