api

package
v0.0.68 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterDeleted

func FilterDeleted(l *LeafEntry) bool

FilterDeleted Accepts all Entries that are marked as deleted

func FilterDeletedNotExplicitDelete

func FilterDeletedNotExplicitDelete(l *LeafEntry) bool

func FilterNew

func FilterNew(l *LeafEntry) bool

FilterNew Accepts New LeafEntries

func FilterNonDeleted

func FilterNonDeleted(l *LeafEntry) bool

FilterNonDeleted Accepts all Entries that are not marked as deleted

func FilterNonDeletedButNewOrUpdated

func FilterNonDeletedButNewOrUpdated(l *LeafEntry) bool

FilterNonDeletedButNewOrUpdated Accepts all Entries that are New or Updated and not Deleted.

func FilterUpdated

func FilterUpdated(l *LeafEntry) bool

FilterUpdated Accepts all entries that are updates

func HighestPrecedenceFilterAll

func HighestPrecedenceFilterAll(le *LeafEntry) bool

func HighestPrecedenceFilterWithoutDeleted

func HighestPrecedenceFilterWithoutDeleted(le *LeafEntry) bool

func HighestPrecedenceFilterWithoutNew

func HighestPrecedenceFilterWithoutNew(le *LeafEntry) bool

func LeafEntriesToUpdates

func LeafEntriesToUpdates(l []*LeafEntry) []*types.Update

LeafEntriesToCacheUpdates

func RegisterEntryFactory

func RegisterEntryFactory(factory EntryFactory)

RegisterEntryFactory registers the factory function for creating Entry instances This is called by the tree package during initialization

func Unfiltered

func Unfiltered(l *LeafEntry) bool

Unfiltered accepts all entries without any filtering

Types

type ChildMap

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

func NewChildMap

func NewChildMap() *ChildMap

func NewChildMapWithEntries

func NewChildMapWithEntries(entries map[string]Entry) *ChildMap

NewChildMapWithEntries creates a ChildMap with initial entries (for testing)

func (*ChildMap) AddOrGet

func (c *ChildMap) AddOrGet(e Entry) Entry

AddOrGet adds the entry if no entry with the same path name exists. If an entry already exists, it returns the existing (canonical) entry. This provides a safe get-or-create primitive for concurrent callers.

func (*ChildMap) DeleteChild

func (c *ChildMap) DeleteChild(name string)

func (*ChildMap) DeleteChilds

func (c *ChildMap) DeleteChilds(names []string)

func (*ChildMap) ForEach

func (c *ChildMap) ForEach(fn func(name string, e Entry))

ForEach iterates over all children while holding a read lock.

func (*ChildMap) GetAll

func (c *ChildMap) GetAll() map[string]Entry

GetAll returns a copy of the map of all entries in the child map

func (*ChildMap) GetAllSorted

func (c *ChildMap) GetAllSorted() []Entry

func (*ChildMap) GetEntry

func (c *ChildMap) GetEntry(s string) (e Entry, exists bool)

func (*ChildMap) GetKeys

func (c *ChildMap) GetKeys() []string

GetKeys returns the keys of the child map

func (*ChildMap) Length

func (c *ChildMap) Length() int

Length returns the number of entries in the child map

func (*ChildMap) SortedKeys

func (c *ChildMap) SortedKeys() []string

SortedKeys returns the keys of the child map in sorted order

type ChoiceResolvers

type ChoiceResolvers map[string]*choiceResolver

func (ChoiceResolvers) AddChoice

func (c ChoiceResolvers) AddChoice(name string) *choiceResolver

AddChoice adds / registers a new Choice to the choiceCasesResolver

func (ChoiceResolvers) DeepCopy

func (c ChoiceResolvers) DeepCopy() ChoiceResolvers

func (ChoiceResolvers) GetDeletes

func (c ChoiceResolvers) GetDeletes() []string

GetDeletes returns the names of the elements that need to be deleted.

