Skip to content

Commit 4de1c5a

Browse files
sort schemaKeys to match tree internal representation
1 parent e738225 commit 4de1c5a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pkg/tree/sharedEntryAttributes.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ func (s *sharedEntryAttributes) checkAndCreateKeysAsLeafs(ctx context.Context, i
212212
// if we're in the last level of keys, then we need to add the defaults
213213
if len(ancestorContainerSchema.Keys) == levelsUp {
214214
// iterate through the keys
215-
for idx, k := range ancestor.GetSchemaKeys() {
215+
schemaKeys := ancestor.GetSchemaKeys()
216+
slices.Sort(schemaKeys)
217+
for idx, k := range schemaKeys {
216218
child, entryExists := s.childs.GetEntry(k)
217219
// if the key Leaf exists continue with next key
218220
if entryExists {
@@ -1140,13 +1142,13 @@ func (s *sharedEntryAttributes) ImportConfig(ctx context.Context, t importer.Imp
11401142
var exists bool
11411143
var actualEntry Entry = s
11421144
var keyChild Entry
1143-
for _, keySchema := range s.schema.GetContainer().GetKeys() {
1145+
schemaKeys := s.GetSchemaKeys()
1146+
slices.Sort(schemaKeys)
1147+
for _, schemaKey := range schemaKeys {
11441148

1145-
keyElemName := keySchema.Name
1146-
1147-
keyTransf := t.GetElement(keyElemName)
1149+
keyTransf := t.GetElement(schemaKey)
11481150
if keyTransf == nil {
1149-
return fmt.Errorf("unable to find key attribute %s under %s", keyElemName, s.Path())
1151+
return fmt.Errorf("unable to find key attribute %s under %s", schemaKey, s.Path())
11501152
}
11511153
keyElemValue, err := keyTransf.GetKeyValue()
11521154
if err != nil {

0 commit comments

Comments
 (0)