@@ -55,25 +55,25 @@ type Config struct {
55
55
}
56
56
57
57
type Raw struct {
58
- Debug bool `koanf:"debug"`
59
- TimeFormat string `koanf:"time_format"`
60
- MaxPayloadSize string `koanf:"max_payload_size"`
61
- DataDirectory string `koanf:"data_directory"`
62
- PythonExecutable string `koanf:"python_executable"`
63
- RetentionEnvelopeCount * int `koanf:"retention.envelope_count"`
64
- RetentionEnvelopeAge * string `koanf:"retention.envelope_age"`
65
- RetentionAttachmentSize * string `koanf:"retention.attachment_size"`
66
- SMTPDisable bool `koanf:"smtp.disable"`
67
- SMTPHost string `koanf:"smtp.host"`
68
- SMTPPort uint16 `koanf:"smtp.port"`
69
- SMTPUsername string `koanf:"smtp.username"`
70
- SMTPPassword string `koanf:"smtp.password"`
71
- HTTPDisable bool `koanf:"http.disable"`
72
- HTTPHost string `koanf:"http.host"`
73
- HTTPPort uint16 `koanf:"http.port"`
74
- HTTPUsername string `koanf:"http.username"`
75
- HTTPPassword string `koanf:"http.password"`
76
- HTTPURL string `koanf:"http.url"`
58
+ Debug bool `koanf:"debug"`
59
+ TimeFormat string `koanf:"time_format"`
60
+ MaxPayloadSize string `koanf:"max_payload_size"`
61
+ DataDirectory string `koanf:"data_directory"`
62
+ PythonExecutable string `koanf:"python_executable"`
63
+ RetentionEnvelopeCount string `koanf:"retention.envelope_count"`
64
+ RetentionEnvelopeAge string `koanf:"retention.envelope_age"`
65
+ RetentionAttachmentSize string `koanf:"retention.attachment_size"`
66
+ SMTPDisable bool `koanf:"smtp.disable"`
67
+ SMTPHost string `koanf:"smtp.host"`
68
+ SMTPPort uint16 `koanf:"smtp.port"`
69
+ SMTPUsername string `koanf:"smtp.username"`
70
+ SMTPPassword string `koanf:"smtp.password"`
71
+ HTTPDisable bool `koanf:"http.disable"`
72
+ HTTPHost string `koanf:"http.host"`
73
+ HTTPPort uint16 `koanf:"http.port"`
74
+ HTTPUsername string `koanf:"http.username"`
75
+ HTTPPassword string `koanf:"http.password"`
76
+ HTTPURL string `koanf:"http.url"`
77
77
// IMAPDisable bool `koanf:"imap.disable"`
78
78
// IMAPHost string `koanf:"imap.host"`
79
79
// IMAPPort uint16 `koanf:"imap.port"`
@@ -187,17 +187,26 @@ func (p Parser) Parse(raw Raw) (Config, error) {
187
187
188
188
var config * models.Config
189
189
{
190
+ var envelopeCount * int
191
+ if raw .RetentionEnvelopeCount != "" {
192
+ count , err := strconv .Atoi (raw .RetentionEnvelopeCount )
193
+ if err != nil {
194
+ return Config {}, err
195
+ }
196
+
197
+ envelopeCount = & count
198
+ }
190
199
var attachmentsSize * int64
191
- if raw .RetentionAttachmentSize != nil {
192
- size , err := bytes .Parse (* raw .RetentionAttachmentSize )
200
+ if raw .RetentionAttachmentSize != "" {
201
+ size , err := bytes .Parse (raw .RetentionAttachmentSize )
193
202
if err != nil {
194
203
return Config {}, err
195
204
}
196
205
attachmentsSize = & size
197
206
}
198
207
var envelopeAge * time.Duration
199
- if raw .RetentionEnvelopeAge != nil {
200
- age , err := time .ParseDuration (* raw .RetentionEnvelopeAge )
208
+ if raw .RetentionEnvelopeAge != "" {
209
+ age , err := time .ParseDuration (raw .RetentionEnvelopeAge )
201
210
if err != nil {
202
211
return Config {}, err
203
212
}
@@ -206,7 +215,7 @@ func (p Parser) Parse(raw Raw) (Config, error) {
206
215
207
216
config = & models.Config {
208
217
RetentionPolicy : models.ConfigRetentionPolicy {
209
- EnvelopeCount : raw . RetentionEnvelopeCount ,
218
+ EnvelopeCount : envelopeCount ,
210
219
AttachmentSize : attachmentsSize ,
211
220
EnvelopeAge : envelopeAge ,
212
221
MinAge : 5 * time .Minute ,
0 commit comments