Skip to content

get/set: ignore empty YAML hints and delete files on "set network=null" (LP: #1946957)#246

Closed
slyon wants to merge 6 commits intomainfrom
slyon/lp1949884-empty-file-set-null
Closed

get/set: ignore empty YAML hints and delete files on "set network=null" (LP: #1946957)#246
slyon wants to merge 6 commits intomainfrom
slyon/lp1949884-empty-file-set-null

Conversation

@slyon
Copy link
Copy Markdown
Contributor

@slyon slyon commented Nov 24, 2021

Description

This PR contains several improvements wrt. the handling of YAML hint files, as used by the netplan set CLI.

  • If a --origin-hint is specified, that already exists as an empty file, that file is ignored.
  • If netplan set network=null [--origin-hint FILE] is executed, a special handler makes sure that either the specified origin hint file is remove, or all files in etc/netplan/*.yaml are cleared otherwise.

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. LP#1946957

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 25, 2021

Codecov Report

Merging #246 (0187cb3) into main (9a4c2e1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #246   +/-   ##
=======================================
  Coverage   99.09%   99.09%           
=======================================
  Files          58       58           
  Lines        9913     9963   +50     
=======================================
+ Hits         9823     9873   +50     
  Misses         90       90           
Impacted Files Coverage Δ
netplan/cli/commands/set.py 100.00% <100.00%> (ø)
tests/test_cli_get_set.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 9a4c2e1...0187cb3. Read the comment docs.

@slyon slyon force-pushed the slyon/lp1949884-empty-file-set-null branch from 0a07037 to 0187cb3 Compare November 25, 2021 08:50
Copy link
Copy Markdown
Contributor

@mvo5 mvo5 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, this looks very nice.

@slyon slyon marked this pull request as ready for review November 26, 2021 14:30
@slyon slyon force-pushed the slyon/lp1949884-empty-file-set-null branch from 0187cb3 to aa0971b Compare November 26, 2021 14:30
@slyon slyon changed the title get/set: ignore empty YAML hints and delete files on "set network=null" (LP: #1949884) get/set: ignore empty YAML hints and delete files on "set network=null" (LP: #1946957) Nov 29, 2021
@slyon
Copy link
Copy Markdown
Contributor Author

slyon commented Nov 29, 2021

Thanks for the review, Michael! I've added another fix + test-case today. Once we can confirm this passes the original snapd tests, we're good for merging!

slyon added a commit that referenced this pull request Nov 29, 2021
…l" (LP: #1946957) (#246)

This PR contains several improvements wrt. the handling of YAML hint files, as used by the netplan set CLI.

If a --origin-hint is specified, that already exists as an empty file, that file is ignored.
If netplan set network=null [--origin-hint FILE] is executed, a special handler makes sure that either the specified origin hint file is remove, or all files in etc/netplan/*.yaml are cleared otherwise.

COMMITS:
* test:get-set: detect unexpected output in CLI
* cli:set: ignore empty hint files
* cli:set: special case for 'network=null' to clear YAML files
* cli:set: improve logging
* cli:set: do not crash if we try to unset something that does not exist (LP: #1946957)
* cli:set: fix another case of writing an empty origin-hint file (containing whitespace)
@slyon
Copy link
Copy Markdown
Contributor Author

slyon commented Nov 29, 2021

Merged in 5361619

@slyon slyon closed this Nov 29, 2021
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