-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: fail silently for unsupported actions #2
Conversation
Credential storage makes little sense for a plugin based on environment variables. Failure to store or delete is written as a warning, but will not fail the Docker process.
WalkthroughThe recent updates to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2 +/- ##
==========================================
+ Coverage 74.46% 75.92% +1.45%
==========================================
Files 2 2
Lines 47 54 +7
==========================================
+ Hits 35 41 +6
- Misses 12 13 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- helper/env.go (1 hunks)
- helper/env_test.go (1 hunks)
Additional comments not posted (5)
helper/env.go (2)
36-37
: LGTM! The function correctly fails silently for unsupported actions.The
Add
function now logs a warning and returns nil, which aligns with the PR objective.
41-42
: LGTM! The function correctly fails silently for unsupported actions.The
Delete
function now logs a warning and returns nil, which aligns with the PR objective.helper/env_test.go (3)
34-37
: LGTM! The test correctly checks that theAdd
method fails silently.The test function
TestEnvHelper_Add_FailsSilently
asserts no error is returned, which aligns with the new behaviour.
40-43
: LGTM! The test correctly checks that theDelete
method fails silently.The test function
TestEnvHelper_Delete_FailsSilently
asserts no error is returned, which aligns with the new behaviour.
46-48
: LGTM! The test correctly checks that theList
method is not implemented.The test function
TestEnvHelper_List_NotImplemented
asserts an error is returned, which aligns with the behaviour.
Allow the user to configure the helper such that failure to find the required environment variables results in an empty username and password being returned instead of causing the helper to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- helper/env.go (1 hunks)
- helper/env_test.go (2 hunks)
- main.go (1 hunks)
Additional context used
GitHub Check: codecov/patch
main.go
[warning] 24-24: main.go#L24
Added line #L24 was not covered by tests
[warning] 26-26: main.go#L26
Added line #L26 was not covered by tests
Additional comments not posted (13)
helper/env.go (7)
22-22
: LGTM!The new field
CredentialsOptional
in theEnvHelper
struct is a good addition to control the behaviour of credential operations.
32-36
: LGTM!The conditional logic in the
Get
function to handle credential lookup failures based onCredentialsOptional
improves flexibility.
38-39
: LGTM!The error logging behaviour in the
Get
function ensures that users are informed about potential issues whenCredentialsOptional
is false.
42-42
: LGTM!Logging a message when credentials are successfully retrieved is useful for confirming successful operations.
48-48
: LGTM!The
Add
function now logs a warning and returnsnil
, aligning with the new behaviour of failing silently for unsupported actions.
53-54
: LGTM!The
Delete
function now logs a warning and returnsnil
, aligning with the new behaviour of failing silently for unsupported actions.
58-58
: LGTM!The
List
function logs an error message and returnsErrNotImplemented
, maintaining the appropriate behaviour for an unimplemented action.helper/env_test.go (6)
24-33
: LGTM!The new test function
TestEnvHelper_Get_CredentialsOptional_Success
verifies the behaviour of theGet
function whenCredentialsOptional
is true. This is a necessary test to ensure the new functionality works as expected.
45-45
: LGTM!Renaming the test function to
TestEnvHelper_Add_FailsSilently
clarifies the expected behaviour of theAdd
function, improving test readability.
48-48
: LGTM!The modified assertion in the
TestEnvHelper_Add_FailsSilently
function aligns with the new behaviour of theAdd
function, which is to fail silently.
51-51
: LGTM!Renaming the test function to
TestEnvHelper_Delete_FailsSilently
clarifies the expected behaviour of theDelete
function, improving test readability.
54-54
: LGTM!The modified assertion in the
TestEnvHelper_Delete_FailsSilently
function aligns with the new behaviour of theDelete
function, which is to fail silently.
57-57
: LGTM!Renaming the test function to
TestEnvHelper_List_NotImplemented
clarifies the expected behaviour of theList
function, improving test readability.
Credential storage makes little sense for a plugin based on environment variables.
Failure to store or delete is written as a warning, but will not fail the Docker process.
Summary by CodeRabbit
New Features
Bug Fixes