Skip to content

Commit

Permalink
Port a few minor fixes over from the copy of this code in the Vault r…
Browse files Browse the repository at this point in the history
…epo (#116)

* Port a few minor fixes over from the copy of this code in the Vault repo

There is a copy of this code in the Vault repo, to which some fixes have
been applied there but not here. Copy them over.

* Remove test change from submission

Upon reading through passthrough_test.go, I noticed that this was
a change in style of a single test function, to deviate from all the
rest. Therefore, I don't think it should be ported as is anymore.
  • Loading branch information
maxb committed Jul 25, 2023
1 parent 01b014a commit 0c66f9a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions passthrough.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func LeaseSwitchedPassthroughBackend(ctx context.Context, conf *logical.BackendC
}

if conf == nil {
return nil, fmt.Errorf("Configuation passed into backend is nil")
return nil, fmt.Errorf("configuration passed into backend is nil")
}
backend.Setup(ctx, conf)
b.Backend = backend
Expand All @@ -168,7 +168,7 @@ func (b *PassthroughBackend) handleExistenceCheck() framework.ExistenceFunc {

out, err := req.Storage.Get(ctx, key)
if err != nil {
return false, fmt.Errorf("existence check failed: %v", err)
return false, fmt.Errorf("existence check failed: %w", err)
}

return out != nil, nil
Expand All @@ -182,7 +182,7 @@ func (b *PassthroughBackend) handleRead() framework.OperationFunc {
// Read the path
out, err := req.Storage.Get(ctx, key)
if err != nil {
return nil, fmt.Errorf("read failed: %v", err)
return nil, fmt.Errorf("read failed: %w", err)
}

// Fast-path the no data case
Expand All @@ -194,7 +194,7 @@ func (b *PassthroughBackend) handleRead() framework.OperationFunc {
var rawData map[string]interface{}

if err := jsonutil.DecodeJSON(out.Value, &rawData); err != nil {
return nil, fmt.Errorf("json decoding failed: %v", err)
return nil, fmt.Errorf("json decoding failed: %w", err)
}

var resp *logical.Response
Expand Down Expand Up @@ -260,7 +260,7 @@ func (b *PassthroughBackend) handleWrite() framework.OperationFunc {
// JSON encode the data
buf, err := json.Marshal(req.Data)
if err != nil {
return nil, fmt.Errorf("json encoding failed: %v", err)
return nil, fmt.Errorf("json encoding failed: %w", err)
}

// Write out a new key
Expand All @@ -269,7 +269,7 @@ func (b *PassthroughBackend) handleWrite() framework.OperationFunc {
Value: buf,
}
if err := req.Storage.Put(ctx, entry); err != nil {
return nil, fmt.Errorf("failed to write: %v", err)
return nil, fmt.Errorf("failed to write: %w", err)
}

kvEvent(ctx, b.Backend, 1, "write",
Expand Down

0 comments on commit 0c66f9a

Please sign in to comment.