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

Add support for multiple local classes #304

Merged
merged 1 commit into from
Jan 22, 2022

Conversation

erijo
Copy link
Contributor

@erijo erijo commented Jan 10, 2021

What does this PR do?

Make it possible to have 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.

TODO: no documentation has been updated. I'll update it later if this seems like a good idea.

What issues does this PR fix or reference?

Previous Behavior

Only one class was supported.

New Behavior

Multiple classes are supported.

Have tests been written for this change?

Yes

Have these commits been signed with GnuPG?

Yes


Please review yadm's Contributing Guide for best practices.

@erijo erijo changed the title Add support for multiple local classes RFC: Add support for multiple local classes Mar 22, 2021
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 TheLocehiliosan#185.
@erijo erijo changed the title RFC: Add support for multiple local classes Add support for multiple local classes Dec 27, 2021
@erijo erijo marked this pull request as ready for review December 27, 2021 20:22
@erijo
Copy link
Contributor Author

erijo commented Dec 27, 2021

@TheLocehiliosan: I've rebased this on top of latest develop.

I haven't updated the documentation since I'm not sure how it should be described (or even if). Suggestions are welcome.

@TheLocehiliosan TheLocehiliosan merged commit 5e26aef into TheLocehiliosan:develop Jan 22, 2022
@TheLocehiliosan
Copy link
Owner

@erijo - Another high quality PR 👍

This has been merged into develop, and will be part of the next release. I'll figure out the documentation.

@TheLocehiliosan TheLocehiliosan self-assigned this Jan 22, 2022
@TheLocehiliosan TheLocehiliosan added this to In progress in 3.2.1 via automation Jan 22, 2022
@erijo erijo deleted the multiple-classes branch January 24, 2022 21:15
@TheLocehiliosan TheLocehiliosan moved this from In progress to Done in 3.2.1 Feb 21, 2022
TheLocehiliosan added a commit that referenced this pull request Feb 21, 2022
* Support architecture for alternates/templates (#202, #203, #393)
* Support distro_family for alternates/templates (#213)
* Support setting multiple classes (#185, #304)
* Support environment variables in default template processor (#347)
* Update version command to include Bash & Git versions (#377)
TheLocehiliosan added a commit that referenced this pull request Mar 12, 2022
* Support architecture for alternates/templates (#202, #203, #393)
* Support distro_family for alternates/templates (#213)
* Support setting multiple classes (#185, #304)
* Support environment variables in default template processor (#347)
* Update version command to include Bash & Git versions (#377)
TheLocehiliosan added a commit that referenced this pull request Mar 16, 2022
* Support architecture for alternates/templates (#202, #203, #393)
* Support distro_family for alternates/templates (#213)
* Support setting multiple classes (#185, #304)
* Support environment variables in default template processor (#347)
* Update version command to include Bash & Git versions (#377)
@tkna91 tkna91 mentioned this pull request Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
3.2.1
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants