Skip to content

Commit

Permalink
ygnmi.MustPath
Browse files Browse the repository at this point in the history
  • Loading branch information
wenovus committed Dec 2, 2023
1 parent cb492f2 commit 9cd33e2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ygnmi/path_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ func ResolvePath(n PathStruct) (*gpb.Path, map[string]interface{}, error) {
return &gpb.Path{Elem: p}, root.CustomData(), nil
}

// MustPath calls ResolvePath and panics on error.
// It is intended for use in tests with generated PathStructs.
//
// ygnmi.MustResolvePath(ocpath.Interface("port0").Name().Config().PathStruct())
// returns "/interfaces/interface[name=port0]/config/name
func MustPath(q UntypedQuery) *gpb.Path {
p, _, err := ResolvePath(q.PathStruct())
if err != nil {
panic(err)
}
return p
}

// ResolveRelPath returns the partial []*gpb.PathElem representing the
// PathStruct's relative path.
func ResolveRelPath(n PathStruct) ([]*gpb.PathElem, []error) {
Expand Down

0 comments on commit 9cd33e2

Please sign in to comment.