internal

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PolicyTbl              = "policy"
	PolicyTblIDCol         = "id"
	PolicyTblKindCol       = "kind"
	PolicyTblNameCol       = "name"
	PolicyTblVerCol        = "version"
	PolicyTblScopeCol      = "scope"
	PolicyTblDefinitionCol = "definition"
	PolicyTblDisabledCol   = "disabled"

	PolicyDepTbl            = "policy_dependency"
	PolicyDepTblPolicyIDCol = "policy_id"
	PolicyDepTblDepIDCol    = "dependency_id"

	PolicyAncestorTbl              = "policy_ancestor"
	PolicyAncestorTblPolicyIDCol   = "policy_id"
	PolicyAncestorTblAncestorIDCol = "ancestor_id"

	SchemaTbl              = "attr_schema_defs"
	SchemaTblIDCol         = "id"
	SchemaTblDefinitionCol = "definition"
)

Variables

This section is empty.

Functions

func ConcatWithSepFunc added in v0.12.0

func ConcatWithSepFunc(dialect string) func(string, ...any) exp.Expression

Types

type ConnPoolConf

type ConnPoolConf struct {
	MaxLifetime time.Duration `yaml:"maxLifeTime"`
	MaxIdleTime time.Duration `yaml:"maxIdleTime"`
	MaxOpen     uint          `yaml:"maxOpen"`
	MaxIdle     uint          `yaml:"maxIdle"`
}

ConnPoolConf holds common SQL connection pool settings.

func (*ConnPoolConf) Configure

func (cc *ConnPoolConf) Configure(db *sqlx.DB)

type DBOpt added in v0.13.0

type DBOpt func(*dbOpt)

DBOpt defines database driver options.

func WithUpsertPolicy added in v0.13.0

func WithUpsertPolicy(f upsertPolicyFunc) DBOpt

WithUpsertPolicy sets custom upsert policy function.

func WithUpsertSchema added in v0.13.0

func WithUpsertSchema(f upsertSchemaFunc) DBOpt

WithUpsertSchema sets custom upsert schema function.

type DBStorage

type DBStorage interface {
	storage.Subscribable
	storage.Instrumented
	AddOrUpdate(ctx context.Context, policies ...policy.Wrapper) error
	GetCompilationUnits(ctx context.Context, ids ...namer.ModuleID) (map[namer.ModuleID]*policy.CompilationUnit, error)
	GetDependents(ctx context.Context, ids ...namer.ModuleID) (map[namer.ModuleID][]namer.ModuleID, error)
	Delete(ctx context.Context, ids ...namer.ModuleID) error
	ListPolicyIDs(ctx context.Context) ([]string, error)
	ListSchemaIDs(ctx context.Context) ([]string, error)
	AddOrUpdateSchema(ctx context.Context, schemas ...*schemav1.Schema) error
	DeleteSchema(ctx context.Context, ids ...string) error
	LoadSchema(ctx context.Context, url string) (io.ReadCloser, error)
	LoadPolicy(ctx context.Context, policyKey ...string) ([]*policy.Wrapper, error)
}

func NewDBStorage

func NewDBStorage(ctx context.Context, db *goqu.Database, dbOpts ...DBOpt) (DBStorage, error)

type Policy

type Policy struct {
	Definition  PolicyDefWrapper
	Kind        string
	Name        string
	Version     string
	Scope       string
	Description string
	ID          namer.ModuleID
	Disabled    bool
}

type PolicyAncestor added in v0.13.0

type PolicyAncestor struct {
	PolicyID   namer.ModuleID `db:"policy_id"`
	AncestorID namer.ModuleID `db:"ancestor_id"`
}

type PolicyCount added in v0.15.0

type PolicyCount struct {
	Kind  string
	Count int
}

type PolicyDefWrapper

type PolicyDefWrapper struct {
	*policyv1.Policy
}

func (*PolicyDefWrapper) Scan

func (pdw *PolicyDefWrapper) Scan(src any) error

func (PolicyDefWrapper) Value

func (pdw PolicyDefWrapper) Value() (driver.Value, error)

type PolicyDependency

type PolicyDependency struct {
	PolicyID     namer.ModuleID `db:"policy_id"`
	DependencyID namer.ModuleID `db:"dependency_id"`
}

type PolicyRevision added in v0.7.0

type PolicyRevision struct {
	Timestamp   time.Time `db:"update_timestamp"`
	Definition  PolicyDefWrapper
	Action      string
	Version     string
	Scope       string
	Description string
	Kind        string
	Name        string
	ID          namer.ModuleID
	RevisionID  int64 `db:"revision_id"`
	Disabled    bool
}

type Schema added in v0.11.0

type Schema struct {
	Definition *pgtype.JSON
	ID         string
}

Jump to

Keyboard shortcuts

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