Skip to content

Commit c1af82c

Browse files
committed
Identityref to take prefix into account
1 parent 3c79b39 commit c1af82c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/tree/yang-parser-adapter.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66

7-
schema_server "github.com/sdcio/sdc-protos/sdcpb"
7+
sdcpb "github.com/sdcio/sdc-protos/sdcpb"
88
"github.com/sdcio/yang-parser/xpath"
99
"github.com/sdcio/yang-parser/xpath/xutils"
1010
)
@@ -44,11 +44,15 @@ func (y *yangParserEntryAdapter) GetValue() (xpath.Datum, error) {
4444

4545
var result xpath.Datum
4646
switch tv.Value.(type) {
47-
case *schema_server.TypedValue_BoolVal:
47+
case *sdcpb.TypedValue_BoolVal:
4848
result = xpath.NewBoolDatum(tv.GetBoolVal())
49-
case *schema_server.TypedValue_StringVal:
50-
result = xpath.NewLiteralDatum(tv.GetStringVal())
51-
case *schema_server.TypedValue_UintVal:
49+
case *sdcpb.TypedValue_StringVal:
50+
prefix := ""
51+
if y.e.GetSchema().GetField().GetType().GetTypeName() == "identityref" {
52+
prefix = fmt.Sprintf("%s:", y.e.GetSchema().GetField().GetType().IdentityPrefix)
53+
}
54+
result = xpath.NewLiteralDatum(prefix + tv.GetStringVal())
55+
case *sdcpb.TypedValue_UintVal:
5256
result = xpath.NewNumDatum(float64(tv.GetUintVal()))
5357
default:
5458
result = xpath.NewLiteralDatum(tv.GetStringVal())

0 commit comments

Comments
 (0)