From 23d43061fb88515c009bdc156948a35f88c5ab2d Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Thu, 4 Sep 2025 10:08:40 -0600 Subject: [PATCH] refactor: update pyjinja2 implementation --- pkg/plugins/pyjinja2/pyjinja2.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/plugins/pyjinja2/pyjinja2.go b/pkg/plugins/pyjinja2/pyjinja2.go index fe823f2..673f1a1 100644 --- a/pkg/plugins/pyjinja2/pyjinja2.go +++ b/pkg/plugins/pyjinja2/pyjinja2.go @@ -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)