@@ -41,54 +41,54 @@ var cachedConfig Config
41
41
42
42
// Config represents the configuration for sshproxy.
43
43
type Config struct {
44
- ready bool // true when the configuration has already been loaded
45
- Nodeset string
46
- Debug bool
47
- Log string
48
- CheckInterval Duration `yaml:"check_interval"`
49
- ErrorBanner string `yaml:"error_banner"`
50
- Dump string
51
- DumpLimitSize uint64 `yaml:"dump_limit_size"`
52
- DumpLimitWindow Duration `yaml:"dump_limit_window"`
53
- Etcd etcdConfig
54
- EtcdStatsInterval Duration `yaml:"etcd_stats_interval"`
55
- LogStatsInterval Duration `yaml:"log_stats_interval"`
56
- BlockingCommand string `yaml:"blocking_command"`
57
- BgCommand string `yaml:"bg_command"`
58
- SSH sshConfig
59
- TranslateCommands map [string ]* TranslateCommandConfig `yaml:"translate_commands"`
60
- Environment map [string ]string
61
- Service string
62
- Dest []string
63
- RouteSelect string `yaml:"route_select"`
64
- Mode string
65
- ForceCommand string `yaml:"force_command"`
66
- CommandMustMatch bool `yaml:"command_must_match"`
67
- EtcdKeyTTL int64 `yaml:"etcd_keyttl"`
68
- MaxConnectionsPerUser int `yaml:"max_connections_per_user"`
69
- Overrides []subConfig
44
+ ready bool // true when the configuration has already been loaded
45
+ Nodeset string `yaml:",omitempty"`
46
+ Debug bool `yaml:",omitempty"`
47
+ Log string `yaml:",omitempty"`
48
+ CheckInterval time. Duration `yaml:"check_interval,omitempty "`
49
+ ErrorBanner string `yaml:"error_banner,omitempty "`
50
+ Dump string `yaml:",omitempty"`
51
+ DumpLimitSize uint64 `yaml:"dump_limit_size,omitempty "`
52
+ DumpLimitWindow time. Duration `yaml:"dump_limit_window,omitempty "`
53
+ Etcd etcdConfig `yaml:",omitempty"`
54
+ EtcdStatsInterval time. Duration `yaml:"etcd_stats_interval,omitempty "`
55
+ LogStatsInterval time. Duration `yaml:"log_stats_interval,omitempty "`
56
+ BlockingCommand string `yaml:"blocking_command,omitempty "`
57
+ BgCommand string `yaml:"bg_command,omitempty "`
58
+ SSH sshConfig `yaml:",omitempty"`
59
+ TranslateCommands map [string ]* TranslateCommandConfig `yaml:"translate_commands,omitempty "`
60
+ Environment map [string ]string `yaml:",omitempty"`
61
+ Service string `yaml:",omitempty"`
62
+ Dest []string `yaml:",flow,omitempty"`
63
+ RouteSelect string `yaml:"route_select,omitempty "`
64
+ Mode string `yaml:",omitempty"`
65
+ ForceCommand string `yaml:"force_command,omitempty "`
66
+ CommandMustMatch bool `yaml:"command_must_match,omitempty "`
67
+ EtcdKeyTTL int64 `yaml:"etcd_keyttl,omitempty "`
68
+ MaxConnectionsPerUser int `yaml:"max_connections_per_user,omitempty "`
69
+ Overrides []subConfig `yaml:",omitempty"`
70
70
}
71
71
72
72
// TranslateCommandConfig represents the configuration of a translate_command.
73
73
// SSHArgs is optional. Command is mandatory. DisableDump defaults to false
74
74
type TranslateCommandConfig struct {
75
75
SSHArgs []string `yaml:"ssh_args"`
76
76
Command string
77
- DisableDump bool `yaml:"disable_dump"`
77
+ DisableDump bool `yaml:"disable_dump,omitempty "`
78
78
}
79
79
80
80
type sshConfig struct {
81
- Exe string
82
- Args []string
81
+ Exe string `yaml:",omitempty"`
82
+ Args []string `yaml:",flow,omitempty"`
83
83
}
84
84
85
85
type etcdConfig struct {
86
- Endpoints []string
87
- TLS etcdTLSConfig
88
- Username string
89
- Password string
90
- KeyTTL int64
91
- Mandatory bool
86
+ Endpoints []string `yaml:",flow"`
87
+ TLS etcdTLSConfig `yaml:",omitempty"`
88
+ Username string `yaml:",omitempty"`
89
+ Password string `yaml:",omitempty"`
90
+ KeyTTL int64 `yaml:",omitempty"`
91
+ Mandatory bool `yaml:",omitempty"`
92
92
}
93
93
94
94
type etcdTLSConfig struct {
@@ -100,30 +100,30 @@ type etcdTLSConfig struct {
100
100
// We use interface{} instead of real type to check if the option was specified
101
101
// or not.
102
102
type subConfig struct {
103
- Match []map [string ][]string
104
- Debug interface {}
105
- Log interface {}
106
- CheckInterval interface {} `yaml:"check_interval"`
107
- ErrorBanner interface {} `yaml:"error_banner"`
108
- Dump interface {}
109
- DumpLimitSize interface {} `yaml:"dump_limit_size"`
110
- DumpLimitWindow interface {} `yaml:"dump_limit_window"`
111
- Etcd interface {}
112
- EtcdStatsInterval interface {} `yaml:"etcd_stats_interval"`
113
- LogStatsInterval interface {} `yaml:"log_stats_interval"`
114
- BlockingCommand interface {} `yaml:"blocking_command"`
115
- BgCommand interface {} `yaml:"bg_command"`
116
- SSH interface {}
117
- TranslateCommands map [string ]* TranslateCommandConfig `yaml:"translate_commands"`
118
- Environment map [string ]string
119
- Service interface {}
120
- Dest []string
121
- RouteSelect interface {} `yaml:"route_select"`
122
- Mode interface {}
123
- ForceCommand interface {} `yaml:"force_command"`
124
- CommandMustMatch interface {} `yaml:"command_must_match"`
125
- EtcdKeyTTL interface {} `yaml:"etcd_keyttl"`
126
- MaxConnectionsPerUser interface {} `yaml:"max_connections_per_user"`
103
+ Match []map [string ][]string `yaml:",omitempty"`
104
+ Debug interface {} `yaml:",omitempty"`
105
+ Log interface {} `yaml:",omitempty"`
106
+ CheckInterval interface {} `yaml:"check_interval,omitempty "`
107
+ ErrorBanner interface {} `yaml:"error_banner,omitempty "`
108
+ Dump interface {} `yaml:",omitempty"`
109
+ DumpLimitSize interface {} `yaml:"dump_limit_size,omitempty "`
110
+ DumpLimitWindow interface {} `yaml:"dump_limit_window,omitempty "`
111
+ Etcd interface {} `yaml:",omitempty"`
112
+ EtcdStatsInterval interface {} `yaml:"etcd_stats_interval,omitempty "`
113
+ LogStatsInterval interface {} `yaml:"log_stats_interval,omitempty "`
114
+ BlockingCommand interface {} `yaml:"blocking_command,omitempty "`
115
+ BgCommand interface {} `yaml:"bg_command,omitempty "`
116
+ SSH interface {} `yaml:",omitempty"`
117
+ TranslateCommands map [string ]* TranslateCommandConfig `yaml:"translate_commands,omitempty "`
118
+ Environment map [string ]string `yaml:",omitempty"`
119
+ Service interface {} `yaml:",omitempty"`
120
+ Dest []string `yaml:",flow,omitempty"`
121
+ RouteSelect interface {} `yaml:"route_select,omitempty "`
122
+ Mode interface {} `yaml:",omitempty"`
123
+ ForceCommand interface {} `yaml:"force_command,omitempty "`
124
+ CommandMustMatch interface {} `yaml:"command_must_match,omitempty "`
125
+ EtcdKeyTTL interface {} `yaml:"etcd_keyttl,omitempty "`
126
+ MaxConnectionsPerUser interface {} `yaml:"max_connections_per_user,omitempty "`
127
127
}
128
128
129
129
// Return slice of strings containing formatted configuration values
@@ -132,14 +132,14 @@ func PrintConfig(config *Config, groups map[string]bool) []string {
132
132
output = append (output , fmt .Sprintf ("groups = %v" , groups ))
133
133
output = append (output , fmt .Sprintf ("config.debug = %v" , config .Debug ))
134
134
output = append (output , fmt .Sprintf ("config.log = %s" , config .Log ))
135
- output = append (output , fmt .Sprintf ("config.check_interval = %s" , config .CheckInterval . Duration () ))
135
+ output = append (output , fmt .Sprintf ("config.check_interval = %s" , config .CheckInterval ))
136
136
output = append (output , fmt .Sprintf ("config.error_banner = %s" , config .ErrorBanner ))
137
137
output = append (output , fmt .Sprintf ("config.dump = %s" , config .Dump ))
138
138
output = append (output , fmt .Sprintf ("config.dump_limit_size = %d" , config .DumpLimitSize ))
139
- output = append (output , fmt .Sprintf ("config.dump_limit_window = %s" , config .DumpLimitWindow . Duration () ))
139
+ output = append (output , fmt .Sprintf ("config.dump_limit_window = %s" , config .DumpLimitWindow ))
140
140
output = append (output , fmt .Sprintf ("config.etcd = %+v" , config .Etcd ))
141
- output = append (output , fmt .Sprintf ("config.etcd_stats_interval = %s" , config .EtcdStatsInterval . Duration () ))
142
- output = append (output , fmt .Sprintf ("config.log_stats_interval = %s" , config .LogStatsInterval . Duration () ))
141
+ output = append (output , fmt .Sprintf ("config.etcd_stats_interval = %s" , config .EtcdStatsInterval ))
142
+ output = append (output , fmt .Sprintf ("config.log_stats_interval = %s" , config .LogStatsInterval ))
143
143
output = append (output , fmt .Sprintf ("config.blocking_command = %s" , config .BlockingCommand ))
144
144
output = append (output , fmt .Sprintf ("config.bg_command = %s" , config .BgCommand ))
145
145
output = append (output , fmt .Sprintf ("config.ssh = %+v" , config .SSH ))
@@ -169,7 +169,7 @@ func parseSubConfig(config *Config, subconfig *subConfig) error {
169
169
170
170
if subconfig .CheckInterval != nil {
171
171
var err error
172
- config .CheckInterval , err = ParseDuration (subconfig .CheckInterval .(string ))
172
+ config .CheckInterval , err = time . ParseDuration (subconfig .CheckInterval .(string ))
173
173
if err != nil {
174
174
return err
175
175
}
@@ -189,7 +189,7 @@ func parseSubConfig(config *Config, subconfig *subConfig) error {
189
189
190
190
if subconfig .DumpLimitWindow != nil {
191
191
var err error
192
- config .DumpLimitWindow , err = ParseDuration (subconfig .DumpLimitWindow .(string ))
192
+ config .DumpLimitWindow , err = time . ParseDuration (subconfig .DumpLimitWindow .(string ))
193
193
if err != nil {
194
194
return err
195
195
}
@@ -201,15 +201,15 @@ func parseSubConfig(config *Config, subconfig *subConfig) error {
201
201
202
202
if subconfig .EtcdStatsInterval != nil {
203
203
var err error
204
- config .EtcdStatsInterval , err = ParseDuration (subconfig .EtcdStatsInterval .(string ))
204
+ config .EtcdStatsInterval , err = time . ParseDuration (subconfig .EtcdStatsInterval .(string ))
205
205
if err != nil {
206
206
return err
207
207
}
208
208
}
209
209
210
210
if subconfig .LogStatsInterval != nil {
211
211
var err error
212
- config .LogStatsInterval , err = ParseDuration (subconfig .LogStatsInterval .(string ))
212
+ config .LogStatsInterval , err = time . ParseDuration (subconfig .LogStatsInterval .(string ))
213
213
if err != nil {
214
214
return err
215
215
}
0 commit comments