Add --validate action: Validate borgmatic configuration file and exit #158
No reviewers
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#158
Loading…
Reference in New Issue
No description provided.
Delete Branch "(deleted):add/validate_action"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Useful when generating the borgmatic configuration file with configuration management and before moving the generated file in place checking if it is actually valid.
The added unit tests are currently incomplete. Can you help me with those? How should I pass a valid and invalid configuration to the command?
PS: Thanks again very much for maintaining borgmatic. I contributed some time ago already and still have the feeling that borgmatic is in pretty good shape 👍
Thank you for doing this! Great idea for a feature.. I do the same config-management-driven borgmatic config generation thing on at least one of my hosts.
What do you think of making this feature an entirely separate
validate-borgmatic-config
command-line command rather than part of the mainborgmatic
command? I suggest that for a couple of reasons:--validate
and--create
simultaneously. In fact, if a user did that with your current branch, they might be surprised that no archives got created! So a separate validation-only command might have less surprising behaviorparse_configuration()
is already factored out ofborgmatic.py
. (And side note: You wouldn't need to do any of the cross-file validation checks.)main()
function at all. (Evenborgmatic.py
'smain()
is not under test, you'll notice.)Let me know what you think!
Thanks for this good work! Just passing by and thought I would pitch in with a review (not really familiar with the code, so feel free to ignore).
@ -48,2 +48,4 @@
actions_group = parser.add_argument_group('actions')
actions_group.add_argument(
'-V', '--validate', dest='validate', action='store_true', help='Validate borgmatic configuration file and exit'
Can drop the
and exit
?--version
has the same. Also note:@ -484,4 +489,9 @@ def main(): # pragma: no cover
[logger.handle(log) for log in summary_logs if log.levelno >= logger.getEffectiveLevel()]
if any(log.levelno == logging.CRITICAL for log in summary_logs):
if args.validate:
This is never triggered because the above section where
logging.CRITICAL
is outputted is now not run?Thanks for the input. I am actually unsure why I wanted to skip
exit_with_help_link()
.@ -487,1 +494,4 @@
exit_with_help_link()
if args.validate:
print('Configuration files are valid.')
Should also
logging.makeLogRecord
or?Nitpicking but don't see any other user facing messages with
.
either.Uhhh, I clicked the wrong button ... not approving, just wanted to comment! ;)
Thanks for your feedback!
@witten: I agree with your points. Please have a look at witten/borgmatic#161. Feel free to do the finishing touches yourself. That might be more efficient for us.
Closing this in favor of #161. Thanks again for taking the time to do both.
Pull request closed