openconfig / ygot

A YANG-centric Go toolkit - Go/Protobuf Code Generation; Validation; Marshaling/Unmarshaling
Apache License 2.0
285 stars 107 forks source link

Make Schema Tree public #895

Closed Ankur19 closed 1 year ago

Ankur19 commented 1 year ago

I would like to build the SchemaTree using yang Entries and then use the ResolveLeafRefTarget method to calculate the actual data type of a leafref.

Ankur19 commented 1 year ago

@wenovus Please review.

coveralls commented 1 year ago

Coverage Status

coverage: 89.603% (-0.05%) from 89.649% when pulling 291ec5d7742322423b232db082315d701b3ed9c0 on Ankur19:master into 9ceedc03f63336ebea74f630cb154f21ab6e96ab on openconfig:master.

wenovus commented 1 year ago

@Ankur19 Does https://github.com/openconfig/goyang/blob/1d9b70a64cbe8e0ba42f95ab5c4e1ea81ac17c19/pkg/yang/entry.go#L1310 work? I'm assuming you're working with goyang structs so if the use case is not ygot-specific then goyang should be satisfying the need.

Ankur19 commented 1 year ago

@Ankur19 Does https://github.com/openconfig/goyang/blob/1d9b70a64cbe8e0ba42f95ab5c4e1ea81ac17c19/pkg/yang/entry.go#L1310 work? I'm assuming you're working with goyang structs so if the use case is not ygot-specific then goyang should be satisfying the need.

Let me check. Thanks for the pointer.

Ankur19 commented 1 year ago

@Ankur19 Does https://github.com/openconfig/goyang/blob/1d9b70a64cbe8e0ba42f95ab5c4e1ea81ac17c19/pkg/yang/entry.go#L1310 work? I'm assuming you're working with goyang structs so if the use case is not ygot-specific then goyang should be satisfying the need.

The Find method returns a null pointer for a few Paths.

e.g. /oc-netinst:network-instances/oc-netinst:network-instance/oc-netinst:config/oc-netinst:name

Ankur19 commented 1 year ago

Exporting this functionality looks fine to me since it provides handling that goyang's Entry.Find doesn't have.

Can you put it in a separate package called yangschema? Then we can rename the type to yangschema.Tree.

Done!