diff --git a/gogen/genir_test.go b/gogen/genir_test.go index 5545c510..71dfc2bc 100644 --- a/gogen/genir_test.go +++ b/gogen/genir_test.go @@ -161,6 +161,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/zero", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{ @@ -211,6 +212,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/two", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{ @@ -451,6 +453,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/zero", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{NativeType: "string", ZeroValue: `""`}, @@ -472,6 +475,7 @@ func TestGenerateIR(t *testing.T) { ShadowSchemaPath: "/parent/child/config/one", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{ @@ -498,6 +502,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/two", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{ @@ -525,6 +530,7 @@ func TestGenerateIR(t *testing.T) { ShadowSchemaPath: "/parent/child/config/three", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{ @@ -552,6 +558,7 @@ func TestGenerateIR(t *testing.T) { ShadowSchemaPath: "/parent/child/config/four", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{ @@ -589,6 +596,7 @@ func TestGenerateIR(t *testing.T) { ShadowSchemaPath: "/remote-container/config/a-leaf", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{ @@ -753,6 +761,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 1, MappedPaths: [][]string{{"state"}}, @@ -872,6 +881,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/four", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -898,6 +908,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/one", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -924,6 +935,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/three", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -950,6 +962,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/two", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -976,6 +989,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/zero", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -1030,6 +1044,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/remote-container/state", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 1, MappedPaths: [][]string{{"state"}}, @@ -1095,6 +1110,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/remote-container/state/a-leaf", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -1365,6 +1381,7 @@ func TestGenerateIR(t *testing.T) { DefiningModule: "openconfig-complex", Path: "/openconfig-complex/model/c/unkeyed-list", SchemaPath: "/model/c/unkeyed-list", + ConfigFalse: true, }, Type: ygen.ListNode, MappedPaths: [][]string{{"c", "unkeyed-list"}}, @@ -1783,6 +1800,7 @@ func TestGenerateIR(t *testing.T) { DefiningModule: "openconfig-complex", Path: "/openconfig-complex/model/c/unkeyed-list/field", SchemaPath: "/model/c/unkeyed-list/field", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{NativeType: "Binary", ZeroValue: "nil"}, diff --git a/protogen/genir_test.go b/protogen/genir_test.go index afd04010..47f17f2d 100644 --- a/protogen/genir_test.go +++ b/protogen/genir_test.go @@ -201,6 +201,7 @@ func protoIR(nestedDirectories bool) *ygen.IR { DefiningModule: "openconfig-complex", Path: "/openconfig-complex/model/c/unkeyed-list", SchemaPath: "/model/c/unkeyed-list", + ConfigFalse: true, }, Type: ygen.ListNode, MappedPaths: [][]string{{"", "model", "c", "unkeyed-list"}}, @@ -837,6 +838,7 @@ func protoIR(nestedDirectories bool) *ygen.IR { DefiningModule: "openconfig-complex", Path: "/openconfig-complex/model/c/unkeyed-list/field", SchemaPath: "/model/c/unkeyed-list/field", + ConfigFalse: true, }, Type: ygen.LeafNode, LangType: &ygen.MappedType{NativeType: "ywrapper.BytesValue"}, @@ -1154,6 +1156,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 1, MappedPaths: [][]string{{"state"}}, @@ -1273,6 +1276,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/four", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -1299,6 +1303,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/one", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -1325,6 +1330,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/three", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -1352,6 +1358,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/two", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -1378,6 +1385,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/parent/child/state/zero", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ @@ -1432,6 +1440,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/remote-container/state", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 1, MappedPaths: [][]string{{"state"}}, @@ -1498,6 +1507,7 @@ func TestGenerateIR(t *testing.T) { SchemaPath: "/remote-container/state/a-leaf", LeafrefTargetPath: "", Description: "", + ConfigFalse: true, }, Type: 3, LangType: &ygen.MappedType{ diff --git a/ygen/directory.go b/ygen/directory.go index 17020a04..ca3231c4 100644 --- a/ygen/directory.go +++ b/ygen/directory.go @@ -263,6 +263,7 @@ func getOrderedDirDetails(langMapper LangMapper, directory map[string]*Directory SchemaPath: util.SchemaTreePathNoModule(field), LeafrefTargetPath: target.Path(), Description: field.Description, + ConfigFalse: !util.IsConfig(field), }, MappedPaths: mp, MappedPathModules: mm, diff --git a/ygen/ir.go b/ygen/ir.go index 1bfa5af7..81a521e2 100644 --- a/ygen/ir.go +++ b/ygen/ir.go @@ -699,6 +699,12 @@ type YANGNodeDetails struct { // OrderedByUser indicates whether the node has the modifier // "ordered-by user". OrderedByUser bool + // ConfigFalse represents whether the node is state data as opposed to + // configuration data. + // The meaning of "config" is exactly the same as the "config" + // statement in YANG: + // https://datatracker.ietf.org/doc/html/rfc7950#section-7.21.1 + ConfigFalse bool } // EnumeratedValueType is used to indicate the source YANG type