Documentation ¶
Index ¶
Constants ¶
const ErrConflictingSchemaType = "ErrConflictingSchema"
const ErrNilMutator = util.Error("attempted to add nil mutator")
ErrNilMutator reports that a method which expected an actual Mutator was a nil pointer.
const ErrNotFound = util.Error("path not found")
const Set = parser.NodeType("Set")
Set represents a list populated by unique values.
const String = parser.NodeType("String")
String represents a string element.
const Unknown = parser.NodeType("Unknown")
Unknown represents a path element we do not know the type of. Elements of type unknown do not conflict with path elements of known types.
Variables ¶
This section is empty.
Functions ¶
func NewErrConflictingSchema ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a database that caches all the implied schemas. Returns an error when upserting a mutator which conflicts with the existing ones.
Mutators implicitly define a part of the schema of the object they intend to mutate. For example, modifying `spec.containers[name: foo].image` implies that: - spec is an object - containers is a list - image exists, but no type information
If another mutator on the same GVK declares that it modifies `spec.containers.image`, then we know we have a contradiction as that path implies containers is an object.
Conflicting schemas are stored within DB. HasConflicts returns true for the IDs of Mutators with conflicting schemas until Remove() is called on the Mutators which conflict with the ID.
func (*DB) HasConflicts ¶
HasConflicts returns true if the Mutator of the passed ID has been upserted in DB and has conflicts with another Mutator. Returns false if the Mutator does not exist.
func (*DB) Upsert ¶
func (db *DB) Upsert(mutator MutatorWithSchema) error
Upsert inserts or updates the given mutator. Returns an error if the implicit schema in mutator conflicts with any mutators previously added.
Schema conflicts are only detected using mutator.Path() - DB does not check that assigned types are compatible. For example, one Mutator might assign a string to a path and another might assign a list.
type ErrConflictingSchema ¶
type ErrConflictingSchema struct {
Conflicts IDSet
}
ErrConflictingSchema reports that adding a Mutator to the DB resulted in conflicting implicit schemas.
func (ErrConflictingSchema) Error ¶
func (e ErrConflictingSchema) Error() string
func (ErrConflictingSchema) Is ¶
func (e ErrConflictingSchema) Is(other error) bool
type MutatorWithSchema ¶
type MutatorWithSchema interface { types.Mutator // SchemaBindings returns the set of GVKs this Mutator applies to. SchemaBindings() []schema.GroupVersionKind // TerminalType specifies the inferred type of the last node in a path TerminalType() parser.NodeType }
MutatorWithSchema is a mutator exposing the implied schema of the target object.