39 lines
899 B
Go
39 lines
899 B
Go
package makecmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"yizhisec.com/hsv2/forge/internal/controller/maker"
|
|
"yizhisec.com/hsv2/forge/internal/opt"
|
|
)
|
|
|
|
func Redis() *cobra.Command {
|
|
var (
|
|
replicas int
|
|
password string
|
|
storage int
|
|
)
|
|
|
|
_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(opt.Cfg.Make.Dir)
|
|
return mk.Redis(
|
|
cmd.Context(),
|
|
maker.WithRedisReplicaCount(replicas),
|
|
maker.WithRedisPassword(password),
|
|
maker.WithRedisStorage(fmt.Sprintf("%dGi")),
|
|
)
|
|
},
|
|
}
|
|
|
|
_cmd.Flags().IntVar(&replicas, "replica-count", 2, "Redis 副本数")
|
|
_cmd.Flags().StringVar(&password, "password", "", "Redis 密码")
|
|
_cmd.Flags().IntVar(&storage, "storage-size", 5, "Redis 存储大小(单位Gi)如: 5")
|
|
|
|
return _cmd
|
|
}
|