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)
|
||||
for profileID, profile := range profiles.(makeshift.ProfileMap) {
|
||||
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,
|
||||
jinja2.WithGlobal("makeshift", map[string]any{
|
||||
// get mappings supplied by this plugin
|
||||
mappings.Data = map[string]any{
|
||||
"makeshift": map[string]any{
|
||||
"profiles": ps,
|
||||
"plugin": map[string]any{
|
||||
"name": p.Name(),
|
||||
|
|
@ -93,7 +95,11 @@ func (p *Jinja2) Run(store storage.KVStore, args []string) error {
|
|||
"description": p.Description(),
|
||||
"metadata": p.Metadata(),
|
||||
},
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
j2, err := jinja2.NewJinja2("makeshift", 1,
|
||||
jinja2.WithGlobals(mappings.Data),
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(pyjinja2) failed to create new Jinja 2 instance: %v", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue