Skip to content

Commit 234e32f

Browse files
authored
Stop requiring an input flag (#58)
Since we are now moving in the direction of using a config file we want to be able to control inputs from the config instead. There is already validation for the resulting conf struct to catch duplicate inputs so just remove the requirement from the flags. While here replace "exluded_with_all" with "exluded_with", a field must no be set if _any_ of the other fields are set.
1 parent 191d2a5 commit 234e32f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

cmd/run.go

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func init() {
3838
runCmd.Flags().String("input-unix", "", "create unix socket for reading dnstap (e.g. /var/lib/unbound/dnstap.sock)")
3939
runCmd.Flags().String("input-tcp", "", "create TCP socket for reading dnstap (e.g. '127.0.0.1:53535')")
4040
runCmd.Flags().String("input-tls", "", "create TLS TCP socket for reading dnstap (e.g. '127.0.0.1:53535')")
41-
runCmd.MarkFlagsOneRequired("input-unix", "input-tcp", "input-tls")
4241
runCmd.MarkFlagsMutuallyExclusive("input-unix", "input-tcp", "input-tls")
4342

4443
runCmd.Flags().String("input-tls-cert-file", "", "file containing cert used for TLS TCP socket")

pkg/runner/runner.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ type config struct {
6464
DisableHistogramSender bool `mapstructure:"disable-histogram-sender"`
6565
DisableMQTT bool `mapstructure:"disable-mqtt"`
6666
DisableMQTTFilequeue bool `mapstructure:"disable-mqtt-filequeue"`
67-
InputUnix string `mapstructure:"input-unix" validate:"required_without_all=InputTCP InputTLS,excluded_with_all=InputTCP InputTLS"`
68-
InputTCP string `mapstructure:"input-tcp" validate:"required_without_all=InputUnix InputTLS,excluded_with_all=InputUnix InputTLS"`
69-
InputTLS string `mapstructure:"input-tls" validate:"required_without_all=InputUnix InputTCP,excluded_with_all=InputUnix InputTCP"`
67+
InputUnix string `mapstructure:"input-unix" validate:"required_without_all=InputTCP InputTLS,excluded_with=InputTCP InputTLS"`
68+
InputTCP string `mapstructure:"input-tcp" validate:"required_without_all=InputUnix InputTLS,excluded_with=InputUnix InputTLS"`
69+
InputTLS string `mapstructure:"input-tls" validate:"required_without_all=InputUnix InputTCP,excluded_with=InputUnix InputTCP"`
7070
InputTLSCertFile string `mapstructure:"input-tls-cert-file" validate:"required_with=InputTLS"`
7171
InputTLSKeyFile string `mapstructure:"input-tls-key-file" validate:"required_with=InputTLS"`
7272
InputTLSClientCAFile string `mapstructure:"input-tls-client-ca-file" validate:"required_with=InputTLS"`

0 commit comments

Comments
 (0)