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

o/registrystate: support snapctl get --pristine #14552

Merged
merged 3 commits into from
Oct 8, 2024

Conversation

MiguelPires
Copy link
Contributor

Support snapctl get --pristine ... which allows snaps to read the state of the view disregarding the pending changes in the current transaction. Includes a small refactor to the registrystate functions that was necessary.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
@MiguelPires MiguelPires added the confdb confdb work (previously called registries and before aspects) label Sep 30, 2024
@github-actions github-actions bot added the Needs Documentation -auto- Label automatically added which indicates the change needs documentation label Sep 30, 2024
Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 82.14286% with 5 lines in your changes missing coverage. Please review.

Project coverage is 78.87%. Comparing base (ac897ee) to head (a4bab62).
Report is 56 commits behind head on master.

Files with missing lines Patch % Lines
overlord/hookstate/ctlcmd/get.go 72.72% 2 Missing and 1 partial ⚠️
overlord/registrystate/registrystate.go 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14552      +/-   ##
==========================================
+ Coverage   78.85%   78.87%   +0.01%     
==========================================
  Files        1079     1082       +3     
  Lines      145615   146054     +439     
==========================================
+ Hits       114828   115200     +372     
- Misses      23601    23655      +54     
- Partials     7186     7199      +13     
Flag Coverage Δ
unittests 78.87% <82.14%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ZeyadYasser ZeyadYasser left a comment

Choose a reason for hiding this comment

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

Changes look really good, Thank you!

I am curious about the intended use case for a snap to use --pristine? can't a snap just get a copy of the view data before adding changes to the transaction and get the same data?

It would be great to have comment that explains why we have it.

overlord/hookstate/ctlcmd/get_test.go Show resolved Hide resolved
overlord/registrystate/transaction_test.go Outdated Show resolved Hide resolved
@MiguelPires
Copy link
Contributor Author

I am curious about the intended use case for a snap to use --pristine? can't a snap just get a copy of the view data before adding changes to the transaction and get the same data?

A snap might be deciding whether to allow changes made by another snap, in which case it might be useful to know what was the previous state and there would be no other way of getting this data. Even if it's the same snap, several hooks are called in different stages so the snap would have to retain that data in the snap and access it across different hooks

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Copy link
Member

@andrewphelpsj andrewphelpsj left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good!

@MiguelPires MiguelPires merged commit 0d30934 into canonical:master Oct 8, 2024
54 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confdb confdb work (previously called registries and before aspects) Needs Documentation -auto- Label automatically added which indicates the change needs documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants