don't configure root command with PersistentPostRun, because it doesn't apply for all subcommands. (#77)

do configure run subcommand with PostRun.
This commit is contained in:
Shawn Carey
2020-04-02 08:56:03 -04:00
committed by GitHub
parent e259c1223a
commit fa666be37f
2 changed files with 11 additions and 11 deletions
+3 -4
View File
@@ -45,10 +45,9 @@ func init() {
}
var root = &cobra.Command{
Use: filepath.Base(os.Args[0]),
Short: "Ziti Tunnel",
PersistentPreRun: rootPreRun,
PersistentPostRun: rootPostRun,
Use: filepath.Base(os.Args[0]),
Short: "Ziti Tunnel",
PersistentPreRun: rootPreRun,
}
var interceptor intercept.Interceptor
+8 -7
View File
@@ -19,19 +19,20 @@
package subcmd
import (
"github.com/michaelquigley/pfxlog"
"github.com/netfoundry/ziti-edge/tunnel/intercept"
"github.com/netfoundry/ziti-edge/tunnel/intercept/tproxy"
"github.com/netfoundry/ziti-edge/tunnel/intercept/tun"
"github.com/michaelquigley/pfxlog"
"github.com/spf13/cobra"
)
var runCmd = &cobra.Command{
Use: "run <config>",
Short: "Auto-select interceptor",
Long: "Provided for backwards compatibility with scripts that were coded around older ziti-tunnel versions.",
Args: cobra.MaximumNArgs(1),
Run: run,
Use: "run <config>",
Short: "Auto-select interceptor",
Long: "Provided for backwards compatibility with scripts that were coded around older ziti-tunnel versions.",
Args: cobra.MaximumNArgs(1),
Run: run,
PostRun: rootPostRun,
}
func init() {
@@ -68,4 +69,4 @@ func run(cmd *cobra.Command, args []string) {
if interceptor == nil {
log.Fatal("failed to initialize an interceptor")
}
}
}