mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
'zrok admin grants' CLI (#744)
This commit is contained in:
parent
d2ee09bd44
commit
a37009249a
@ -27,9 +27,7 @@ func newAdminGenerateCommand() *adminGenerateCommand {
|
|||||||
}
|
}
|
||||||
command := &adminGenerateCommand{cmd: cmd}
|
command := &adminGenerateCommand{cmd: cmd}
|
||||||
cmd.Run = command.run
|
cmd.Run = command.run
|
||||||
|
|
||||||
cmd.Flags().IntVarP(&command.amount, "count", "n", 5, "Number of tokens to generate")
|
cmd.Flags().IntVarP(&command.amount, "count", "n", 5, "Number of tokens to generate")
|
||||||
|
|
||||||
return command
|
return command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
51
cmd/zrok/adminGrants.go
Normal file
51
cmd/zrok/adminGrants.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/openziti/zrok/environment"
|
||||||
|
"github.com/openziti/zrok/rest_client_zrok/admin"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
adminCmd.AddCommand(newAdminGrantsCommand().cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
type adminGrantsCommand struct {
|
||||||
|
cmd *cobra.Command
|
||||||
|
email string
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAdminGrantsCommand() *adminGrantsCommand {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "grants <email>",
|
||||||
|
Short: "Synchronize ziti objects with account grants",
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
}
|
||||||
|
command := &adminGrantsCommand{cmd: cmd}
|
||||||
|
cmd.Run = command.run
|
||||||
|
cmd.Flags().StringVarP(&command.email, "email", "e", "", "email address")
|
||||||
|
return command
|
||||||
|
}
|
||||||
|
|
||||||
|
func (command *adminGrantsCommand) 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.NewGrantsParams()
|
||||||
|
req.Body.Email = args[0]
|
||||||
|
|
||||||
|
_, err = zrok.Admin.Grants(req, mustGetAdminAuth())
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("success.")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user