sql

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(conf *DatabaseConfig) (*gorm.DB, error)

func EnsureDatabaseExists

func EnsureDatabaseExists(cnf *DatabaseConfig) error

Types

type Data

type Data struct {
	gorm.Model
	AppName string
	Scope   string
	Value   datatypes.JSON
	Version int64
}

Data represents per-scope data(configs/secrets) which consists of a JSON field

type DatabaseConfig

type DatabaseConfig struct {
	Driver string               `yaml:"driver" env:"KAIGARA_DATABASE_DRIVER" env-description:"Database driver"`
	Host   string               `yaml:"host" env:"KAIGARA_DATABASE_HOST" env-description:"Database host"`
	Port   string               `yaml:"port" env:"KAIGARA_DATABASE_PORT" env-description:"Database port"`
	Name   string               `yaml:"name" env:"KAIGARA_DATABASE_NAME" env-description:"Database name"`
	Schema string               `yaml:"schema" env:"KAIGARA_DATABASE_SCHEMA" env-description:"Database schema"`
	Table  TableNameReplaceable `yaml:"table" env:"KAIGARA_DATABASE_TABLE" env-description:"Database table"`
	User   string               `yaml:"user" env:"KAIGARA_DATABASE_USER" env-description:"Database user"`
	Pass   string               `env:"KAIGARA_DATABASE_PASS" env-description:"Database user password"`
	Pool   int                  `yaml:"pool" env:"KAIGARA_DATABASE_POOL" env-description:"Database pool size" env-default:"0"`
}

type Service

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

Service contains a gorm DB client and a container for data loaded from DB into memory

func NewService

func NewService(deploymentID string, conf *DatabaseConfig, encryptor types.Encryptor, logLevel int) (*Service, error)

func (*Service) DeleteEntry

func (ss *Service) DeleteEntry(appName, scope, name string) error

func (*Service) GetCurrentVersion

func (ss *Service) GetCurrentVersion(appName, scope string) (int64, error)

func (*Service) GetEntries

func (ss *Service) GetEntries(appName string, scope string) (map[string]interface{}, error)

func (*Service) GetEntry

func (ss *Service) GetEntry(appName, scope, name string) (interface{}, error)

func (*Service) GetLatestVersion

func (ss *Service) GetLatestVersion(appName, scope string) (int64, error)

func (*Service) ListAppNames

func (ss *Service) ListAppNames() ([]string, error)

func (*Service) ListEntries

func (ss *Service) ListEntries(appName, scope string) ([]string, error)

func (*Service) Read

func (ss *Service) Read(appName, scope string) error

func (*Service) SetEntries

func (ss *Service) SetEntries(appName string, scope string, values map[string]interface{}) error

func (*Service) SetEntry

func (ss *Service) SetEntry(appName, scope, name string, value interface{}) error

func (*Service) Write

func (ss *Service) Write(appName, scope string) error

type TableNameReplaceable

type TableNameReplaceable string

func (TableNameReplaceable) Replace

func (customName TableNameReplaceable) Replace(name string) string

Jump to

Keyboard shortcuts

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