configrefs

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package configrefs holds the rules for references among a configuration's entities as entities change: what an existing reference names afterwards and how it is written. The console's edits (x/admin/configapp) and plans (x/configplan) apply the same rules, each over its own representation.

The rule: a reference keeps naming the entity it named before the change, in its shortest unambiguous form when it no longer names it alone; a reference to a removed entity goes; one that named no single entity before stays as it was.

Index

Constants

View Source
const (
	UsePrimaryKey   = "primaryKey"
	UseUniqueKey    = "uniqueKey"
	UseTenantPolicy = "tenantPolicy"
	UseFieldACL     = "fieldACL"  // entity-level, by role
	UseRowPolicy    = "rowPolicy" // entity-level, by role
	UseRelationship = "relationship"
)

The kinds of FieldUse: what in an entity's definition names a field.

Variables

This section is empty.

Functions

func FieldUses added in v0.1.21

func FieldUses(e config.EntityConfig, resolve func(ref string) (string, bool), fn func(FieldUse))

FieldUses calls fn for every field e's definition names, in one order: its relationships' join columns on both sides (the target as resolve finds it, none when it names no single entity), its keys, its tenant policy, and its entity-level access. Grants, which name fields of the entities they are on, are their own.

func FilterFields

func FilterFields(v any) []string

FilterFields lists the fields a row filter (decoded YAML or JSON) names: a condition {op, field, value} names its field, an and/or those of its items, and a not those of its filter.

func Retarget

func Retarget(ref string, before, after Index, moved map[string]string) (out string, keep bool)

Retarget is what the existing reference ref becomes once the entities changed from before to after; moved maps the IDs of renamed or moved entities to their new IDs, and of removed ones to "" (needed when another entity takes over the ID). keep is false when ref named an entity that is gone: the reference goes with it.

Types

type FieldUse added in v0.1.21

type FieldUse struct {
	// Entity is the ID of the entity whose field it is.
	Entity, Field, Kind string
	// Relationship names the relationship, for UseRelationship.
	Relationship string
}

FieldUse is a field an entity's definition names: one of its own, or the target's a relationship joins on.

type Index

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

Index resolves references among a set of entities.

func NewIndex

func NewIndex(entities []config.EntityConfig) Index

NewIndex indexes entities; only their names, datasources and schemas matter.

func (Index) Has

func (x Index) Has(id string) bool

Has reports whether an entity has the ID id.

func (Index) IDOf

func (x Index) IDOf(ref string) (string, bool)

IDOf is the ID of the one entity ref names.

func (Index) ShortName

func (x Index) ShortName(id string) string

ShortName is the shortest reference naming the entity id alone (its ID when none does, or when there is no such entity).

Jump to

Keyboard shortcuts

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