🏗️ move make sub-cmd to sub-dir
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"gitea.loveuer.com/yizhisec/pkg3/logger"
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/cmd/makecmd"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
"yizhisec.com/hsv2/forge/internal/opt"
|
||||
)
|
||||
@@ -25,6 +26,10 @@ func makeCmd() *cobra.Command {
|
||||
logger.Warn("Running in debug mode")
|
||||
}
|
||||
|
||||
if err = os.MkdirAll(opt.Cfg.Make.Dir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if opt.Cfg.Make.DisableDependencyCheck {
|
||||
logger.Info("Dependency check disabled")
|
||||
return nil
|
||||
@@ -35,10 +40,6 @@ func makeCmd() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = os.MkdirAll(opt.Cfg.Make.Dir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Debug("Running make prerun success")
|
||||
|
||||
return nil
|
||||
@@ -49,18 +50,20 @@ func makeCmd() *cobra.Command {
|
||||
_cmd.PersistentFlags().StringVar(&opt.Cfg.Make.Dir, "dir", "/root/hsv2-installation", "make base directory")
|
||||
|
||||
_cmd.AddCommand(
|
||||
makeImages(),
|
||||
makeBinaries(),
|
||||
makeDebs(),
|
||||
makeFlannel(),
|
||||
makeLonghorn(),
|
||||
makeMysql(),
|
||||
makeRedis(),
|
||||
makeES(),
|
||||
makeEMQX(),
|
||||
makeYosguard(),
|
||||
makeLessDNS(), // hs-net dependency
|
||||
makeHSNet(),
|
||||
makecmd.Images(),
|
||||
makecmd.Binaries(),
|
||||
makecmd.Debs(),
|
||||
makecmd.Flannel(),
|
||||
makecmd.Longhorn(),
|
||||
makecmd.Mysql(),
|
||||
makecmd.Redis(),
|
||||
makecmd.ES(),
|
||||
makecmd.EMQX(),
|
||||
makecmd.Yosguard(),
|
||||
makecmd.LessDNS(),
|
||||
makecmd.HSNet(),
|
||||
makecmd.ConfigMap(),
|
||||
makecmd.App(),
|
||||
)
|
||||
|
||||
return _cmd
|
||||
|
||||
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
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeBinaries() *cobra.Command {
|
||||
func Binaries() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "binaries",
|
||||
Aliases: []string{"bin", "B"},
|
||||
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
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeDebs() *cobra.Command {
|
||||
func Debs() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "debs",
|
||||
Aliases: []string{"deb"},
|
||||
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeEMQX() *cobra.Command {
|
||||
func EMQX() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "emqx",
|
||||
Short: "Make EMQX",
|
||||
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeES() *cobra.Command {
|
||||
func ES() *cobra.Command {
|
||||
var (
|
||||
makeHelper bool
|
||||
memRate int
|
||||
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeFlannel() *cobra.Command {
|
||||
func Flannel() *cobra.Command {
|
||||
var (
|
||||
_mode string
|
||||
)
|
||||
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeHSNet() *cobra.Command {
|
||||
func HSNet() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "hs-net",
|
||||
Short: "Build hs-net",
|
||||
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"yizhisec.com/hsv2/forge/internal/opt"
|
||||
)
|
||||
|
||||
func makeImages() *cobra.Command {
|
||||
func Images() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "images",
|
||||
Aliases: []string{"image"},
|
||||
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeLessDNS() *cobra.Command {
|
||||
func LessDNS() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "lessdns",
|
||||
Short: "Build lessdns",
|
||||
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeLonghorn() *cobra.Command {
|
||||
func Longhorn() *cobra.Command {
|
||||
var (
|
||||
replicaCount int
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -7,8 +7,7 @@ import (
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeMysql() *cobra.Command {
|
||||
|
||||
func Mysql() *cobra.Command {
|
||||
var (
|
||||
replicas int
|
||||
storage int
|
||||
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeRedis() *cobra.Command {
|
||||
func Redis() *cobra.Command {
|
||||
var (
|
||||
replicas int
|
||||
password string
|
||||
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
package makecmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
||||
)
|
||||
|
||||
func makeYosguard() *cobra.Command {
|
||||
func Yosguard() *cobra.Command {
|
||||
_cmd := &cobra.Command{
|
||||
Use: "yosguard",
|
||||
Aliases: []string{"YOS"},
|
||||
Reference in New Issue
Block a user