mirror of
https://github.com/juanfont/headscale.git
synced 2025-11-09 21:49:39 -05:00
Use JsonOutput in version too
This commit is contained in:
@@ -30,7 +30,7 @@ var CreateNamespaceCmd = &cobra.Command{
|
||||
}
|
||||
namespace, err := h.CreateNamespace(args[0])
|
||||
if strings.HasPrefix(o, "json") {
|
||||
jsonOutput(namespace, err, o)
|
||||
JsonOutput(namespace, err, o)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
@@ -52,7 +52,7 @@ var ListNamespacesCmd = &cobra.Command{
|
||||
}
|
||||
namespaces, err := h.ListNamespaces()
|
||||
if strings.HasPrefix(o, "json") {
|
||||
jsonOutput(namespaces, err, o)
|
||||
JsonOutput(namespaces, err, o)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -30,7 +30,7 @@ var RegisterCmd = &cobra.Command{
|
||||
}
|
||||
m, err := h.RegisterMachine(args[0], n)
|
||||
if strings.HasPrefix(o, "json") {
|
||||
jsonOutput(m, err, o)
|
||||
JsonOutput(m, err, o)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
@@ -57,7 +57,7 @@ var ListNodesCmd = &cobra.Command{
|
||||
}
|
||||
machines, err := h.ListMachinesInNamespace(n)
|
||||
if strings.HasPrefix(o, "json") {
|
||||
jsonOutput(machines, err, o)
|
||||
JsonOutput(machines, err, o)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ var ListPreAuthKeys = &cobra.Command{
|
||||
}
|
||||
keys, err := h.GetPreAuthKeys(n)
|
||||
if strings.HasPrefix(o, "json") {
|
||||
jsonOutput(keys, err, o)
|
||||
JsonOutput(keys, err, o)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ var CreatePreAuthKeyCmd = &cobra.Command{
|
||||
|
||||
k, err := h.CreatePreAuthKey(n, reusable, expiration)
|
||||
if strings.HasPrefix(o, "json") {
|
||||
jsonOutput(k, err, o)
|
||||
JsonOutput(k, err, o)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -36,10 +36,10 @@ var ListRoutesCmd = &cobra.Command{
|
||||
routes, err := h.GetNodeRoutes(n, args[0])
|
||||
|
||||
if strings.HasPrefix(o, "json") {
|
||||
jsonOutput(routes, err, o)
|
||||
JsonOutput(routes, err, o)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
@@ -71,7 +71,7 @@ var EnableRouteCmd = &cobra.Command{
|
||||
}
|
||||
route, err := h.EnableNodeRoute(n, args[0], args[1])
|
||||
if strings.HasPrefix(o, "json") {
|
||||
jsonOutput(route, err, o)
|
||||
JsonOutput(route, err, o)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ func loadDerpMap(path string) (*tailcfg.DERPMap, error) {
|
||||
return &derpMap, err
|
||||
}
|
||||
|
||||
func jsonOutput(result interface{}, errResult error, outputFormat string) {
|
||||
func JsonOutput(result interface{}, errResult error, outputFormat string) {
|
||||
var j []byte
|
||||
var err error
|
||||
switch outputFormat {
|
||||
|
||||
Reference in New Issue
Block a user