Skip to content

Commit

Permalink
feat: add resources dir starlark custom variable (#867)
Browse files Browse the repository at this point in the history
Signed-off-by: Mehant Kammakomati <kmehant@gmail.com>
  • Loading branch information
kmehant authored Sep 19, 2022
1 parent c21c835 commit 4caa926
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions transformer/external/starlarktransformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
templatesRelDirVarName = "templates_reldir"
transformerConfigVarName = "config"
projectVarName = "project"
resourcesDirVarName = "resources_dir"

// Function names
qaFnName = "query"
Expand Down Expand Up @@ -132,6 +133,11 @@ func (t *Starlark) Init(tc transformertypes.Transformer, env *environment.Enviro
logrus.Errorf("Unable to load source : %s", err)
return err
}
t.StarGlobals[resourcesDirVarName], err = starutil.Marshal(filepath.Join(env.GetEnvironmentContext(), "resources"))
if err != nil {
logrus.Errorf("Unable to load source : %s", err)
return err
}
t.StarGlobals, err = starlark.ExecFile(t.StarThread, filepath.Join(t.Env.GetEnvironmentContext(), t.StarConfig.StarFile), nil, t.StarGlobals)
if err != nil {
if t.StarConfig.StarFile == "" {
Expand Down

0 comments on commit 4caa926

Please sign in to comment.