Documentation ¶
Index ¶
- Constants
- func GetMysqlOpQuery(operation Operation) (string, error)
- func RenderGoTemplate(text string, values interface{}, options ...string) (string, error)
- type Dbms
- type DbmsConn
- type DbmsList
- type Driver
- type Dsn
- type Endpoint
- type MysqlConn
- type OpOutput
- type OpValues
- type Operation
- type PsqlConn
- type RateLimitedDbmsConn
- type SecretFormat
- type SecretKeyRef
- type SqlserverConn
Constants ¶
const ( Sqlserver = "sqlserver" Postgres = "postgres" Mysql = "mysql" Mariadb = "mariadb" CreateMapKey = "create" DeleteMapKey = "delete" RotateMapKey = "rotate" OperationsConfigKey = "operations" ErrorOnMissingKeyOption = "missingkey=error" DbmsConfigKey = "dbms" )
Variables ¶
This section is empty.
Functions ¶
func GetMysqlOpQuery ¶ added in v0.2.0
GetMysqlOpQuery constructs a CALL query from the specified operation. Keys of operation.Inputs must be integers, they are converted from string to int and then used to sort the parameters in the stored procedure call. If keys are not specified as integers, an error is returned.
Types ¶
type Dbms ¶
type Dbms struct { DatabaseClassName string `json:"databaseClassName"` Endpoints []Endpoint `json:"endpoints"` }
+kubebuilder:object:generate=true Dbms is the instance associated with a Dbms resource. It contains the Driver responsible for the Operations executed on Endpoints.
func (*Dbms) DeepCopy ¶ added in v0.2.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Dbms.
func (*Dbms) DeepCopyInto ¶ added in v0.2.0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type DbmsConn ¶
type DbmsConn struct {
Driver
}
DbmsConn represents the DBMS connection. See Driver.
type DbmsList ¶ added in v0.2.0
type DbmsList []Dbms
+kubebuilder:object:generate=true DbmsList is a slice containing Dbms structs.
func (DbmsList) DeepCopy ¶ added in v0.2.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DbmsList.
func (DbmsList) DeepCopyInto ¶ added in v0.2.0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (DbmsList) GetDatabaseClassNameByEndpointName ¶ added in v0.2.0
GetDatabaseClassNameByEndpointName performs a linear search on the receiver in search of endpointName. If an entry is found, it is returned.
type Driver ¶
type Driver interface { CreateDb(operation Operation) OpOutput DeleteDb(operation Operation) OpOutput Rotate(operation Operation) OpOutput Ping() error }
Driver represents a struct responsible for executing CreateDb and DeleteDb operations on a system it supports. Drivers should provide a way to check their current status (i.e. whether it can accept CreateDb and DeleteDb operations at the moment of a Ping call
type Dsn ¶
type Dsn string
func (Dsn) GenPostgres ¶ added in v0.2.0
func (Dsn) GenSqlserver ¶ added in v0.2.0
type Endpoint ¶
type Endpoint struct { Name string `json:"name"` SecretKeyRef SecretKeyRef `json:"secretKeyRef,omitempty"` Dsn Dsn `json:"dsn,omitempty"` }
+kubebuilder:object:generate=true +kubebuilder:kubebuilder:validation:MinItems=1 Endpoint represent the configuration of a DBMS endpoint identified by a name.
func (*Endpoint) DeepCopy ¶ added in v0.2.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Endpoint.
func (*Endpoint) DeepCopyInto ¶ added in v0.2.0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (Endpoint) IsDsnPresent ¶
IsDsnPresent return true if an endpoint dsn is not empty, else it returns false.
func (Endpoint) IsNamePresent ¶
IsNamePresent return true if an endpoint name is not empty, else it returns false.
type MysqlConn ¶ added in v0.2.0
type MysqlConn struct {
// contains filtered or unexported fields
}
MysqlConn represents a connection to a MySQL DBMS.
func NewMysqlConn ¶ added in v0.2.0
NewMysqlConn opens a new SQL Server connection from a given dsn.
func (*MysqlConn) CreateDb ¶ added in v0.2.0
CreateDb attempts to create a new database as specified in the operation parameter. It returns an OpOutput with the result of the call.
func (*MysqlConn) DeleteDb ¶ added in v0.2.0
DeleteDb attempts to delete a database instance as specified in the operation parameter. It returns an OpOutput with the result of the call if present.
type OpOutput ¶
OpOutput represents the return values of an operation. If the operation generates an error, it must be set in the Err field. If Err is nil, the operation is assumed to be successful.
type Operation ¶
type Operation struct { Name string `json:"name,omitempty"` Inputs map[string]string `json:"inputs,omitempty"` }
+kubebuilder:object:generate=true Operation represents an operation performed on a DBMS identified by name and containing a map of inputs and a map of outputs.
func (*Operation) DeepCopy ¶ added in v0.2.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Operation.
func (*Operation) DeepCopyInto ¶ added in v0.2.0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (Operation) RenderOperation ¶ added in v0.2.0
RenderOperation renders "actions" specified through the use of the Go text/template format. It renders Input of the receiver. Data to be inserted is taken directly from values. See OpValues. If the rendering is successful, the method returns ah na rendered Operation, if an error is generated, it is returned along with an empty Operation struct. Keys which are specified but not found generate an error (i.e. no unreferenced keys are allowed).
type PsqlConn ¶
type PsqlConn struct {
// contains filtered or unexported fields
}
PsqlConn represents a connection to a SQL Server DBMS.
func NewPsqlConn ¶
NewPsqlConn opens a new PostgreSQL connection from a given dsn.
func (*PsqlConn) CreateDb ¶
CreateDb attempts to create a new database as specified in the operation parameter. It returns an OpOutput with the result of the call.
func (*PsqlConn) DeleteDb ¶
DeleteDb attempts to delete a database instance as specified in the operation parameter. It returns an OpOutput with the result of the call if present.
type RateLimitedDbmsConn ¶ added in v0.2.0
type RateLimitedDbmsConn struct { Driver // contains filtered or unexported fields }
func NewRateLimitedDbmsConn ¶ added in v0.2.0
func NewRateLimitedDbmsConn(dbmsConn Driver, rps int) (*RateLimitedDbmsConn, error)
NewRateLimitedDbmsConn returns a new rate-limited dbms connection. Rps specifies the number of allowed requests per second for this dbms connection. If rps is equal to 0, it returns a connection that is not rate-limited. Rps cannot be a negative number.
func (*RateLimitedDbmsConn) CreateDb ¶ added in v0.2.0
func (conn *RateLimitedDbmsConn) CreateDb(operation Operation) OpOutput
func (*RateLimitedDbmsConn) DeleteDb ¶ added in v0.2.0
func (conn *RateLimitedDbmsConn) DeleteDb(operation Operation) OpOutput
func (*RateLimitedDbmsConn) Ping ¶ added in v0.2.0
func (conn *RateLimitedDbmsConn) Ping() error
type SecretFormat ¶ added in v0.2.0
+kubebuilder:object:generate=true
func (SecretFormat) DeepCopy ¶ added in v0.2.0
func (in SecretFormat) DeepCopy() SecretFormat
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretFormat.
func (SecretFormat) DeepCopyInto ¶ added in v0.2.0
func (in SecretFormat) DeepCopyInto(out *SecretFormat)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (SecretFormat) RenderSecretFormat ¶ added in v0.2.0
func (s SecretFormat) RenderSecretFormat(createOpOutput OpOutput) (SecretFormat, error)
RenderSecretFormat renders a secret from OpOutput.Result create operation.
type SecretKeyRef ¶ added in v1.0.0
SecretKeyRef specifies a reference to a value contained in a Secret resource identified by name and key.
type SqlserverConn ¶ added in v0.2.0
type SqlserverConn struct {
// contains filtered or unexported fields
}
SqlserverConn represents a connection to a SQL Server DBMS.
func NewSqlserverConn ¶ added in v0.2.0
func NewSqlserverConn(dsn string) (*SqlserverConn, error)
NewSqlserverConn opens a new SQL Server connection from a given dsn.
func (*SqlserverConn) CreateDb ¶ added in v0.2.0
func (c *SqlserverConn) CreateDb(operation Operation) OpOutput
CreateDb attempts to create a new database as specified in the operation parameter. It returns an OpOutput with the result of the call.
func (*SqlserverConn) DeleteDb ¶ added in v0.2.0
func (c *SqlserverConn) DeleteDb(operation Operation) OpOutput
DeleteDb attempts to delete a database instance as specified in the operation parameter. It returns an OpOutput with the result of the call.
func (*SqlserverConn) Ping ¶ added in v0.2.0
func (c *SqlserverConn) Ping() error
func (*SqlserverConn) Rotate ¶ added in v0.2.0
func (c *SqlserverConn) Rotate(operation Operation) OpOutput
Rotate attempts to rotate the credentials of a connection.