vault: Index | Files

package connutil

import ""


Package Files

connutil.go sql.go


var (
    ErrNotInitialized = errors.New("connection has not been initialized")

type ConnectionProducer Uses

type ConnectionProducer interface {
    Close() error
    Init(context.Context, map[string]interface{}, bool) (map[string]interface{}, error)
    Connection(context.Context) (interface{}, error)


    // DEPRECATED, will be removed in 0.12
    Initialize(context.Context, map[string]interface{}, bool) error

ConnectionProducer can be used as an embedded interface in the Database definition. It implements the methods dealing with individual database connections and is used in all the builtin database types.

type SQLConnectionProducer Uses

type SQLConnectionProducer struct {
    ConnectionURL            string      `json:"connection_url" mapstructure:"connection_url" structs:"connection_url"`
    MaxOpenConnections       int         `json:"max_open_connections" mapstructure:"max_open_connections" structs:"max_open_connections"`
    MaxIdleConnections       int         `json:"max_idle_connections" mapstructure:"max_idle_connections" structs:"max_idle_connections"`
    MaxConnectionLifetimeRaw interface{} `json:"max_connection_lifetime" mapstructure:"max_connection_lifetime" structs:"max_connection_lifetime"`
    Username                 string      `json:"username" mapstructure:"username" structs:"username"`
    Password                 string      `json:"password" mapstructure:"password" structs:"password"`

    Type      string
    RawConfig map[string]interface{}

    Initialized bool

    // contains filtered or unexported fields

SQLConnectionProducer implements ConnectionProducer and provides a generic producer for most sql databases

func (*SQLConnectionProducer) Close Uses

func (c *SQLConnectionProducer) Close() error

Close attempts to close the connection

func (*SQLConnectionProducer) Connection Uses

func (c *SQLConnectionProducer) Connection(ctx context.Context) (interface{}, error)

func (*SQLConnectionProducer) Init Uses

func (c *SQLConnectionProducer) Init(ctx context.Context, conf map[string]interface{}, verifyConnection bool) (map[string]interface{}, error)

func (*SQLConnectionProducer) Initialize Uses

func (c *SQLConnectionProducer) Initialize(ctx context.Context, conf map[string]interface{}, verifyConnection bool) error

func (*SQLConnectionProducer) SecretValues Uses

func (c *SQLConnectionProducer) SecretValues() map[string]interface{}

func (*SQLConnectionProducer) SetCredentials Uses

func (c *SQLConnectionProducer) SetCredentials(ctx context.Context, statements dbplugin.Statements, staticUser dbplugin.StaticUserConfig) (username, password string, err error)

SetCredentials uses provided information to set/create a user in the database. Unlike CreateUser, this method requires a username be provided and uses the name given, instead of generating a name. This is used for creating and setting the password of static accounts, as well as rolling back passwords in the database in the event an updated database fails to save in Vault's storage.

Package connutil imports 13 packages (graph) and is imported by 7 packages. Updated 2019-07-20. Refresh now. Tools for package owners.