🏗️ move make sub-cmd to sub-dir
This commit is contained in:
18
internal/cmd/makecmd/app.go
Normal file
18
internal/cmd/makecmd/app.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func App() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "app",
|
||||
Short: "Make Apps(user, client, gateway, mie, nginx, etc...)",
|
||||
}
|
||||
|
||||
_cmd.AddCommand(
|
||||
appUser(),
|
||||
)
|
||||
|
||||
return _cmd
|
||||
}
|
||||
25
internal/cmd/makecmd/app.user.go
Normal file
25
internal/cmd/makecmd/app.user.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func appUser() *cobra.Command {
|
||||
var (
|
||||
replica int
|
||||
)
|
||||
|
||||
_cmd := &cobra.Command{
|
||||
Use: "user",
|
||||
Short: "Make User App",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.AppUser(cmd.Context(), replica)
|
||||
},
|
||||
}
|
||||
|
||||
_cmd.Flags().IntVar(&replica, "replica-count", 2, "Replica count")
|
||||
|
||||
return _cmd
|
||||
}
|
||||
21
internal/cmd/makecmd/binaries.go
Normal file
21
internal/cmd/makecmd/binaries.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func Binaries() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "binaries",
|
||||
Aliases: []string{"bin", "B"},
|
||||
Short: "Build binary files",
|
||||
Long: `Build all required binary files for the project.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.Binary(cmd.Context())
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
20
internal/cmd/makecmd/configmap.go
Normal file
20
internal/cmd/makecmd/configmap.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func ConfigMap() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "configmap",
|
||||
Aliases: []string{"cm"},
|
||||
Short: "构建 ConfigMap",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.ConfigMap(cmd.Context())
|
||||
},
|
||||
}
|
||||
|
||||
return _cmd
|
||||
}
|
||||
21
internal/cmd/makecmd/debs.go
Normal file
21
internal/cmd/makecmd/debs.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func Debs() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "debs",
|
||||
Aliases: []string{"deb"},
|
||||
Short: "Build Debian packages",
|
||||
Long: `Build all required Debian packages for the project.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.Deb(cmd.Context())
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
19
internal/cmd/makecmd/emqx.go
Normal file
19
internal/cmd/makecmd/emqx.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func EMQX() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "emqx",
|
||||
Short: "Make EMQX",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.EMQX(cmd.Context())
|
||||
},
|
||||
}
|
||||
|
||||
return _cmd
|
||||
}
|
||||
36
internal/cmd/makecmd/es.go
Normal file
36
internal/cmd/makecmd/es.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func ES() *cobra.Command {
|
||||
var (
|
||||
makeHelper bool
|
||||
memRate int
|
||||
storage int
|
||||
)
|
||||
|
||||
_cmd := &cobra.Command{
|
||||
Use: "es",
|
||||
Aliases: []string{"elastic", "elasticsearch"},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.Elastic(
|
||||
cmd.Context(),
|
||||
maker.WithElasticMakeHelper(makeHelper),
|
||||
maker.WithElasticMemRate(memRate),
|
||||
maker.WithElasticStorageGi(fmt.Sprintf("%dGi", storage)),
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
_cmd.Flags().BoolVar(&makeHelper, "make-helper", false, "重新构建 helper 镜像")
|
||||
_cmd.Flags().IntVar(&memRate, "mem-rate", 1, "内存倍率(从 1G 开始)")
|
||||
_cmd.Flags().IntVar(&storage, "storage-size", 100, "存储空间(单位: G)")
|
||||
|
||||
return _cmd
|
||||
}
|
||||
26
internal/cmd/makecmd/flannel.go
Normal file
26
internal/cmd/makecmd/flannel.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func Flannel() *cobra.Command {
|
||||
var (
|
||||
_mode string
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "flannel",
|
||||
Short: "Build Flannel resources",
|
||||
Long: `Build and prepare Flannel network resources.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.Flannel(cmd.Context(), _mode)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringVar(&_mode, "mode", "host-gw", "Flannel backend mode (vxlan or host-gw)")
|
||||
|
||||
return cmd
|
||||
}
|
||||
20
internal/cmd/makecmd/hsnet.go
Normal file
20
internal/cmd/makecmd/hsnet.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func HSNet() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "hs-net",
|
||||
Short: "Build hs-net",
|
||||
Long: `Build hs-net`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.HSNet(cmd.Context())
|
||||
},
|
||||
}
|
||||
|
||||
return _cmd
|
||||
}
|
||||
31
internal/cmd/makecmd/images.go
Normal file
31
internal/cmd/makecmd/images.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
"yizhisec.com/hsv2/forge/internal/opt"
|
||||
)
|
||||
|
||||
func Images() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "images",
|
||||
Aliases: []string{"image"},
|
||||
Short: "Build and pull Docker images",
|
||||
Long: `Build and pull all required Docker images for the project.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
if err := os.MkdirAll(filepath.Join(opt.Cfg.Make.Dir, "dependency", "image"), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mk := maker.NewMaker()
|
||||
|
||||
return mk.Images(cmd.Context())
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
20
internal/cmd/makecmd/lessdns.go
Normal file
20
internal/cmd/makecmd/lessdns.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func LessDNS() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "lessdns",
|
||||
Short: "Build lessdns",
|
||||
Long: `Build lessdns`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.LessDNS(cmd.Context())
|
||||
},
|
||||
}
|
||||
|
||||
return _cmd
|
||||
}
|
||||
26
internal/cmd/makecmd/longhorn.go
Normal file
26
internal/cmd/makecmd/longhorn.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func Longhorn() *cobra.Command {
|
||||
var (
|
||||
replicaCount int
|
||||
)
|
||||
|
||||
_cmd := &cobra.Command{
|
||||
Use: "longhorn",
|
||||
Short: "Build Longhorn resources",
|
||||
Long: `Build and prepare Longhorn storage resources.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.Longhorn(cmd.Context(), replicaCount)
|
||||
},
|
||||
}
|
||||
|
||||
_cmd.Flags().IntVar(&replicaCount, "replica-count", 2, "存储副本数")
|
||||
|
||||
return _cmd
|
||||
}
|
||||
35
internal/cmd/makecmd/mysql.go
Normal file
35
internal/cmd/makecmd/mysql.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func Mysql() *cobra.Command {
|
||||
var (
|
||||
replicas int
|
||||
storage int
|
||||
)
|
||||
|
||||
_cmd := &cobra.Command{
|
||||
Use: "mysql",
|
||||
Short: "Build MySQL resources",
|
||||
Long: `Build and prepare MySQL database resources.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts := []maker.MysqlOpt{
|
||||
maker.WithMySQLReplica(replicas),
|
||||
maker.WithMySQLStorage(fmt.Sprintf("%dGi", storage)),
|
||||
}
|
||||
|
||||
mk := maker.NewMaker()
|
||||
return mk.MySQL(cmd.Context(), opts...)
|
||||
},
|
||||
}
|
||||
|
||||
_cmd.Flags().IntVar(&replicas, "replica-count", 2, "mysql 的副本数")
|
||||
_cmd.Flags().IntVar(&storage, "storage-size", 50, "mysql 的存储空间(GB)")
|
||||
|
||||
return _cmd
|
||||
}
|
||||
35
internal/cmd/makecmd/redis.go
Normal file
35
internal/cmd/makecmd/redis.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func Redis() *cobra.Command {
|
||||
var (
|
||||
replicas int
|
||||
password string
|
||||
storage string
|
||||
)
|
||||
|
||||
_cmd := &cobra.Command{
|
||||
Use: "redis",
|
||||
Short: "Build Redis resources",
|
||||
Long: `Build and prepare Redis cache resources.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.Redis(
|
||||
cmd.Context(),
|
||||
maker.WithRedisReplicaCount(replicas),
|
||||
maker.WithRedisPassword(password),
|
||||
maker.WithRedisStorage(storage),
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
_cmd.Flags().IntVar(&replicas, "replica-count", 2, "Redis 副本数")
|
||||
_cmd.Flags().StringVar(&password, "password", "", "Redis 密码")
|
||||
_cmd.Flags().StringVar(&storage, "storage-size", "5Gi", "Redis 存储大小(如: 5Gi)")
|
||||
|
||||
return _cmd
|
||||
}
|
||||
20
internal/cmd/makecmd/yosguard.go
Normal file
20
internal/cmd/makecmd/yosguard.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func Yosguard() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "yosguard",
|
||||
Aliases: []string{"YOS"},
|
||||
Short: "Make Yosguard",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
mk := maker.NewMaker()
|
||||
return mk.Yosguard(cmd.Context())
|
||||
},
|
||||
}
|
||||
|
||||
return _cmd
|
||||
}
|
||||
Reference in New Issue
Block a user