cli: Move printing of hook flags to correct file
This commit is contained in:
parent
59213a5b3a
commit
e7dfc9405d
|
@ -34,9 +34,6 @@ var Flags struct {
|
|||
MetricsPath string
|
||||
BehindProxy bool
|
||||
VerboseOutput bool
|
||||
|
||||
FileHooksInstalled bool
|
||||
HttpHooksInstalled bool
|
||||
}
|
||||
|
||||
func ParseFlags() {
|
||||
|
@ -70,15 +67,6 @@ func ParseFlags() {
|
|||
|
||||
if Flags.FileHooksDir != "" {
|
||||
Flags.FileHooksDir, _ = filepath.Abs(Flags.FileHooksDir)
|
||||
Flags.FileHooksInstalled = true
|
||||
|
||||
stdout.Printf("Using '%s' for hooks", Flags.FileHooksDir)
|
||||
}
|
||||
|
||||
if Flags.HttpHooksEndpoint != "" {
|
||||
Flags.HttpHooksInstalled = true
|
||||
|
||||
stdout.Printf("Using '%s' as the endpoint for hooks", Flags.HttpHooksEndpoint)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,11 +88,4 @@ func SetEnabledHooks() {
|
|||
if len(Flags.EnabledHooks) == 0 {
|
||||
Flags.EnabledHooks = hooks.AvailableHooks
|
||||
}
|
||||
|
||||
var enabledHooksString []string
|
||||
for _, h := range Flags.EnabledHooks {
|
||||
enabledHooksString = append(enabledHooksString, string(h))
|
||||
}
|
||||
|
||||
stdout.Printf("Enabled hook events: %s", strings.Join(enabledHooksString, ", "))
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cli
|
|||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/tus/tusd/cmd/tusd/cli/hooks"
|
||||
"github.com/tus/tusd/pkg/handler"
|
||||
|
@ -44,16 +45,22 @@ func SetupHookMetrics() {
|
|||
|
||||
func SetupPreHooks(config *handler.Config) error {
|
||||
if Flags.FileHooksDir != "" {
|
||||
stdout.Printf("Using '%s' for hooks", Flags.FileHooksDir)
|
||||
|
||||
hookHandler = &hooks.FileHook{
|
||||
Directory: Flags.FileHooksDir,
|
||||
}
|
||||
} else if Flags.HttpHooksEndpoint != "" {
|
||||
stdout.Printf("Using '%s' as the endpoint for hooks", Flags.HttpHooksEndpoint)
|
||||
|
||||
hookHandler = &hooks.HttpHook{
|
||||
Endpoint: Flags.HttpHooksEndpoint,
|
||||
MaxRetries: Flags.HttpHooksRetry,
|
||||
Backoff: Flags.HttpHooksBackoff,
|
||||
}
|
||||
} else if Flags.PluginHookPath != "" {
|
||||
stdout.Printf("Using '%s' to load plugin for hooks", Flags.PluginHookPath)
|
||||
|
||||
hookHandler = &hooks.PluginHook{
|
||||
Path: Flags.PluginHookPath,
|
||||
}
|
||||
|
@ -61,6 +68,13 @@ func SetupPreHooks(config *handler.Config) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
var enabledHooksString []string
|
||||
for _, h := range Flags.EnabledHooks {
|
||||
enabledHooksString = append(enabledHooksString, string(h))
|
||||
}
|
||||
|
||||
stdout.Printf("Enabled hook events: %s", strings.Join(enabledHooksString, ", "))
|
||||
|
||||
if err := hookHandler.Setup(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue