Skip to content

Commit

Permalink
rename Validate to ΛValidate (#643)
Browse files Browse the repository at this point in the history
* implemented ΛValidate(...)

* adjusted tests to ΛValidate(...)

* go fmt tests

* update exampleoc

* added test for GoOpts ValidateFunctionName

* fixing new tests
  • Loading branch information
steiler authored Apr 26, 2022
1 parent 2a4e1f3 commit c2a594c
Show file tree
Hide file tree
Showing 32 changed files with 136,800 additions and 120,501 deletions.
6 changes: 3 additions & 3 deletions demo/getting_started/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
i.Description = ygot.String("An Interface")

// We can then validate the contents of the interface that we created.
if err := d.Interface["eth0"].Validate(); err != nil {
if err := d.Interface["eth0"].ΛValidate(); err != nil {
panic(fmt.Sprintf("Interface validation failed: %v", err))
}

Expand Down Expand Up @@ -115,14 +115,14 @@ func main() {
}
ygot.BuildEmptyTree(subif)
_, err = subif.Ipv4.NewAddress("Not a valid address")
if err := invalidIf.Validate(); err == nil {
if err := invalidIf.ΛValidate(); err == nil {
panic(fmt.Sprintf("Did not find invalid address, got nil err: %v", err))
} else {
fmt.Printf("Got expected error: %v\n", err)
}

// We can also validate the device overall.
if err := d.Validate(); err != nil {
if err := d.ΛValidate(); err != nil {
panic(fmt.Sprintf("Device validation failed: %v", err))
}

Expand Down
85,134 changes: 45,279 additions & 39,855 deletions exampleoc/oc.go

Large diffs are not rendered by default.

124 changes: 73 additions & 51 deletions exampleoc/ocpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package exampleoc is a generated package which contains definitions
of structs which generate gNMI paths for a YANG schema. The generated paths are
based on a compressed form of the schema.

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:
- public/release/models/network-instance/openconfig-network-instance.yang
- public/release/models/optical-transport/openconfig-optical-amplifier.yang
Expand Down Expand Up @@ -54441,8 +54441,10 @@ func (n *NetworkInstancePathAny) Mtu() *NetworkInstance_MtuPathAny {
}
}

// Name (leaf): An operator-assigned unique name for the forwarding
// instance
// Name (leaf): An operator-assigned unique name for the network instance.
// If the operator does not designate a name for the instance of
// type 'DEFAULT_INSTANCE' (e.g. config), the implementation
// should use the name of 'DEFAULT' (e.g. state).
// ----------------------------------------
// Defining module: "openconfig-network-instance"
// Instantiating module: "openconfig-network-instance"
Expand All @@ -54458,8 +54460,10 @@ func (n *NetworkInstancePath) Name() *NetworkInstance_NamePath {
}
}

// Name (leaf): An operator-assigned unique name for the forwarding
// instance
// Name (leaf): An operator-assigned unique name for the network instance.
// If the operator does not designate a name for the instance of
// type 'DEFAULT_INSTANCE' (e.g. config), the implementation
// should use the name of 'DEFAULT' (e.g. state).
// ----------------------------------------
// Defining module: "openconfig-network-instance"
// Instantiating module: "openconfig-network-instance"
Expand Down Expand Up @@ -55190,12 +55194,14 @@ func (n *NetworkInstance_TableConnectionPathAny) WithAddressFamily(AddressFamily

// Type (leaf): The type of network instance. The value of this leaf
// indicates the type of forwarding entries that should be
// supported by this network instance. Signalling protocols
// also use the network instance type to infer the type of
// service they advertise; for example MPLS signalling
// for an L2VSI network instance would infer a VPLS service
// whereas a type of L2PTP would infer a VPWS (pseudo-wire)
// service
// supported by this network instance. Signalling protocols also
// use the network instance type to infer the type of service
// they advertise; for example MPLS signalling for an L2VSI
// network instance would infer a VPLS service whereas a type of
// L2PTP would infer a VPWS (pseudo-wire) service.
//
// An implementation must support only a single network-instance
// of type 'DEFAULT_INSTANCE'.
// ----------------------------------------
// Defining module: "openconfig-network-instance"
// Instantiating module: "openconfig-network-instance"
Expand All @@ -55213,12 +55219,14 @@ func (n *NetworkInstancePath) Type() *NetworkInstance_TypePath {

// Type (leaf): The type of network instance. The value of this leaf
// indicates the type of forwarding entries that should be
// supported by this network instance. Signalling protocols
// also use the network instance type to infer the type of
// service they advertise; for example MPLS signalling
// for an L2VSI network instance would infer a VPLS service
// whereas a type of L2PTP would infer a VPWS (pseudo-wire)
// service
// supported by this network instance. Signalling protocols also
// use the network instance type to infer the type of service
// they advertise; for example MPLS signalling for an L2VSI
// network instance would infer a VPLS service whereas a type of
// L2PTP would infer a VPWS (pseudo-wire) service.
//
// An implementation must support only a single network-instance
// of type 'DEFAULT_INSTANCE'.
// ----------------------------------------
// Defining module: "openconfig-network-instance"
// Instantiating module: "openconfig-network-instance"
Expand Down Expand Up @@ -86444,7 +86452,14 @@ func (n *NetworkInstance_ProtocolPathAny) Isis() *NetworkInstance_Protocol_IsisP
}
}

// Name (leaf): A unique name for the protocol instance
// Name (leaf): A unique name for the protocol instance.
//
// If the operator does not designate a name for the protocol
// instance (e.g. config), the implementation should use the
// name of 'DEFAULT' (e.g. state). In addition, for
// implementations that support single protocol instances, the
// default value is recommended for consistency and uniqueness
// per protocol instance.
// ----------------------------------------
// Defining module: "openconfig-network-instance"
// Instantiating module: "openconfig-network-instance"
Expand All @@ -86460,7 +86475,14 @@ func (n *NetworkInstance_ProtocolPath) Name() *NetworkInstance_Protocol_NamePath
}
}