func (ChoiceResolvers) GetSkipElements

func (c ChoiceResolvers) GetSkipElements() []string

GetSkipElements returns the list of all choices elements that are not highes priority. The resulting slice is used to skip these elements.

type DeletePathPrio

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

func NewDeletePathPrio

func NewDeletePathPrio(owner string, prio int32) *DeletePathPrio

func (*DeletePathPrio) DeepCopy

func (ddp *DeletePathPrio) DeepCopy() *DeletePathPrio

func (*DeletePathPrio) GetOwner

func (dpp *DeletePathPrio) GetOwner() string

func (*DeletePathPrio) GetPathSet

func (dpp *DeletePathPrio) GetPathSet() *sdcpb.PathSet

func (*DeletePathPrio) GetPrio

func (dpp *DeletePathPrio) GetPrio() int32

func (*DeletePathPrio) PathItems

func (dpp *DeletePathPrio) PathItems() iter.Seq[*sdcpb.Path]

type DeletePathSet

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

func NewDeletePaths

func NewDeletePaths() *DeletePathSet

func (*DeletePathSet) Add

func (dp *DeletePathSet) Add(intentName string, prio int32, pathset *sdcpb.PathSet)

func (*DeletePathSet) DeepCopy

func (dp *DeletePathSet) DeepCopy() *DeletePathSet

func (*DeletePathSet) GetByIntentName

func (dp *DeletePathSet) GetByIntentName(intentName string) *sdcpb.PathSet

func (*DeletePathSet) Items

func (dp *DeletePathSet) Items() iter.Seq[*DeletePathPrio]

func (*DeletePathSet) Remove

func (dp *DeletePathSet) Remove(intentName string) *sdcpb.PathSet

type DescendMethod

type DescendMethod int
const (
	DescendMethodAll DescendMethod = iota
	DescendMethodActiveChilds
)

type Entry

type Entry interface {
	// PathName returns the last Path element, the name of the Entry
	PathName() string
	// GetLevel returns the depth of the Entry in the tree
	GetLevel() int
	// AddOrGetChild adds a child entry or returns the existing one if it already exists
	AddOrGetChild(context.Context, Entry) (Entry, error)
	// StringIndent debug tree struct as indented string slice
	StringIndent(result []string) []string
	// GetSchema returns the *sdcpb.SchemaElem of the Entry
	GetSchema() *sdcpb.SchemaElem
	// IsRoot returns true if the Entry is the root of the tree
	IsRoot() bool
	// FinishInsertionPhase indicates, that the insertion of Entries into the tree is over
	// Hence calculations for e.g. choice/case can be performed.
	FinishInsertionPhase(ctx context.Context) error
	// GetParent returns the parent entry
	GetParent() Entry
	// SdcpbPath returns the sdcpb.Path struct for the Entry
	SdcpbPath() *sdcpb.Path
	// // // GetSchemaKeys checks for the schema of the entry, and returns the defined keys
	// // GetSchemaKeys() []string
	// // GetRootBasedEntryChain returns all the entries starting from the root down to the actual Entry.
	// GetRootBasedEntryChain() []Entry
	// remainsToExist indicates if a LeafEntry for this entry will survive the update.
	// Since we add running to the tree, there will always be Entries, that will disappear in the
	// as part of the SetIntent process. We need to consider this, when evaluating e.g. LeafRefs.
	// The returned boolean will in indicate if the value remains existing (true) after the setintent.
	// Or will disappear from device (running) as part of the update action.
	RemainsToExist() bool
	// shouldDelete returns true if an explicit delete should be issued for the given branch
	ShouldDelete() bool
	// canDelete checks if the entry can be Deleted.
	// This is e.g. to cover e.g. defaults and running. They can be deleted, but should not, they are basically implicitly existing.
	// In caomparison to
	//    - remainsToExists() returns true, because they remain to exist even though implicitly.
	//    - shouldDelete() returns false, because no explicit delete should be issued for them.
	CanDelete() bool
	GetChildMap() *ChildMap
	GetChilds(types.DescendMethod) EntryMap

	// // DeleteBranch Deletes from the tree, all elements of the PathSlice defined branch of the given owner
	// DeleteBranch(ctx context.Context, path *sdcpb.Path, owner string) (err error)
	// GetListChilds collects all the childs of the list. In the tree we store them seperated into their key branches.
	// this is collecting all the last level key entries.
	// GetListChilds() ([]Entry, error)
	DeepCopy(tc TreeContext, parent Entry) (Entry, error)
	GetLeafVariants() *LeafVariants
	CanDeleteBranch(keepDefault bool) bool
	DeleteCanDeleteChilds(keepDefault bool)
	// GetTreeContext returns the TreeContext of the Entry, which holds global information about the tree
	// and is used for certain operations that require access to this global information.
	GetTreeContext() TreeContext
	// ChoicesResolvers returns the choice case resolvers for the entry, if any
	ChoicesResolvers() ChoiceResolvers
}

