Skip to content

Commit

Permalink
Support skipping any-xml using -ignore_unsupported.
Browse files Browse the repository at this point in the history
Currently it fails because containers are being detected via the
`default` case, so they're being classified as containers.
  • Loading branch information
wenovus committed Nov 11, 2023
1 parent efd1f1d commit c3dd384
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions testdata/modules/openconfig-simple-with-unsupported.yang
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module openconfig-simple {
leaf four {
type binary;
}
anyxml xml-data {
description "updated stuff";
}
}

container parent {
Expand Down
9 changes: 8 additions & 1 deletion ygen/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"reflect"
"sort"

log "github.com/golang/glog"
"github.com/openconfig/goyang/pkg/yang"
"github.com/openconfig/ygot/genutil"
"github.com/openconfig/ygot/util"
Expand Down Expand Up @@ -295,7 +296,7 @@ func getOrderedDirDetails(langMapper LangMapper, directory map[string]*Directory
nd.YANGDetails.OrderedByUser = field.ListAttr.OrderedByUser
case util.IsAnydata(field):
nd.Type = AnyDataNode
default:
case field.IsContainer():
nd.Type = ContainerNode
// TODO(wenovus):
// a presence container is an unimplemented keyword in goyang.
Expand All @@ -307,6 +308,12 @@ func getOrderedDirDetails(langMapper LangMapper, directory map[string]*Directory
return nil, fmt.Errorf("unable to retrieve presence statement, expected non-nil *yang.Value, got %v", dir.Entry.Extra["presence"][0])
}
}
default:
if opts.ParseOptions.IgnoreUnsupportedStatements {
log.Infof("Unsupported field type (%v) ignored: %s", field.Kind, field.Path())
continue
}
return nil, fmt.Errorf("unsupported field type (%v) at: %s", field.Kind, field.Path())
}

nd.Flags = langMapper.PopulateFieldFlags(*nd, field)
Expand Down

0 comments on commit c3dd384

Please sign in to comment.