mirror of
https://github.com/openziti/zrok.git
synced 2025-06-24 11:41:25 +02:00
more cmd lint
This commit is contained in:
parent
7f2afc13cd
commit
1ef84865f0
@ -10,7 +10,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type controllerCommand struct {
|
type controllerCommand struct {
|
||||||
dbPath string
|
|
||||||
cmd *cobra.Command
|
cmd *cobra.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,9 +20,7 @@ func newControllerCommand() *controllerCommand {
|
|||||||
Aliases: []string{"ctrl"},
|
Aliases: []string{"ctrl"},
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
}
|
}
|
||||||
command := &controllerCommand{
|
command := &controllerCommand{cmd: cmd}
|
||||||
cmd: cmd,
|
|
||||||
}
|
|
||||||
cmd.Run = command.run
|
cmd.Run = command.run
|
||||||
return command
|
return command
|
||||||
}
|
}
|
||||||
|
@ -13,19 +13,27 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
enableCmd.Flags().StringVarP(&enableDescription, "description", "d", "<user>@<hostname>", "Description of this environment")
|
rootCmd.AddCommand(newEnableCommand().cmd)
|
||||||
rootCmd.AddCommand(enableCmd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var enableCmd = &cobra.Command{
|
type enableCommand struct {
|
||||||
|
description string
|
||||||
|
cmd *cobra.Command
|
||||||
|
}
|
||||||
|
|
||||||
|
func newEnableCommand() *enableCommand {
|
||||||
|
cmd := &cobra.Command{
|
||||||
Use: "enable <token>",
|
Use: "enable <token>",
|
||||||
Short: "Enable an environment for zrok",
|
Short: "Enable an environment for zrok",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: enable,
|
|
||||||
}
|
}
|
||||||
var enableDescription string
|
command := &enableCommand{cmd: cmd}
|
||||||
|
cmd.Flags().StringVarP(&command.description, "description", "d", "<user>@<hostname>", "Description of this environment")
|
||||||
|
cmd.Run = command.run
|
||||||
|
return command
|
||||||
|
}
|
||||||
|
|
||||||
func enable(_ *cobra.Command, args []string) {
|
func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
||||||
token := args[0]
|
token := args[0]
|
||||||
|
|
||||||
hostName, hostDetail, err := getHost()
|
hostName, hostDetail, err := getHost()
|
||||||
@ -37,15 +45,15 @@ func enable(_ *cobra.Command, args []string) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
hostDetail = fmt.Sprintf("%v; %v", user.Username, hostDetail)
|
hostDetail = fmt.Sprintf("%v; %v", user.Username, hostDetail)
|
||||||
if enableDescription == "<user>@<hostname>" {
|
if cmd.description == "<user>@<hostname>" {
|
||||||
enableDescription = fmt.Sprintf("%v@%v", user.Username, hostName)
|
cmd.description = fmt.Sprintf("%v@%v", user.Username, hostName)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok := newZrokClient()
|
zrok := newZrokClient()
|
||||||
auth := httptransport.APIKeyAuth("X-TOKEN", "header", token)
|
auth := httptransport.APIKeyAuth("X-TOKEN", "header", token)
|
||||||
req := identity.NewEnableParams()
|
req := identity.NewEnableParams()
|
||||||
req.Body = &rest_model_zrok.EnableRequest{
|
req.Body = &rest_model_zrok.EnableRequest{
|
||||||
Description: enableDescription,
|
Description: cmd.description,
|
||||||
Host: hostDetail,
|
Host: hostDetail,
|
||||||
}
|
}
|
||||||
resp, err := zrok.Identity.Enable(req, auth)
|
resp, err := zrok.Identity.Enable(req, auth)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user