feat(go-swagger): Improve Makefile
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Matthieu 'JP' DERASSE
2022-09-21 21:54:13 +00:00
parent b7f0d796e4
commit edbd97705a
4 changed files with 66 additions and 15 deletions

View File

@ -24,11 +24,7 @@ func (a APIType) GenerateLauncher(path string, config *models.Config) error {
templatePath := filepath.Join(templateDirectory, "launcher.sh.tmpl")
savePath := filepath.Join(path, "launcher.sh")
data := launcherTemplate{
APIs: []*models.Process{},
Crons: []*models.Process{},
Workers: []*models.Process{},
}
data := launcherTemplate{}
processes, err := a.getProcesses(path)
if err != nil {

View File

@ -3,7 +3,6 @@ package go_swagger
import (
"path/filepath"
"github.com/iancoleman/strcase"
"github.com/juju/errors"
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
@ -13,7 +12,9 @@ import (
)
type makefileTemplate struct {
AppNameKebabCase string
APIs []*models.Process
Crons []*models.Process
Workers []*models.Process
}
// GenerateMakefile will generate makefile based on the given config.
@ -24,11 +25,26 @@ func (a APIType) GenerateMakefile(path string, config *models.Config) error {
templatePath := filepath.Join(templateDirectory, "Makefile.tmpl")
savePath := filepath.Join(path, "Makefile")
data := makefileTemplate{
AppNameKebabCase: strcase.ToKebab(config.ProjectName),
data := makefileTemplate{}
processes, err := a.getProcesses(path)
if err != nil {
log.Error("Fail to list processes")
return errors.Trace(err)
}
err := helpers.WriteTemplate(templatePath, savePath, data)
for _, process := range processes {
switch process.Type {
case models.ProcessType_API:
data.APIs = append(data.APIs, process)
case models.ProcessType_CRON:
data.Crons = append(data.Crons, process)
case models.ProcessType_WORKER:
data.Workers = append(data.Workers, process)
}
}
err = helpers.WriteTemplate(templatePath, savePath, data)
if err != nil {
return errors.Trace(err)
}