package generator

import (
	"github.com/dave/jennifer/jen"
	"github.com/hashicorp/go-hclog"
)

type GeneratorOptions struct {
	Logger              hclog.Logger
	GetFieldInformation FieldInformationGetter
	AttributeConverters []AttributeConverter
}

func (o *GeneratorOptions) validate() *GeneratorOptions {
	res := &GeneratorOptions{
		Logger:              hclog.Default(),
		GetFieldInformation: GetFieldInformationFromTerraformTag,
		AttributeConverters: DefaultConverters,
	}
	if o == nil {
		return res
	}

	if o.Logger != nil {
		res.Logger = o.Logger
	}
	if o.AttributeConverters != nil {
		res.AttributeConverters = o.AttributeConverters
	}
	if o.GetFieldInformation != nil {
		res.GetFieldInformation = o.GetFieldInformation
	}
	return res
}

func newFile(pkg string) *jen.File {
	f := jen.NewFile(pkg)
	f.HeaderComment(headerComment)
	return f
}

const headerComment = `Code generated by github-terraform-generator; DO NOT EDIT.
Any modifications will be overwritten`
