func (c EnvContext) EvalContext(cleanMode bool) eval.Context {
	p, err := json.Marshal(c.props)
	if err != nil {
		sio.Warnln("unable to serialize env properties to JSON:", err)
	}
	cm := "off"
	if cleanMode {
		cm = "on"
	}
	baseVars := c.vars.WithVars(
		vm.NewVar(model.QbecNames.EnvVarName, c.env),
		vm.NewVar(model.QbecNames.TagVarName, c.app.Tag()),
		vm.NewVar(model.QbecNames.DefaultNsVarName, c.app.DefaultNamespace(c.env)),
		vm.NewVar(model.QbecNames.CleanModeVarName, cm),
		vm.NewCodeVar(model.QbecNames.EnvPropsVarName, string(p)),
	)
	return eval.Context{
		BaseContext: eval.BaseContext{
			Vars:        baseVars,
			LibPaths:    c.ext.LibPaths,
			DataSources: c.dataSources,
			Verbose:     c.Verbosity() > 1,
		},
		Concurrency:      c.EvalConcurrency(),
		PostProcessFiles: c.App().PostProcessors(),
	}
}
EvalContext returns the evaluation context for the supplied environment.
package cmd
import (
	"encoding/json"
	"fmt"
	"github.com/pkg/errors"
	"github.com/splunk/qbec/internal/eval"
	"github.com/splunk/qbec/internal/model"
	"github.com/splunk/qbec/internal/remote"
	"github.com/splunk/qbec/internal/sio"
	"github.com/splunk/qbec/vm"
	vmds "github.com/splunk/qbec/vm/datasource"
)
type EnvContext struct {
	AppContext
	env         string
	props       map[string]interface{}
	dataSources []vmds.DataSource
}
func (c *EnvContext) configProvider(name string) (string, error) {
	baseCtx := c.EvalContext(false).BaseContext
	code := fmt.Sprintf(`std.extVar('%s')`, name)
	return eval.Code(fmt.Sprintf("<%s>", name), vm.MakeCode(code), baseCtx)
}
func (c *EnvContext) createDataSources() error {
	sources, closer, err := vm.CreateDataSources(c.App().DataSources(), c.configProvider)
	RegisterCleanupTask(closer)
	if err != nil {
		return err
	}
	c.dataSources = sources
	return nil
}
func (c *EnvContext) computeVars() error {
	cVars := c.App().DeclaredComputedVars()
	for _, varObj := range cVars {
		name := varObj.Name
		baseCtx := c.EvalContext(false).BaseContext
		jsonData, err := eval.Code(fmt.Sprintf("<%s>", name), vm.MakeCode(varObj.Code), baseCtx)
		if err != nil {
			return errors.Wrapf(err, "eval computed var %s", name)
		}
		c.vars = c.vars.WithVars(vm.NewCodeVar(name, jsonData))
	}
	return nil
}
func (c *EnvContext) initEnv() error {
	if err := c.createDataSources(); err != nil {
		return err
	}
	if err := c.computeVars(); err != nil {
		return err
	}
	return nil
}
func (c EnvContext) Env() string { return c.env }