resticprofile
resticprofile copied to clipboard
env-file: Implement dotenv and {{env}} support
Implementation of #316
Supporting:
-
env-filein profiles:my-profile: env-file: /path/to/.env -
{{env}}function to get a temporary .env file that can be used to adjust the environment between shell command runs:my-profile: run-before: echo "VAR=WORLD" >> "{{env}}" backup: run-before: echo "Hello $VAR"
Codecov Report
Attention: Patch coverage is 98.55072% with 2 lines in your changes are missing coverage. Please review.
Project coverage is 70.12%. Comparing base (
71ce2d0) to head (ffb8fca).
| Files | Patch % | Lines |
|---|---|---|
| util/templates/functions.go | 89.47% | 1 Missing and 1 partial :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #323 +/- ##
==========================================
+ Coverage 69.88% 70.12% +0.24%
==========================================
Files 118 119 +1
Lines 11891 11993 +102
==========================================
+ Hits 8309 8409 +100
- Misses 3193 3194 +1
- Partials 389 390 +1
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 70.12% <98.55%> (+0.24%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
~I can see there are still some broken links in the documentation since the latest version of Hugo 😞 Maybe I should just pin the version for now 🤔 that's annoying~
Nah it is a mistake in my CI script 😨 Fixed in #328
Thanks a lot for the hint. Yes we should recreate the env for every shell call. I’ll update the PR.
Rebased and updated so that env is created for every shell command invocation. Done from my side.
Agree that it all became too verbose with the --verbose flag enabled. Still I think changes to the env is an important log output. I've reduced unfiltered-log to trace level and changed the env log to display the full env only when it was changed.
E.g. it now looks like this:
resticprofile --verbose containers.backup
2024/03/10 14:09:29 resticprofile 0.27.0-dev
2024/03/10 14:09:29 using configuration file: /etc/resticprofile/profiles.yaml
...
2024/03/10 14:09:29 profile 'containers': initializing repository (if not existing)
2024/03/10 14:09:29 command environment:
TMPDIR=/tmp
2024/03/10 14:09:29 starting command: /usr/bin/restic init ...
2024/03/10 14:09:29 starting run-before backup on profile 1/1
2024/03/10 14:09:29 command environment: reusing previous
Create a readonly snapshot of '/opt/containers' in '/opt/snapshot_containers'
2024/03/10 14:09:29 profile 'containers': starting 'backup'
2024/03/10 14:09:29 command environment: reusing previous
2024/03/10 14:09:29 starting command: /usr/bin/restic backup ... /opt/snapshot_containers
Agree that it all became too verbose with the
--verboseflag enabled. Still I think changes to the env is an important log output. I've reduced unfiltered-log to trace level and changed the env log to display the full env only when it was changed.
Perfect! Thanks 😉