mirror of
https://github.com/openziti/zrok.git
synced 2025-06-26 04:31:30 +02:00
'zrok admin delete account' CLI (#993)
This commit is contained in:
parent
9d90f7a2cc
commit
5751acdd0d
50
cmd/zrok/adminDeleteAccount.go
Normal file
50
cmd/zrok/adminDeleteAccount.go
Normal file
@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/openziti/zrok/environment"
|
||||
"github.com/openziti/zrok/rest_client_zrok/admin"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
adminDeleteCmd.AddCommand(newAdminDeleteAccountCommand().cmd)
|
||||
}
|
||||
|
||||
type adminDeleteAccountCommand struct {
|
||||
cmd *cobra.Command
|
||||
}
|
||||
|
||||
func newAdminDeleteAccountCommand() *adminDeleteAccountCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "account <email>",
|
||||
Short: "Delete an account and disable all allocated resources",
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
command := &adminDeleteAccountCommand{cmd: cmd}
|
||||
cmd.Run = command.run
|
||||
return command
|
||||
}
|
||||
|
||||
func (cmd *adminDeleteAccountCommand) run(_ *cobra.Command, args []string) {
|
||||
email := args[0]
|
||||
|
||||
root, err := environment.LoadRoot()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
zrok, err := root.Client()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
req := admin.NewDeleteAccountParams()
|
||||
req.Body.Email = email
|
||||
|
||||
if _, err := zrok.Admin.DeleteAccount(req, mustGetAdminAuth()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
logrus.Infof("deleted account '%v'", email)
|
||||
}
|
@ -42,8 +42,7 @@ func (cmd *adminDeleteFrontendCommand) run(_ *cobra.Command, args []string) {
|
||||
req := admin.NewDeleteFrontendParams()
|
||||
req.Body.FrontendToken = feToken
|
||||
|
||||
_, err = zrok.Admin.DeleteFrontend(req, mustGetAdminAuth())
|
||||
if err != nil {
|
||||
if _, err := zrok.Admin.DeleteFrontend(req, mustGetAdminAuth()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user