gouick/cmd/generateDocker.go
Matthieu 'JP' DERASSE b1f168286f
All checks were successful
continuous-integration/drone Build is passing
continuous-integration/drone/push Build is passing
feat(generate): Prepare general generate command
2022-11-11 17:52:44 +00:00

48 lines
1.1 KiB
Go

/*
Copyright © 2022 Matthieu Derasse <git@derasse.fr>
*/
package cmd
import (
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_types"
"github.com/spf13/cobra"
log "github.com/sirupsen/logrus"
)
// dockerCmd represents the docker command.
var dockerCmd = &cobra.Command{
Use: "docker",
Short: "Generate Dockerfile & co for API, Crons and Workers",
Run: runGenerateDocker,
}
func init() {
generateCmd.AddCommand(dockerCmd)
}
// runGenerateDocker will generate the Dockerfile & co for the current project.
func runGenerateDocker(cmd *cobra.Command, args []string) {
log.Debugf("Starting command GenerateDocker")
currentPath, config, err := loadProjectAndConfig()
if err != nil {
return
}
apiType, err := api_types.GetAPIType(config.ProjectType)
if err != nil {
log.Error("Impossible to load that API Type generator")
return
}
// Generate Dockerfile
log.Info("Generating Dockerfile")
err = apiType.GenerateDockerfile(currentPath, config)
if err != nil {
log.Errorf("Fail to generate Dockerfile. The following error happen: %s", err.Error())
return
}
}