From ea9d7e8d4e85f65d15b2dc713279825a0c0d0fb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:21:20 +0000 Subject: [PATCH] chore(deps): Bump github.com/jacobbrewer1/vaulty from 0.1.4 to 0.1.5 Bumps [github.com/jacobbrewer1/vaulty](https://github.com/jacobbrewer1/vaulty) from 0.1.4 to 0.1.5. - [Release notes](https://github.com/jacobbrewer1/vaulty/releases) - [Commits](https://github.com/jacobbrewer1/vaulty/compare/v0.1.4...v0.1.5) --- updated-dependencies: - dependency-name: github.com/jacobbrewer1/vaulty dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +-- .../github.com/jacobbrewer1/vaulty/client.go | 33 ++++++++++++++++--- .../{client_options.go => client_opts.go} | 23 +++++++------ vendor/modules.txt | 2 +- 5 files changed, 45 insertions(+), 19 deletions(-) rename vendor/github.com/jacobbrewer1/vaulty/{client_options.go => client_opts.go} (84%) diff --git a/go.mod b/go.mod index 22587df..afddc2e 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/jacobbrewer1/pagefilter v0.1.4 github.com/jacobbrewer1/patcher v0.1.10 github.com/jacobbrewer1/uhttp v0.0.4 - github.com/jacobbrewer1/vaulty v0.1.4 + github.com/jacobbrewer1/vaulty v0.1.5 github.com/jacobbrewer1/workerpool v0.0.3 github.com/jmoiron/sqlx v1.4.0 github.com/oapi-codegen/runtime v1.1.1 diff --git a/go.sum b/go.sum index eed4dd9..c74745e 100644 --- a/go.sum +++ b/go.sum @@ -139,8 +139,8 @@ github.com/jacobbrewer1/patcher v0.1.10 h1:k0T4/hW6F5r5bQ+WDzeaBg0u5ykAr6shQ7Z1P github.com/jacobbrewer1/patcher v0.1.10/go.mod h1:DbPetwfn5Fgarwn5VOjALRjNflSX0rbkGssZ0cRsOlo= github.com/jacobbrewer1/uhttp v0.0.4 h1:3RrRmz0fjsnLKuAs5fkflOcsjuBFoL0XvC6Xct/TDCk= github.com/jacobbrewer1/uhttp v0.0.4/go.mod h1:qwLAdGw4SLYJY2MS0sE1m/w1ILTr61bjwRtlbGwqo5c= -github.com/jacobbrewer1/vaulty v0.1.4 h1:JLcSDX5f1UMBxNNzCxQ0neqV4Mvw6030OgxE44B/pqI= -github.com/jacobbrewer1/vaulty v0.1.4/go.mod h1:BDrZxaM1mMWSqJ3UXHGOQyy6+2l5NxjAjva2V7ijwNI= +github.com/jacobbrewer1/vaulty v0.1.5 h1:VWVlu4DnFNLWvVaM2K8fFaqEMVkI/3L8bKUiSm0N92s= +github.com/jacobbrewer1/vaulty v0.1.5/go.mod h1:3x2pJ0lPDGQWud6TPcrB+dc0tu1A/3s9bnRi265HtMI= github.com/jacobbrewer1/workerpool v0.0.3 h1:MnRiYACaCO9+M2ogM6gxQcySdbER/T6mehTvBQLRg6I= github.com/jacobbrewer1/workerpool v0.0.3/go.mod h1:vZnQ5Ynp2rnihrFubKfyf7S+hnxC2TgQt755PFQ7cBQ= github.com/jawher/mow.cli v1.1.0/go.mod h1:aNaQlc7ozF3vw6IJ2dHjp2ZFiA4ozMIYY6PyuRJwlUg= diff --git a/vendor/github.com/jacobbrewer1/vaulty/client.go b/vendor/github.com/jacobbrewer1/vaulty/client.go index 195f8f7..097483a 100644 --- a/vendor/github.com/jacobbrewer1/vaulty/client.go +++ b/vendor/github.com/jacobbrewer1/vaulty/client.go @@ -11,7 +11,14 @@ import ( ) var ( + // ErrSecretNotFound is returned when a secret is not found. ErrSecretNotFound = hashiVault.ErrSecretNotFound + + // ErrInvalidClient is returned when the client is nil. + ErrInvalidClient = errors.New("client is nil") + + // ErrInvalidAuth is returned when the auth method is nil. + ErrInvalidAuth = errors.New("auth method is nil") ) type ClientHandler interface { @@ -37,13 +44,22 @@ type client struct { auth loginFunc + config *hashiVault.Config + // Below are set on initialization v *hashiVault.Client authCreds *hashiVault.Secret } func NewClient(opts ...ClientOption) (Client, error) { - c := new(client) + c := &client{ + ctx: context.Background(), + kvv2Mount: "", + auth: nil, + config: hashiVault.DefaultConfig(), + v: nil, + authCreds: nil, + } for _, opt := range opts { opt(c) @@ -53,10 +69,17 @@ func NewClient(opts ...ClientOption) (Client, error) { c.ctx = context.Background() } - if c.v == nil { - return nil, errors.New("vault client is nil") - } else if c.auth == nil { - return nil, errors.New("auth method is nil") + vc, err := hashiVault.NewClient(c.config) + if err != nil { + return nil, fmt.Errorf("unable to create vault client: %w", err) + } else if vc == nil { + return nil, ErrInvalidClient + } + + c.v = vc + + if c.auth == nil { + return nil, ErrInvalidAuth } authCreds, err := c.auth(c.v) diff --git a/vendor/github.com/jacobbrewer1/vaulty/client_options.go b/vendor/github.com/jacobbrewer1/vaulty/client_opts.go similarity index 84% rename from vendor/github.com/jacobbrewer1/vaulty/client_options.go rename to vendor/github.com/jacobbrewer1/vaulty/client_opts.go index 4a9e378..f1d0109 100644 --- a/vendor/github.com/jacobbrewer1/vaulty/client_options.go +++ b/vendor/github.com/jacobbrewer1/vaulty/client_opts.go @@ -3,7 +3,6 @@ package vaulty import ( "context" "fmt" - "log/slog" "os" hashiVault "github.com/hashicorp/vault/api" @@ -18,18 +17,22 @@ func WithContext(ctx context.Context) ClientOption { } } +// WithGeneratedVaultClient creates a vault client with the given address. +// +// Deprecated: Use WithAddr instead for the same effect. func WithGeneratedVaultClient(vaultAddress string) ClientOption { - return func(c *client) { - config := hashiVault.DefaultConfig() - config.Address = vaultAddress + return WithAddr(vaultAddress) +} - vc, err := hashiVault.NewClient(config) - if err != nil { - slog.Error("Error creating vault client", slog.String(loggingKeyError, err.Error())) - os.Exit(1) - } +func WithAddr(addr string) ClientOption { + return func(c *client) { + c.config.Address = addr + } +} - c.v = vc +func WithConfig(config *hashiVault.Config) ClientOption { + return func(c *client) { + c.config = config } } diff --git a/vendor/modules.txt b/vendor/modules.txt index 03c0af3..cda4839 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -157,7 +157,7 @@ github.com/jacobbrewer1/patcher/inserter ## explicit; go 1.23 github.com/jacobbrewer1/uhttp github.com/jacobbrewer1/uhttp/common -# github.com/jacobbrewer1/vaulty v0.1.4 +# github.com/jacobbrewer1/vaulty v0.1.5 ## explicit; go 1.23 github.com/jacobbrewer1/vaulty github.com/jacobbrewer1/vaulty/repositories