database

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(db Database, admin AdminCredentials) error

Create executes queries to create database and user

func Delete

func Delete(db Database, admin AdminCredentials) error

Delete executes queries to delete database and user

Types

type AdminCredentials

type AdminCredentials struct {
	Username string `yaml:"user"`
	Password string `yaml:"password"`
}

AdminCredentials contains admin username and password of database server

type Credentials

type Credentials struct {
	Name             string
	Username         string
	Password         string
	TemplatedSecrets map[string]string
}

Credentials contains credentials to connect database

type Database

type Database interface {
	CheckStatus() error
	GetCredentials() Credentials
	ParseAdminCredentials(data map[string][]byte) (AdminCredentials, error)
	GetDatabaseAddress() DatabaseAddress
	// contains filtered or unexported methods
}

Database is interface for CRUD operate of different types of databases

func New added in v0.3.0

func New(engine string) Database

New returns database interface according to engine type

type DatabaseAddress added in v1.6.1

type DatabaseAddress struct {
	Host string
	Port uint16
}

DatabaseAddress contains host and port of a database instance

type Mysql

type Mysql struct {
	Backend      string
	Host         string
	Port         uint16
	Database     string
	User         string
	Password     string
	SSLEnabled   bool
	SkipCAVerify bool
}

Mysql is a database interface, abstraced object represents a database on mysql instance can be used to execute query to mysql database

func (Mysql) CheckStatus

func (m Mysql) CheckStatus() error

CheckStatus checks status of mysql database if the connection to database works

func (Mysql) GetCredentials

func (m Mysql) GetCredentials() Credentials

GetCredentials returns credentials of the mysql database

func (Mysql) GetDatabaseAddress added in v1.6.1

func (m Mysql) GetDatabaseAddress() DatabaseAddress

func (Mysql) ParseAdminCredentials added in v0.3.0

func (m Mysql) ParseAdminCredentials(data map[string][]byte) (AdminCredentials, error)

ParseAdminCredentials parse admin username and password of mysql database from secret data If "user" key is not defined, take "root" as admin user by default

type Postgres

type Postgres struct {
	Backend          string
	Host             string
	Port             uint16
	Database         string
	User             string
	Password         string
	Monitoring       bool
	Extensions       []string
	SSLEnabled       bool
	SkipCAVerify     bool
	DropPublicSchema bool
	Schemas          []string
}

Postgres is a database interface, abstraced object represents a database on postgres instance can be used to execute query to postgres database

func (Postgres) CheckStatus

func (p Postgres) CheckStatus() error

CheckStatus checks status of postgres database if the connection to database works

func (Postgres) GetCredentials

func (p Postgres) GetCredentials() Credentials

GetCredentials returns credentials of the postgres database

func (Postgres) GetDatabaseAddress added in v1.6.1

func (p Postgres) GetDatabaseAddress() DatabaseAddress

func (Postgres) ParseAdminCredentials added in v0.3.0

func (p Postgres) ParseAdminCredentials(data map[string][]byte) (AdminCredentials, error)

ParseAdminCredentials parse admin username and password of postgres database from secret data If "user" key is not defined, take "postgres" as admin user by default

Jump to

Keyboard shortcuts

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