Skip to content
Permalink
Browse files

Merge pull request #95 from openconfig/flag-uses

Flag-control whether new 'Uses' field is populated.
  • Loading branch information...
robshakir committed Apr 8, 2019
2 parents dd67dc9 + 65283be commit e8b0ed2cbb0c40683bc0785ea2c796b2c12df80f
Showing with 16 additions and 3 deletions.
  1. +3 −1 pkg/yang/entry.go
  2. +8 −2 pkg/yang/entry_test.go
  3. +5 −0 pkg/yang/options.go
@@ -796,7 +796,9 @@ func ToEntry(n Node) (e *Entry) {
for _, a := range fv.Interface().([]*Uses) {
grouping := ToEntry(a)
e.merge(nil, nil, grouping)
e.Uses = append(e.Uses, &UsesStmt{a, grouping.shallowDup()})
if ParseOptions.StoreUses {
e.Uses = append(e.Uses, &UsesStmt{a, grouping.shallowDup()})
}
}
case "type":
// The type keyword is specific to deviate to change a type. Other type handling
@@ -405,7 +405,7 @@ module when {
}
anyxml eta {
when "../condition = 'eta'";
when "../condition = 'eta'";
}
anydata theta {
@@ -428,6 +428,9 @@ module when {
}

func TestGetWhenXPath(t *testing.T) {
ParseOptions.StoreUses = true
defer func() { ParseOptions.StoreUses = false }()

ms := NewModules()
for _, tt := range testWhenModules {
if err := ms.Parse(tt.in, tt.name); err != nil {
@@ -696,6 +699,9 @@ func TestAugmentedEntry(t *testing.T) {
}

func TestUsesEntry(t *testing.T) {
ParseOptions.StoreUses = true
defer func() { ParseOptions.StoreUses = false }()

ms := NewModules()
for _, tt := range testAugmentAndUsesModules {
if err := ms.Parse(tt.in, tt.name); err != nil {
@@ -813,7 +819,7 @@ module mod {
container level1-3{
container level2-3 {
leaf level3-1 { type string;}
}
}
}
}
}
@@ -22,6 +22,11 @@ type Options struct {
// package will explicitly ignore the case where a submodule will include
// itself through a circular reference.
IgnoreSubmoduleCircularDependencies bool
// StoreUses controls whether the Uses field of each YANG entry should be
// populated. Setting this value to true will cause each Entry which is
// generated within the schema to store the logical grouping from which it
// is derived.
StoreUses bool
}

// ParseOptions sets the options for the current YANG module parsing. It can be

0 comments on commit e8b0ed2

Please sign in to comment.
You can’t perform that action at this time.