Documentation ¶
Index ¶
- Variables
- func Initialize(logger *zap.SugaredLogger)
- type Conn
- type Database
- func (d *Database) AddExtension(name string, schema string, version string) (e *Extension, err error)
- func (d Database) Create() (err error)
- func (d *Database) CreateOrDropExtensions() (err error)
- func (d *Database) Drop() (err error)
- func (d *Database) GetDbConnection() (c *Conn)
- func (d *Database) SetDefaults()
- func (d Database) SetReadOnlyGrants(readOnlyRoleName string) (err error)
- type Databases
- type Dsn
- type Extension
- type Extensions
- type Handler
- func (ph *Handler) CreateOrDropDatabases() (err error)
- func (ph *Handler) CreateOrDropSlots() (err error)
- func (ph *Handler) GetDb(dbName string) (d *Database)
- func (ph *Handler) GetRole(roleName string) (d *Role, err error)
- func (ph *Handler) GrantRole(granteeName string, grantedName string) (err error)
- func (ph *Handler) StrictifyDatabases() (err error)
- func (ph *Handler) StrictifyExtensions() (err error)
- func (ph *Handler) StrictifyRoles() (err error)
- type ReplicationSlot
- type ReplicationSlots
- type Role
- func (r Role) Create() (err error)
- func (r *Role) Drop() (err error)
- func (r Role) GrantRole(grantedRole *Role) (err error)
- func (r Role) ResetExpiry() (err error)
- func (r Role) ResetPassword() (err error)
- func (r Role) RevokeRole(roleName string) (err error)
- func (r Role) SetExpiry(expiry time.Time) (err error)
- func (r Role) SetPassword(password string) (err error)
- type RoleOption
- func (opt RoleOption) Inverse() (invOpt RoleOption)
- func (opt RoleOption) MarshalYAML() (interface{}, error)
- func (opt RoleOption) Sql() (sql string)
- func (opt RoleOption) String() (name string)
- func (opt *RoleOption) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (opt RoleOption) Valid() (isValid bool)
- type RoleOptions
- type Roles
- type State
- type StrictOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ProtectedRoles = map[string]bool{"aq_administrator_role": true, "enterprisedb": true, "postgres": true, "pg_monitor": true, "pg_read_all_settings": true, "pg_read_all_stats": true, "pg_stat_scan_tables": true, "pg_signal_backend": true, "pg_read_server_files": true, "pg_write_server_files": true, "pg_execute_server_program": true, } ProtectedDatabases = map[string]bool{"postgres": true, "template0": true, "template1": true, } )
View Source
var (
LoginOption, _ = NewRoleOption("LOGIN")
LoginOptions = RoleOptions{LoginOption.name: LoginOption}
)
View Source
var ( // Present means the object should be created Present = State{statePresent} // Absent means the object should be removed Absent = State{stateAbsent} )
View Source
var InvalidOption = errors.New("invalid role option")
View Source
var (
ValidRoleOptions = map[string]string{
"SUPERUSER": "rolsuper",
"CREATEROLE ": "rolcreaterole",
"CREATEUSER": "rolcreaterole",
"INHERIT": "rolinherit",
"LOGIN": "rolcanlogin",
"REPLICATION": "rolreplication",
}
)
Functions ¶
func Initialize ¶
func Initialize(logger *zap.SugaredLogger)
Types ¶
type Database ¶
type Database struct { Owner string `yaml:"owner"` Extensions Extensions `yaml:"extensions"` State State `yaml:"state"` // contains filtered or unexported fields }
func (*Database) AddExtension ¶
func (*Database) CreateOrDropExtensions ¶
func (*Database) GetDbConnection ¶
func (*Database) SetDefaults ¶
func (d *Database) SetDefaults()
SetDefaults is called to set all defaults for databases created from yaml
func (Database) SetReadOnlyGrants ¶
type Extension ¶
type Extension struct { Schema string `yaml:"schema"` State State `yaml:"state"` Version string `yaml:"version"` // contains filtered or unexported fields }
func NewExtension ¶
type Extensions ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewPgHandler ¶
func NewPgHandler(connParams Dsn, options StrictOptions, databases Databases, slots []string) (ph *Handler)
func (*Handler) CreateOrDropDatabases ¶
func (*Handler) CreateOrDropSlots ¶
func (*Handler) StrictifyDatabases ¶
func (*Handler) StrictifyExtensions ¶
func (*Handler) StrictifyRoles ¶
type ReplicationSlot ¶
type ReplicationSlot struct { State State `yaml:"state"` // contains filtered or unexported fields }
func NewSlot ¶
func NewSlot(handler *Handler, name string) (rs *ReplicationSlot)
func (ReplicationSlot) Create ¶
func (rs ReplicationSlot) Create() (err error)
func (ReplicationSlot) Drop ¶
func (rs ReplicationSlot) Drop() (err error)
type ReplicationSlots ¶
type ReplicationSlots map[string]ReplicationSlot
type Role ¶
type Role struct { State State // contains filtered or unexported fields }
func (Role) ResetExpiry ¶
func (Role) ResetPassword ¶
func (Role) RevokeRole ¶
func (Role) SetPassword ¶
type RoleOption ¶
type RoleOption struct {
// contains filtered or unexported fields
}
func NewRoleOption ¶
func NewRoleOption(name string) (opt RoleOption, err error)
func (RoleOption) Inverse ¶
func (opt RoleOption) Inverse() (invOpt RoleOption)
func (RoleOption) MarshalYAML ¶
func (opt RoleOption) MarshalYAML() (interface{}, error)
MarshalYAML marshals the enum as a quoted json string
func (RoleOption) Sql ¶
func (opt RoleOption) Sql() (sql string)
func (RoleOption) String ¶
func (opt RoleOption) String() (name string)
func (*RoleOption) UnmarshalYAML ¶
func (opt *RoleOption) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML converts a yaml string to the enum value
func (RoleOption) Valid ¶
func (opt RoleOption) Valid() (isValid bool)
type RoleOptions ¶
type RoleOptions map[string]RoleOption
func (RoleOptions) AddOption ¶
func (ro RoleOptions) AddOption(opt RoleOption)
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the state of a pg object (Present or Absent)
func (State) MarshalYAML ¶
MarshalYAML marshals the enum as a quoted json string
func (*State) UnmarshalYAML ¶
UnmarshalYAML converts a yaml string to the enum value
Click to show internal directories.
Click to hide internal directories.