Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate ΛEnumTypes for shadow paths #917

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93,551 changes: 49,129 additions & 44,422 deletions exampleoc/oc.go

Large diffs are not rendered by default.

4,895 changes: 4,307 additions & 588 deletions exampleoc/ocpath.go

Large diffs are not rendered by default.

92,494 changes: 48,488 additions & 44,006 deletions exampleoc/opstateoc/oc.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions exampleoc/opstateoc/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ go run ../../generator/generator.go -path=public,deps -output_file=oc.go \
public/release/models/optical-transport/openconfig-terminal-device.yang \
public/release/models/optical-transport/openconfig-transport-line-protection.yang \
public/release/models/platform/openconfig-platform.yang \
public/release/models/bgp/openconfig-bgp-policy.yang \
public/release/models/policy/openconfig-routing-policy.yang \
public/release/models/lacp/openconfig-lacp.yang \
public/release/models/system/openconfig-system.yang \
Expand Down
1 change: 1 addition & 0 deletions exampleoc/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ go run ../generator/generator.go -path=public,deps -output_file=oc.go \
public/release/models/optical-transport/openconfig-terminal-device.yang \
public/release/models/optical-transport/openconfig-transport-line-protection.yang \
public/release/models/platform/openconfig-platform.yang \
public/release/models/bgp/openconfig-bgp-policy.yang \
public/release/models/policy/openconfig-routing-policy.yang \
public/release/models/lacp/openconfig-lacp.yang \
public/release/models/system/openconfig-system.yang \
Expand Down
5 changes: 5 additions & 0 deletions exampleoc/wrapperunionoc/oc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ It should not be used within your application, as it WILL change,
without warning. Rather, you should generate structs directly from
OpenConfig models using the ygot package.

NOTE WELL: This is an example code file that is distributed with ygot.
It should not be used within your application, as it WILL change,
without warning. Rather, you should generate structs directly from
OpenConfig models using the ygot package.

This package was generated by github.com/openconfig/ygot
using the following YANG input files:
- public/release/models/network-instance/openconfig-network-instance.yang
Expand Down
8 changes: 6 additions & 2 deletions gogen/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bytes"
"fmt"
"sort"
"strings"

"github.com/openconfig/ygot/internal/igenutil"
"github.com/openconfig/ygot/util"
Expand Down Expand Up @@ -275,7 +274,7 @@ func (cg *CodeGenerator) Generate(yangFiles, includePaths []string) (*GeneratedC
field := dir.Fields[fn]

// Strip the module name from the path.
wenovus marked this conversation as resolved.
Show resolved Hide resolved
schemaPath := util.SlicePathToString(append([]string{""}, strings.Split(field.YANGDetails.Path, "/")[2:]...))
schemaPath := field.YANGDetails.SchemaPath
switch {
case field.LangType == nil:
// This is a directory, so we continue.
Expand Down Expand Up @@ -304,6 +303,11 @@ func (cg *CodeGenerator) Generate(yangFiles, includePaths []string) (*GeneratedC
return field.LangType.UnionTypes[enumTypeMap[schemaPath][i]].Index < field.LangType.UnionTypes[enumTypeMap[schemaPath][j]].Index
})
}
if v, ok := enumTypeMap[schemaPath]; ok {
if shadowPath := field.YANGDetails.ShadowSchemaPath; shadowPath != "" {
enumTypeMap[shadowPath] = v
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,8 @@ func initΛEnumTypes(){
"/parent/child/config/three": []reflect.Type{
reflect.TypeOf((E_Child_Three)(0)),
},
"/parent/child/state/three": []reflect.Type{
reflect.TypeOf((E_Child_Three)(0)),
},
}
}
Loading
Loading