Skip to content

config: Refactor AgentConfig Source trait implementation #856

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

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

ansasaki
Copy link
Contributor

Instead of using explicit dedicated transformations for each option in the configuration structure, use an intermediary JSON structure to implement the collect() method in a more generic way.

This makes it easier to add new configuration options and simplifies maintenance.

Also, instead of duplicating the AgentConfig structure to receive the options set in the environment variables, use the built-in Environment Source trait implementation with a small change to make it possible to use as a source for a KeylimeConfig structure.

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 60.06711% with 119 lines in your changes missing coverage. Please review.

Project coverage is 59.58%. Comparing base (2f7b3ad) to head (9067f99).
Report is 55 commits behind head on master.

Files with missing lines Patch % Lines
keylime-agent/src/config.rs 64.23% 98 Missing ⚠️
keylime-agent/src/main.rs 0.00% 14 Missing ⚠️
keylime-agent/src/payloads.rs 25.00% 6 Missing ⚠️
keylime-agent/src/error.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
Flag Coverage Δ
e2e-testsuite 59.58% <60.06%> (+2.00%) ⬆️
upstream-unit-tests 59.58% <60.06%> (+8.57%) ⬆️

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

Files with missing lines Coverage Δ
keylime-agent/src/error.rs 12.21% <50.00%> (-3.04%) ⬇️
keylime-agent/src/payloads.rs 81.64% <25.00%> (-1.21%) ⬇️
keylime-agent/src/main.rs 27.35% <0.00%> (+1.34%) ⬆️
keylime-agent/src/config.rs 74.11% <64.23%> (-13.39%) ⬇️

... and 6 files with indirect coverage changes

@ansasaki
Copy link
Contributor Author

/packit retest-failed

1 similar comment
@ansasaki
Copy link
Contributor Author

/packit retest-failed

@ansasaki ansasaki requested review from ueno and aplanas October 16, 2024 16:50
@ansasaki
Copy link
Contributor Author

/packit retest-failed

Instead of using explicit dedicated transformations for each option in
the configuration structure, use an intermediary JSON structure to
implement the collect() method in a more generic way.

This makes it easier to add new configuration options and simplifies
maintenance.

Also, instead of duplicating the AgentConfig structure to receive the
options set in the environment variables, use the built-in Environment
Source trait implementation with a small change to make it possible to
use as a source for a KeylimeConfig structure.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Copy link
Member

@THS-on THS-on left a comment

Choose a reason for hiding this comment

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

LGTM! Looks definitely cleaner and easier to use than the previous implementation.

@ansasaki ansasaki merged commit c4af854 into keylime:master Oct 18, 2024
15 of 16 checks passed
@ansasaki ansasaki deleted the refactor_config branch October 18, 2024 11:59
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.

5 participants