role

package
v0.0.0-...-c5ff7ba Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: PostgreSQL Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(all, managed, wanted Map, fallbackOwner string) <-chan postgres.SyncQuery

func ProcessColumns

func ProcessColumns(columns []string, super bool) []string

Types

type Config

type Config map[string]string

func (Config) Parse

func (c Config) Parse(rows []string)

type Map

type Map map[string]Role

func (Map) Check

func (m Map) Check() error

func (Map) Flatten

func (m Map) Flatten() []string

type Membership

type Membership struct {
	Grantor string
	Name    string
}

func (Membership) String

func (m Membership) String() string

type Options

type Options struct {
	Super       bool `column:"rolsuper" mapstructure:"SUPERUSER"`
	CreateDB    bool `column:"rolcreatedb" mapstructure:"CREATEDB"`
	CreateRole  bool `column:"rolcreaterole" mapstructure:"CREATEROLE"`
	Inherit     bool `column:"rolinherit" mapstructure:"INHERIT"`
	CanLogin    bool `column:"rolcanlogin" mapstructure:"LOGIN"`
	Replication bool `column:"rolreplication" mapstructure:"REPLICATION"`
	ByPassRLS   bool `column:"rolbypassrls" mapstructure:"BYPASSRLS"`
	ConnLimit   int  `column:"rolconnlimit" mapstructure:"CONNECTION LIMIT"`
}

func (Options) Diff

func (o Options) Diff(wanted Options) string

Diff returns the SQL to match wanted role options

func (*Options) LoadRow

func (o *Options) LoadRow(row []any)

func (Options) String

func (o Options) String() string

type Role

type Role struct {
	Name         string
	Comment      string
	Parents      []Membership
	Options      Options
	Config       *Config
	BeforeCreate string
	AfterCreate  string
}

func New

func New() Role

func RowTo

func RowTo(row pgx.CollectableRow) (r Role, err error)

func (*Role) Alter

func (r *Role) Alter(wanted Role) (out []postgres.SyncQuery)

Generate queries to update current role configuration to match wanted role configuration.

func (*Role) BlacklistKey

func (r *Role) BlacklistKey() string

func (Role) Check

func (r Role) Check(m Map, genealogy []string) error

func (*Role) Create

func (r *Role) Create() (out []postgres.SyncQuery)

func (*Role) Drop

func (r *Role) Drop(fallbackOwner string) (out []postgres.SyncQuery)

func (Role) MemberOf

func (r Role) MemberOf(p string) bool

func (*Role) Merge

func (r *Role) Merge(o Role)

func (Role) MissingParents

func (r Role) MissingParents(o []Membership) (out []Membership)

func (*Role) String

func (r *Role) String() string

Jump to

Keyboard shortcuts

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