mirror of
https://github.com/openziti/zrok.git
synced 2026-08-24 10:14:56 -05:00
52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/michaelquigley/df/dl"
|
|
"github.com/openziti/zrok/v2/environment"
|
|
"github.com/openziti/zrok/v2/rest_client_zrok/admin"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
adminDeleteCmd.AddCommand(newAdminDeleteNamespaceCommand().cmd)
|
|
}
|
|
|
|
type adminDeleteNamespaceCommand struct {
|
|
cmd *cobra.Command
|
|
}
|
|
|
|
func newAdminDeleteNamespaceCommand() *adminDeleteNamespaceCommand {
|
|
cmd := &cobra.Command{
|
|
Use: "namespace <token>",
|
|
Short: "Delete a namespace",
|
|
Args: cobra.ExactArgs(1),
|
|
}
|
|
command := &adminDeleteNamespaceCommand{cmd: cmd}
|
|
cmd.Run = command.run
|
|
return command
|
|
}
|
|
|
|
func (cmd *adminDeleteNamespaceCommand) run(_ *cobra.Command, args []string) {
|
|
env, err := environment.LoadRoot()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
zrok, err := env.Client()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
req := admin.NewDeleteNamespaceParams()
|
|
req.Body = admin.DeleteNamespaceBody{
|
|
NamespaceToken: args[0],
|
|
}
|
|
|
|
_, err = zrok.Admin.DeleteNamespace(req, mustGetAdminAuth())
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
dl.Infof("deleted namespace '%v'", args[0])
|
|
}
|