Skip to content
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

Support leaf-list defaults using latest version of goyang. #618

Merged
merged 4 commits into from
Feb 22, 2022

Conversation

wenovus
Copy link
Collaborator

@wenovus wenovus commented Feb 5, 2022

Note: I haven't released the goyang commit this is dependent on yet
(hence the go.mod replace statement) since I want to release both repos
at the same time. This is to avoid a downstream issue:
openconfig/models-ci#59

  • Update ygot to use the updated Entry.Default []string and its
    corresponding helpers for storing defaults for leaf-lists.
  • Change some helper function such as yangDefaultValueToGo() to return
    string instead of *string. There is no good reason for returning a
    pointer and makes the code less convenient.
  • Factor out generateGoDefaultValue() from writeGoStruct(), and have it
    handle multiple default values.
  • In protogen's logic to generate default enums, check whether an enum
    is not a leaf-list before setting a particular one as the default enum
    value.
    Note: I'm not 100% sure whether this is the correct handling -- it
    appears to me that having a default enum value doesn't make sense for
    leaf-lists as repeated fields.

Testing:

  • Added integration tests for Go and proto generation.

Note: I haven't released goyang yet since I want to release both repos
at the same time. This is to avoid a downstream issue:
openconfig/models-ci#59

- Update ygot to use the updated `Entry.Default []string` and its
  corresponding helpers for storing defaults for leaf-lists.
- Change some helper function such as `yangDefaultValueToGo` to return
  `string` instead of `*string`. There is no good reason for returning a
  pointer and makes the code less convenient.
- Factor out `generateGoDefaultValue` from `writeGoStruct`, and have it
  handle multiple default values.
- In protogen's logic to generate default enums, check whether an enum
  is not a leaf-list before setting a particular one as the default enum
  value.
  Note: I'm not sure whether this is the correct handling -- though it
  appears to me that having a default value doesn't make sense for
  leaf-lists as repeated fields.

Testing:
- Added integration tests for Go and proto generation.
@wenovus wenovus requested a review from robshakir February 5, 2022 01:35
@coveralls
Copy link

coveralls commented Feb 5, 2022

Coverage Status

Coverage decreased (-0.0008%) to 90.957% when pulling 67d882f on leaflist-default into 1ac0edc on master.

@wenovus wenovus requested a review from dplore February 17, 2022 18:07
@wenovus
Copy link
Collaborator Author

wenovus commented Feb 17, 2022

@dplore I added you as another pair of eyes. Feel free to leave some high-level comments/questions. The context here is that goyang had a backwards-incompatible change (allowing defaults for leaf-lists): openconfig/goyang#139

This PR adapts ygot to be able to generate defaults for leaf-lists, see this integration test:

@wenovus
Copy link
Collaborator Author

wenovus commented Feb 22, 2022

I'm going to merge this with Rob's approval.

wenovus and others added 2 commits February 22, 2022 09:34
Note: I haven't released the goyang commit this is dependent on yet
(hence the go.mod replace statement) since I want to release both repos
at the same time. This is to avoid a downstream issue:
openconfig/models-ci#59
@wenovus wenovus merged commit 606b2e7 into master Feb 22, 2022
@wenovus wenovus deleted the leaflist-default branch February 22, 2022 18:26
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