Skip to content

workaround for map declaration limit (ΛEnumTypes) #641

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

Merged
merged 5 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
80,453 changes: 40,241 additions & 40,212 deletions exampleoc/oc.go

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions exampleoc/ocpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -96022,6 +96022,16 @@ type NetworkInstance_Protocol_Bgp_Neighbor_NeighborAddressPathAny struct {
*ygot.NodePath
}

// NetworkInstance_Protocol_Bgp_Neighbor_NeighborPortPath represents the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/config/neighbor-port YANG schema element.
type NetworkInstance_Protocol_Bgp_Neighbor_NeighborPortPath struct {
*ygot.NodePath
}

// NetworkInstance_Protocol_Bgp_Neighbor_NeighborPortPathAny represents the wildcard version of the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/config/neighbor-port YANG schema element.
type NetworkInstance_Protocol_Bgp_Neighbor_NeighborPortPathAny struct {
*ygot.NodePath
}

// NetworkInstance_Protocol_Bgp_Neighbor_PeerAsPath represents the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/config/peer-as YANG schema element.
type NetworkInstance_Protocol_Bgp_Neighbor_PeerAsPath struct {
*ygot.NodePath
Expand Down Expand Up @@ -96806,6 +96816,38 @@ func (n *NetworkInstance_Protocol_Bgp_NeighborPathAny) NeighborAddress() *Networ
}
}

// NeighborPort (leaf): Port number of the BGP peer
// ----------------------------------------
// Defining module: "openconfig-bgp-neighbor"
// Instantiating module: "openconfig-network-instance"
// Path from parent: "config/neighbor-port"
// Path from root: "/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/config/neighbor-port"
func (n *NetworkInstance_Protocol_Bgp_NeighborPath) NeighborPort() *NetworkInstance_Protocol_Bgp_Neighbor_NeighborPortPath {
return &NetworkInstance_Protocol_Bgp_Neighbor_NeighborPortPath{
NodePath: ygot.NewNodePath(
[]string{"config", "neighbor-port"},
map[string]interface{}{},
n,
),
}
}

// NeighborPort (leaf): Port number of the BGP peer
// ----------------------------------------
// Defining module: "openconfig-bgp-neighbor"
// Instantiating module: "openconfig-network-instance"
// Path from parent: "config/neighbor-port"
// Path from root: "/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/config/neighbor-port"
func (n *NetworkInstance_Protocol_Bgp_NeighborPathAny) NeighborPort() *NetworkInstance_Protocol_Bgp_Neighbor_NeighborPortPathAny {
return &NetworkInstance_Protocol_Bgp_Neighbor_NeighborPortPathAny{
NodePath: ygot.NewNodePath(
[]string{"config", "neighbor-port"},
map[string]interface{}{},
n,
),
}
}

// PeerAs (leaf): AS number of the peer.
// ----------------------------------------
// Defining module: "openconfig-bgp-common"
Expand Down
80,194 changes: 40,105 additions & 40,089 deletions exampleoc/opstateoc/oc.go

Large diffs are not rendered by default.

80,698 changes: 40,369 additions & 40,329 deletions exampleoc/wrapperunionoc/oc.go

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions integration_tests/schemaops/testschema/testschema.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 /usr/local/google/home/wenbli/gocode/src/github.com/openconfig/ygot4/genutil/names.go
This package was generated by /home/steiler/projects/ygot/genutil/names.go
using the following YANG input files:
- yang/testschema.yang
- yang/refschema.yang
Expand Down Expand Up @@ -75,10 +75,12 @@ type UnionUnsupported struct {

var (
SchemaTree map[string]*yang.Entry
ΛEnumTypes map[string][]reflect.Type
)

func init() {
var err error
initΛEnumTypes()
if SchemaTree, err = UnzipSchema(); err != nil {
panic("schema error: " + err.Error())
}
Expand Down Expand Up @@ -641,4 +643,6 @@ var (
// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{}
func initΛEnumTypes() {
ΛEnumTypes = map[string][]reflect.Type{}
}
10,074 changes: 5,041 additions & 5,033 deletions uexampleoc/oc.go

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion ygen/gogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,12 @@ type UnionUnsupported struct {

var (
SchemaTree map[string]*yang.Entry
ΛEnumTypes map[string][]reflect.Type
)

func init() {
var err error
initΛEnumTypes()
if SchemaTree, err = UnzipSchema(); err != nil {
panic("schema error: " + err.Error())
}
Expand Down Expand Up @@ -1005,14 +1007,16 @@ var ΛEnum = map[string]map[int64]ygot.EnumDefinition{
// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{
func initΛEnumTypes(){
ΛEnumTypes = map[string][]reflect.Type{
{{- range $schemapath, $types := . }}
"{{ $schemapath }}": []reflect.Type{
{{- range $i, $t := $types }}
reflect.TypeOf(({{ $t }})(0)),
{{- end }}
},
{{- end }}
}
}
`)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ type UnionUnsupported struct {

var (
SchemaTree map[string]*yang.Entry
ΛEnumTypes map[string][]reflect.Type
)

func init() {
var err error
initΛEnumTypes()
if SchemaTree, err = UnzipSchema(); err != nil {
panic("schema error: " + err.Error())
}
Expand Down Expand Up @@ -453,11 +455,13 @@ var (
// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{
func initΛEnumTypes(){
ΛEnumTypes = map[string][]reflect.Type{
"/bgp/neighbors/neighbor/state/enabled-address-family": []reflect.Type{
reflect.TypeOf((E_OpenconfigOptions_AFI)(0)),
},
"/bgp/neighbors/neighbor/state/session-state": []reflect.Type{
reflect.TypeOf((E_Neighbor_SessionState)(0)),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ type UnionUnsupported struct {

var (
SchemaTree map[string]*yang.Entry
ΛEnumTypes map[string][]reflect.Type
)

func init() {
var err error
initΛEnumTypes()
if SchemaTree, err = UnzipSchema(); err != nil {
panic("schema error: " + err.Error())
}
Expand Down Expand Up @@ -423,11 +425,13 @@ var (
// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{
func initΛEnumTypes(){
ΛEnumTypes = map[string][]reflect.Type{
"/bgp/neighbors/neighbor/state/enabled-address-family": []reflect.Type{
reflect.TypeOf((E_OpenconfigOptions_AFI)(0)),
},
"/bgp/neighbors/neighbor/state/session-state": []reflect.Type{
reflect.TypeOf((E_Neighbor_SessionState)(0)),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ type UnionUnsupported struct {

var (
SchemaTree map[string]*yang.Entry
ΛEnumTypes map[string][]reflect.Type
)

func init() {
var err error
initΛEnumTypes()
if SchemaTree, err = UnzipSchema(); err != nil {
panic("schema error: " + err.Error())
}
Expand Down Expand Up @@ -346,8 +348,10 @@ var (
// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{
func initΛEnumTypes(){
ΛEnumTypes = map[string][]reflect.Type{
"/parent/child/config/three": []reflect.Type{
reflect.TypeOf((E_Child_Three)(0)),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ type UnionUnsupported struct {

var (
SchemaTree map[string]*yang.Entry
ΛEnumTypes map[string][]reflect.Type
)

func init() {
var err error
initΛEnumTypes()
if SchemaTree, err = UnzipSchema(); err != nil {
panic("schema error: " + err.Error())
}
Expand Down Expand Up @@ -539,11 +541,13 @@ var (
// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{
func initΛEnumTypes(){
ΛEnumTypes = map[string][]reflect.Type{
"/bgp/neighbors/neighbor/state/enabled-address-family": []reflect.Type{
reflect.TypeOf((E_OpenconfigOptions_AFI)(0)),
},
"/bgp/neighbors/neighbor/state/session-state": []reflect.Type{
reflect.TypeOf((E_OpenconfigOptions_Bgp_Neighbors_Neighbor_State_SessionState)(0)),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ type UnionUnsupported struct {

var (
SchemaTree map[string]*yang.Entry
ΛEnumTypes map[string][]reflect.Type
)

func init() {
var err error
initΛEnumTypes()
if SchemaTree, err = UnzipSchema(); err != nil {
panic("schema error: " + err.Error())
}
Expand Down Expand Up @@ -510,11 +512,13 @@ var (
// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{
func initΛEnumTypes(){
ΛEnumTypes = map[string][]reflect.Type{
"/bgp/neighbors/neighbor/state/enabled-address-family": []reflect.Type{
reflect.TypeOf((E_OpenconfigOptions_AFI)(0)),
},
"/bgp/neighbors/neighbor/state/session-state": []reflect.Type{
reflect.TypeOf((E_OpenconfigOptions_Bgp_Neighbors_Neighbor_State_SessionState)(0)),
},
}
}
6 changes: 5 additions & 1 deletion ygen/testdata/structs/enum-multi-module.formatted-txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ type UnionUnsupported struct {

var (
SchemaTree map[string]*yang.Entry
ΛEnumTypes map[string][]reflect.Type
)

func init() {
var err error
initΛEnumTypes()
if SchemaTree, err = UnzipSchema(); err != nil {
panic("schema error: " + err.Error())
}
Expand Down Expand Up @@ -522,7 +524,8 @@ var (
// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{
func initΛEnumTypes(){
ΛEnumTypes = map[string][]reflect.Type{
"/parent/child/state/inline-multi-value": []reflect.Type{
reflect.TypeOf((E_EnumTypes_Td_Enum)(0)),
reflect.TypeOf((E_Child_InlineMultiValue)(0)),
Expand All @@ -535,4 +538,5 @@ var ΛEnumTypes = map[string][]reflect.Type{
reflect.TypeOf((E_EnumTypes_Td2_Enum)(0)),
reflect.TypeOf((E_EnumTypes_TdEnum)(0)),
},
}
}