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

refact "cscli bouncers" #2776

Merged
merged 16 commits into from Jan 31, 2024
Merged

refact "cscli bouncers" #2776

merged 16 commits into from Jan 31, 2024

Conversation

mmetc
Copy link
Contributor

@mmetc mmetc commented Jan 24, 2024

There are a few patterns there that, if applied consistently to cmd/crowdsec-cli, would enhance maintainability.

  • encapsulate reference to global state (even csConfig) via command constructors
  • don't export functions if not needed
  • it should be possible to split crowdsec-cli in sub-packages (cmd/crowdsec-cli/bouncers) I didn't do it here because we ought to do it with the table helpers first
  • no need to parse each flag, or to store them together, or to share them as global vars
  • don't ask for more configuration than required (db vs lapi server)
  • don't over-indent or overuse closures
  • parse flags directly to their type (for time.Duration)
  • don't repeat information in user facing messages (i.e. error doing thing with X: tried to blahblah X: failed because X is not Y)

Copy link

@mmetc: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind enhancement
  • /kind fix
  • /kind chore
  • /kind dependencies
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

Copy link

@mmetc: There are no area labels on this PR. You can add as many areas as you see fit.

  • /area agent
  • /area local-api
  • /area cscli
  • /area appsec
  • /area security
  • /area configuration
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

Attention: 89 lines in your changes are missing coverage. Please review.

Comparison is base (6507e8f) 56.85% compared to head (746e1a9) 56.95%.

Files Patch % Lines
cmd/crowdsec-cli/bouncers.go 41.72% 83 Missing and 5 partials ⚠️
cmd/crowdsec-cli/support.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2776      +/-   ##
==========================================
+ Coverage   56.85%   56.95%   +0.09%     
==========================================
  Files         237      237              
  Lines       30640    30632       -8     
==========================================
+ Hits        17419    17445      +26     
+ Misses      11532    11507      -25     
+ Partials     1689     1680       -9     
Flag Coverage Δ
bats 36.76% <45.39%> (+0.10%) ⬆️
unit-linux 52.23% <75.00%> (-0.01%) ⬇️
unit-windows 47.75% <75.00%> (-0.02%) ⬇️

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.

@mmetc mmetc added the kind/enhancement New feature or request label Jan 24, 2024
@mmetc mmetc marked this pull request as ready for review January 24, 2024 09:03
@mmetc mmetc marked this pull request as draft January 24, 2024 09:21
@mmetc
Copy link
Contributor Author

mmetc commented Jan 24, 2024

Actually - we do need to load LAPI configuration because that's how we check the command is running on the right node. But I'll have to nerf the logs in this case

@mmetc mmetc marked this pull request as ready for review January 24, 2024 10:26
@mmetc mmetc added this to the 1.6.1 milestone Jan 24, 2024
Copy link
Contributor

@sabban sabban left a comment

Choose a reason for hiding this comment

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

lgtm

@mmetc mmetc merged commit 4192af3 into master Jan 31, 2024
16 checks passed
@mmetc mmetc deleted the cscli-bouncers branch January 31, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request needs/area
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants