Skip to content

Commit 36b1fe1

Browse files
committed
ongoing
1 parent 9fff7ee commit 36b1fe1

12 files changed

+149
-51
lines changed

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ require (
2727
github.com/spf13/cobra v1.9.1
2828
github.com/spf13/pflag v1.0.6
2929
go.uber.org/mock v0.5.2
30-
google.golang.org/grpc v1.73.0
30+
google.golang.org/grpc v1.74.2
3131
google.golang.org/protobuf v1.36.6
3232
gopkg.in/yaml.v2 v2.4.0
3333
sigs.k8s.io/controller-runtime v0.20.4
3434
)
3535

3636
require (
37-
cloud.google.com/go/compute/metadata v0.6.0 // indirect
37+
cloud.google.com/go/compute/metadata v0.7.0 // indirect
3838
github.com/beorn7/perks v1.0.1 // indirect
3939
github.com/bufbuild/protocompile v0.14.1 // indirect
4040
github.com/cespare/xxhash/v2 v2.3.0 // indirect
@@ -53,7 +53,7 @@ require (
5353
github.com/go-openapi/jsonreference v0.21.0 // indirect
5454
github.com/go-openapi/swag v0.23.0 // indirect
5555
github.com/gogo/protobuf v1.3.2 // indirect
56-
github.com/golang/glog v1.2.4 // indirect
56+
github.com/golang/glog v1.2.5 // indirect
5757
github.com/golang/protobuf v1.5.4 // indirect
5858
github.com/google/flatbuffers v25.2.10+incompatible // indirect
5959
github.com/google/gnostic-models v0.6.9 // indirect
@@ -90,7 +90,7 @@ require (
9090
golang.org/x/crypto v0.39.0 // indirect
9191
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
9292
golang.org/x/net v0.41.0 // indirect
93-
golang.org/x/oauth2 v0.28.0 // indirect
93+
golang.org/x/oauth2 v0.30.0 // indirect
9494
golang.org/x/sync v0.15.0 // indirect
9595
golang.org/x/sys v0.33.0 // indirect
9696
golang.org/x/term v0.32.0 // indirect

go.sum

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2-
cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I=
3-
cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
2+
cloud.google.com/go/compute/metadata v0.7.0 h1:PBWF+iiAerVNe8UCHxdOt6eHLVc3ydFeOCw78U8ytSU=
3+
cloud.google.com/go/compute/metadata v0.7.0/go.mod h1:j5MvL9PprKL39t166CoB1uVHfQMs4tFQZZcKwksXUjo=
44
github.com/AlekSi/pointer v1.2.0 h1:glcy/gc4h8HnG2Z3ZECSzZ1IX1x2JxRVuDzaJwQE0+w=
55
github.com/AlekSi/pointer v1.2.0/go.mod h1:gZGfd3dpW4vEc/UlyfKKi1roIqcCgwOIvb0tSNSBle0=
66
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
@@ -66,8 +66,8 @@ github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZ
6666
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
6767
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
6868
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
69-
github.com/golang/glog v1.2.4 h1:CNNw5U8lSiiBk7druxtSHHTsRWcxKoac6kZKm2peBBc=
70-
github.com/golang/glog v1.2.4/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
69+
github.com/golang/glog v1.2.5 h1:DrW6hGnjIhtvhOIiAKT6Psh/Kd/ldepEa81DKeiRJ5I=
70+
github.com/golang/glog v1.2.5/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
7171
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
7272
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
7373
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -181,8 +181,6 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN
181181
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
182182
github.com/scrapli/scrapligo v1.3.3 h1:D9zj1QrOYNYAQ30YT7wfQBINvPGxvs5L5Lz+2LnL7V4=
183183
github.com/scrapli/scrapligo v1.3.3/go.mod h1:pOWxVyPsQRrWTrkoSSDg05tjOqtWfLffAZtAsCc0w3M=
184-
github.com/sdcio/cache v0.0.37 h1:PQHG8brcGrUHXQKvIab6ymgfJQOBZdfdSuA9Xrz9QXM=
185-
github.com/sdcio/cache v0.0.37/go.mod h1:TbeFOQTWU9RH+NpvwwcUc0KNeYGItfn2y0XxVFBLkiE=
186184
github.com/sdcio/goyang v1.6.2-2 h1:qfeUKBmoKpiKAruuEc3+V8wgHKP/n1jRDEnTy23knV8=
187185
github.com/sdcio/goyang v1.6.2-2/go.mod h1:5WolITjek1NF8yrNERyVZ7jqjOClJTpO8p/+OwmETM4=
188186
github.com/sdcio/schema-server v0.0.31 h1:gWSSDvyzwWy2xYu2TCQdXYvqCA0gg3RhYKb9PplYeD4=
@@ -218,10 +216,10 @@ go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
218216
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
219217
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
220218
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
221-
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
222-
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
223-
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
224-
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
219+
go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs=
220+
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
221+
go.opentelemetry.io/otel/sdk/metric v1.36.0 h1:r0ntwwGosWGaa0CrSt8cuNuTcccMXERFwHX4dThiPis=
222+
go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4=
225223
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
226224
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
227225
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
@@ -261,8 +259,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
261259
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
262260
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
263261
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
264-
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
265-
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
262+
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
263+
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
266264
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
267265
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
268266
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -318,8 +316,8 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac
318316
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
319317
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
320318
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
321-
google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok=
322-
google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc=
319+
google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4=
320+
google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM=
323321
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
324322
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
325323
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

pkg/tree/entry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ type Entry interface {
144144
ToXML(onlyNewOrUpdated bool, honorNamespace bool, operationWithNamespace bool, useOperationRemove bool) (*etree.Document, error)
145145
toXmlInternal(parent *etree.Element, onlyNewOrUpdated bool, honorNamespace bool, operationWithNamespace bool, useOperationRemove bool) (doAdd bool, err error)
146146
// ImportConfig allows importing config data received from e.g. the device in different formats (json, xml) to be imported into the tree.
147-
ImportConfig(ctx context.Context, importer importer.ImportConfigAdapter, intentName string, intentPrio int32, flags *types.UpdateInsertFlags) error
147+
ImportConfig(ctx context.Context, importer importer.ImportConfigAdapterElement, intentName string, intentPrio int32, flags *types.UpdateInsertFlags) error
148148
TreeExport(owner string) ([]*tree_persist.TreeElement, error)
149149
// DeleteSubtree Deletes from the tree, all elements of the PathSlice defined branch of the given owner
150150
DeleteSubtree(relativePath types.PathSlice, owner string) (remainsToExist bool, err error)

pkg/tree/importer/import_config_adapter.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ import (
77
// ImportConfigAdapter is used by the ImportConfig() of the Tree. It allows to import hierarchically organized config data into the tree with little overhead.
88
// implementation for JSON and XML do exist.
99
type ImportConfigAdapter interface {
10+
ImportConfigAdapterElement
11+
GetDeletes() *sdcpb.PathSet
12+
}
13+
14+
type ImportConfigAdapterElement interface {
1015
// GetElements returns the elements of a certain level.
1116
// This can be maps or arrays.
1217
// In case of arrays, the name is the key of the map that pointed to the List and
1318
// the content are the array values one after the other.
1419
// For maps, the key is the GetName() result and the GetElements() result is the referenced value
15-
GetElements() []ImportConfigAdapter
20+
GetElements() []ImportConfigAdapterElement
1621
// GetElement returns the value TreeImportable for a given field.
1722
// if the field is not present, nil is returned
18-
GetElement(key string) ImportConfigAdapter
23+
GetElement(key string) ImportConfigAdapterElement
1924
// GetKeyValue can be called on Leafs or LeafList elements to retrieve the underlaying value
2025
// When and were to expect a Leafs or LeafList is defined by the yang schema.
2126
// The String value is typically used for the keys.

pkg/tree/importer/json/json_tree_importer.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ func NewJsonTreeImporter(d any) *JsonTreeImporter {
2929
}
3030
}
3131

32-
func (j *JsonTreeImporter) GetElement(key string) importer.ImportConfigAdapter {
32+
func (j *JsonTreeImporter) GetDeletes() *sdcpb.PathSet {
33+
return sdcpb.NewPathSet()
34+
}
35+
36+
func (j *JsonTreeImporter) GetElement(key string) importer.ImportConfigAdapterElement {
3337
switch d := j.data.(type) {
3438
case map[string]any:
3539

@@ -46,11 +50,11 @@ func (j *JsonTreeImporter) GetElement(key string) importer.ImportConfigAdapter {
4650
return nil
4751
}
4852

49-
func (j *JsonTreeImporter) GetElements() []importer.ImportConfigAdapter {
50-
var result []importer.ImportConfigAdapter
53+
func (j *JsonTreeImporter) GetElements() []importer.ImportConfigAdapterElement {
54+
var result []importer.ImportConfigAdapterElement
5155
switch d := j.data.(type) {
5256
case map[string]any:
53-
result = make([]importer.ImportConfigAdapter, 0, len(d))
57+
result = make([]importer.ImportConfigAdapterElement, 0, len(d))
5458
for k, v := range d {
5559
beforeColon, key, found := strings.Cut(k, ":")
5660
if !found {

pkg/tree/importer/proto/proto_tree_importer.go

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,64 +11,69 @@ import (
1111
)
1212

1313
type ProtoTreeImporter struct {
14-
data *tree_persist.TreeElement
14+
ProtoTreeImporterElement
15+
deletes *sdcpb.PathSet
1516
}
1617

1718
func NewProtoTreeImporter(data *tree_persist.TreeElement) *ProtoTreeImporter {
1819
return &ProtoTreeImporter{
20+
ProtoTreeImporterElement: ProtoTreeImporterElement{
21+
data: data,
22+
},
23+
}
24+
}
25+
26+
type ProtoTreeImporterElement struct {
27+
data *tree_persist.TreeElement
28+
}
29+
30+
func NewProtoTreeImporterElement(data *tree_persist.TreeElement) *ProtoTreeImporterElement {
31+
return &ProtoTreeImporterElement{
1932
data: data,
2033
}
2134
}
2235

23-
func (p *ProtoTreeImporter) GetElements() []importer.ImportConfigAdapter {
36+
func (p *ProtoTreeImporter) GetDeletes() *sdcpb.PathSet {
37+
return p.deletes
38+
}
39+
40+
func (p *ProtoTreeImporterElement) GetElements() []importer.ImportConfigAdapterElement {
2441
if len(p.data.Childs) == 0 {
2542
return nil
2643
}
27-
result := []importer.ImportConfigAdapter{}
44+
result := []importer.ImportConfigAdapterElement{}
2845
for _, c := range p.data.Childs {
29-
result = append(result, NewProtoTreeImporter(c))
46+
result = append(result, NewProtoTreeImporterElement(c))
3047
}
3148
return result
3249
}
3350

34-
// func (p *ProtoTreeImporter) getListElements(elems []*tree_persist.TreeElement) []*tree_persist.TreeElement {
35-
// result := make([]*tree_persist.TreeElement, 0, len(elems))
36-
// for _, elem := range elems {
37-
// if elem.Name == "" {
38-
// result = append(result, &tree_persist.TreeElement{Name: p.data.Name, Childs: p.getListElements(elem.GetChilds())})
39-
// } else {
40-
// result = append(result, p.getListElements(elem.GetChilds())...)
41-
// }
42-
// }
43-
// return result
44-
// }
45-
46-
func (p *ProtoTreeImporter) GetElement(key string) importer.ImportConfigAdapter {
51+
func (p *ProtoTreeImporterElement) GetElement(key string) importer.ImportConfigAdapterElement {
4752
for _, c := range p.data.Childs {
4853
if c.Name == key {
49-
return NewProtoTreeImporter(c)
54+
return NewProtoTreeImporterElement(c)
5055
}
5156
}
5257
return nil
5358
}
5459

55-
func (p *ProtoTreeImporter) GetKeyValue() (string, error) {
60+
func (p *ProtoTreeImporterElement) GetKeyValue() (string, error) {
5661
tv, err := p.GetTVValue(nil)
5762
if err != nil {
5863
return "", fmt.Errorf("failed GetTVValue for %s", p.data.Name)
5964
}
6065
return utils.TypedValueToString(tv), nil
6166
}
6267

63-
func (p *ProtoTreeImporter) GetTVValue(slt *sdcpb.SchemaLeafType) (*sdcpb.TypedValue, error) {
68+
func (p *ProtoTreeImporterElement) GetTVValue(slt *sdcpb.SchemaLeafType) (*sdcpb.TypedValue, error) {
6469
result := &sdcpb.TypedValue{}
6570
err := proto.Unmarshal(p.data.LeafVariant, result)
6671
if err != nil {
6772
return nil, err
6873
}
6974
return result, nil
7075
}
71-
func (p *ProtoTreeImporter) GetName() string {
76+
func (p *ProtoTreeImporterElement) GetName() string {
7277
return p.data.Name
7378
}
7479

pkg/tree/importer/xml/xml_tree_importer.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,25 @@ func NewXmlTreeImporter(d *etree.Element) *XmlTreeImporter {
1717
}
1818
}
1919

20-
func (x *XmlTreeImporter) GetElement(key string) importer.ImportConfigAdapter {
20+
func (x *XmlTreeImporter) GetDeletes() *sdcpb.PathSet {
21+
return sdcpb.NewPathSet()
22+
}
23+
24+
func (x *XmlTreeImporter) GetElement(key string) importer.ImportConfigAdapterElement {
2125
e := x.elem.FindElement(key)
2226
if e == nil {
2327
return nil
2428
}
2529
return NewXmlTreeImporter(e)
2630
}
2731

28-
func (x *XmlTreeImporter) GetElements() []importer.ImportConfigAdapter {
32+
func (x *XmlTreeImporter) GetElements() []importer.ImportConfigAdapterElement {
2933
childs := x.elem.ChildElements()
3034
if len(childs) == 0 {
3135
return nil
3236
}
3337

34-
result := make([]importer.ImportConfigAdapter, 0, len(childs))
38+
result := make([]importer.ImportConfigAdapterElement, 0, len(childs))
3539

3640
for _, c := range childs {
3741
result = append(result, NewXmlTreeImporter(c))

pkg/tree/intent_path_mapping.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package tree
2+
3+
import (
4+
"iter"
5+
6+
sdcpb "github.com/sdcio/sdc-protos/sdcpb"
7+
)
8+
9+
type DeletePaths struct {
10+
data map[string]*sdcpb.PathSet
11+
}
12+
13+
func NewDeletePaths() *DeletePaths {
14+
return &DeletePaths{
15+
data: map[string]*sdcpb.PathSet{},
16+
}
17+
}
18+
19+
func (dp *DeletePaths) Add(intentName string, pathset *sdcpb.PathSet) {
20+
set, exists := dp.data[intentName]
21+
if !exists {
22+
set = sdcpb.NewPathSet()
23+
dp.data[intentName] = set
24+
}
25+
set.Join(pathset)
26+
}
27+
28+
func (dp *DeletePaths) Items() iter.Seq[*sdcpb.Path] {
29+
return func(yield func(*sdcpb.Path) bool) {
30+
for _, val := range dp.data {
31+
for path := range val.Items() {
32+
if !yield(path) {
33+
return
34+
}
35+
}
36+
}
37+
}
38+
}

pkg/tree/root_entry.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import (
1212
"github.com/sdcio/data-server/pkg/tree/tree_persist"
1313
"github.com/sdcio/data-server/pkg/tree/types"
1414
sdcpb "github.com/sdcio/sdc-protos/sdcpb"
15+
log "github.com/sirupsen/logrus"
1516
)
1617

1718
// RootEntry the root of the cache.Update tree
1819
type RootEntry struct {
1920
*sharedEntryAttributes
21+
explicitDeletes *DeletePaths
2022
}
2123

2224
var (
@@ -32,6 +34,7 @@ func NewTreeRoot(ctx context.Context, tc *TreeContext) (*RootEntry, error) {
3234

3335
root := &RootEntry{
3436
sharedEntryAttributes: sea,
37+
explicitDeletes: NewDeletePaths(),
3538
}
3639

3740
err = tc.SetRoot(sea)
@@ -86,6 +89,8 @@ func (r *RootEntry) ImportConfig(ctx context.Context, basePath types.PathSlice,
8689
return err
8790
}
8891

92+
r.explicitDeletes.Add(intentName, importer.GetDeletes())
93+
8994
return e.ImportConfig(ctx, importer, intentName, intentPrio, flags)
9095
}
9196

@@ -228,3 +233,20 @@ func (r *RootEntry) DeleteSubtreePaths(deletes types.DeleteEntriesList, intentNa
228233
}
229234
return remainsToExist, nil
230235
}
236+
237+
func (r *RootEntry) FinishInsertionPhase(ctx context.Context) error {
238+
// apply the explicit deletes
239+
edv := NewExplicitDeleteVisitor()
240+
for path := range r.explicitDeletes.Items() {
241+
entry, err := r.NavigateSdcpbPath(ctx, path.Elem, true)
242+
if err != nil {
243+
log.Warnf("Applying explicit delete: path %s not found, skipping", path.ToXPath(false))
244+
}
245+
err = entry.Walk(ctx, edv)
246+
if err != nil {
247+
return err
248+
}
249+
}
250+
251+
return r.sharedEntryAttributes.FinishInsertionPhase(ctx)
252+
}

pkg/tree/sharedEntryAttributes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ func (s *sharedEntryAttributes) validatePattern(resultChan chan<- *types.Validat
11461146
}
11471147
}
11481148

1149-
func (s *sharedEntryAttributes) ImportConfig(ctx context.Context, t importer.ImportConfigAdapter, intentName string, intentPrio int32, insertFlags *types.UpdateInsertFlags) error {
1149+
func (s *sharedEntryAttributes) ImportConfig(ctx context.Context, t importer.ImportConfigAdapterElement, intentName string, intentPrio int32, insertFlags *types.UpdateInsertFlags) error {
11501150
var err error
11511151

11521152
switch x := s.schema.GetSchema().(type) {

0 commit comments

Comments
 (0)