mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Run a more strict formatter over the code (#11312)
* Update tooling * Run gofumpt * go mod vendor
This commit is contained in:
@@ -32,18 +32,17 @@ func (dc *DatabasePluginClient) Close() error {
|
||||
// plugin. The client is wrapped in a DatabasePluginClient object to ensure the
|
||||
// plugin is killed on call of Close().
|
||||
func NewPluginClient(ctx context.Context, sys pluginutil.RunnerUtil, pluginRunner *pluginutil.PluginRunner, logger log.Logger, isMetadataMode bool) (Database, error) {
|
||||
|
||||
// pluginSets is the map of plugins we can dispense.
|
||||
pluginSets := map[int]plugin.PluginSet{
|
||||
// Version 3 used to supports both protocols. We want to keep it around
|
||||
// since it's possible old plugins built against this version will still
|
||||
// work with gRPC. There is currently no difference between version 3
|
||||
// and version 4.
|
||||
3: plugin.PluginSet{
|
||||
3: {
|
||||
"database": new(GRPCDatabasePlugin),
|
||||
},
|
||||
// Version 4 only supports gRPC
|
||||
4: plugin.PluginSet{
|
||||
4: {
|
||||
"database": new(GRPCDatabasePlugin),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ func (s *gRPCServer) RevokeUser(ctx context.Context, req *RevokeUserRequest) (*E
|
||||
}
|
||||
|
||||
func (s *gRPCServer) RotateRootCredentials(ctx context.Context, req *RotateRootCredentialsRequest) (*RotateRootCredentialsResponse, error) {
|
||||
|
||||
resp, err := s.impl.RotateRootCredentials(ctx, req.Statements)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -128,7 +127,6 @@ func (s *gRPCServer) GenerateCredentials(ctx context.Context, _ *Empty) (*Genera
|
||||
}
|
||||
|
||||
func (s *gRPCServer) SetCredentials(ctx context.Context, req *SetCredentialsRequest) (*SetCredentialsResponse, error) {
|
||||
|
||||
username, password, err := s.impl.SetCredentials(ctx, *req.Statements, *req.StaticUserConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -222,7 +220,6 @@ func (c *gRPCClient) RevokeUser(ctx context.Context, statements Statements, user
|
||||
Statements: &statements,
|
||||
Username: username,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
if c.doneCtx.Err() != nil {
|
||||
return ErrPluginShutdown
|
||||
@@ -243,7 +240,6 @@ func (c *gRPCClient) RotateRootCredentials(ctx context.Context, statements []str
|
||||
resp, err := c.client.RotateRootCredentials(ctx, &RotateRootCredentialsRequest{
|
||||
Statements: statements,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
if c.doneCtx.Err() != nil {
|
||||
return nil, ErrPluginShutdown
|
||||
@@ -330,6 +326,7 @@ func (c *gRPCClient) GenerateCredentials(ctx context.Context) (string, error) {
|
||||
|
||||
return resp.Password, nil
|
||||
}
|
||||
|
||||
func (c *gRPCClient) SetCredentials(ctx context.Context, statements Statements, staticUser StaticUserConfig) (username, password string, err error) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
quitCh := pluginutil.CtxCancelIfCanceled(cancel, c.doneCtx)
|
||||
@@ -340,7 +337,6 @@ func (c *gRPCClient) SetCredentials(ctx context.Context, statements Statements,
|
||||
StaticUserConfig: &staticUser,
|
||||
Statements: &statements,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
// Fall back to old call if not implemented
|
||||
grpcStatus, ok := status.FromError(err)
|
||||
|
||||
@@ -146,8 +146,10 @@ var handshakeConfig = plugin.HandshakeConfig{
|
||||
MagicCookieValue: "926a0820-aea2-be28-51d6-83cdf00e8edb",
|
||||
}
|
||||
|
||||
var _ plugin.Plugin = &GRPCDatabasePlugin{}
|
||||
var _ plugin.GRPCPlugin = &GRPCDatabasePlugin{}
|
||||
var (
|
||||
_ plugin.Plugin = &GRPCDatabasePlugin{}
|
||||
_ plugin.GRPCPlugin = &GRPCDatabasePlugin{}
|
||||
)
|
||||
|
||||
// GRPCDatabasePlugin is the plugin.Plugin implementation that only supports GRPC
|
||||
// transport
|
||||
|
||||
@@ -28,12 +28,12 @@ func ServeConfig(db Database, tlsProvider func() (*tls.Config, error)) *plugin.S
|
||||
// since it's possible old plugins built against this version will still
|
||||
// work with gRPC. There is currently no difference between version 3
|
||||
// and version 4.
|
||||
3: plugin.PluginSet{
|
||||
3: {
|
||||
"database": &GRPCDatabasePlugin{
|
||||
Impl: db,
|
||||
},
|
||||
},
|
||||
4: plugin.PluginSet{
|
||||
4: {
|
||||
"database": &GRPCDatabasePlugin{
|
||||
Impl: db,
|
||||
},
|
||||
|
||||
@@ -491,6 +491,7 @@ func intPtr(i int) *int {
|
||||
func float64Ptr(f float64) *float64 {
|
||||
return &f
|
||||
}
|
||||
|
||||
func strPtr(str string) *string {
|
||||
return &str
|
||||
}
|
||||
|
||||
@@ -25,8 +25,10 @@ type GRPCDatabasePlugin struct {
|
||||
plugin.NetRPCUnsupportedPlugin
|
||||
}
|
||||
|
||||
var _ plugin.Plugin = &GRPCDatabasePlugin{}
|
||||
var _ plugin.GRPCPlugin = &GRPCDatabasePlugin{}
|
||||
var (
|
||||
_ plugin.Plugin = &GRPCDatabasePlugin{}
|
||||
_ plugin.GRPCPlugin = &GRPCDatabasePlugin{}
|
||||
)
|
||||
|
||||
func (d GRPCDatabasePlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error {
|
||||
proto.RegisterDatabaseServer(s, gRPCServer{impl: d.Impl})
|
||||
|
||||
@@ -17,10 +17,8 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var (
|
||||
// Before minValidSeconds in ptypes package
|
||||
invalidExpiration = time.Date(0, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
)
|
||||
// Before minValidSeconds in ptypes package
|
||||
var invalidExpiration = time.Date(0, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
func TestGRPCServer_Initialize(t *testing.T) {
|
||||
type testCase struct {
|
||||
|
||||
@@ -34,7 +34,7 @@ func (dc *DatabasePluginClient) Close() error {
|
||||
func NewPluginClient(ctx context.Context, sys pluginutil.RunnerUtil, pluginRunner *pluginutil.PluginRunner, logger log.Logger, isMetadataMode bool) (Database, error) {
|
||||
// pluginSets is the map of plugins we can dispense.
|
||||
pluginSets := map[int]plugin.PluginSet{
|
||||
5: plugin.PluginSet{
|
||||
5: {
|
||||
"database": new(GRPCDatabasePlugin),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func ServeConfig(db Database) *plugin.ServeConfig {
|
||||
|
||||
// pluginSets is the map of plugins we can dispense.
|
||||
pluginSets := map[int]plugin.PluginSet{
|
||||
5: plugin.PluginSet{
|
||||
5: {
|
||||
"database": &GRPCDatabasePlugin{
|
||||
Impl: db,
|
||||
},
|
||||
|
||||
@@ -6,9 +6,7 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotInitialized = errors.New("connection has not been initialized")
|
||||
)
|
||||
var ErrNotInitialized = errors.New("connection has not been initialized")
|
||||
|
||||
// ConnectionProducer can be used as an embedded interface in the Database
|
||||
// definition. It implements the methods dealing with individual database
|
||||
|
||||
@@ -2,9 +2,8 @@ package credsutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/sdk/database/dbplugin"
|
||||
"github.com/hashicorp/vault/sdk/helper/base62"
|
||||
|
||||
@@ -58,5 +58,4 @@ func TestStatementCompatibilityHelper(t *testing.T) {
|
||||
if !reflect.DeepEqual(expectedStatements3, StatementCompatibilityHelper(statements3)) {
|
||||
t.Fatalf("mismatch: %#v, %#v", expectedStatements3, statements3)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user