Entry is the primary Element of the Tree.

func NewEntry

func NewEntry(ctx context.Context, parent Entry, pathElemName string, tc TreeContext) (Entry, error)

NewEntry creates a new Entry instance as a child of the given parent The parent's AddChild method is called to register the new entry

type EntryFactory

type EntryFactory func(ctx context.Context, parent Entry, pathElemName string, tc TreeContext) (Entry, error)

EntryFactory is a function type for creating new Entry instances

type EntryMap

type EntryMap map[string]Entry

func (EntryMap) SortedKeys

func (e EntryMap) SortedKeys() []string

type HighestPrecedenceFilter

type HighestPrecedenceFilter func(le *LeafEntry) bool

type LeafEntry

type LeafEntry struct {
	*types.Update

	IsNew              bool
	Delete             bool
	DeleteOnlyIntended bool
	IsUpdated          bool
	IsExplicitDelete   bool
	// contains filtered or unexported fields
}

LeafEntry stores the *cache.Update along with additional attributes. These Attributes indicate if the entry is to be deleted / added (new) or updated.

func NewLeafEntry

func NewLeafEntry(c *types.Update, flags *types.UpdateInsertFlags, parent Entry) *LeafEntry

NewLeafEntry constructor for a new LeafEntry

func (*LeafEntry) Compare

func (l *LeafEntry) Compare(other *LeafEntry) int

Compare used for slices.SortFunc. Sorts by path and if equal paths then by owner as the second criteria

func (*LeafEntry) DeepCopy

func (l *LeafEntry) DeepCopy(parentEntry Entry) *LeafEntry

func (*LeafEntry) DropDeleteFlag

func (l *LeafEntry) DropDeleteFlag() *LeafEntry

func (*LeafEntry) Equal

func (l *LeafEntry) Equal(other *LeafEntry) bool

func (*LeafEntry) GetDeleteFlag

func (l *LeafEntry) GetDeleteFlag() bool

func (*LeafEntry) GetDeleteOnlyIntendedFlag

func (l *LeafEntry) GetDeleteOnlyIntendedFlag() bool

func (*LeafEntry) GetEntry

func (l *LeafEntry) GetEntry() Entry

func (*LeafEntry) GetExplicitDeleteFlag

func (l *LeafEntry) GetExplicitDeleteFlag() bool

func (*LeafEntry) GetNewFlag

func (l *LeafEntry) GetNewFlag() bool

func (*LeafEntry) GetUpdate

func (l *LeafEntry) GetUpdate() *types.Update

func (*LeafEntry) GetUpdateFlag

func (l *LeafEntry) GetUpdateFlag() bool

func (*LeafEntry) MarkDelete

func (l *LeafEntry) MarkDelete(onlyIntended bool)

MarkDelete indicate that the entry is to be deleted

