Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DefaultTokenHelper from github.com/hashicorp/vault/api/cliconfig (vault >=1.18) #94

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions timer/token_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions token/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions token/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions vault/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
Expand Down
Loading