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

YAML consolidation prelude: new YAML dump APIs (FR-702) #251

Merged
merged 3 commits into from
Jan 17, 2022

Conversation

schopin-pro
Copy link
Contributor

Description

Introduce a couple of APIs that are needed for the various YAML consolidation efforts. Note that this is technically an API break, but the function that is removed has never been part of a release, so this should be OK.

Checklist

  • Runs make check successfully.
  • Retains 100% code coverage (make check-coverage).
  • New/changed keys in YAML format are documented.
  • (Optional) Adds example YAML for new feature.
  • (Optional) Closes an open bug in Launchpad.

@schopin-pro
Copy link
Contributor Author

Draft as it depends on #250

@schopin-pro schopin-pro changed the title YAML consolidation prelude: new YAML dump APIs YAML consolidation prelude: new YAML dump APIs (FR-702) Jan 5, 2022
@schopin-pro schopin-pro force-pushed the yaml-consolidation-api-prelude branch from c68271a to b605144 Compare January 5, 2022 22:10
@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2022

Codecov Report

Merging #251 (2496e6f) into main (d3f81b3) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 2496e6f differs from pull request most recent head b10ff76. Consider uploading reports for the commit b10ff76 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #251      +/-   ##
==========================================
+ Coverage   99.12%   99.13%   +0.01%     
==========================================
  Files          60       60              
  Lines       10229    10404     +175     
==========================================
+ Hits        10139    10314     +175     
  Misses         90       90              
Impacted Files Coverage Δ
tests/generator/base.py 100.00% <ø> (ø)
netplan/libnetplan.py 100.00% <100.00%> (ø)
src/abi_compat.c 100.00% <100.00%> (ø)
src/netplan.c 100.00% <100.00%> (ø)
src/util.c 100.00% <100.00%> (ø)
tests/test_libnetplan.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3f81b3...b10ff76. Read the comment docs.

@schopin-pro schopin-pro force-pushed the yaml-consolidation-api-prelude branch 2 times, most recently from bb22c20 to 086c4c8 Compare January 11, 2022 09:37
@schopin-pro schopin-pro force-pushed the yaml-consolidation-api-prelude branch 2 times, most recently from 4744eb7 to 2496e6f Compare January 13, 2022 15:15
@schopin-pro schopin-pro marked this pull request as ready for review January 13, 2022 15:16
Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

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

Thank you Simon! This is another great step in consolidating our YAML parsing story.

It is looking very good overall. I asked for some clarification and mentioned a few nitpicks in the inline comments. We should be good to merge this after those are resolved!

Also, I can confirm that the netplan_state_write_yaml() function isn't used anywhere and was never released. So we're good to "break" that API.

src/netplan.c Outdated Show resolved Hide resolved
src/util.c Outdated Show resolved Hide resolved
src/util.c Outdated Show resolved Hide resolved
tests/generator/base.py Outdated Show resolved Hide resolved
This allows for more flexibility than using filenames. The
implementation is split in two functions to allow for future variants,
i.e. updating an existing netplan configuration tree.

This patch is technically an API break but the removed API was never
released.

V2:
* use a helper function netplan_state_has_nondefault_globals()
* fix the write_netplan_conf_full behavior on empty state to not create
  an empty file
* DRASTICALLY simplify the implementation of netplan_state_dump_yaml(),
  fixing a leak by not using a new list in the first place
This API is also using file descriptors for flexibility. The idea is to
be able to copy only part of a YAML document based on a "prefix", that
is subsequent keys into YAML maps, separated by '\t' characters.

V2: add some comments and use better names for the static helpers
Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the comments, especially the netplan_state_nondefault_globals() function should avoid issues with our snapd integration so good idea going with option (3) there!

LGTM. Let's merge this.

@slyon slyon merged commit 0917c59 into canonical:main Jan 17, 2022
@schopin-pro schopin-pro deleted the yaml-consolidation-api-prelude branch May 5, 2022 10:05
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