package cmd

import (
	"fmt"

	"github.com/spf13/cobra"
	"yizhisec.com/hsv2/forge/internal/controller/maker"
)

func makeMysql() *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
}