// Name (leaf): A unique name for the protocol instance
// Name (leaf): A unique name for the protocol instance.
//
// If the operator does not designate a name for the protocol
// instance (e.g. config), the implementation should use the
// name of 'DEFAULT' (e.g. state). In addition, for
// implementations that support single protocol instances, the
// default value is recommended for consistency and uniqueness
// per protocol instance.
// ----------------------------------------
// Defining module: "openconfig-network-instance"
// Instantiating module: "openconfig-network-instance"
Expand Down Expand Up @@ -182124,13 +182146,13 @@ type NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_PriorityPathAny str
*ygot.NodePath
}

// NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetranmissionQueueLengthPath represents the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/interfaces/interface/neighbors/neighbor/state/retranmission-queue-length YANG schema element.
type NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetranmissionQueueLengthPath struct {
// NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetransmissionQueueLengthPath represents the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/interfaces/interface/neighbors/neighbor/state/retransmission-queue-length YANG schema element.
type NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetransmissionQueueLengthPath struct {
*ygot.NodePath
}

// NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetranmissionQueueLengthPathAny represents the wildcard version of the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/interfaces/interface/neighbors/neighbor/state/retranmission-queue-length YANG schema element.
type NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetranmissionQueueLengthPathAny struct {
// NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetransmissionQueueLengthPathAny represents the wildcard version of the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/interfaces/interface/neighbors/neighbor/state/retransmission-queue-length YANG schema element.
type NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetransmissionQueueLengthPathAny struct {
*ygot.NodePath
}

Expand Down Expand Up @@ -182432,34 +182454,34 @@ func (n *NetworkInstance_Protocol_Ospfv2_Area_Interface_NeighborPathAny) Priorit
}
}