func (*LeafEntry) MarkExpliciteDelete

func (l *LeafEntry) MarkExpliciteDelete()

MarkExpliciteDelete indicate that the entry is to be explicitely deleted

func (*LeafEntry) MarkNew

func (l *LeafEntry) MarkNew()

func (*LeafEntry) MarkUpdate

func (l *LeafEntry) MarkUpdate(u *types.Update)

MarkUpdate indicate that the entry is an Updated value

func (*LeafEntry) NonRevertive

func (l *LeafEntry) NonRevertive() bool

func (*LeafEntry) String

func (l *LeafEntry) String() string

String returns a string representation of the LeafEntry

type LeafEntryFilter

type LeafEntryFilter func(*LeafEntry) bool

type LeafVariantSlice

type LeafVariantSlice []*LeafEntry

func (LeafVariantSlice) Equal

func (lvs LeafVariantSlice) Equal(otherLvs LeafVariantSlice) (bool, error)

Equal checks equality of the LeafVariantSlice with the other LeafVariantSlice

func (LeafVariantSlice) String

func (lvs LeafVariantSlice) String() string

func (LeafVariantSlice) ToPathAndUpdateSlice

func (lvs LeafVariantSlice) ToPathAndUpdateSlice() []*types.PathAndUpdate

func (LeafVariantSlice) ToSdcpbUpdateSlice

func (lvs LeafVariantSlice) ToSdcpbUpdateSlice() []*sdcpb.Update

func (LeafVariantSlice) ToUpdateSlice

func (lvs LeafVariantSlice) ToUpdateSlice() types.UpdateSlice

type LeafVariants

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

func NewLeafVariants

func NewLeafVariants(tc TreeContext, parentEnty Entry) *LeafVariants

func (*LeafVariants) Add

func (lv *LeafVariants) Add(le *LeafEntry)

func (*LeafVariants) AddExplicitDeleteEntry

func (lv *LeafVariants) AddExplicitDeleteEntry(intentName string, priority int32) *LeafEntry

func (*LeafVariants) AddWithStats

func (lv *LeafVariants) AddWithStats(le *LeafEntry, stats *types.ImportStats)

func (*LeafVariants) CanDelete

func (lv *LeafVariants) CanDelete() bool

CanDelete returns true if leafValues exist that are not owned by default or running that do not have the DeleteFlag set [or if delete is set, also the DeleteOnlyIntendedFlag set]

func (*LeafVariants) CanDeleteBranch

func (lv *LeafVariants) CanDeleteBranch(keepDefault bool) bool

func (*LeafVariants) DeepCopy

func (lv *LeafVariants) DeepCopy(tc TreeContext, parent Entry) *LeafVariants

func (*LeafVariants) DeleteByOwner

func (lv *LeafVariants) DeleteByOwner(owner string) *LeafEntry

func (*LeafVariants) GetByOwner

func (lv *LeafVariants) GetByOwner(owner string) *LeafEntry

GetByOwner returns the entry that is owned by the given owner, returns nil if no entry exists.

func (*LeafVariants) GetDeviations

func (lv *LeafVariants) GetDeviations(ctx context.Context, ch chan<- *types.DeviationEntry, isActiveCase bool)

func (*LeafVariants) GetHighestPrecedence

func (lv *LeafVariants) GetHighestPrecedence(onlyNewOrUpdated bool, includeDefaults bool, includeExplicitDelete bool) *LeafEntry

GetHighesNewUpdated returns the LeafEntry with the highes priority nil if no leaf entry exists.

func (*LeafVariants) GetHighestPrecedenceValue

func (lv *LeafVariants) GetHighestPrecedenceValue(filter HighestPrecedenceFilter) int32

func (*LeafVariants) GetRunning

func (lv *LeafVariants) GetRunning() *LeafEntry

func (*LeafVariants) Items

func (lv *LeafVariants) Items() iter.Seq[*LeafEntry]

