The current implementation doesn't allow the languages package to be imported for use outside draft as it relies on the builders embed in /pkg/languages which embeds the /pkg/languages/builders directory that is only populated after go:generate is executed through the makefile.
Since the draft makefile isn't executed when importing draft packages, the /pkg/languages/builders directory doesn't exist and the embed fails.
By creating a builders property on the languages struct and creating a public embed of the /templates/builders folder,
existing functionality is retained
users can supply custom builders fs.FS to create their own language dockerFile generation templates
the languages package can be imported and used outside draft (without any changes to makefiles) as follows:
import "github.com/Azure/draft/templates"
import "github.com/Azure/draft/pkg/languages"
...
l := languages.CreateLanguagesFromEmbedFS(template.Dockerfiles, dest)
The current implementation doesn't allow the
languages
package to be imported for use outside draft as it relies on thebuilders
embed in/pkg/languages
which embeds the/pkg/languages/builders
directory that is only populated after go:generate is executed through the makefile.Since the draft makefile isn't executed when importing draft packages, the
/pkg/languages/builders
directory doesn't exist and the embed fails.By creating a
builders
property on thelanguages
struct and creating a public embed of the/templates/builders
folder,builders
fs.FS to create their own language dockerFile generation templateslanguages
package can be imported and used outside draft (without any changes to makefiles) as follows:l.createDockerfileForLanguage(lang,inputs,templateWriter)