refactor: update pyjinja2 implementation
This commit is contained in:
parent
62b58f4cbb
commit
23d43061fb
1 changed files with 9 additions and 3 deletions
|
|
@ -75,6 +75,7 @@ func (p *Jinja2) Run(store storage.KVStore, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get mappings from provided profiles
|
||||||
var ps = make(map[string]any)
|
var ps = make(map[string]any)
|
||||||
for profileID, profile := range profiles.(makeshift.ProfileMap) {
|
for profileID, profile := range profiles.(makeshift.ProfileMap) {
|
||||||
ps[profileID] = map[string]any{
|
ps[profileID] = map[string]any{
|
||||||
|
|
@ -84,8 +85,9 @@ func (p *Jinja2) Run(store storage.KVStore, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j2, err := jinja2.NewJinja2("pyjinja", 1,
|
// get mappings supplied by this plugin
|
||||||
jinja2.WithGlobal("makeshift", map[string]any{
|
mappings.Data = map[string]any{
|
||||||
|
"makeshift": map[string]any{
|
||||||
"profiles": ps,
|
"profiles": ps,
|
||||||
"plugin": map[string]any{
|
"plugin": map[string]any{
|
||||||
"name": p.Name(),
|
"name": p.Name(),
|
||||||
|
|
@ -93,7 +95,11 @@ func (p *Jinja2) Run(store storage.KVStore, args []string) error {
|
||||||
"description": p.Description(),
|
"description": p.Description(),
|
||||||
"metadata": p.Metadata(),
|
"metadata": p.Metadata(),
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
j2, err := jinja2.NewJinja2("makeshift", 1,
|
||||||
|
jinja2.WithGlobals(mappings.Data),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(pyjinja2) failed to create new Jinja 2 instance: %v", err)
|
return fmt.Errorf("(pyjinja2) failed to create new Jinja 2 instance: %v", err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue