mirror of
https://github.com/juanfont/headscale.git
synced 2026-02-07 20:04:00 +01:00
Convert the 10 commands that were still using Run with ErrorOutput/SuccessOutput or log.Fatal/os.Exit: - backfillNodeIPsCmd: use grpcRunE-style manual connection with error returns; simplify the confirm/force logic - getPolicy, setPolicy, checkPolicy: replace ErrorOutput with fmt.Errorf returns in both the bypass-gRPC and gRPC paths - serveCmd, configTestCmd: replace log.Fatal with error returns - mockOidcCmd: replace log.Error+os.Exit with error return - versionCmd, generatePrivateKeyCmd: replace SuccessOutput with printOutput - dumpConfigCmd: return the error instead of swallowing it
30 lines
582 B
Go
30 lines
582 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(dumpConfigCmd)
|
|
}
|
|
|
|
var dumpConfigCmd = &cobra.Command{
|
|
Use: "dumpConfig",
|
|
Short: "dump current config to /etc/headscale/config.dump.yaml, integration test only",
|
|
Hidden: true,
|
|
Args: func(cmd *cobra.Command, args []string) error {
|
|
return nil
|
|
},
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
err := viper.WriteConfigAs("/etc/headscale/config.dump.yaml")
|
|
if err != nil {
|
|
return fmt.Errorf("dumping config: %w", err)
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|