sqlconnect

package
v0.4.33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 20 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientCertConfig added in v0.4.23

type ClientCertConfig struct {
	RootCert *string

	ClientCert *string
	ClientKey  *string
}

type ConnectionDetails

type ConnectionDetails struct {
	GeneralDbConnectConfig
	MaxConnectionLimit *int32

	Tunnel *sshtunnel.Sshtunnel
}

func GetConnectionDetails

func GetConnectionDetails(
	c *mgmtv1alpha1.ConnectionConfig,
	connectionTimeout *uint32,
	handleClientTlsConfig clienttls.ClientTlsFileHandler,
	logger *slog.Logger,
) (*ConnectionDetails, error)

Method for retrieving connection details, including tunneling information. Only use if requiring direct access to the SSH Tunnel, otherwise the SqlConnector should be used instead.

func (*ConnectionDetails) GetTunnel added in v0.4.26

func (c *ConnectionDetails) GetTunnel() *sshtunnel.Sshtunnel

func (*ConnectionDetails) String added in v0.4.26

func (c *ConnectionDetails) String() string

type GeneralDbConnectConfig

type GeneralDbConnectConfig struct {
	Driver string

	Host     string
	Port     int32
	Database string
	User     string
	Pass     string

	Protocol *string

	QueryParams url.Values
}

func (*GeneralDbConnectConfig) String

func (g *GeneralDbConnectConfig) String() string

type MockPgPoolContainer

type MockPgPoolContainer struct {
	mock.Mock
}

MockPgPoolContainer is an autogenerated mock type for the PgPoolContainer type

func NewMockPgPoolContainer

func NewMockPgPoolContainer(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockPgPoolContainer

NewMockPgPoolContainer creates a new instance of MockPgPoolContainer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockPgPoolContainer) Close

func (_m *MockPgPoolContainer) Close()

Close provides a mock function with given fields:

func (*MockPgPoolContainer) EXPECT

func (*MockPgPoolContainer) Open

Open provides a mock function with given fields: _a0

type MockPgPoolContainer_Close_Call

type MockPgPoolContainer_Close_Call struct {
	*mock.Call
}

MockPgPoolContainer_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'

func (*MockPgPoolContainer_Close_Call) Return

func (*MockPgPoolContainer_Close_Call) Run

func (*MockPgPoolContainer_Close_Call) RunAndReturn

func (_c *MockPgPoolContainer_Close_Call) RunAndReturn(run func()) *MockPgPoolContainer_Close_Call

type MockPgPoolContainer_Expecter

type MockPgPoolContainer_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockPgPoolContainer_Expecter) Close

Close is a helper method to define mock.On call

func (*MockPgPoolContainer_Expecter) Open

Open is a helper method to define mock.On call

  • _a0 context.Context

type MockPgPoolContainer_Open_Call

type MockPgPoolContainer_Open_Call struct {
	*mock.Call
}

MockPgPoolContainer_Open_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Open'

func (*MockPgPoolContainer_Open_Call) Return

func (*MockPgPoolContainer_Open_Call) Run

func (*MockPgPoolContainer_Open_Call) RunAndReturn

type MockSqlConnector

type MockSqlConnector struct {
	mock.Mock
}

MockSqlConnector is an autogenerated mock type for the SqlConnector type

func NewMockSqlConnector

func NewMockSqlConnector(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSqlConnector

NewMockSqlConnector creates a new instance of MockSqlConnector. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSqlConnector) EXPECT

func (*MockSqlConnector) NewDbFromConnectionConfig

func (_m *MockSqlConnector) NewDbFromConnectionConfig(connectionConfig *mgmtv1alpha1.ConnectionConfig, connectionTimeout *uint32, logger *slog.Logger) (SqlDbContainer, error)

NewDbFromConnectionConfig provides a mock function with given fields: connectionConfig, connectionTimeout, logger

func (*MockSqlConnector) NewPgPoolFromConnectionConfig

func (_m *MockSqlConnector) NewPgPoolFromConnectionConfig(pgconfig *mgmtv1alpha1.PostgresConnectionConfig, connectionTimeout *uint32, logger *slog.Logger) (PgPoolContainer, error)

NewPgPoolFromConnectionConfig provides a mock function with given fields: pgconfig, connectionTimeout, logger

type MockSqlConnector_Expecter

type MockSqlConnector_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockSqlConnector_Expecter) NewDbFromConnectionConfig

func (_e *MockSqlConnector_Expecter) NewDbFromConnectionConfig(connectionConfig interface{}, connectionTimeout interface{}, logger interface{}) *MockSqlConnector_NewDbFromConnectionConfig_Call

NewDbFromConnectionConfig is a helper method to define mock.On call

  • connectionConfig *mgmtv1alpha1.ConnectionConfig
  • connectionTimeout *uint32
  • logger *slog.Logger

func (*MockSqlConnector_Expecter) NewPgPoolFromConnectionConfig

func (_e *MockSqlConnector_Expecter) NewPgPoolFromConnectionConfig(pgconfig interface{}, connectionTimeout interface{}, logger interface{}) *MockSqlConnector_NewPgPoolFromConnectionConfig_Call

