mirror of
https://github.com/openziti/zrok.git
synced 2024-11-25 17:43:53 +01:00
40 lines
839 B
Go
40 lines
839 B
Go
package main
|
|
|
|
import (
|
|
"github.com/michaelquigley/cf"
|
|
"github.com/openziti-test-kitchen/zrok/controller"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(newControllerCommand().cmd)
|
|
}
|
|
|
|
type controllerCommand struct {
|
|
cmd *cobra.Command
|
|
}
|
|
|
|
func newControllerCommand() *controllerCommand {
|
|
cmd := &cobra.Command{
|
|
Use: "controller <configPath>",
|
|
Short: "Start a zrok controller",
|
|
Aliases: []string{"ctrl"},
|
|
Args: cobra.ExactArgs(1),
|
|
}
|
|
command := &controllerCommand{cmd: cmd}
|
|
cmd.Run = command.run
|
|
return command
|
|
}
|
|
|
|
func (cmd *controllerCommand) run(_ *cobra.Command, args []string) {
|
|
cfg, err := controller.LoadConfig(args[0])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
logrus.Infof(cf.Dump(cfg, cf.DefaultOptions()))
|
|
if err := controller.Run(cfg); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|