mirror of
https://github.com/openziti/zrok.git
synced 2024-12-23 07:09:12 +01:00
cmd lint
This commit is contained in:
parent
1d655a2b0d
commit
7f2afc13cd
@ -21,11 +21,11 @@ func newControllerCommand() *controllerCommand {
|
||||
Aliases: []string{"ctrl"},
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
ccmd := &controllerCommand{
|
||||
command := &controllerCommand{
|
||||
cmd: cmd,
|
||||
}
|
||||
cmd.Run = ccmd.run
|
||||
return ccmd
|
||||
cmd.Run = command.run
|
||||
return command
|
||||
}
|
||||
|
||||
func (cmd *controllerCommand) run(_ *cobra.Command, args []string) {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
createCmd.AddCommand(createAccountCmd)
|
||||
createCmd.AddCommand(newCreateAccountCommand().cmd)
|
||||
rootCmd.AddCommand(createCmd)
|
||||
}
|
||||
|
||||
@ -18,37 +18,48 @@ var createCmd = &cobra.Command{
|
||||
Short: "Create objects",
|
||||
}
|
||||
|
||||
var createAccountCmd = &cobra.Command{
|
||||
Use: "account",
|
||||
Short: "create new zrok account",
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
username, err := term.Prompt("New Username: ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
password, err := term.PromptPassword("New Password: ", false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
confirm, err := term.PromptPassword("Confirm Password: ", false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if confirm != password {
|
||||
panic("confirmed password mismatch")
|
||||
}
|
||||
|
||||
zrok := newZrokClient()
|
||||
req := identity.NewCreateAccountParams()
|
||||
req.Body = &rest_model_zrok.AccountRequest{
|
||||
Username: username,
|
||||
Password: password,
|
||||
}
|
||||
resp, err := zrok.Identity.CreateAccount(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
logrus.Infof("api token: %v", resp.Payload.Token)
|
||||
},
|
||||
type createAccountCommand struct {
|
||||
cmd *cobra.Command
|
||||
}
|
||||
|
||||
func newCreateAccountCommand() *createAccountCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "account",
|
||||
Short: "Create new zrok account",
|
||||
Args: cobra.ExactArgs(0),
|
||||
}
|
||||
command := &createAccountCommand{cmd: cmd}
|
||||
cmd.Run = command.run
|
||||
return command
|
||||
}
|
||||
|
||||
func (cmd *createAccountCommand) run(_ *cobra.Command, _ []string) {
|
||||
username, err := term.Prompt("New Username: ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
password, err := term.PromptPassword("New Password: ", false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
confirm, err := term.PromptPassword("Confirm Password: ", false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if confirm != password {
|
||||
panic("confirmed password mismatch")
|
||||
}
|
||||
|
||||
zrok := newZrokClient()
|
||||
req := identity.NewCreateAccountParams()
|
||||
req.Body = &rest_model_zrok.AccountRequest{
|
||||
Username: username,
|
||||
Password: password,
|
||||
}
|
||||
resp, err := zrok.Identity.CreateAccount(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
logrus.Infof("api token: %v", resp.Payload.Token)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user