Items iterator for the LeafVariants

func (*LeafVariants) Length

func (lv *LeafVariants) Length() int

func (*LeafVariants) MarkOwnerForDeletion

func (lv *LeafVariants) MarkOwnerForDeletion(owner string, onlyIntended bool) *LeafEntry

MarkOwnerForDeletion searches for a LefVariant of given owner, if it exists the entry is marked for deletion. returning the leafentry if an owner entry was found, nil if not.

func (*LeafVariants) RemainsToExist

func (lv *LeafVariants) RemainsToExist() bool

func (*LeafVariants) RemoveDeletedByOwner

func (lv *LeafVariants) RemoveDeletedByOwner(owner string) *LeafEntry

RemoveDeletedByOwner removes and returns the LeafEntry owned by the given owner if it is marked for deletion.

func (*LeafVariants) ResetFlags

func (lv *LeafVariants) ResetFlags(deleteFlag bool, newFlag bool, updatedFlag bool) int

func (*LeafVariants) ShouldDelete

func (lv *LeafVariants) ShouldDelete() bool

ShouldDelete evaluates the LeafVariants and indicates if the overall result is, that the Entry referencing these LeafVariants is explicitly to be deleted. Meaning there are no other LeafVariants remaining after the pending action, that any LeafVariant other then Running or Defaults exist.

type NonRevertiveInfo

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

func NewNonRevertiveInfo

func NewNonRevertiveInfo(intentName string, nonRevertive bool) *NonRevertiveInfo

func (*NonRevertiveInfo) AddPaths

func (n *NonRevertiveInfo) AddPaths(path ...*sdcpb.Path) *NonRevertiveInfo

func (*NonRevertiveInfo) DeepCopy

func (n *NonRevertiveInfo) DeepCopy() *NonRevertiveInfo

func (*NonRevertiveInfo) IsGenerallyNonRevertive

func (n *NonRevertiveInfo) IsGenerallyNonRevertive() bool

IsGenerallyNonRevertive returns the general non-revertive state of the intent, which is true if the intent is non-revertive for all paths, false otherwise.

func (*NonRevertiveInfo) IsNonRevertive

func (n *NonRevertiveInfo) IsNonRevertive(p SdcpbPath) bool

IsNonRevertive returns true if the intent is non-revertive for the given path, false otherwise. If no paths are set for the intent, the general non-revertive state is returned.

func (*NonRevertiveInfo) SetNonRevertive

func (n *NonRevertiveInfo) SetNonRevertive(nonRevertive bool)

func (*NonRevertiveInfo) String

func (n *NonRevertiveInfo) String() string

type NonRevertiveInfos

type NonRevertiveInfos map[string]*NonRevertiveInfo

func NewNonRevertiveInfos

func NewNonRevertiveInfos() NonRevertiveInfos

func (NonRevertiveInfos) Add

func (n NonRevertiveInfos) Add(owner string, nonRevertive bool, paths ...*sdcpb.Path)

func (NonRevertiveInfos) DeepCopy

func (n NonRevertiveInfos) DeepCopy() NonRevertiveInfos

func (NonRevertiveInfos) IsGenerallyNonRevertive

func (n NonRevertiveInfos) IsGenerallyNonRevertive(owner string) bool

func (NonRevertiveInfos) IsNonRevertive

func (n NonRevertiveInfos) IsNonRevertive(owner string, path SdcpbPath) bool

func (NonRevertiveInfos) String

func (n NonRevertiveInfos) String() string

type SdcpbPath

type SdcpbPath interface {
	SdcpbPath() *sdcpb.Path
}

type TreeContext

type TreeContext interface {
	PoolFactory() pool.VirtualPoolFactory
	SchemaClient() schemaClient.SchemaClientBound
	DeepCopy() TreeContext
	ExplicitDeletes() *DeletePathSet
	NonRevertiveInfo() NonRevertiveInfos
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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