package connutil
import "github.com/hashicorp/vault/sdk/database/helper/connutil"
Index ¶
- Constants
- Variables
- func GetCloudSQLAuthOptions(credentials string, usePrivateIP bool) ([]cloudsqlconn.Option, error)
- func SQLConnectionProducerFieldNames() map[string]any
- func ValidateAuthType(authType string) bool
- type ConnectionProducer
- type SQLConnectionProducer
- func (c *SQLConnectionProducer) Close() error
- func (c *SQLConnectionProducer) Connection(ctx context.Context) (interface{}, error)
- func (c *SQLConnectionProducer) Init(ctx context.Context, conf map[string]interface{}, verifyConnection bool) (map[string]interface{}, error)
- func (c *SQLConnectionProducer) Initialize(ctx context.Context, conf map[string]interface{}, verifyConnection bool) error
- func (c *SQLConnectionProducer) SecretValues() map[string]interface{}
- func (c *SQLConnectionProducer) SetCredentials(ctx context.Context, statements dbplugin.Statements, staticUser dbplugin.StaticUserConfig) (username, password string, err error)
- func (c *SQLConnectionProducer) StaticConnection(_ context.Context, _, _ string) (*sql.DB, error)
Constants ¶
const ( AuthTypeGCPIAM = "gcp_iam" AuthTypeCert = "cert" AuthTypeUsernamePassword = "" )
Variables ¶
Functions ¶
func GetCloudSQLAuthOptions ¶
func GetCloudSQLAuthOptions(credentials string, usePrivateIP bool) ([]cloudsqlconn.Option, error)
GetCloudSQLAuthOptions takes a credentials JSON and returns a set of GCP CloudSQL options - always WithIAMAUthN, and then the appropriate file/JSON option.
func SQLConnectionProducerFieldNames ¶
This provides the field names for SQLConnectionProducer for field validation in the framework handler.
func ValidateAuthType ¶
Types ¶
type ConnectionProducer ¶
type ConnectionProducer interface { Close() error Init(context.Context, map[string]interface{}, bool) (map[string]interface{}, error) Connection(context.Context) (interface{}, error) sync.Locker // 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 ¶
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"` DisableEscaping bool `json:"disable_escaping" mapstructure:"disable_escaping" structs:"disable_escaping"` SelfManaged bool `json:"self_managed" mapstructure:"self_managed" structs:"self_managed"` // Username/Password is the default auth type when AuthType is not set Username string `json:"username" mapstructure:"username" structs:"username"` Password string `json:"password" mapstructure:"password" structs:"password"` // AuthType defines the type of client authenticate used for this connection AuthType string `json:"auth_type" mapstructure:"auth_type" structs:"auth_type"` ServiceAccountJSON string `json:"service_account_json" mapstructure:"service_account_json" structs:"service_account_json"` TLSConfig *tls.Config Type string RawConfig map[string]interface{} Initialized bool sync.Mutex // contains filtered or unexported fields }
SQLConnectionProducer implements ConnectionProducer and provides a generic producer for most sql databases
func (*SQLConnectionProducer) Close ¶
func (c *SQLConnectionProducer) Close() error
Close attempts to close the connection
func (*SQLConnectionProducer) Connection ¶
func (c *SQLConnectionProducer) Connection(ctx context.Context) (interface{}, error)
func (*SQLConnectionProducer) Init ¶
func (c *SQLConnectionProducer) Init(ctx context.Context, conf map[string]interface{}, verifyConnection bool) (map[string]interface{}, error)
func (*SQLConnectionProducer) Initialize ¶
func (c *SQLConnectionProducer) Initialize(ctx context.Context, conf map[string]interface{}, verifyConnection bool) error
func (*SQLConnectionProducer) SecretValues ¶
func (c *SQLConnectionProducer) SecretValues() map[string]interface{}
func (*SQLConnectionProducer) SetCredentials ¶
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.
func (*SQLConnectionProducer) StaticConnection ¶
Source Files ¶
cloudsql.go connutil.go postgres.go sql.go sql_stubs_oss.go
- Version
- v0.18.0 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 30 packages
- Last checked
- 1 month ago –
Tools for package owners.