feat(goctl): Support gateway sample generation (#3049)

This commit is contained in:
anqiansong
2023-03-29 17:06:23 +08:00
committed by GitHub
parent 95b85336d6
commit 1904af2323
32 changed files with 1399 additions and 513 deletions

View File

@@ -1,6 +1,6 @@
package docker
import "github.com/spf13/cobra"
import "github.com/zeromicro/go-zero/tools/goctl/internal/cobrax"
var (
varExeName string
@@ -14,21 +14,18 @@ var (
varStringTZ string
// Cmd describes a docker command.
Cmd = &cobra.Command{
Use: "docker",
Short: "Generate Dockerfile",
RunE: dockerCommand,
}
Cmd = cobrax.NewCommand("docker", cobrax.WithRunE(dockerCommand))
)
func init() {
Cmd.Flags().StringVar(&varExeName, "exe", "", "The executable name in the built image")
Cmd.Flags().StringVar(&varStringGo, "go", "", "The file that contains main function")
Cmd.Flags().StringVar(&varStringBase, "base", "scratch", "The base image to build the docker image, default scratch")
Cmd.Flags().IntVar(&varIntPort, "port", 0, "The port to expose, default none")
Cmd.Flags().StringVar(&varStringHome, "home", "", "The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority")
Cmd.Flags().StringVar(&varStringRemote, "remote", "", "The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority\nThe git repo directory must be consistent with the https://github.com/zeromicro/go-zero-template directory structure")
Cmd.Flags().StringVar(&varStringBranch, "branch", "", "The branch of the remote repo, it does work with --remote")
Cmd.Flags().StringVar(&varStringVersion, "version", "", "The goctl builder golang image version")
Cmd.Flags().StringVar(&varStringTZ, "tz", "Asia/Shanghai", "The timezone of the container")
dockerCmdFlags := Cmd.Flags()
dockerCmdFlags.StringVar(&varExeName, "exe")
dockerCmdFlags.StringVar(&varStringGo, "go")
dockerCmdFlags.StringVarWithDefaultValue(&varStringBase, "base", "scratch")
dockerCmdFlags.IntVar(&varIntPort, "port")
dockerCmdFlags.StringVar(&varStringHome, "home")
dockerCmdFlags.StringVar(&varStringRemote, "remote")
dockerCmdFlags.StringVar(&varStringBranch, "branch")
dockerCmdFlags.StringVar(&varStringVersion, "version")
dockerCmdFlags.StringVarWithDefaultValue(&varStringTZ, "tz", "Asia/Shanghai")
}