Skip to content

Conversation

@alexandernorth
Copy link
Contributor

@alexandernorth alexandernorth commented Apr 24, 2025

This PR implements the logic to process parsed refine statements according to the Yang 1.1 RFC.
It also implements a fix for choice cases, where the case statement is not present (allowed as per RFC). It does this by inserting the case automatically, such that a choice always has a case and no shorthand is used. This is important as paths are defined as if there is always a case node in the tree, even if it is missing in the schema.
It also implements native presence fields in the Entry as discussed in #226 and #286

@google-cla
Copy link

google-cla bot commented Apr 24, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@alexandernorth alexandernorth changed the title Implement processing of refine statements, choice shorthand fixes Support presence field natively,implement refine statements, choice/case shorthand fixes Apr 28, 2025
alexandernorth and others added 6 commits May 21, 2025 14:16
…plicitly there. Updated Choice struct to support yang 1.1, and the processing is based on the rules for 1.1.
…checks resulting in duplicate node errors (due to merge function)
* Added default refine for leaf

* Changed defaults to list to support refine of leaf-list

* fixed comments and renamed refine tests

* added presence to refine

* Added choice type for refine defaults and proper type checking for container in presence'
@alexandernorth alexandernorth force-pushed the feature/refine-and-choicecases branch from d1ec13f to b2a76ed Compare May 21, 2025 12:18
Copy link
Member

@robshakir robshakir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, and extending goyang's functionality -- apologies for the delay in getting to review this contribution.

Please take a look at the comments.

// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright 2025 Swisscom (Schweiz) AG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads like this whole file is (c) Swisscom, can you please adjust this to follow the first line and make it "additions copyright"? Alternatively, we can make this "(c) the OpenConfig contributors" and create a CONTRIBUTORS file.

// grouping has a leafref that references outside the group.
e = ToEntry(g).dup()

for _, refine := range s.Refine {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is a relatively long block -- can we split it out into its own function that we can also test individually?


// o A leaf, anydata, anyxml, or choice node may get a different
// "mandatory" statement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) remove blank like to match other cases.

}
case "choice":
for _, a := range fv.Interface().([]*Choice) {
// https://datatracker.ietf.org/doc/html/rfc7950#section-7.9.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, can we pull this logic out into a separate function that we can test?

// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright 2025 Swisscom (Schweiz) AG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here re: copyright statements as the other file. (No problem noting the copyright, but we should just make it compliant with usual styles.)

Extensions []*Statement `yang:"Ext"`

Default *Value `yang:"default"`
Defaults []*Value `yang:"default"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a backwards incompatible change, that needs to be handled by downstream consumers too.

We have had some discussion before on this: #51

The conclusion was that we would have a Default and Defaults field, and this would allow handling of these cases in a backwards compatible way. Can we do this here so that we don't break the existing users?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants