Skip to content

scripts: refactored scripts located under target/bin/#2500

Merged
georglauterbach merged 15 commits intomasterfrom
scripts/refactoring/target-bin
Mar 26, 2022
Merged

scripts: refactored scripts located under target/bin/#2500
georglauterbach merged 15 commits intomasterfrom
scripts/refactoring/target-bin

Conversation

@georglauterbach
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach commented Mar 21, 2022

Description

The scripts under target/bin/ now use the new log and I replaced some
"" with '' on the way. The functionality stays the same, this mostly
style and log.

Type of change

  • Improvement (non-breaking change that does improve existing functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

The scripts under `target/bin/` now use the new log and I replaced some
`""` with `''` on the way. The functionality stays the same, this mostly
style and log.
@georglauterbach georglauterbach added area/scripts kind/improvement Improve an existing feature, configuration file or the documentation labels Mar 21, 2022
@georglauterbach georglauterbach added this to the v11.0.0 milestone Mar 21, 2022
@georglauterbach georglauterbach self-assigned this Mar 21, 2022
@georglauterbach georglauterbach marked this pull request as draft March 21, 2022 12:03
@georglauterbach georglauterbach marked this pull request as ready for review March 21, 2022 21:07
Comment thread target/bin/sedfile Outdated
Comment thread target/bin/sedfile Outdated
Comment thread target/bin/delmailuser Outdated
Comment thread target/bin/fail2ban Outdated
Comment thread target/bin/fail2ban Outdated
Comment thread target/bin/listmailuser Outdated
Comment thread target/bin/open-dkim Outdated
Comment thread target/bin/setquota
Comment thread target/bin/restrict-access
Comment thread target/bin/delmailuser Outdated
Comment thread target/bin/delmailuser Outdated
Comment thread target/bin/addmailuser Outdated
@georglauterbach

This comment was marked as resolved.

The new output has a single, clear message with the '[  ERROR  ]  '
prefix, and then output that explains the error afterwards. This is
coherent with the logging style which should be used while providing
more information than just a single line about IPTables not functioning.
polarathene
polarathene previously approved these changes Mar 22, 2022
Comment thread target/bin/setquota
polarathene
polarathene previously approved these changes Mar 22, 2022
Before, scripts located under `target/bin/` were using `usage` or
`__usage`. Now, they're using `__usage` as they should.
@georglauterbach
Copy link
Copy Markdown
Member Author

georglauterbach commented Mar 22, 2022

It seems I was (literally less than) 1 minute too late. I noticed that usage was used inconsistently @polarathene - sorry for getting on your nerves with reviewing this (again 😆)... I promise this was my final commit :D

polarathene
polarathene previously approved these changes Mar 22, 2022
Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Comment thread target/bin/sedfile Outdated
Comment thread target/bin/sedfile Outdated
Comment thread target/bin/sedfile Outdated
Comment thread target/bin/setquota
Comment thread target/bin/updatemailuser
With `sedfile`, we cannot use the helper functions in a nice way because
it is used early in the Dockerfile at a stage where the helper scripts
are not yet copied. The script has been adjusted to be canonical with
all the other scripts under `target/bin/`.
@georglauterbach
Copy link
Copy Markdown
Member Author

georglauterbach commented Mar 23, 2022

I have added another commit (4560650) to adjust sedfile (due to feedback by @casperklein) to be canonical with the other scripts under target/bin/. I think further changes are not required.

polarathene
polarathene previously approved these changes Mar 23, 2022
@georglauterbach
Copy link
Copy Markdown
Member Author

🤦🏼 🤦🏼 🤦🏼 Nice test failure (due to not matching substring). @polarathene sorry for updating the PR again. I feel like I'm pestering you, and I promise, I'm not doing it on purpose :)

polarathene
polarathene previously approved these changes Mar 23, 2022
Comment thread target/bin/setquota Outdated
`__usage` is to be used on wrong user input, not on other failures as
well. This was fixed in `delquota` and `setquota`.
polarathene
polarathene previously approved these changes Mar 24, 2022
Comment thread target/bin/delmailuser Outdated
Comment thread target/bin/sedfile Outdated
Comment thread target/bin/sedfile Outdated
Comment thread target/bin/sedfile
set -ueo pipefail

HASHTOOL="sha1sum"
function __usage { echo "Usage: ${0} -i <replace/delete operation> <file>" ; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why introducing a function, that is only called once?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably the intention was to just be consistent with other CLI utility scripts in this folder? That's not such a bad thing even if it might be redundant in this particular file 😅

Copy link
Copy Markdown
Member Author

@georglauterbach georglauterbach Mar 25, 2022

Choose a reason for hiding this comment

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

All the changes are done for uniformity with the other scripts. In #2493 (comment) you pledged for a "continuous look and feel" - this is it (looking at all the other scripts). I have become a bit tired of never-ending small nitpicks like this to be frank. Therefore, I will leave this in (because it really is a nice addition to script uniformity), but I will revert some of the other changes to sedfile - otherwise I fear, these changes might never end up in master...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you pledged for a "continuous look and feel" - this is it

Fair point. And with that argumentation, I agree with keeping _usage. For the same reason I wonder, why you decline to introduce _log in this PR? Technically it's no problem to copy the needed files before the first usage of sedfile.
Keeping the echos is clearly against a "continuous look and feel".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you want to add _log to sedfile do it as a follow-up PR, lets just get this stuff merged while it's in a good state and approved 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree with @polarathene :) @casperklein I will add a smaller follow-up PR that introduces _log to sedfile :D

Comment thread target/bin/setquota
@georglauterbach georglauterbach merged commit b9dbec3 into master Mar 26, 2022
@georglauterbach georglauterbach deleted the scripts/refactoring/target-bin branch March 26, 2022 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/scripts kind/improvement Improve an existing feature, configuration file or the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants