Skip to content

Commit 9b4d0a4

Browse files
authored
the presence of "dest" must only be checked when necessary (#45)
1 parent c1bfc60 commit 9b4d0a4

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

pkg/utils/config.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,6 @@ func LoadConfig(filename, currentUsername, sid string, start time.Time, groups m
476476
cachedConfig.Environment[k] = replace(v, patterns["{user}"])
477477
}
478478

479-
if len(cachedConfig.Dest) == 0 {
480-
return nil, fmt.Errorf("no destination defined for service '%s'", cachedConfig.Service)
481-
}
482-
483479
// expand destination nodesets
484480
nodesetComment, nodesetDlclose, nodesetExpand := nodesets.InitExpander()
485481
defer nodesetDlclose()

pkg/utils/config_test.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,32 @@ var loadConfigTests = []struct {
116116
err string
117117
}{
118118
{"nonexistingfile.yaml", "alice", []string{}, "open nonexistingfile.yaml: no such file or directory"},
119-
{"../../test/configEmpty.yaml", "alice", []string{}, "no destination defined for service 'default'"},
119+
{"../../test/configEmpty.yaml", "alice", []string{
120+
"libnodeset.so not found, falling back to iskylite's implementation",
121+
"groups = map[bar:true foo:true]",
122+
"config.debug = false",
123+
"config.log = ",
124+
"config.check_interval = 0s",
125+
"config.error_banner = ",
126+
"config.dump = ",
127+
"config.dump_limit_size = 0",
128+
"config.dump_limit_window = 0s",
129+
"config.etcd = {Endpoints:[] TLS:{CAFile: KeyFile: CertFile:} Username: Password: KeyTTL:0 Mandatory:<nil>}",
130+
"config.etcd_stats_interval = 0s",
131+
"config.log_stats_interval = 0s",
132+
"config.blocking_command = ",
133+
"config.bg_command = ",
134+
"config.ssh = {Exe:ssh Args:[-q -Y]}",
135+
"config.environment = map[]",
136+
"config.service = default",
137+
"config.dest = []",
138+
"config.route_select = ordered",
139+
"config.mode = sticky",
140+
"config.force_command = ",
141+
"config.command_must_match = false",
142+
"config.etcd_keyttl = 0",
143+
"config.max_connections_per_user = 0",
144+
}, ""},
120145
{"../../test/configInvalid.yaml", "alice", []string{}, "yaml: found character that cannot start any token"},
121146
{"../../test/configCheckIntervalError.yaml", "alice", []string{}, `time: invalid duration "not a duration"`},
122147
{"../../test/configCheckIntervalNotString.yaml", "alice", []string{}, "check_interval: 10 is not a string"},

0 commit comments

Comments
 (0)