config

package
v0.0.0-...-115e43d Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: PostgreSQL Imports: 25 Imported by: 0

Documentation

Overview

Functions to normalize YAML input before processing into data structure.

Index

Constants

This section is empty.

Variables

View Source
var BuiltinsProfiles = map[string]interface{}{
	"__connect__": []interface{}{map[string]interface{}{
		"type": "CONNECT",
		"on":   "DATABASE",
	}},
	"__temporary__": []interface{}{map[string]interface{}{
		"type": "TEMPORARY",
		"on":   "DATABASE",
	}},
	"__create_on_schemas__": []interface{}{map[string]interface{}{
		"type": "CREATE",
		"on":   "SCHEMA",
	}},
	"__usage_on_schemas__": []interface{}{map[string]interface{}{
		"type": "USAGE",
		"on":   "SCHEMA",
	}},
	"__all_on_schemas__": []interface{}{
		"__create_on_schemas__",
		"__usage_on_schema__",
	},
}

BuiltinsProfiles holds yaml rewrite for BuiltinsProfiles privileges from v5 format to v6.

Functions

func CheckIsString

func CheckIsString(yaml interface{}) error

func CheckPrivilegesACL

func CheckPrivilegesACL(profiles map[string][]interface{}) error

func CheckSpuriousKeys

func CheckSpuriousKeys(yaml *map[string]interface{}, knownKeys ...string) error

func Dump

func Dump(root interface{})

func DuplicateGrantRules

func DuplicateGrantRules(yaml map[string]interface{}) (rules []map[string]interface{})

func DuplicateRoleRules

func DuplicateRoleRules(yaml map[string]interface{}) (rules []map[string]interface{})

Normalize one rule with a list of names to a list of rules with a single name.

func FindConfigFile

func FindConfigFile(userValue string) string

func FindDotEnvFile

func FindDotEnvFile(configpath string) string

func FindFile

func FindFile(userValue string, candidates []string) (configpath string)

func NormalizeAlias

func NormalizeAlias(yaml *map[string]interface{}, key, alias string) (err error)

func NormalizeBoolean

func NormalizeBoolean(v interface{}) interface{}

func NormalizeCommonLdapSearch

func NormalizeCommonLdapSearch(yaml interface{}) (search map[string]interface{}, err error)

func NormalizeConfigRoot

func NormalizeConfigRoot(yaml interface{}) (config map[string]interface{}, err error)

func NormalizeGrantRule

func NormalizeGrantRule(yaml interface{}) (rule map[string]interface{}, err error)

func NormalizeLdapSearch

func NormalizeLdapSearch(yaml interface{}) (search map[string]interface{}, err error)

func NormalizeList

func NormalizeList(yaml interface{}) (list []interface{})

func NormalizeMembership

func NormalizeMembership(raw interface{}) (value map[string]interface{}, err error)

func NormalizeMemberships

func NormalizeMemberships(raw interface{}) (memberships []map[string]interface{}, err error)

func NormalizePostgres

func NormalizePostgres(yaml interface{}) error

func NormalizePrivileges

func NormalizePrivileges(value interface{}) (out map[string][]interface{}, err error)

func NormalizeRoleOptions

func NormalizeRoleOptions(yaml interface{}) (value map[string]interface{}, err error)

func NormalizeRoleRule

func NormalizeRoleRule(yaml interface{}) (rule map[string]interface{}, err error)

func NormalizeStringList

func NormalizeStringList(yaml interface{}) (list []string, err error)

func NormalizeSyncItem

func NormalizeSyncItem(yaml interface{}) (item map[string]interface{}, err error)

func NormalizeSyncMap

func NormalizeSyncMap(yaml interface{}) (syncMap []interface{}, err error)

func ReadYaml

func ReadYaml(path string) (values interface{}, err error)

Marshall YAML from file path or stdin if path is -.

func ResolvePrivilegeRefs

func ResolvePrivilegeRefs(value map[string]interface{}) map[string][]interface{}

func YamlTo

func YamlTo[T any](raw interface{}) (T, error)

Types

type Config

type Config struct {
	Version    int
	Ldap       LdapConfig
	Postgres   PostgresConfig
	Privileges privilege.RefMap
	SyncMap    wanted.Rules `mapstructure:"rules"`
}

Config holds the YAML configuration. Not the flags.

func Load

func Load(path string) (Config, error)

func New

func New() Config

New initiate a config structure with defaults.

func (Config) ArePrivilegesManaged

func (c Config) ArePrivilegesManaged() bool

func (*Config) DecodeYaml

func (c *Config) DecodeYaml(yaml any) (err error)

Wrap mapstructure for config object

func (*Config) DropPrivileges

func (c *Config) DropPrivileges()

func (*Config) Load

func (c *Config) Load(path string) (err error)

func (*Config) LoadYaml

func (c *Config) LoadYaml(root map[string]interface{}) (err error)

Fill configuration from YAML data.

type KeyConflict

type KeyConflict struct {
	Key      string
	Conflict string
}

func (*KeyConflict) Error

func (err *KeyConflict) Error() string

type LdapConfig

type LdapConfig struct {
	URI      string
	BindDn   string
	Password string
}

type PostgresConfig

type PostgresConfig struct {
	FallbackOwner       string                       `mapstructure:"fallback_owner"`
	DatabasesQuery      QueryConfig[string]          `mapstructure:"databases_query"`
	ManagedRolesQuery   QueryConfig[string]          `mapstructure:"managed_roles_query"`
	RolesBlacklistQuery QueryConfig[string]          `mapstructure:"roles_blacklist_query"`
	SchemasQuery        QueryConfig[postgres.Schema] `mapstructure:"schemas_query"`
	PrivilegesMap       privilege.RefMap             `mapstructure:"omit"`
}

PostgresConfig holds the configuration of an inspect.Config.

This structure let mapstructure decode each query individually. The actually Querier object is instanciated early. Use Build() method to produce the final inspect.Config object.

func (PostgresConfig) Build

func (c PostgresConfig) Build() inspect.Config

type QueryConfig

type QueryConfig[T any] struct {
	Value   interface{}
	Querier inspect.Querier[T]
}

func NewSQLQuery

func NewSQLQuery[T any](sql string, rowto pgx.RowToFunc[T]) QueryConfig[T]

func NewYAMLQuery

func NewYAMLQuery[T any](rows ...T) QueryConfig[T]

func (*QueryConfig[T]) Instantiate

func (qc *QueryConfig[T]) Instantiate(rowTo pgx.RowToFunc[T], yamlTo YamlToFunc[T]) error

type YamlToFunc

type YamlToFunc[T any] func(row interface{}) (T, error)

Jump to

Keyboard shortcuts

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