Skip to content

Commit

Permalink
Merge pull request #157 from sdcio/fixmodulelookup
Browse files Browse the repository at this point in the history
Making it possible to also lookup modules
  • Loading branch information
steiler authored Aug 2, 2024
2 parents 1693ada + 1ede93b commit f15cbe3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 46 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
11 changes: 6 additions & 5 deletions pkg/datastore/data_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}})
Expand All @@ -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
}

Expand Down
4 changes: 0 additions & 4 deletions pkg/datastore/intent_rpc_set_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/tree/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
33 changes: 0 additions & 33 deletions tests/schema/sdcio_model_doublekey.yang
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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";
// }
// }
// }
}
}
}
2 changes: 1 addition & 1 deletion tests/sdcioygot/sdcio_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f15cbe3

Please sign in to comment.