mirror of
https://github.com/juanfont/headscale.git
synced 2026-01-23 02:24:10 +00:00
cli: fix preauthkeys expire/delete argument validation
The Args function incorrectly required positional arguments but the commands use --id flag. Move validation into Run function.
This commit is contained in:
parent
c8c3c9d4a0
commit
165c5f0491
1 changed files with 20 additions and 14 deletions
|
|
@ -177,17 +177,20 @@ var expirePreAuthKeyCmd = &cobra.Command{
|
||||||
Use: "expire",
|
Use: "expire",
|
||||||
Short: "Expire a preauthkey",
|
Short: "Expire a preauthkey",
|
||||||
Aliases: []string{"revoke", "exp", "e"},
|
Aliases: []string{"revoke", "exp", "e"},
|
||||||
Args: func(cmd *cobra.Command, args []string) error {
|
|
||||||
if len(args) < 1 {
|
|
||||||
return errMissingParameter
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
output, _ := cmd.Flags().GetString("output")
|
output, _ := cmd.Flags().GetString("output")
|
||||||
id, _ := cmd.Flags().GetUint64("id")
|
id, _ := cmd.Flags().GetUint64("id")
|
||||||
|
|
||||||
|
if id == 0 {
|
||||||
|
ErrorOutput(
|
||||||
|
errMissingParameter,
|
||||||
|
"Error: missing --id parameter",
|
||||||
|
output,
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ctx, client, conn, cancel := newHeadscaleCLIWithConfig()
|
ctx, client, conn, cancel := newHeadscaleCLIWithConfig()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
@ -213,17 +216,20 @@ var deletePreAuthKeyCmd = &cobra.Command{
|
||||||
Use: "delete",
|
Use: "delete",
|
||||||
Short: "Delete a preauthkey",
|
Short: "Delete a preauthkey",
|
||||||
Aliases: []string{"del", "rm", "d"},
|
Aliases: []string{"del", "rm", "d"},
|
||||||
Args: func(cmd *cobra.Command, args []string) error {
|
|
||||||
if len(args) < 1 {
|
|
||||||
return errMissingParameter
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
output, _ := cmd.Flags().GetString("output")
|
output, _ := cmd.Flags().GetString("output")
|
||||||
id, _ := cmd.Flags().GetUint64("id")
|
id, _ := cmd.Flags().GetUint64("id")
|
||||||
|
|
||||||
|
if id == 0 {
|
||||||
|
ErrorOutput(
|
||||||
|
errMissingParameter,
|
||||||
|
"Error: missing --id parameter",
|
||||||
|
output,
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ctx, client, conn, cancel := newHeadscaleCLIWithConfig()
|
ctx, client, conn, cancel := newHeadscaleCLIWithConfig()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue