1
0
Fork 0
mirror of synced 2024-11-16 06:15:34 -05:00
Commit graph

201 commits

Author SHA1 Message Date
Erik Flodin
8ba9823407
Rewrite default template to handle nested ifs, != and env vars in if
The awk script now performs all processing in the BEGIN block using an
implementation that is capable of handling if statements which contain nested
if statments (fixes #436). To make nested ifs look better, if, else and endif
lines can now have optional whitespace before {%.

Includes are now handled in the same way as the main file which means that
included files can both include other files and have if statements in addition
to variables (fixes #406). Include lines can now also have optional whitespace
before {%.

All variables are handled in the same way now so it's now possible to use env
variables in if statements (fixes #488).

Also add support for != in addition to == (fixes #358). Thus it's now
e.g. possible to check if a variable is set (#477) by doing:

{% if yadm.class != ""%}
Class is set to {{ yadm.class }}
{% endif %}

A non-existing yadm or env variable is now replaced with the empty string.
2024-11-04 22:30:23 +01:00
Tim Byrne
76ce3defea
Changes for black compliance 2023-07-12 09:20:00 -05:00
Tim Byrne
e704175201
Add black to linting 2023-07-12 09:20:00 -05:00
Tim Byrne
1b36bf2bb6
Move all test/linting configs into pyproject.toml
Except for flake8 which doesn't support pyproject.toml yet.
2023-07-12 09:19:59 -05:00
Tim Byrne
7af2af52ae
Lint using isort 2023-07-12 09:19:59 -05:00
Tim Byrne
bbc1ca17f0
Changes for new flake8 compliance 2023-07-12 09:19:59 -05:00
Tim Byrne
8a87f4a30f
Changes for new pylint compliance 2023-07-12 09:19:59 -05:00
Tim Byrne
f9e0368385
Changes for new shellcheck compliance 2023-07-12 09:19:59 -05:00
Tim Byrne
c8acf77e04
Adjust pinentry mock
The new test Docker image has a newer gnupg which does not behave the
same way, handling invalid passwords. This type of error is simulated
using an ICP error in the pinentry protocol.
2023-07-12 09:19:59 -05:00
Tim Byrne
9752d801ae
Replace deprecated "pipes" with "shlex" 2023-07-12 09:19:58 -05:00
Tim Byrne
84437894b5
Use man.REAL 2023-07-12 09:19:58 -05:00
Tim Byrne
82ba16db34
Support testing with newer version of Git 2023-07-12 09:19:58 -05:00
Tim Byrne
2253e52ab7
Update test Docker image
* Update base image (which uses a newer python)
* Update linters
* Update other dependencies
2023-07-12 09:19:53 -05:00
Tim Byrne
0f8538d3e3
Create tests for underscores in distro/family 2022-09-13 12:38:18 -05:00
Tim Byrne
46f72c2768
Add local.arch to config introspection 2022-02-21 14:09:57 -06:00
Tim Byrne
ebb6715aad
Reduce supported labels for architecture 2022-02-21 14:01:08 -06:00
Tim Byrne
50bf8716cd
Unify template support for classes (#185) 2022-02-21 11:31:44 -06:00
Tim Byrne
0b75e71237
Merge pull request #347 from rasa/develop 2022-02-17 16:45:45 -06:00
Ross Smith II
487f030405
Update test/test_unit_template_default.py
Co-authored-by: Paulo Köch <paulo.koch@gmail.com>
2022-02-17 16:45:07 -06:00
Paulo Köch
b0e0856658
Add test 2022-02-17 16:44:57 -06:00
Tim Byrne
027c7359ac
Merge pull request #304 from erijo/multiple-classes 2022-01-22 18:14:23 -06:00
Tim Byrne
3d3432516f
Distinguish tests of templates 2022-01-22 18:05:29 -06:00
Tim Byrne
5ae553b078
Add support for distro_family (#213)
Obtained from /etc/os-release: ID_LIKE.
Alternate attributes f & distro_family.
2022-01-22 18:05:15 -06:00
Tim Byrne
32bc9abb0c
Include bash version 2022-01-17 11:45:09 -06:00
Tim Byrne
8186705059
Include Git version with yadm version (#377) 2022-01-17 09:12:41 -06:00
Tim Byrne
f11974140e
Merge pull request #395 from erijo/shellcheck 2022-01-07 00:21:53 -06:00
Erik Flodin
1aa9839096
Bump shellcheck to version 0.8.0 in docker image
And fix the new SC2295 warning.
2021-12-29 21:55:14 +01:00
Erik Flodin
a9fc8b1374
Bump esh to version 0.3.1 in docker image 2021-12-29 20:44:12 +01:00
Erik Flodin
2379d63068
Support overriding architecture
In the same way as os, hostname and user.
2021-12-27 22:21:18 +01:00
Erik Flodin
42c74efbac
Add support for multiple local classes
A local class is set with:
$ yadm config local.class cls1

More classes can be added with:
$ yadm config --add local.class cls2
$ yadm config --add local.class cls3

Any of cls1, cls2 and cls3 can be used in an alternate condition.

For templates, the existing variable yadm.class/YADM_CLASS is set to
the last class (i.e. cls3) to remain compatible with how it works
today and with what the following command gives:
$ yadm config local.class

For the default template processor there is no explicit yadm.classes
variable. Instead a yadm.class condition will check against all
classes.

For the other processors, a new template variable YADM_CLASSES will be
set to all classes separated by newline. For jinja2 templates a class
can be checked with: {%- if "cls" in YADM_CLASSES.split("\n") %}

For esh templates the logic is a bit more complex, but it is possible
to do.

Fixes #185.
2021-12-27 21:14:09 +01:00
Tim Byrne
4843e1fa14
Add arch to template tests 2021-12-23 15:43:30 -06:00
Tim Byrne
85e05d311a
Merge pull request #203 from jameshclrk/arch-alternative 2021-12-21 16:50:41 -06:00
Tim Byrne
5adb486727
Fix support for multiple GPG recipients (#342) 2021-05-17 15:42:35 -05:00
Tim Byrne
216aed2f87
Adjust special handling of existing read-only output files
Instead of duplicating the permissions on the temp file, the permissions
are duplicated on the output file directly. If the output file exists as
read-only, it is made writeable first.

There are some environments which don't allow the mv to work if the file
itself is read-only.
2021-02-28 10:55:37 -06:00
Tim Byrne
1461b1ac33
Merge pull request #311 from erijo/test-upgrade-typo 2021-02-15 12:42:17 -06:00
Tim Byrne
88ee3f09fb
Merge pull request #301 from erijo/relative-path 2021-02-15 12:11:21 -06:00
Tim Byrne
31071d9ac9
Clarify error message
Conflicts are not stashed anymore
2021-02-04 00:06:00 -06:00
Erik Flodin
990b4ce119
Fix typo in test (can_upgraded_... -> can_upgrade_...) 2021-01-17 19:07:36 +01:00
Erik Flodin
accec694f5
Deinit submodules before removing the repo
when forcing init/clone to happen.
2021-01-08 22:21:35 +01:00
Erik Flodin
f45e66d4da
Rework clone
Instead of doing work to find the default branch just to be able to
set up the repository before doing a fetch, do a "git clone" and let
git handle it.

Use -c core.sharedrepository=0600 to get the same result as
--shared=0600 passed to init.

Use --separate-git-dir to get the git directory in $YADM_REPO. Use a
temporary dir as work tree and remove it right after the clone is
done.

When the clone is done, iterate over all missing files in $YADM_WORK
and perform a checkout. If local files exists that differ compared
with the cloned ones the local files are left intact and the user is
instructed to deal with the conflicts.
2021-01-08 22:05:46 +01:00
Erik Flodin
a321c88c7c
Support passing relative paths to --yadm-* and -w
Relative paths are expanded relative the current working dir as
expected.
2021-01-08 21:45:55 +01:00
Erik Flodin
6378fe3073
Print errors to stderr
This makes it possible to run e.g. "yadm -Y foo introspect repo
2>/dev/null" and get an empty output instead of getting the error
message about foo not being fully qualified.
2021-01-05 21:57:32 +01:00
Erik Flodin
cd50c128ba
Fix test when test is run from a git worktree 2021-01-05 21:56:50 +01:00
Tim Byrne
0b4aa767fb
Merge pull request #293 from erijo/submodule-upgrade 2021-01-04 12:52:39 -06:00
Erik Flodin
5818eeb9dd
Change handling of submodules at upgrade
Start with doing "submodule absorbgitdirs" as otherwise "submodule
deinit" will fail if a module has been cloned first and later added as
a submodule (as it will then contain the .git dir instead of it being
under the superprojects .git dir).

Then try to deinit the submodules before moving the repo and abort the
upgrade if it fails for any submodule. Then do the move and finally
initialize the submodules that were initialized before the upgrade.

See #285
2021-01-04 18:31:24 +01:00
Erik Flodin
230b8b9374
Basic test to verify upgrade using real yadm releases
Both with and without submodules.
2021-01-04 17:33:48 +01:00
Tim Byrne
7c1192ae2e
Support upgrading from version 1 repos
* yadm upgrade now updates legacy paths created by yadm 1
* Warnings are issued for invalid alternates again
2020-12-30 14:19:49 -06:00
Tim Byrne
0d3ff086c5
Add test for --no-zle shell option 2020-12-29 17:58:51 -06:00
Erik Flodin
48e7337ef1
Upgrade to latest pytest version (6.2.1) 2020-12-29 21:51:57 +01:00
Erik Flodin
ec3956c560
Configure git email and name in docker
to make it easier to use yadm in the container. Set it in the system
config (i.e. /etc/gitconfig) to avoid getting a clash if one wants to
clone an existing yadm repo that contains a .gitconfig.
2020-12-29 21:50:56 +01:00