Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

OTA-2320: Add an option to aktualizr-info to print delegations metadata #1138

Merged
merged 1 commit into from
Mar 15, 2019

Conversation

mike-sul
Copy link
Collaborator

Signed-off-by: Mike Sul ext-mykhaylo.sul@here.com

  1. Added an option --delegate to aktualizr-info aimed to print delegations metadata;
  2. Added corresponding tests.

src/aktualizr_info/main.cc Outdated Show resolved Hide resolved
@@ -107,6 +107,10 @@ enum class InstalledVersionUpdateMode { kNone, kCurrent, kPending };
// Functions loading/storing multiple pieces of data are supposed to do so atomically as far as implementation makes it
// possible
class INvStorage {
public:
using DelegationRecord = std::tuple<std::string, std::string>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to use std::pair? And shouldn't role_name be the first field?

Probably a matter of test but also not sure if it's worth it adding this type synonym in the header: in client code, we'd have one std::vector<std::pair<Uptane::Role, std::string>>, and the rest can be deduced via auto.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And shouldn't role_name be the first field?
Why should it be the first ? I think, it makes sense to preserve the same field order as in the DB table.

Any reason not to use std::pair?
The reason, I decided to go with std::tuple over std::pair is the fact that the later can accommodate just two fields while the former can have arbitrary number of them what can be handy in case if the table schema changes (more than two fields or just one field).

Probably a matter of test but also not sure if it's worth it adding this type synonym in the header: > in client code, we'd have one std::vector<std::pair<Uptane::Role, std::string>>, and the rest can > be deduced via auto

I think, it makes sense to use Uptane::Role regardless of the type been declared or not, it will make the type more clear and explicit.

Regarding introduction of the new type. IMHO, there are several pros over not doing it:

  1. if the type is changed then you don't need to change it in every spot where it's used;
  2. if adding some methods is required then the type declaration can be replaced with corresponding struct/class;
  3. less typing (at the moment it's used in the storage interface, DB storage interface, DB storage implementation and at least once for each client (although auto cannot be used in function declarations/signature)

In general, it improves Extensibility and Maintainability.

Having said that, I don't mind to get rid of the type declaration since this is very unlikely that loadAllDelegations() will have more than two clients, i.e. aktualizr-info and its tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed code with the changes implied here.

@mike-sul mike-sul force-pushed the feat/OTA-2320/aktualizr-info-delegation-metadata branch from 8259aeb to f5cd7ec Compare March 14, 2019 16:03
@codecov-io
Copy link

codecov-io commented Mar 14, 2019

Codecov Report

Merging #1138 into master will decrease coverage by <.01%.
The diff coverage is 80.64%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1138      +/-   ##
==========================================
- Coverage   76.17%   76.17%   -0.01%     
==========================================
  Files         164      164              
  Lines        9869     9904      +35     
==========================================
+ Hits         7518     7544      +26     
- Misses       2351     2360       +9
Impacted Files Coverage Δ
src/libaktualizr/storage/sqlstorage.h 50% <ø> (ø) ⬆️
src/libaktualizr/storage/invstorage.h 97.43% <ø> (ø) ⬆️
src/libaktualizr/storage/sqlstorage.cc 74.02% <76.47%> (+0.58%) ⬆️
src/aktualizr_info/main.cc 90.4% <85.71%> (+0.3%) ⬆️
src/libaktualizr/package_manager/ostreemanager.cc 64.37% <0%> (-3.44%) ⬇️
src/libaktualizr/storage/sql_utils.h 83.09% <0%> (+1%) ⬆️

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 03b7868...20945b7. Read the comment docs.

Signed-off-by: Mike Sul <ext-mykhaylo.sul@here.com>
@mike-sul mike-sul force-pushed the feat/OTA-2320/aktualizr-info-delegation-metadata branch from f5cd7ec to 20945b7 Compare March 15, 2019 11:58
Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

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

LGTM. @mike-sul do you want to merge now despite the TODO in SpawnProcess? This is higher-priority anyway and if you come back to fix that up later than I don't see a problem.

@mike-sul
Copy link
Collaborator Author

LGTM. @mike-sul do you want to merge now despite the TODO in SpawnProcess? This is higher-priority anyway and if you come back to fix that up later than I don't see a problem.

Yes, anyway the TODO depends on the other PR that hasn't been merged yet.

@pattivacek pattivacek merged commit 058f94b into master Mar 15, 2019
@pattivacek pattivacek deleted the feat/OTA-2320/aktualizr-info-delegation-metadata branch March 15, 2019 13:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants