mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
Fix wrong toml struct tag for arp discovery
This commit is contained in:
committed by
Cuong Manh Le
parent
30c9012004
commit
4d996e317b
@@ -189,7 +189,7 @@ type ServiceConfig struct {
|
||||
DHCPLeaseFile string `mapstructure:"dhcp_lease_file_path" toml:"dhcp_lease_file_path" validate:"omitempty,file"`
|
||||
DHCPLeaseFileFormat string `mapstructure:"dhcp_lease_file_format" toml:"dhcp_lease_file_format" validate:"required_unless=DHCPLeaseFile '',omitempty,oneof=dnsmasq isc-dhcp"`
|
||||
DiscoverMDNS *bool `mapstructure:"discover_mdns" toml:"discover_mdns,omitempty"`
|
||||
DiscoverARP *bool `mapstructure:"discover_arp" toml:"discover_dhcp,omitempty"`
|
||||
DiscoverARP *bool `mapstructure:"discover_arp" toml:"discover_arp,omitempty"`
|
||||
DiscoverDHCP *bool `mapstructure:"discover_dhcp" toml:"discover_dhcp,omitempty"`
|
||||
DiscoverPtr *bool `mapstructure:"discover_ptr" toml:"discover_ptr,omitempty"`
|
||||
DiscoverHosts *bool `mapstructure:"discover_hosts" toml:"discover_hosts,omitempty"`
|
||||
|
||||
@@ -121,6 +121,29 @@ func TestConfigValidation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigDiscoverOverride(t *testing.T) {
|
||||
v := viper.NewWithOptions(viper.KeyDelimiter("::"))
|
||||
ctrld.InitConfig(v, "test_config_discover_override")
|
||||
v.SetConfigType("toml")
|
||||
configStr := `
|
||||
[service]
|
||||
discover_arp = false
|
||||
discover_dhcp = false
|
||||
discover_hosts = false
|
||||
discover_mdns = false
|
||||
discover_ptr = false
|
||||
`
|
||||
require.NoError(t, v.ReadConfig(strings.NewReader(configStr)))
|
||||
cfg := ctrld.Config{}
|
||||
require.NoError(t, v.Unmarshal(&cfg))
|
||||
|
||||
require.False(t, *cfg.Service.DiscoverARP)
|
||||
require.False(t, *cfg.Service.DiscoverDHCP)
|
||||
require.False(t, *cfg.Service.DiscoverHosts)
|
||||
require.False(t, *cfg.Service.DiscoverMDNS)
|
||||
require.False(t, *cfg.Service.DiscoverPtr)
|
||||
}
|
||||
|
||||
func defaultConfig(t *testing.T) *ctrld.Config {
|
||||
v := viper.New()
|
||||
ctrld.InitConfig(v, "test_load_default_config")
|
||||
|
||||
Reference in New Issue
Block a user