-
Notifications
You must be signed in to change notification settings - Fork 91
Uses Augmentation #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Uses Augmentation #272
Conversation
robshakir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change -- generally this LGTM -- please take a look at the comments and then we can get this merged.
Apologies for the delay reviewing the code.
pkg/yang/entry.go
Outdated
| return e | ||
| } | ||
|
|
||
| type YangVersion string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a docstring comment please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| Reference *Value `yang:"reference" json:"-"` | ||
| Status *Value `yang:"status" json:"-"` | ||
| When *Value `yang:"when" json:",omitempty"` | ||
| Augment []*Augment `yang:"augment" json:",omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we create a different field here, since this means that this change is backwards-incompatible for existing API users. There was some discussion historically about making such changes for YANG 1.1.
If we don't do this, then we need to mark this as goyang v2. I'd prefer to see whether we can group up other API changes that would be needed to fully support y1.1 into such a release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure what exactly you want me to do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't support changing Augment from *Augment to []*Augment since this is backwards incompatible. This means that we're going to need to all downstream clients to change.
I suggest this is implemented using a new field Augments which has the slice. If it's not, then I don't think we should merge this without discussing other cardinality changes that are needed to support YANG 1.1 in a goyang v2.
pkg/yang/entry_test.go
Outdated
| for n, m := range tt.inModules { | ||
| if err := ms.Parse(m, n); err != nil { | ||
| errs = append(errs, err) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/yang/entry_test.go
Outdated
| for _, pe := range p { | ||
| y, ok := x.Dir[pe] | ||
| if !ok { | ||
| t.Fatalf("expected module %s to contain path %s", m.Name, strings.Join(p, "/")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add more debugging output here -- e.g., "expected module %s to contain path %s, could not find element %s in parent, got children: %v"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/yang/entry_test.go
Outdated
|
|
||
| var m *Entry | ||
| m, errs = ms.GetModule("mod-a") | ||
| x := m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to make these variable names a little less pithy -- curElem or something would be easier for a reader to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| // grouping has a leafref that references outside the group. | ||
| e = ToEntry(g).dup() | ||
|
|
||
| switch determineYangVersion(g) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't added this kind of error checking elsewhere -- I wonder whether we should try and include the parsed YANG version somewhere in the output entry. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we want to be strict then thats probably a good idea.
pkg/yang/entry.go
Outdated
| type YangVersion string | ||
|
|
||
| const ( | ||
| YangVersion10 YangVersion = "1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/YangVersion10/YANGVersion10/ per usual Go style guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
This would be fantastic to have merged in. |
Allow for the augmentation of groupings.