From 53e839a11b1a7cda1afb89c3d297b8d7cabf3f11 Mon Sep 17 00:00:00 2001 From: steiler Date: Fri, 2 Aug 2024 09:29:31 +0200 Subject: [PATCH 1/2] Making it possible to also lookup modules --- pkg/datastore/data_rpc.go | 11 +++---- pkg/datastore/intent_rpc_set_update_test.go | 4 --- pkg/tree/entry.go | 1 + tests/schema/sdcio_model_doublekey.yang | 33 --------------------- tests/sdcioygot/sdcio_schema.go | 2 +- 5 files changed, 8 insertions(+), 43 deletions(-) diff --git a/pkg/datastore/data_rpc.go b/pkg/datastore/data_rpc.go index 5fa8e42..2a2de10 100644 --- a/pkg/datastore/data_rpc.go +++ b/pkg/datastore/data_rpc.go @@ -1130,11 +1130,7 @@ func getLeafList(s string, cs *sdcpb.SchemaElem_Container) (*sdcpb.LeafListSchem } func (d *Datastore) getChild(ctx context.Context, s string, cs *sdcpb.SchemaElem_Container) (string, bool) { - for _, c := range cs.Container.GetChildren() { - if c == s { - return c, true - } - } + if cs.Container.Name == "__root__" { for _, c := range cs.Container.GetChildren() { rsp, err := d.getValidationClient().GetSchema(ctx, &sdcpb.Path{Elem: []*sdcpb.PathElem{{Name: c}}}) @@ -1154,6 +1150,11 @@ func (d *Datastore) getChild(ctx context.Context, s string, cs *sdcpb.SchemaElem } } } + for _, c := range cs.Container.GetChildren() { + if c == s { + return c, true + } + } return "", false } diff --git a/pkg/datastore/intent_rpc_set_update_test.go b/pkg/datastore/intent_rpc_set_update_test.go index 2902995..a517550 100644 --- a/pkg/datastore/intent_rpc_set_update_test.go +++ b/pkg/datastore/intent_rpc_set_update_test.go @@ -653,10 +653,6 @@ func TestDatastore_populateTree(t *testing.T) { cacheClient := mockcacheclient.NewMockClient(controller) testhelper.ConfigureCacheClientMock(t, cacheClient, tt.intendedStoreUpdates, tt.expectedModify, tt.expectedDeletes) - // create a schema client mock - // schemaClient := mockschema.NewMockClient(controller) - // testhelper.ConfigureSchemaClientMock(t, schemaClient) - schemaClient, schema, err := testhelper.InitSDCIOSchema() if err != nil { t.Fatal(err) diff --git a/pkg/tree/entry.go b/pkg/tree/entry.go index daa8eaa..2570f69 100644 --- a/pkg/tree/entry.go +++ b/pkg/tree/entry.go @@ -622,6 +622,7 @@ func (s *sharedEntryAttributes) populateChoiceCaseResolvers() { if val := s.treeContext.GetBranchesHighesPrecedence(s.Path(), CacheUpdateFilterExcludeOwner(s.treeContext.GetActualOwner())); val < math.MaxInt32 { choiceResolver.SetValue(elem, val, false) } + // set the value from the tree as well if childExists { v := child.getHighestPrecedenceValueOfBranch() diff --git a/tests/schema/sdcio_model_doublekey.yang b/tests/schema/sdcio_model_doublekey.yang index c53c889..5022aaf 100644 --- a/tests/schema/sdcio_model_doublekey.yang +++ b/tests/schema/sdcio_model_doublekey.yang @@ -3,11 +3,6 @@ module sdcio_model_doublekey { namespace "urn:sdcio/model_doublekey"; prefix sdcio_model_doublekey; - // import sdcio_model_common { - // prefix sdcio_model_common; - // } - - description "This is part of the test schema for sdcio"; @@ -42,34 +37,6 @@ module sdcio_model_doublekey { } } - // choice choicecase { - // container case1 { - // presence "case1 is active"; - // description - // "case 1 of the choicecase"; - // leaf log { - // type boolean; - // default "false"; - // description "When this is true, a log is created for each packet matching the entry"; - // } - // container case-elem { - // leaf elem { - // type string; - // description "some element under the case"; - // } - // } - // } - // container case2 { - // presence "case1 is active"; - // description - // "case 1 of the choicecase"; - // leaf log { - // type boolean; - // default "false"; - // description "When this is true, a log is created for each packet matching the entry"; - // } - // } - // } } } } \ No newline at end of file diff --git a/tests/sdcioygot/sdcio_schema.go b/tests/sdcioygot/sdcio_schema.go index 7be0666..14c31b5 100644 --- a/tests/sdcioygot/sdcio_schema.go +++ b/tests/sdcioygot/sdcio_schema.go @@ -4,7 +4,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was false in this case). -This package was generated by /home/mava/go/pkg/mod/github.com/openconfig/ygot@v0.29.19/genutil/names.go +This package was generated by /home/mava/go/pkg/mod/github.com/openconfig/ygot@v0.29.20/genutil/names.go using the following YANG input files: - ./tests/schema/sdcio_model.yang - ./tests/schema/sdcio_model_choice.yang From 1ede93b99b5319556c6095cddd8de62cb550eec5 Mon Sep 17 00:00:00 2001 From: steiler Date: Fri, 2 Aug 2024 09:50:53 +0200 Subject: [PATCH 2/2] update dependency --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6db1792..09f4d66 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/prometheus/client_golang v1.18.0 github.com/scrapli/scrapligo v1.2.0 github.com/sdcio/cache v0.0.34 - github.com/sdcio/schema-server v0.0.18 + github.com/sdcio/schema-server v0.0.19 github.com/sdcio/sdc-protos v0.0.25 github.com/sdcio/yang-parser v0.0.5 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 83873b5..780981b 100644 --- a/go.sum +++ b/go.sum @@ -230,8 +230,8 @@ github.com/scrapli/scrapligo v1.2.0 h1:jn83HPkKAPDzvth7i9V/70BAPuVgriU+/tHHv3eAt github.com/scrapli/scrapligo v1.2.0/go.mod h1:rRx/rT2oNPYztiT3/ik0FRR/Ro7AdzN/eR9AtF8A81Y= github.com/sdcio/cache v0.0.34 h1:mDxIPN9r339yHykCPJZFKX0va8RMoAscErbEkAcql7E= github.com/sdcio/cache v0.0.34/go.mod h1:u/rIbC03e6k+J19VWo8DwJdBWY0vzNZ25viXRmrS+5I= -github.com/sdcio/schema-server v0.0.18 h1:/XOPFLlg6DQpzPREKRvZRvbGuBysq83I4vE4B3z27Jc= -github.com/sdcio/schema-server v0.0.18/go.mod h1:XZ3331BOwLuX+ZXMIqfdpC98GPc6ojBiOAt2X5NLKk4= +github.com/sdcio/schema-server v0.0.19 h1:Toql//LOttivzrlL1QBF2dhrbaA+e2wzdpG2ObwFjAA= +github.com/sdcio/schema-server v0.0.19/go.mod h1:XZ3331BOwLuX+ZXMIqfdpC98GPc6ojBiOAt2X5NLKk4= github.com/sdcio/sdc-protos v0.0.25 h1:VYzuLv07y/kjSTD9x99Il46Uv4leKXjXWN0O/wsi7zI= github.com/sdcio/sdc-protos v0.0.25/go.mod h1:iVVPmQTRzoCV4abQ4QL5mJethvRVfdV8cHcVyDtSNs4= github.com/sdcio/yang-parser v0.0.5 h1:YwpgQt2/n3BHFrEa0n0sQ4Q2hLCrTFY2VDKO+2BgoVg=