feat(goctl): Support gateway sample generation (#3049)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package kube
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import "github.com/zeromicro/go-zero/tools/goctl/internal/cobrax"
|
||||
|
||||
var (
|
||||
varStringName string
|
||||
@@ -26,50 +26,38 @@ var (
|
||||
varStringImagePullPolicy string
|
||||
|
||||
// Cmd describes a kube command.
|
||||
Cmd = &cobra.Command{
|
||||
Use: "kube",
|
||||
Short: "Generate kubernetes files",
|
||||
}
|
||||
|
||||
deployCmd = &cobra.Command{
|
||||
Use: "deploy",
|
||||
Short: "Generate deployment yaml file",
|
||||
RunE: deploymentCommand,
|
||||
}
|
||||
Cmd = cobrax.NewCommand("kube")
|
||||
deployCmd = cobrax.NewCommand("deploy", cobrax.WithRunE(deploymentCommand))
|
||||
)
|
||||
|
||||
func init() {
|
||||
deployCmd.Flags().StringVar(&varStringName, "name", "", "The name of deployment (required)")
|
||||
deployCmd.Flags().StringVar(&varStringNamespace, "namespace", "", "The namespace of deployment (required)")
|
||||
deployCmd.Flags().StringVar(&varStringImage, "image", "", "The docker image of deployment (required)")
|
||||
deployCmd.Flags().StringVar(&varStringSecret, "secret", "", "The secret to image pull from registry")
|
||||
deployCmd.Flags().IntVar(&varIntRequestCpu, "requestCpu", 500, "The request cpu to deploy")
|
||||
deployCmd.Flags().IntVar(&varIntRequestMem, "requestMem", 512, "The request memory to deploy")
|
||||
deployCmd.Flags().IntVar(&varIntLimitCpu, "limitCpu", 1000, "The limit cpu to deploy")
|
||||
deployCmd.Flags().IntVar(&varIntLimitMem, "limitMem", 1024, "The limit memory to deploy")
|
||||
deployCmd.Flags().StringVar(&varStringO, "o", "", "The output yaml file (required)")
|
||||
deployCmd.Flags().IntVar(&varIntReplicas, "replicas", 3, "The number of replicas to deploy")
|
||||
deployCmd.Flags().IntVar(&varIntRevisions, "revisions", 5, "The number of revision history to limit")
|
||||
deployCmd.Flags().IntVar(&varIntPort, "port", 0, "The port of the deployment to listen on pod (required)")
|
||||
deployCmd.Flags().IntVar(&varIntNodePort, "nodePort", 0, "The nodePort of the deployment to expose")
|
||||
deployCmd.Flags().IntVar(&varIntTargetPort, "targetPort", 0, "The targetPort of the deployment, default to port")
|
||||
deployCmd.Flags().IntVar(&varIntMinReplicas, "minReplicas", 3, "The min replicas to deploy")
|
||||
deployCmd.Flags().IntVar(&varIntMaxReplicas, "maxReplicas", 10, "The max replicas to deploy")
|
||||
deployCmd.Flags().StringVar(&varStringImagePullPolicy, "imagePullPolicy", "", "Image pull policy. One of Always, Never, IfNotPresent")
|
||||
deployCmdFlags := deployCmd.Flags()
|
||||
deployCmdFlags.StringVar(&varStringName, "name")
|
||||
deployCmdFlags.StringVar(&varStringNamespace, "namespace")
|
||||
deployCmdFlags.StringVar(&varStringImage, "image")
|
||||
deployCmdFlags.StringVar(&varStringSecret, "secret")
|
||||
deployCmdFlags.IntVarWithDefaultValue(&varIntRequestCpu, "requestCpu", 500)
|
||||
deployCmdFlags.IntVarWithDefaultValue(&varIntRequestMem, "requestMem", 512)
|
||||
deployCmdFlags.IntVarWithDefaultValue(&varIntLimitCpu, "limitCpu", 1000)
|
||||
deployCmdFlags.IntVarWithDefaultValue(&varIntLimitMem, "limitMem", 1024)
|
||||
deployCmdFlags.StringVar(&varStringO, "o")
|
||||
deployCmdFlags.IntVarWithDefaultValue(&varIntReplicas, "replicas", 3)
|
||||
deployCmdFlags.IntVarWithDefaultValue(&varIntRevisions, "revisions", 5)
|
||||
deployCmdFlags.IntVar(&varIntPort, "port")
|
||||
deployCmdFlags.IntVar(&varIntNodePort, "nodePort")
|
||||
deployCmdFlags.IntVar(&varIntTargetPort, "targetPort")
|
||||
deployCmdFlags.IntVarWithDefaultValue(&varIntMinReplicas, "minReplicas", 3)
|
||||
deployCmdFlags.IntVarWithDefaultValue(&varIntMaxReplicas, "maxReplicas", 10)
|
||||
deployCmdFlags.StringVar(&varStringImagePullPolicy, "imagePullPolicy")
|
||||
deployCmdFlags.StringVar(&varStringHome, "home")
|
||||
deployCmdFlags.StringVar(&varStringRemote, "remote")
|
||||
deployCmdFlags.StringVar(&varStringBranch, "branch")
|
||||
deployCmdFlags.StringVar(&varStringServiceAccount, "serviceAccount")
|
||||
|
||||
deployCmd.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")
|
||||
deployCmd.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")
|
||||
deployCmd.Flags().StringVar(&varStringBranch, "branch", "", "The branch of the remote repo, it "+
|
||||
"does work with --remote")
|
||||
deployCmd.Flags().StringVar(&varStringServiceAccount, "serviceAccount", "", "The ServiceAccount "+
|
||||
"for the deployment")
|
||||
deployCmd.MarkFlagRequired("name")
|
||||
deployCmd.MarkFlagRequired("namespace")
|
||||
deployCmd.MarkFlagRequired("o")
|
||||
deployCmd.MarkFlagRequired("port")
|
||||
_ = deployCmd.MarkFlagRequired("name")
|
||||
_ = deployCmd.MarkFlagRequired("namespace")
|
||||
_ = deployCmd.MarkFlagRequired("o")
|
||||
_ = deployCmd.MarkFlagRequired("port")
|
||||
|
||||
Cmd.AddCommand(deployCmd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user