// RetranmissionQueueLength (leaf): The number of LSAs that are currently in the queue to be
// RetransmissionQueueLength (leaf): The number of LSAs that are currently in the queue to be
// retransmitted to the neighbor
// ----------------------------------------
// Defining module: "openconfig-ospfv2-area-interface"
// Instantiating module: "openconfig-network-instance"
// Path from parent: "state/retranmission-queue-length"
// Path from root: "/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/interfaces/interface/neighbors/neighbor/state/retranmission-queue-length"
func (n *NetworkInstance_Protocol_Ospfv2_Area_Interface_NeighborPath) RetranmissionQueueLength() *NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetranmissionQueueLengthPath {
return &NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetranmissionQueueLengthPath{
// Path from parent: "state/retransmission-queue-length"
// Path from root: "/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/interfaces/interface/neighbors/neighbor/state/retransmission-queue-length"
func (n *NetworkInstance_Protocol_Ospfv2_Area_Interface_NeighborPath) RetransmissionQueueLength() *NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetransmissionQueueLengthPath {
return &NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetransmissionQueueLengthPath{
NodePath: ygot.NewNodePath(
[]string{"state", "retranmission-queue-length"},
[]string{"state", "retransmission-queue-length"},
map[string]interface{}{},
n,
),
}
}

// RetranmissionQueueLength (leaf): The number of LSAs that are currently in the queue to be
// RetransmissionQueueLength (leaf): The number of LSAs that are currently in the queue to be
// retransmitted to the neighbor
// ----------------------------------------
// Defining module: "openconfig-ospfv2-area-interface"
// Instantiating module: "openconfig-network-instance"
// Path from parent: "state/retranmission-queue-length"
// Path from root: "/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/interfaces/interface/neighbors/neighbor/state/retranmission-queue-length"
func (n *NetworkInstance_Protocol_Ospfv2_Area_Interface_NeighborPathAny) RetranmissionQueueLength() *NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetranmissionQueueLengthPathAny {
return &NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetranmissionQueueLengthPathAny{
// Path from parent: "state/retransmission-queue-length"
// Path from root: "/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/interfaces/interface/neighbors/neighbor/state/retransmission-queue-length"
func (n *NetworkInstance_Protocol_Ospfv2_Area_Interface_NeighborPathAny) RetransmissionQueueLength() *NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetransmissionQueueLengthPathAny {
return &NetworkInstance_Protocol_Ospfv2_Area_Interface_Neighbor_RetransmissionQueueLengthPathAny{
NodePath: ygot.NewNodePath(
[]string{"state", "retranmission-queue-length"},
[]string{"state", "retransmission-queue-length"},
map[string]interface{}{},
n,
),
Expand Down Expand Up @@ -191636,13 +191658,13 @@ type NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RemoteRouterIdPathAny stru
*ygot.NodePath
}

// NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetranmissionQueueLengthPath represents the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/virtual-links/virtual-link/state/retranmission-queue-length YANG schema element.
type NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetranmissionQueueLengthPath struct {
// NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetransmissionQueueLengthPath represents the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/virtual-links/virtual-link/state/retransmission-queue-length YANG schema element.
type NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetransmissionQueueLengthPath struct {
*ygot.NodePath
}

// NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetranmissionQueueLengthPathAny represents the wildcard version of the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/virtual-links/virtual-link/state/retranmission-queue-length YANG schema element.
type NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetranmissionQueueLengthPathAny struct {
// NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetransmissionQueueLengthPathAny represents the wildcard version of the /openconfig-network-instance/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/virtual-links/virtual-link/state/retransmission-queue-length YANG schema element.
type NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetransmissionQueueLengthPathAny struct {
*ygot.NodePath
}

Expand Down Expand Up @@ -191932,34 +191954,34 @@ func (n *NetworkInstance_Protocol_Ospfv2_Area_VirtualLinkPathAny) RemoteRouterId
}
}

// RetranmissionQueueLength (leaf): The number of LSAs that are currently in the queue to be
// RetransmissionQueueLength (leaf): The number of LSAs that are currently in the queue to be
// retransmitted to the neighbor
// ----------------------------------------
// Defining module: "openconfig-ospfv2-area-interface"
// Instantiating module: "openconfig-network-instance"
// Path from parent: "state/retranmission-queue-length"
// Path from root: "/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/virtual-links/virtual-link/state/retranmission-queue-length"
func (n *NetworkInstance_Protocol_Ospfv2_Area_VirtualLinkPath) RetranmissionQueueLength() *NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetranmissionQueueLengthPath {
return &NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetranmissionQueueLengthPath{
// Path from parent: "state/retransmission-queue-length"
// Path from root: "/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/virtual-links/virtual-link/state/retransmission-queue-length"
func (n *NetworkInstance_Protocol_Ospfv2_Area_VirtualLinkPath) RetransmissionQueueLength() *NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetransmissionQueueLengthPath {
return &NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetransmissionQueueLengthPath{
NodePath: ygot.NewNodePath(
[]string{"state", "retranmission-queue-length"},
[]string{"state", "retransmission-queue-length"},
map[string]interface{}{},
n,
),
}
}

// RetranmissionQueueLength (leaf): The number of LSAs that are currently in the queue to be
// RetransmissionQueueLength (leaf): The number of LSAs that are currently in the queue to be
// retransmitted to the neighbor
// ----------------------------------------
// Defining module: "openconfig-ospfv2-area-interface"
// Instantiating module: "openconfig-network-instance"
// Path from parent: "state/retranmission-queue-length"
// Path from root: "/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/virtual-links/virtual-link/state/retranmission-queue-length"
func (n *NetworkInstance_Protocol_Ospfv2_Area_VirtualLinkPathAny) RetranmissionQueueLength() *NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetranmissionQueueLengthPathAny {
return &NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetranmissionQueueLengthPathAny{
// Path from parent: "state/retransmission-queue-length"
// Path from root: "/network-instances/network-instance/protocols/protocol/ospfv2/areas/area/virtual-links/virtual-link/state/retransmission-queue-length"
func (n *NetworkInstance_Protocol_Ospfv2_Area_VirtualLinkPathAny) RetransmissionQueueLength() *NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetransmissionQueueLengthPathAny {
return &NetworkInstance_Protocol_Ospfv2_Area_VirtualLink_RetransmissionQueueLengthPathAny{
NodePath: ygot.NewNodePath(
[]string{"state", "retranmission-queue-length"},
[]string{"state", "retransmission-queue-length"},
map[string]interface{}{},
n,
),
Expand Down
Loading

0 comments on commit c2a594c

Please sign in to comment.