From caa2e9352e0f22cb25ddf3830ac43434a9c22cb6 Mon Sep 17 00:00:00 2001 From: Till Kuhn Date: Mon, 9 Dec 2024 15:49:32 +0100 Subject: [PATCH] switch to github.com/hashicorp/vault/api/cliconfig (vault 1.18) --- go.mod | 6 +++++- go.sum | 2 ++ timer/token_timer.go | 4 ++-- token/handler.go | 4 ++-- token/handler_test.go | 4 ++-- vault/client.go | 4 ++-- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index b8f218a..585bf3f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,9 @@ module github.com/dbschenker/vaultpal -go 1.22.2 +go 1.22.5 + +toolchain go1.23.3 + // STILL NEEDED FOR INTELLIJ ? //replace github.com/SAP/go-hdb => github.com/SAP/go-hdb v1.8.11 @@ -147,6 +150,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/natefinch/atomic v1.0.1 // indirect github.com/oklog/run v1.1.0 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect diff --git a/go.sum b/go.sum index 7e34df2..5feda08 100644 --- a/go.sum +++ b/go.sum @@ -402,6 +402,8 @@ github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7P github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +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/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= diff --git a/timer/token_timer.go b/timer/token_timer.go index 5f402d6..41a24cf 100644 --- a/timer/token_timer.go +++ b/timer/token_timer.go @@ -15,7 +15,7 @@ import ( "github.com/fatih/color" "github.com/hashicorp/vault/api" - "github.com/hashicorp/vault/command/config" + "github.com/hashicorp/vault/api/cliconfig" ) const ( @@ -64,7 +64,7 @@ func Timer(bash bool, query bool, clear bool) { } func currentToken() (string, error) { - tokenHelper, err := config.DefaultTokenHelper() + tokenHelper, err := cliconfig.DefaultTokenHelper() if err != nil { return "", fmt.Errorf("error getting token helper: %s", err) } diff --git a/token/handler.go b/token/handler.go index fd4ca87..18274ac 100644 --- a/token/handler.go +++ b/token/handler.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/dbschenker/vaultpal/vault" "github.com/hashicorp/vault/api" - "github.com/hashicorp/vault/command/config" + "github.com/hashicorp/vault/api/cliconfig" "github.com/pkg/errors" log "github.com/sirupsen/logrus" ) @@ -19,7 +19,7 @@ func SwitchRole(role string) error { return errors.Wrap(err, "cannot create role token") } - tokenHelper, err := config.DefaultTokenHelper() + tokenHelper, err := cliconfig.DefaultTokenHelper() if err != nil { return fmt.Errorf("error getting token helper: %s", err) } diff --git a/token/handler_test.go b/token/handler_test.go index 0250615..169d3e3 100644 --- a/token/handler_test.go +++ b/token/handler_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" u "github.com/dbschenker/vaultpal/internal/testutil" "github.com/hashicorp/vault/api" - "github.com/hashicorp/vault/command/config" + "github.com/hashicorp/vault/api/cliconfig" "github.com/stretchr/testify/assert" "io/ioutil" "net/http" @@ -163,7 +163,7 @@ func TestSwitchTokenRoleWrite(t *testing.T) { err := SwitchRole(test.role) assert.Nil(t, err) - tokenHelper, err := config.DefaultTokenHelper() + tokenHelper, err := cliconfig.DefaultTokenHelper() token, err := tokenHelper.Get() assert.Equal(t, test.WantRoleToken, token) } diff --git a/vault/client.go b/vault/client.go index 35a0e59..84a61cb 100644 --- a/vault/client.go +++ b/vault/client.go @@ -3,7 +3,7 @@ package vault import ( "fmt" "github.com/hashicorp/vault/api" - "github.com/hashicorp/vault/command/config" + "github.com/hashicorp/vault/api/cliconfig" "github.com/pkg/errors" "net/url" "os" @@ -17,7 +17,7 @@ func NewClient() (*api.Client, error) { // if unset, fallback to ~/.vault-token or external token helper token := os.Getenv(api.EnvVaultToken) if token == "" { - tokenHelper, err := config.DefaultTokenHelper() + tokenHelper, err := cliconfig.DefaultTokenHelper() if err != nil { return nil, fmt.Errorf("error getting token helper: %s", err) }