fix(go-swagger): Reorganize go swagger directory
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
251c4bf0d1
commit
6268aad2ac
@ -20,7 +20,7 @@ func (a APIType) CreateProjectSkeleton(path string, config *models.Config) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate Makefile
|
// Generate Makefile
|
||||||
err = a.generateMakefile(path, config)
|
err = a.GenerateMakefile(path, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to generate Makefile")
|
log.Error("Fail to generate Makefile")
|
||||||
return errors.Trace(err)
|
return errors.Trace(err)
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
package go_swagger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/juju/errors"
|
|
||||||
|
|
||||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
// deleteTempApiYaml will delete the temporary yaml api file generated by go-swagger.
|
|
||||||
func (a APIType) deleteTempApiYaml(path string) error {
|
|
||||||
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
|
||||||
|
|
||||||
tempFilePath := filepath.Join(path, mergeYamlFileName)
|
|
||||||
|
|
||||||
// delete
|
|
||||||
exist, err := helpers.FileExists(tempFilePath)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Trace(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !exist {
|
|
||||||
log.Debug("File doesn't exist already")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
err = os.Remove(tempFilePath)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("fail to delete file in %s", tempFilePath)
|
|
||||||
return errors.Trace(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -16,9 +16,9 @@ type makefileTemplate struct {
|
|||||||
AppNameKebabCase string
|
AppNameKebabCase string
|
||||||
}
|
}
|
||||||
|
|
||||||
// generateMakefile will generate makefile based on the given config.
|
// GenerateMakefile will generate makefile based on the given config.
|
||||||
// Launched only at project init or on force.
|
// Launched only at project init or on force.
|
||||||
func (a APIType) generateMakefile(path string, config *models.Config) error {
|
func (a APIType) GenerateMakefile(path string, config *models.Config) error {
|
||||||
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
||||||
|
|
||||||
templatePath := filepath.Join(templateDirectory, "Makefile.tmpl")
|
templatePath := filepath.Join(templateDirectory, "Makefile.tmpl")
|
||||||
|
@ -7,10 +7,37 @@ import (
|
|||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
|
|
||||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
||||||
|
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// initializeGoModule will launch a go mod init.
|
||||||
|
func (a APIType) initializeGoModule(path string, config *models.Config) error {
|
||||||
|
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
||||||
|
|
||||||
|
if err := os.Chdir(path); err != nil {
|
||||||
|
log.Error("Fail to move to the path")
|
||||||
|
return errors.Trace(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
modulePath := ""
|
||||||
|
if config.ModulePath != nil {
|
||||||
|
modulePath = *config.ModulePath
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command("go", "mod", "init", modulePath)
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("fail to execute go mod init %s", modulePath)
|
||||||
|
return errors.Trace(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("go mod init %s returned the following output: %s", modulePath, string(output))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// downloadGoDeps will execute go get ./... in the give repository.
|
// downloadGoDeps will execute go get ./... in the give repository.
|
||||||
func (a APIType) downloadGoDeps(path string) error {
|
func (a APIType) downloadGoDeps(path string) error {
|
||||||
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
package go_swagger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
|
|
||||||
"github.com/juju/errors"
|
|
||||||
|
|
||||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
|
||||||
"git.home.m-and-m.ovh/mderasse/gouick/models"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
// initializeGoModule will launch a go mod init.
|
|
||||||
func (a APIType) initializeGoModule(path string, config *models.Config) error {
|
|
||||||
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
|
||||||
|
|
||||||
if err := os.Chdir(path); err != nil {
|
|
||||||
log.Error("Fail to move to the path")
|
|
||||||
return errors.Trace(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
modulePath := ""
|
|
||||||
if config.ModulePath != nil {
|
|
||||||
modulePath = *config.ModulePath
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command("go", "mod", "init", modulePath)
|
|
||||||
output, err := cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("fail to execute go mod init %s", modulePath)
|
|
||||||
return errors.Trace(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("go mod init %s returned the following output: %s", modulePath, string(output))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
package go_swagger
|
package go_swagger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
@ -23,7 +24,7 @@ type apiYamlContact struct {
|
|||||||
URL string
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
// generateAPIYamls will generate a readme based on the given config.
|
// generateAPIYamls will generate the main api yaml file based on the given config.
|
||||||
// Launched only at project init.
|
// Launched only at project init.
|
||||||
func (a APIType) generateAPIYamls(path string, config *models.Config) error {
|
func (a APIType) generateAPIYamls(path string, config *models.Config) error {
|
||||||
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
||||||
@ -68,3 +69,29 @@ func (a APIType) generateAPIYamls(path string, config *models.Config) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deleteTempApiYaml will delete the temporary yaml api file generated by go-swagger.
|
||||||
|
func (a APIType) deleteTempApiYaml(path string) error {
|
||||||
|
log.Debugf("Starting %s - %s", a.GetName(), helpers.GetCurrentFuncName())
|
||||||
|
|
||||||
|
tempFilePath := filepath.Join(path, mergeYamlFileName)
|
||||||
|
|
||||||
|
// delete
|
||||||
|
exist, err := helpers.FileExists(tempFilePath)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Trace(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !exist {
|
||||||
|
log.Debug("File doesn't exist already")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.Remove(tempFilePath)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("fail to delete file in %s", tempFilePath)
|
||||||
|
return errors.Trace(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user