2024-04-23 07:23:35 +00:00
|
|
|
/*
|
2024-04-22 04:35:37 +00:00
|
|
|
reCoreD-UI provides web ui for CoreDNS
|
|
|
|
|
|
|
|
NAME:
|
|
|
|
reCoreD-UI - Web UI for CoreDNS
|
|
|
|
|
|
|
|
USAGE:
|
2024-04-23 07:23:35 +00:00
|
|
|
|
|
|
|
reCoreD-UI [global options] command [command options]
|
2024-04-22 04:35:37 +00:00
|
|
|
|
|
|
|
COMMANDS:
|
2024-04-23 07:23:35 +00:00
|
|
|
|
|
|
|
server run server
|
|
|
|
config config some settings
|
|
|
|
help, h Shows a list of commands or help for one command
|
2024-04-22 04:35:37 +00:00
|
|
|
|
|
|
|
GLOBAL OPTIONS:
|
2024-04-23 07:23:35 +00:00
|
|
|
|
|
|
|
--config value, -c value config yaml file [$RECORED_CONFIG_FILE]
|
|
|
|
--mysql-dsn value mysql dsn [$RECORED_MYSQL_DSN]
|
|
|
|
--debug enable debug mode (default: false)
|
|
|
|
--help, -h show help
|
2024-04-22 04:35:37 +00:00
|
|
|
*/
|
2024-04-03 09:05:12 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2024-04-10 05:24:01 +00:00
|
|
|
"reCoreD-UI/cmd/config"
|
|
|
|
"reCoreD-UI/cmd/server"
|
2024-04-13 02:30:02 +00:00
|
|
|
_ "reCoreD-UI/docs"
|
2024-04-03 09:05:12 +00:00
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"github.com/urfave/cli/v2/altsrc"
|
|
|
|
)
|
|
|
|
|
2024-04-23 07:23:35 +00:00
|
|
|
// will be modified when building
|
|
|
|
var Version string = "v0.0.1"
|
|
|
|
|
2024-04-03 09:05:12 +00:00
|
|
|
func init() {
|
|
|
|
logrus.SetReportCaller(true)
|
|
|
|
}
|
|
|
|
|
2024-04-23 07:23:35 +00:00
|
|
|
// @title reCoreD-UI API
|
|
|
|
// @version 1.0
|
|
|
|
// @description APIs for reCoreD-UI
|
|
|
|
// @BasePath /api/v1
|
|
|
|
// @securityDefinitions.basic BasicAuth
|
2024-04-03 09:05:12 +00:00
|
|
|
func main() {
|
|
|
|
flags := []cli.Flag{
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "config",
|
|
|
|
Usage: "config yaml file",
|
|
|
|
Aliases: []string{"c"},
|
|
|
|
EnvVars: []string{"RECORED_CONFIG_FILE"},
|
|
|
|
},
|
2024-04-10 05:24:01 +00:00
|
|
|
altsrc.NewStringFlag(&cli.StringFlag{
|
2024-04-13 02:30:02 +00:00
|
|
|
Name: "mysql-dsn",
|
|
|
|
Usage: "mysql dsn",
|
|
|
|
EnvVars: []string{"RECORED_MYSQL_DSN"},
|
2024-04-10 05:24:01 +00:00
|
|
|
}),
|
|
|
|
altsrc.NewBoolFlag(&cli.BoolFlag{
|
2024-04-03 09:05:12 +00:00
|
|
|
Name: "debug",
|
|
|
|
Usage: "enable debug mode",
|
|
|
|
Value: false,
|
|
|
|
Action: func(ctx *cli.Context, b bool) error {
|
|
|
|
if b {
|
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
2024-04-10 05:24:01 +00:00
|
|
|
}),
|
2024-04-03 09:05:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app := &cli.App{
|
2024-04-23 07:23:35 +00:00
|
|
|
Name: "reCoreD-UI",
|
|
|
|
Version: Version,
|
|
|
|
Usage: "Web UI for CoreDNS",
|
2024-04-03 09:05:12 +00:00
|
|
|
Before: altsrc.InitInputSourceWithContext(
|
|
|
|
flags, altsrc.NewYamlSourceFromFlagFunc("config"),
|
|
|
|
),
|
|
|
|
Flags: flags,
|
2024-04-10 05:24:01 +00:00
|
|
|
Commands: []*cli.Command{
|
|
|
|
server.Command,
|
|
|
|
config.Command,
|
|
|
|
},
|
2024-04-03 09:05:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
logrus.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|