output from enrolling in ziti-tunnel should be nicer too

This commit is contained in:
dovholuknf
2020-06-16 14:41:55 -04:00
parent 8a71bd075c
commit ee309da1a6
2 changed files with 12 additions and 3 deletions
+11 -1
View File
@@ -66,6 +66,8 @@ func init() {
}
var enrollSubCmd = &cobra.Command{
SilenceErrors: true,
SilenceUsage: true,
Use: "enroll",
Short: "enroll an identity",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
@@ -74,6 +76,14 @@ var enrollSubCmd = &cobra.Command{
}
},
RunE: func(cmd *cobra.Command, args []string) error {
//set the formatter for enrolling via ziti-tunnel
logrus.SetFormatter(&logrus.TextFormatter{
ForceColors: true,
DisableTimestamp: true,
TimestampFormat: "",
PadLevelText: true,
})
logrus.SetReportCaller(false) // for enrolling don't bother with this
return processEnrollment()
},
}
@@ -135,7 +145,7 @@ func processEnrollment() error {
encErr := enc.Encode(&conf)
if encErr == nil {
fmt.Printf("enrolled successfully. identity file written to: %s", outpath)
logrus.Errorf("enrolled successfully. identity file written to: %s", outpath)
return nil
} else {
return fmt.Errorf("enrollment successful but the identity file was not able to be written to: %s [%s]", outpath, encErr)
+1 -2
View File
@@ -17,7 +17,6 @@
package subcmd
import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/edge/tunnel/dns"
"github.com/openziti/edge/tunnel/entities"
@@ -56,7 +55,7 @@ var logFormatter string
func Execute() {
if err := root.Execute(); err != nil {
fmt.Printf("error: %s", err)
pfxlog.Logger().Errorf("error: %s", err)
}
}