openconfig / ygot

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

Identity Support in Ygot #960

Open Sneh-Prabha opened 5 months ago

Sneh-Prabha commented 5 months ago

Hi, We are using YGOT for yang to go-struct conversion. I can see in generated go struct code it seems Identity type is being treated as ENUM. Do we have support for Identity type in Ygot and if not can you suggest how can we solve this issue?

wenovus commented 5 months ago

Since identities are used to form a hierarchical subclass relationship with a single base identity, in practice (esp. with the OpenConfig YANG models) they effectively form a enumeration structure, where the base identity is the UNSET/default enum value and all sub-identities are possible values for the "enum". This is a major reason why we have chosen to model the two the same way in generated code. The marshalling/unmarshalling work in a way compatible with RFC7951 for identities.

Is there a special use case you're looking at which makes this modelling not work?