1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-08-10 13:46:46 +02:00

Improve clarity and consistency of error messages by using descriptive

operation names when calling findSingleUser across all CLI commands.
This commit is contained in:
Tevin Flores 2025-05-29 15:42:23 -04:00
parent a32b156d25
commit 78d89dff6b
3 changed files with 17 additions and 14 deletions

View File

@ -95,7 +95,7 @@ var registerNodeCmd = &cobra.Command{
defer cancel()
defer conn.Close()
user, err := findSingleUser(ctx, client, cmd, "register Node", output)
user, err := findSingleUser(ctx, client, cmd, "registerNodeCmd", output)
if err != nil {
// The helper already calls ErrorOutput, so we can just return
return
@ -156,7 +156,7 @@ var listNodesCmd = &cobra.Command{
// Only filter by user if user flags are provided
if id >= 0 || username != "" {
user, err := findSingleUser(ctx, client, cmd, "list", output)
user, err := findSingleUser(ctx, client, cmd, "listNodesCmd", output)
if err != nil {
// The helper already calls ErrorOutput, so we can just return
return
@ -199,7 +199,7 @@ var listNodeRoutesCmd = &cobra.Command{
Aliases: []string{"lsr", "routes"},
Run: func(cmd *cobra.Command, args []string) {
output, _ := cmd.Flags().GetString("output")
identifier, err := cmd.Flags().GetUint64("identifier")
identifier, err := cmd.Flags().GetUint64("node-id")
if err != nil {
ErrorOutput(
err,
@ -267,7 +267,7 @@ var expireNodeCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
output, _ := cmd.Flags().GetString("output")
identifier, err := cmd.Flags().GetUint64("identifier")
identifier, err := cmd.Flags().GetUint64("node-id")
if err != nil {
ErrorOutput(
err,
@ -310,7 +310,7 @@ var renameNodeCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
output, _ := cmd.Flags().GetString("output")
identifier, err := cmd.Flags().GetUint64("identifier")
identifier, err := cmd.Flags().GetUint64("node-id")
if err != nil {
ErrorOutput(
err,
@ -359,7 +359,7 @@ var deleteNodeCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
output, _ := cmd.Flags().GetString("output")
identifier, err := cmd.Flags().GetUint64("identifier")
identifier, err := cmd.Flags().GetUint64("node-id")
if err != nil {
ErrorOutput(
err,
@ -463,7 +463,7 @@ var moveNodeCmd = &cobra.Command{
defer cancel()
defer conn.Close()
user, err := findSingleUser(ctx, client, cmd, "move Node", output)
user, err := findSingleUser(ctx, client, cmd, "moveNodeCmd", output)
if err != nil {
// The helper already calls ErrorOutput, so we can just return
return
@ -745,7 +745,7 @@ var tagCmd = &cobra.Command{
defer conn.Close()
// retrieve flags from CLI
identifier, err := cmd.Flags().GetUint64("identifier")
identifier, err := cmd.Flags().GetUint64("node-id")
if err != nil {
ErrorOutput(
err,
@ -802,7 +802,7 @@ var approveRoutesCmd = &cobra.Command{
defer conn.Close()
// retrieve flags from CLI
identifier, err := cmd.Flags().GetUint64("identifier")
identifier, err := cmd.Flags().GetUint64("node-id")
if err != nil {
ErrorOutput(
err,

View File

@ -61,8 +61,9 @@ var listPreAuthKeys = &cobra.Command{
defer cancel()
defer conn.Close()
user, err := findSingleUser(ctx, client, cmd, "list", output)
user, err := findSingleUser(ctx, client, cmd, "listPreAuthKeys", output)
if err != nil {
// The helper already calls ErrorOutput, so we can just return
return
}
@ -145,8 +146,9 @@ var createPreAuthKeyCmd = &cobra.Command{
defer cancel()
defer conn.Close()
user, err := findSingleUser(ctx, client, cmd, "list", output)
user, err := findSingleUser(ctx, client, cmd, "createPreAuthKeyCmd", output)
if err != nil {
// The helper already calls ErrorOutput, so we can just return
return
}
@ -211,8 +213,9 @@ var expirePreAuthKeyCmd = &cobra.Command{
defer cancel()
defer conn.Close()
user, err := findSingleUser(ctx, client, cmd, "list", output)
user, err := findSingleUser(ctx, client, cmd, "expirePreAuthKeyCmd", output)
if err != nil {
// The helper already calls ErrorOutput, so we can just return
return
}

View File

@ -112,7 +112,7 @@ var destroyUserCmd = &cobra.Command{
defer cancel()
defer conn.Close()
user, err := findSingleUser(ctx, client, cmd, "rename", output)
user, err := findSingleUser(ctx, client, cmd, "destroyUserCmd", output)
if err != nil {
// The helper already calls ErrorOutput, so we can just return
return
@ -232,7 +232,7 @@ var renameUserCmd = &cobra.Command{
defer cancel()
defer conn.Close()
user, err := findSingleUser(ctx, client, cmd, "rename", output)
user, err := findSingleUser(ctx, client, cmd, "renameUserCmd", output)
if err != nil {
// The helper already calls ErrorOutput, so we can just return
return