func Run(confPath, outPath string, opts *Options) error {
	var err error
	confPath, err = fileutil.Expand(confPath)
	if err != nil {
		return err
	}
	outPath, err = fileutil.Expand(outPath)
	if err != nil {
		return err
	}
	c, err := loadConfig(confPath, nil)
	if err != nil {
		return err
	}
	compat, err := version.IsCompatible(c.Version)
	if err != nil {
		return err
	}
	if !compat {
		return fmt.Errorf("Binary version %v incompatible with template version constraint %v in %v", cmd.Version, c.Version, confPath)
	}
	tmpDir, err := ioutil.TempDir("", "")
	if err != nil {
		return err
	}
	defer os.RemoveAll(tmpDir)
	if err := dump(c, filepath.Dir(confPath), opts.CacheDir, tmpDir, opts.WantedTemplates); err != nil {
		return err
	}
	if err := os.MkdirAll(outPath, 0755); err != nil {
		return fmt.Errorf("mkdir %q: %v", outPath, err)
	}
	var errs []string
	if opts.AddLicenses {
		if err := licenseutil.AddLicense(tmpDir); err != nil {
			errs = append(errs, fmt.Sprintf("add license header: %v", err))
		}
	}
	if opts.Format {
		if err := hcl.FormatDir(&runner.Default{Quiet: true}, tmpDir); err != nil {
			errs = append(errs, fmt.Sprintf("format output dir: %v", err))
		}
	}
	if opts.ShowUnmanaged {
		if err := findUnmanaged(tmpDir, outPath, opts.DeleteUnmanaged); err != nil {
			errs = append(errs, err.Error())
		}
	}
	if err := copy.Copy(tmpDir, outPath); err != nil {
		errs = append(errs, fmt.Sprintf("copy temp dir to output dir: %v", err))
	}
	if len(errs) > 0 {
		return errors.New(strings.Join(errs, "\n"))
	}
	return nil
}
Run executes the main tfengine logic.
package tfengine
import (
	"errors"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"reflect"
	"regexp"
	"strings"
	"github.com/GoogleCloudPlatform/healthcare-data-protection-suite/cmd"
	"github.com/GoogleCloudPlatform/healthcare-data-protection-suite/internal/fileutil"
	"github.com/GoogleCloudPlatform/healthcare-data-protection-suite/internal/hcl"
	"github.com/GoogleCloudPlatform/healthcare-data-protection-suite/internal/jsonschema"
	"github.com/GoogleCloudPlatform/healthcare-data-protection-suite/internal/licenseutil"
	"github.com/GoogleCloudPlatform/healthcare-data-protection-suite/internal/runner"
	"github.com/GoogleCloudPlatform/healthcare-data-protection-suite/internal/template"
	"github.com/GoogleCloudPlatform/healthcare-data-protection-suite/internal/version"
	"github.com/otiai10/copy"
)
type Options struct {
	Format          bool
	AddLicenses     bool
	CacheDir        string
	ShowUnmanaged   bool
	DeleteUnmanaged bool
	WantedTemplates map[string]bool
}