Skip to content

Commit

Permalink
Add ConfigFalse to IR for directory fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
wenovus committed Jul 26, 2023
1 parent 0a6b89a commit b078e92
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions gogen/genir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/zero",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: ygen.LeafNode,
LangType: &ygen.MappedType{
Expand Down Expand Up @@ -211,6 +212,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/two",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: ygen.LeafNode,
LangType: &ygen.MappedType{
Expand Down Expand Up @@ -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: `""`},
Expand All @@ -472,6 +475,7 @@ func TestGenerateIR(t *testing.T) {
ShadowSchemaPath: "/parent/child/config/one",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: ygen.LeafNode,
LangType: &ygen.MappedType{
Expand All @@ -498,6 +502,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/two",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: ygen.LeafNode,
LangType: &ygen.MappedType{
Expand Down Expand Up @@ -525,6 +530,7 @@ func TestGenerateIR(t *testing.T) {
ShadowSchemaPath: "/parent/child/config/three",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: ygen.LeafNode,
LangType: &ygen.MappedType{
Expand Down Expand Up @@ -552,6 +558,7 @@ func TestGenerateIR(t *testing.T) {
ShadowSchemaPath: "/parent/child/config/four",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: ygen.LeafNode,
LangType: &ygen.MappedType{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -753,6 +761,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 1,
MappedPaths: [][]string{{"state"}},
Expand Down Expand Up @@ -872,6 +881,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/four",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand All @@ -898,6 +908,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/one",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand All @@ -924,6 +935,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/three",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand All @@ -950,6 +962,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/two",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand All @@ -976,6 +989,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/zero",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand Down Expand Up @@ -1030,6 +1044,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/remote-container/state",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 1,
MappedPaths: [][]string{{"state"}},
Expand Down Expand Up @@ -1095,6 +1110,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/remote-container/state/a-leaf",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand Down Expand Up @@ -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"}},
Expand Down Expand Up @@ -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"},
Expand Down
10 changes: 10 additions & 0 deletions protogen/genir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}},
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -1154,6 +1156,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 1,
MappedPaths: [][]string{{"state"}},
Expand Down Expand Up @@ -1273,6 +1276,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/four",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand All @@ -1299,6 +1303,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/one",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand All @@ -1325,6 +1330,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/three",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand Down Expand Up @@ -1352,6 +1358,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/two",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand All @@ -1378,6 +1385,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/parent/child/state/zero",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand Down Expand Up @@ -1432,6 +1440,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/remote-container/state",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 1,
MappedPaths: [][]string{{"state"}},
Expand Down Expand Up @@ -1498,6 +1507,7 @@ func TestGenerateIR(t *testing.T) {
SchemaPath: "/remote-container/state/a-leaf",
LeafrefTargetPath: "",
Description: "",
ConfigFalse: true,
},
Type: 3,
LangType: &ygen.MappedType{
Expand Down
1 change: 1 addition & 0 deletions ygen/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions ygen/ir.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b078e92

Please sign in to comment.