-
Notifications
You must be signed in to change notification settings - Fork 5
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
Handle plugins sequentially in apply #51
Comments
Sorry for not getting back to you earlier, I really let this fall through the cracks. On handling plugins sequentially in applyI'm rather against this. The main reason is that I want On the meta-plugin proposalGiven the above, doing the "meta-plugin" as an actual separate plugin is pretty much DoA, but I'm interested in having something like this as part of Holo itself. I'm not sure if I understand your proposal in its entirety. A concrete end-to-end example would be illuminating. A particular concern for me is that if we do anything like this, it should also cover the use-case described in #7, and I'm not seeing that in your proposal. #7 is IMO the biggest gap in Holo's resource-file model right now. It really limits the expressiveness of holograms. By comparison, #10 is not a particularly big concern for me anymore since Replicator turned out much more solid than the quick hack I had in mind. In fact, I ought to add a manpage to it, slap the "1.0" sticker on it and just close #10. A counter-proposalGiven my current track record in terms of answering time, it probably makes sense to pack as much as possible in this response, so I'll include a counter-proposal. I let the idea of rendering resource files at scan-time simmer in my head, and was reminded of systemd generators. In case you're not familiar, systemd includes a bunch of helper programs called "generators" that produce unit files at startup time. For example, systemd-fstab-generator converts each entry of /etc/fstab into a mount unit. Generators in systemd are just programs that put a bunch of unit files in In my proposal, a generator is any executable file at From that point, everything progresses like before. The other plugins pick up the generated resource files like they do static resource files. Since plugins expect only a single ExamplesThe use-case from #7: We want to add $ cat /usr/share/holo/generators/add-intel-ucode.sh
#!/bin/bash
set -euo pipefail
for FILE in /boot/loader/entries/*.conf; do
cat > "${OUT}/files/${FILE}.holoscript" <<-EOF
#!/bin/sh
sed '/^initrd / i initrd /intel-ucode.img'
EOF
chmod +x "${OUT}/files/${FILE}.holoscript"
done This would run $ cat /usr/share/holo/generators/templated-users-groups.sh
#!/bin/bash
set -euo pipefail
cd "${HOLO_RESOURCE_DIR}/users-groups"
for FILE in $(grep -l '{{.*}}' *.toml); do
replicator < "${FILE}" > "${OUT}/users-groups/${FILE}"
done Note that this example assumes that generated resource files take precedence over static ones in case of a name conflict, which seems like the most plausible of the possible behaviors. You may have noticed that this example breaks my previously mentioned rule that generators ought not require superuser privileges ( |
Thank you very much for your response. I really like your counter proposal. I seems to solve the problem just right and also doesn't have the problem with dynamic paths that my initial idea had. I think it's the right way to go forward since it also allows you to use whatever template engine you prefer. One thing I think would be important: |
Yeah, makes sense. Any executable file somewhere in there should be considered. |
I'm currently working on a pull request for this feature and encountered an issues along the way: Problem with the current proposalWouldn't the symlinking to Changing to multiple entries in Temp dirTo avoid the need for root privileges in scan we could use the existing Generator behaviorI would allow generators to decide themselves wether they want to overwrite files or not. |
When I say "symlink into |
Oh I see thank you very much for the clarification that makes way more sense. In terms of the temp dir would you prefer |
I'm aware of it. Haven't managed to review it during the day, and after work my budget for code review is quite exhausted. I'll try to get to it over the weekend. |
No problem. Take your time. Just wanted to make sure you noticed it and it didn't fall between the cracks ;) |
Currently an execution of
holo apply
works like this:I would like it to be:
For each plugin
So the scan of the current plugin runs after the apply of the plugin before it.
But why?
So why am I requesting this?
Well is has to do with #10. We want a flexible system to make configs more generic and sharable.
I had an idea on how this can be achieved. And my solution is what I call the meta-plugin.
The meta plugin basically generates files for the other plugins using templates.
For this to work its apply needs to be run before the other plugins scan for their entities.
That's the reason for the change requested above.
The meta-plugin
So now that the why has been established I want to further detail the concept of the meta-plugin
and how I invision it to work.
The files for the meta-plugin will be located under
/usr/share/holo/meta
and be structured as follows:{hologram name/group}/path/realtive/to/holo_recource_dir/file.tmpl
On apply the meta plugin loades variables from it's configurations file and complies stored templates (similar to replicator).
Variables can be defined per hologram or group (holograms can symlink files to the groups).
Environmentvariables will also be available inside the templates.
The compiled templates are then deployed into the
holo_resource_dir
. Using the example above the compiled template would be deployed at${HOLO_RESOURCE_DIR}/path/realtive/to/holo_recource_dir/file
.Templated paths
Additionally one might want to define a dynamic deploy path for a template file (e.g. in oder to deploy a specific file into a users home directory).
This can be achived by placing a path specifier file besides the template file:
{hologram name/group}/path/realtive/to/holo_recource_dir/file.tmpl.path
This files contains a template string that is parsed into the files path realtive to were it resides.
It's content could for example look like this:
{{var.user}}}/file
meaning the compiled template would be deployed at${HOLO_RESOURCE_DIR}/path/realtive/to/holo_recource_dir/stefan/file
if the user variable is set tostefan
.Remarks
I am willing to develop the meta-plugin myself. But before I start working on it I wanted approval from you @majewsky. Do you argee with the idea? Are you willing to make the according changes to holo?
I would greatly appriciate feedback from you on this idea.
The text was updated successfully, but these errors were encountered: