@@ -18,7 +18,6 @@ import (
1818 "github.com/sdcio/data-server/pkg/utils"
1919 sdcpb "github.com/sdcio/sdc-protos/sdcpb"
2020 log "github.com/sirupsen/logrus"
21- "google.golang.org/protobuf/proto"
2221 "google.golang.org/protobuf/types/known/emptypb"
2322)
2423
@@ -111,7 +110,7 @@ func newSharedEntryAttributes(ctx context.Context, parent Entry, pathElemName st
111110}
112111
113112func (s * sharedEntryAttributes ) GetRoot () Entry {
114- if s .parent == nil {
113+ if s .IsRoot () {
115114 return s
116115 }
117116 return s .parent .GetRoot ()
@@ -410,7 +409,7 @@ func (s *sharedEntryAttributes) GetLevel() int {
410409 return * s .level
411410 }
412411 // if we're at the root level, return 0
413- if s .parent == nil {
412+ if s .IsRoot () {
414413 return 0
415414 }
416415 // Get parent level and add 1
@@ -673,7 +672,7 @@ func (s *sharedEntryAttributes) GetDeletes(deletes []types.DeleteEntry, aggregat
673672// the level of recursion is indicated via the levelUp attribute
674673func (s * sharedEntryAttributes ) GetFirstAncestorWithSchema () (Entry , int ) {
675674 // if root node is reached
676- if s .parent == nil {
675+ if s .IsRoot () {
677676 return nil , 0
678677 }
679678 // check if the parent has a schema
@@ -705,7 +704,7 @@ func (s *sharedEntryAttributes) GetByOwner(owner string, result []*LeafEntry) Le
705704// Path returns the root based path of the Entry
706705func (s * sharedEntryAttributes ) Path () types.PathSlice {
707706 // special handling for root node
708- if s .parent == nil {
707+ if s .IsRoot () {
709708 return types.PathSlice {}
710709 }
711710 return append (s .parent .Path (), s .pathElemName )
@@ -942,7 +941,6 @@ func (s *sharedEntryAttributes) getHighestPrecedenceLeafValue(ctx context.Contex
942941}
943942
944943func (s * sharedEntryAttributes ) GetRootBasedEntryChain () []Entry {
945- s .GetLevel ()
946944 if s .IsRoot () {
947945 return []Entry {}
948946 }
@@ -1550,15 +1548,6 @@ func (s *sharedEntryAttributes) StringIndent(result []string) []string {
15501548 return result
15511549}
15521550
1553- // markOwnerDelete Sets the delete flag on all the LeafEntries belonging to the given owner.
1554- func (s * sharedEntryAttributes ) MarkOwnerDelete (o string , onlyIntended bool ) {
1555- s .leafVariants .MarkOwnerForDeletion (o , onlyIntended )
1556- // recurse into childs
1557- for _ , child := range s .childs .GetAll () {
1558- child .MarkOwnerDelete (o , onlyIntended )
1559- }
1560- }
1561-
15621551// SdcpbPath returns the sdcpb.Path, with its elements and keys based on the local schema
15631552func (s * sharedEntryAttributes ) SdcpbPath () (* sdcpb.Path , error ) {
15641553 return s .SdcpbPathInternal (s .Path ())
@@ -1669,52 +1658,6 @@ func (s *sharedEntryAttributes) TreeExport(owner string) ([]*tree_persist.TreeEl
16691658 return nil , nil
16701659}
16711660
1672- func (s * sharedEntryAttributes ) BlameConfig (includeDefaults bool ) (* sdcpb.BlameTreeElement , error ) {
1673- name := s .pathElemName
1674- if s .GetLevel () == 0 {
1675- name = "root"
1676- }
1677- result := sdcpb .NewBlameTreeElement (name )
1678-
1679- // process Value
1680- highestLe := s .leafVariants .GetHighestPrecedence (false , true )
1681- if highestLe != nil {
1682- if highestLe .Update .Owner () != DefaultsIntentName || includeDefaults {
1683- result .SetValue (highestLe .Update .Value ()).SetOwner (highestLe .Update .Owner ())
1684-
1685- // check if running equals the expected
1686- runningLe := s .leafVariants .GetRunning ()
1687- if runningLe != nil {
1688- if ! proto .Equal (runningLe .Update .Value (), highestLe .Update .Value ()) {
1689- result .DeviationValue = runningLe .Value ()
1690- }
1691- }
1692- } else {
1693- // if it is default but no default is meant to be returned
1694- return nil , nil
1695- }
1696- }
1697-
1698- // process Childs
1699- for _ , c := range s .filterActiveChoiceCaseChilds () {
1700- childBlame , err := c .BlameConfig (includeDefaults )
1701- if err != nil {
1702- return nil , err
1703- }
1704- // if it is not meant to be added we will get nil, so check and skip in case
1705- if childBlame != nil {
1706- result .AddChild (childBlame )
1707- }
1708- }
1709-
1710- // sort to make te output stable
1711- slices .SortFunc (result .Childs , func (a * sdcpb.BlameTreeElement , b * sdcpb.BlameTreeElement ) int {
1712- return strings .Compare (a .GetName (), b .GetName ())
1713- })
1714-
1715- return result , nil
1716- }
1717-
17181661// getKeyName checks if s is a key level element in the tree, if not an error is throw
17191662// if it is a key level element, the name of the key is determined via the ancestor schemas
17201663func (s * sharedEntryAttributes ) getKeyName () (string , error ) {
@@ -1822,3 +1765,7 @@ func (s *sharedEntryAttributes) containsOnlyDefaults() bool {
18221765
18231766 return true
18241767}
1768+
1769+ func (s * sharedEntryAttributes ) GetLeafVariantEntries () LeafVariantEntries {
1770+ return s .leafVariants
1771+ }
0 commit comments