NewPgPoolFromConnectionConfig is a helper method to define mock.On call

  • pgconfig *mgmtv1alpha1.PostgresConnectionConfig
  • connectionTimeout *uint32
  • logger *slog.Logger

type MockSqlConnector_NewDbFromConnectionConfig_Call

type MockSqlConnector_NewDbFromConnectionConfig_Call struct {
	*mock.Call
}

MockSqlConnector_NewDbFromConnectionConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewDbFromConnectionConfig'

func (*MockSqlConnector_NewDbFromConnectionConfig_Call) Return

func (*MockSqlConnector_NewDbFromConnectionConfig_Call) Run

type MockSqlConnector_NewPgPoolFromConnectionConfig_Call

type MockSqlConnector_NewPgPoolFromConnectionConfig_Call struct {
	*mock.Call
}

MockSqlConnector_NewPgPoolFromConnectionConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewPgPoolFromConnectionConfig'

func (*MockSqlConnector_NewPgPoolFromConnectionConfig_Call) Return

func (*MockSqlConnector_NewPgPoolFromConnectionConfig_Call) Run

type MockSqlDbContainer

type MockSqlDbContainer struct {
	mock.Mock
}

MockSqlDbContainer is an autogenerated mock type for the SqlDbContainer type

func NewMockSqlDbContainer

func NewMockSqlDbContainer(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSqlDbContainer

NewMockSqlDbContainer creates a new instance of MockSqlDbContainer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSqlDbContainer) Close

func (_m *MockSqlDbContainer) Close() error

Close provides a mock function with given fields:

func (*MockSqlDbContainer) EXPECT

func (*MockSqlDbContainer) Open

func (_m *MockSqlDbContainer) Open() (SqlDBTX, error)

Open provides a mock function with given fields:

type MockSqlDbContainer_Close_Call

type MockSqlDbContainer_Close_Call struct {
	*mock.Call
}

MockSqlDbContainer_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'

func (*MockSqlDbContainer_Close_Call) Return

func (*MockSqlDbContainer_Close_Call) Run

func (*MockSqlDbContainer_Close_Call) RunAndReturn

type MockSqlDbContainer_Expecter

type MockSqlDbContainer_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockSqlDbContainer_Expecter) Close

Close is a helper method to define mock.On call

func (*MockSqlDbContainer_Expecter) Open

Open is a helper method to define mock.On call

type MockSqlDbContainer_Open_Call

type MockSqlDbContainer_Open_Call struct {
	*mock.Call
}

MockSqlDbContainer_Open_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Open'

func (*MockSqlDbContainer_Open_Call) Return

func (*MockSqlDbContainer_Open_Call) Run

func (*MockSqlDbContainer_Open_Call) RunAndReturn

type PgPool

type PgPool struct {
	// contains filtered or unexported fields
}

func (*PgPool) Close

func (s *PgPool) Close()

func (*PgPool) GetDsn

func (s *PgPool) GetDsn() string

func (*PgPool) Open

func (s *PgPool) Open(ctx context.Context) (pg_queries.DBTX, error)

type PgPoolContainer

type PgPoolContainer interface {
	Open(context.Context) (pg_queries.DBTX, error)
	Close()
}

interface used by SqlConnector to abstract away the opening and closing of a Pgxpool that includes tunneling

type SqlConnector

type SqlConnector interface {
	NewDbFromConnectionConfig(connectionConfig *mgmtv1alpha1.ConnectionConfig, connectionTimeout *uint32, logger *slog.Logger) (SqlDbContainer, error)
	NewPgPoolFromConnectionConfig(pgconfig *mgmtv1alpha1.PostgresConnectionConfig, connectionTimeout *uint32, logger *slog.Logger) (PgPoolContainer, error)
}

Allows instantiating a sql db or pg pool container that includes SSH tunneling if the config requires it

type SqlDBTX

type SqlDBTX interface {
	mysql_queries.DBTX

	PingContext(context.Context) error
	BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
}

type SqlDb

type SqlDb struct {
	// contains filtered or unexported fields
}

func (*SqlDb) Close

func (s *SqlDb) Close() error

func (*SqlDb) GetDsn

func (s *SqlDb) GetDsn() string

func (*SqlDb) Open

func (s *SqlDb) Open() (SqlDBTX, error)

type SqlDbContainer

type SqlDbContainer interface {
	Open() (SqlDBTX, error)
	Close() error
}

interface used by SqlConnector to abstract away the opening and closing of a sqldb that includes tunneling

type SqlOpenConnector

type SqlOpenConnector struct{}

func (*SqlOpenConnector) NewDbFromConnectionConfig

func (rc *SqlOpenConnector) NewDbFromConnectionConfig(connectionConfig *mgmtv1alpha1.ConnectionConfig, connectionTimeout *uint32, logger *slog.Logger) (SqlDbContainer, error)

func (*SqlOpenConnector) NewPgPoolFromConnectionConfig

func (rc *SqlOpenConnector) NewPgPoolFromConnectionConfig(pgconfig *mgmtv1alpha1.PostgresConnectionConfig, connectionTimeout *uint32, logger *slog.Logger) (PgPoolContainer, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL