func (fm *ContextManager) Generate(instanceSpec models.InstanceSpec) (
	envMap map[string]string, fileMap map[string]string, err error) {
	projectPrefixedConfig, projRawConfig := fm.projectEnvs()
	instanceEnvMap, instanceFileMap := fm.getInstanceData(instanceSpec)
	projectInstanceContext := MergeInterfaceMapToInterface(instanceEnvMap, projectPrefixedConfig)
	projectInstanceContext["proj"] = projRawConfig
	projectInstanceContext["inst"] = instanceEnvMap
	envMap, err = fm.generateEnvs(instanceSpec.Name, instanceSpec.Type, projectInstanceContext)
	if err != nil {
		return nil, nil, err
	}
	for k, v := range instanceEnvMap {
		if vs, ok := v.(string); ok {
			envMap[k] = vs
		}
	}
	compiledAssetResponse, err := fm.jobRun.Spec.Task.Unit.CLIMod.CompileAssets(context.Background(), models.CompileAssetsRequest{
		Window:           fm.jobRun.Spec.Task.Window,
		Config:           models.PluginConfigs{}.FromJobSpec(fm.jobRun.Spec.Task.Config),
		Assets:           models.PluginAssets{}.FromJobSpec(fm.jobRun.Spec.Assets),
		InstanceSchedule: fm.jobRun.ScheduledAt,
		InstanceData:     instanceSpec.Data,
	})
	if err != nil {
		return nil, nil, err
	}
	fileMap = MergeStringMap(instanceFileMap, compiledAssetResponse.Assets.ToJobSpec().ToMap())
	if fileMap, err = fm.engine.CompileFiles(fileMap, projectInstanceContext); err != nil {
		return
	}
	return envMap, fileMap, nil
}
Generate fetches and compiles all config data related to an instance and
returns a map of env variables and a map[fileName]fileContent
It compiles any templates/macros present in the config.
package run
import (
	"context"
	"fmt"
	"time"
	"github.com/odpf/optimus/models"
	"github.com/pkg/errors"
)
const (
	TaskConfigPrefix = "TASK__"
	ProjectConfigPrefix = "GLOBAL__"
)
var (
	IgnoreTemplateRenderExtension = []string{".gtpl", ".j2", ".tmpl", ".tpl"}
)
type ContextManager struct {
	namespace models.NamespaceSpec
	jobRun    models.JobRun
	engine    models.TemplateEngine
}