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
[feature] ability to merge hash variables on includes #404
Comments
I have my dynvariables and import_variables is very good fit, so I will clone required repositories and will use them as separate dotdrop projects, while my main project will attach some related to it variables to patch things, but without merges (or ability in j2 to list all variables to find by some key all related to current template, like gitconfig_A, gitconfig_B) I can't create some "infinity" variable, where first say to add
Hope this explanation is clear..) |
Is vanilla j2 has a way to find/access variable by dynamic name? Ansible has some variables that stores all available variables like Lets for cleanliness I understand that I want in general - I want an ultimate platform for ricing. I want to have common bases and patch them for current rice, patch from rice, like plugins, maybe I'm doing something wrong or overcomplicating(..), I have implemented a small PoC to help better understand my thought, what I was trying to achieve:
And in general it all works, I have achieved this, but it feels like everything is done on the edge. For ex. pluggable dotfile Once again, I'm not saying that everything should work like this, I'm saying what I'm trying to do in general, maybe I'm doing something wrong! It also can look like I'm trying to reinvent
|
Currently dotdrop allows to lookup environement variables using something like For example providing all variables under the keyword |
In context of merges - yes, I think, if we will can list all variables with Small future investigation based on PoC and above messages: I understand that if config B extends/includes config A, than config B can't use dotfiles of config A if the configs stored in different folders, so their dotfiles stored in different places, config B has access to dotfiles A, but tries to lookup them relative to himself, not relative to config A as they are, BUT, if this dotfiles are in profile defined in config A, than config B can use this profile and related dotfiles will be accessed, is it by design or a bug? should I create an issue? |
No that should be working. Here's something you can do:
config:
backup: true
create: true
dotpath: some-dotpath-dir
import_configs:
- ../somepath/child-config.yaml
dotfiles:
f_abc:
dst: ~/.abc
src: abc
profiles:
p0:
include:
- p1
dotfiles:
- f_abc
config:
backup: true
create: true
dotpath: some-other-dotpath-dir
dotfiles:
f_def:
dst: ~/def
src: def
profiles:
p1:
dotfiles:
- f_def Is that what you are looking for? |
Yep, I said that it works via profile. But:
this will fail with error like |
Ok, I took some time to go through your poc and here are a few ideas:
Here's an example of the kind of filters you can add: def vars_contain(variables, pattern):
"""
return dict of all vars containing
"pattern" in their key
"""
found = {}
for k in variables.keys():
if k.contains(pattern):
found[k] = variables[k]
return found
def vars_contain_to_list(variables, pattern):
"""
return list of the values of all vars containing
"pattern" in their key
"""
found = []
for k in variables.keys():
if k.contains(pattern):
found.append(variables[k])
return found I have the feeling it became complex due to the fact that you're not able (for valid reasons) to store all dotfiles/configs in a single repository but have to selectively add them. Since you can't actually store those elements in clear text, wouldn't transformations help?
Also the |
@deadc0de6 I'm late, sorry, I saw the answer, I will digest all this soon and will continue the topic, a little not up to it.. Thanks a lot for the detailed answer! (: |
Like in Ansible, it will simplify some advanced things.
The text was updated successfully, but these errors were encountered: