Skip to content

Commit e69258d

Browse files
authored
Bugfix: config.Etcd.Mandatory must not be nil (#49)
1 parent a7b49a5 commit e69258d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pkg/utils/config.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ var (
3333
defaultAlgorithm = "ordered"
3434
// defaultMode is the default mode used to find a route if no other mode is
3535
// specified in the configuration.
36-
defaultMode = "sticky"
37-
defaultService = "default"
38-
defaultDest = []string{}
36+
defaultMode = "sticky"
37+
defaultService = "default"
38+
defaultDest = []string{}
39+
defaultEtcdMandatory = false
3940
)
4041

4142
var cachedConfig Config
@@ -427,6 +428,10 @@ func LoadConfig(filename, currentUsername, sid string, start time.Time, groups m
427428
cachedConfig.SSH.Args = defaultSSHArgs
428429
}
429430

431+
if cachedConfig.Etcd.Mandatory == nil {
432+
cachedConfig.Etcd.Mandatory = defaultEtcdMandatory
433+
}
434+
430435
if cachedConfig.RouteSelect == "" {
431436
cachedConfig.RouteSelect = defaultAlgorithm
432437
}

pkg/utils/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ var loadConfigTests = []struct {
7575
"config.dump = ",
7676
"config.dump_limit_size = 0",
7777
"config.dump_limit_window = 0s",
78-
"config.etcd = {Endpoints:[] TLS:{CAFile: KeyFile: CertFile:} Username: Password: KeyTTL:0 Mandatory:<nil>}",
78+
"config.etcd = {Endpoints:[] TLS:{CAFile: KeyFile: CertFile:} Username: Password: KeyTTL:0 Mandatory:false}",
7979
"config.etcd_stats_interval = 0s",
8080
"config.log_stats_interval = 0s",
8181
"config.blocking_command = ",
@@ -116,7 +116,7 @@ var loadConfigTests = []struct {
116116
"config.dump = ",
117117
"config.dump_limit_size = 0",
118118
"config.dump_limit_window = 0s",
119-
"config.etcd = {Endpoints:[] TLS:{CAFile: KeyFile: CertFile:} Username: Password: KeyTTL:0 Mandatory:<nil>}",
119+
"config.etcd = {Endpoints:[] TLS:{CAFile: KeyFile: CertFile:} Username: Password: KeyTTL:0 Mandatory:false}",
120120
"config.etcd_stats_interval = 0s",
121121
"config.log_stats_interval = 0s",
122122
"config.blocking_command = ",

0 commit comments

Comments
 (0)