Skip to content

Commit 379cf22

Browse files
committed
Flags
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent ab11cc1 commit 379cf22

File tree

10 files changed

+1405
-759
lines changed

10 files changed

+1405
-759
lines changed

coderd/apidoc/docs.go

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/notifications/dispatch/smtp.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func (s *SMTPHandler) tlsConfig() (*tls.Config, error) {
332332
return nil, err
333333
}
334334

335-
srvName := s.cfg.TLS.ServerName
335+
srvName := s.cfg.TLS.ServerName.String()
336336
if srvName == "" {
337337
srvName = host
338338
}
@@ -354,7 +354,7 @@ func (s *SMTPHandler) tlsConfig() (*tls.Config, error) {
354354

355355
return &tls.Config{
356356
ServerName: srvName,
357-
InsecureSkipVerify: s.cfg.TLS.InsecureSkipVerify,
357+
InsecureSkipVerify: s.cfg.TLS.InsecureSkipVerify.Value(),
358358

359359
RootCAs: ca,
360360
Certificates: certs,
@@ -367,7 +367,7 @@ func (s *SMTPHandler) loadCAFile() (*x509.CertPool, error) {
367367
return nil, nil
368368
}
369369

370-
ca, err := s.loadFile(s.cfg.TLS.CAFile)
370+
ca, err := s.loadFile(s.cfg.TLS.CAFile.String())
371371
if err != nil {
372372
return nil, xerrors.Errorf("load CA file: %w", err)
373373
}
@@ -385,11 +385,11 @@ func (s *SMTPHandler) loadCertificate() (*tls.Certificate, error) {
385385
return nil, nil
386386
}
387387

388-
cert, err := s.loadFile(s.cfg.TLS.CertFile)
388+
cert, err := s.loadFile(s.cfg.TLS.CertFile.Value())
389389
if err != nil {
390390
return nil, xerrors.Errorf("load cert: %w", err)
391391
}
392-
key, err := s.loadFile(s.cfg.TLS.KeyFile)
392+
key, err := s.loadFile(s.cfg.TLS.KeyFile.String())
393393
if err != nil {
394394
return nil, xerrors.Errorf("load key: %w", err)
395395
}

codersdk/deployment.go

Lines changed: 82 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -527,19 +527,18 @@ func (c *NotificationsEmailAuthConfig) Empty() bool {
527527
return reflect.ValueOf(*c).IsZero()
528528
}
529529

530-
// TODO: wire up to flags.
531530
type NotificationsEmailTLSConfig struct {
532-
StartTLS bool `json:"start_tls" typescript:",notnull"`
531+
StartTLS serpent.Bool `json:"start_tls" typescript:",notnull"`
533532
// ServerName to verify the hostname for the targets.
534-
ServerName string `json:"server_name" typescript:",notnull"`
533+
ServerName serpent.String `json:"server_name" typescript:",notnull"`
535534
// InsecureSkipVerify skips target certificate validation.
536-
InsecureSkipVerify bool `json:"insecure_skip_verify" typescript:",notnull"`
535+
InsecureSkipVerify serpent.Bool `json:"insecure_skip_verify" typescript:",notnull"`
537536
// CAFile specifies the location of the CA certificate to use.
538-
CAFile string `json:"ca_file"`
537+
CAFile serpent.String `json:"ca_file" typescript:",notnull"`
539538
// CertFile specifies the location of the certificate to use.
540-
CertFile string `json:"cert_file"`
539+
CertFile serpent.String `json:"cert_file" typescript:",notnull"`
541540
// KeyFile specifies the location of the key to use.
542-
KeyFile string `json:"key_file"`
541+
KeyFile serpent.String `json:"key_file" typescript:",notnull"`
543542
}
544543

545544
func (c *NotificationsEmailTLSConfig) Empty() bool {
@@ -697,18 +696,27 @@ when required by your organization's security policy.`,
697696
Description: `Use a YAML configuration file when your server launch become unwieldy.`,
698697
}
699698
deploymentGroupNotifications = serpent.Group{
700-
Name: "Notifications",
701-
YAML: "notifications",
699+
Name: "Notifications",
700+
YAML: "notifications",
701+
Description: "Configure how notifications are processed and delivered.",
702702
}
703703
deploymentGroupNotificationsEmail = serpent.Group{
704-
Name: "Email",
705-
Parent: &deploymentGroupNotifications,
706-
YAML: "email",
704+
Name: "Email",
705+
Parent: &deploymentGroupNotifications,
706+
Description: "Configure how email notifications are sent.",
707+
YAML: "email",
707708
}
708709
deploymentGroupNotificationsEmailAuth = serpent.Group{
709-
Name: "Email Authentication",
710-
Parent: &deploymentGroupNotificationsEmail,
711-
YAML: "email_auth",
710+
Name: "Email Authentication",
711+
Parent: &deploymentGroupNotificationsEmail,
712+
Description: "Configure SMTP authentication options.",
713+
YAML: "email_auth",
714+
}
715+
deploymentGroupNotificationsEmailTLS = serpent.Group{
716+
Name: "Email TLS",
717+
Parent: &deploymentGroupNotificationsEmail,
718+
Description: "Configure TLS for your SMTP server target.",
719+
YAML: "email_tls",
712720
}
713721
deploymentGroupNotificationsWebhook = serpent.Group{
714722
Name: "Webhook",
@@ -2150,7 +2158,7 @@ Write out the current server config as YAML to stdout.`,
21502158
Value: &c.Notifications.DispatchTimeout,
21512159
Default: time.Minute.String(),
21522160
Group: &deploymentGroupNotifications,
2153-
YAML: "dispatch-timeout",
2161+
YAML: "dispatchTimeout",
21542162
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
21552163
},
21562164
{
@@ -2190,14 +2198,13 @@ Write out the current server config as YAML to stdout.`,
21902198
Default: "false",
21912199
Value: &c.Notifications.SMTP.ForceTLS,
21922200
Group: &deploymentGroupNotificationsEmail,
2193-
YAML: "force_tls",
2201+
YAML: "forceTLS",
21942202
},
21952203
{
21962204
Name: "Notifications: Email Auth: Identity",
21972205
Description: "Identity to use with PLAIN authentication.",
21982206
Flag: "notifications-email-auth-identity",
21992207
Env: "CODER_NOTIFICATIONS_EMAIL_AUTH_IDENTITY",
2200-
Default: "",
22012208
Value: &c.Notifications.SMTP.Auth.Identity,
22022209
Group: &deploymentGroupNotificationsEmailAuth,
22032210
YAML: "identity",
@@ -2207,7 +2214,6 @@ Write out the current server config as YAML to stdout.`,
22072214
Description: "Username to use with PLAIN/LOGIN authentication.",
22082215
Flag: "notifications-email-auth-username",
22092216
Env: "CODER_NOTIFICATIONS_EMAIL_AUTH_USERNAME",
2210-
Default: "",
22112217
Value: &c.Notifications.SMTP.Auth.Username,
22122218
Group: &deploymentGroupNotificationsEmailAuth,
22132219
YAML: "username",
@@ -2217,7 +2223,6 @@ Write out the current server config as YAML to stdout.`,
22172223
Description: "Password to use with PLAIN/LOGIN authentication.",
22182224
Flag: "notifications-email-auth-password",
22192225
Env: "CODER_NOTIFICATIONS_EMAIL_AUTH_PASSWORD",
2220-
Default: "",
22212226
Value: &c.Notifications.SMTP.Auth.Password,
22222227
Group: &deploymentGroupNotificationsEmailAuth,
22232228
YAML: "password",
@@ -2227,10 +2232,63 @@ Write out the current server config as YAML to stdout.`,
22272232
Description: "File from which to load password for use with PLAIN/LOGIN authentication.",
22282233
Flag: "notifications-email-auth-password-file",
22292234
Env: "CODER_NOTIFICATIONS_EMAIL_AUTH_PASSWORD_FILE",
2230-
Default: "",
22312235
Value: &c.Notifications.SMTP.Auth.PasswordFile,
22322236
Group: &deploymentGroupNotificationsEmailAuth,
2233-
YAML: "password_file",
2237+
YAML: "passwordFile",
2238+
},
2239+
{
2240+
Name: "Notifications: Email TLS: StartTLS",
2241+
Description: "Enable STARTTLS to upgrade insecure SMTP connections using TLS.",
2242+
Flag: "notifications-email-tls-starttls",
2243+
Env: "CODER_NOTIFICATIONS_EMAIL_TLS_STARTTLS",
2244+
Value: &c.Notifications.SMTP.TLS.StartTLS,
2245+
Group: &deploymentGroupNotificationsEmailTLS,
2246+
YAML: "startTLS",
2247+
},
2248+
{
2249+
Name: "Notifications: Email TLS: Server Name",
2250+
Description: "Server name to verify against the target certificate.",
2251+
Flag: "notifications-email-tls-server-name",
2252+
Env: "CODER_NOTIFICATIONS_EMAIL_TLS_SERVERNAME",
2253+
Value: &c.Notifications.SMTP.TLS.ServerName,
2254+
Group: &deploymentGroupNotificationsEmailTLS,
2255+
YAML: "serverName",
2256+
},
2257+
{
2258+
Name: "Notifications: Email TLS: Skip Certificate Verification (Insecure)",
2259+
Description: "Skip verification of the target server's certificate (insecure).",
2260+
Flag: "notifications-email-tls-skip-verify",
2261+
Env: "CODER_NOTIFICATIONS_EMAIL_TLS_SKIPVERIFY",
2262+
Value: &c.Notifications.SMTP.TLS.InsecureSkipVerify,
2263+
Group: &deploymentGroupNotificationsEmailTLS,
2264+
YAML: "insecureSkipVerify",
2265+
},
2266+
{
2267+
Name: "Notifications: Email TLS: Certificate Authority File",
2268+
Description: "CA certificate file to use.",
2269+
Flag: "notifications-email-tls-ca-cert-file",
2270+
Env: "CODER_NOTIFICATIONS_EMAIL_TLS_CACERTFILE",
2271+
Value: &c.Notifications.SMTP.TLS.CAFile,
2272+
Group: &deploymentGroupNotificationsEmailTLS,
2273+
YAML: "caCertFile",
2274+
},
2275+
{
2276+
Name: "Notifications: Email TLS: Certificate File",
2277+
Description: "Certificate file to use.",
2278+
Flag: "notifications-email-tls-cert-file",
2279+
Env: "CODER_NOTIFICATIONS_EMAIL_TLS_CERTFILE",
2280+
Value: &c.Notifications.SMTP.TLS.CertFile,
2281+
Group: &deploymentGroupNotificationsEmailTLS,
2282+
YAML: "certFile",
2283+
},
2284+
{
2285+
Name: "Notifications: Email TLS: Certificate Key File",
2286+
Description: "Certificate key file to use.",
2287+
Flag: "notifications-email-tls-cert-key-file",
2288+
Env: "CODER_NOTIFICATIONS_EMAIL_TLS_CERTKEYFILE",
2289+
Value: &c.Notifications.SMTP.TLS.KeyFile,
2290+
Group: &deploymentGroupNotificationsEmailTLS,
2291+
YAML: "certKeyFile",
22342292
},
22352293
{
22362294
Name: "Notifications: Webhook: Endpoint",
@@ -2249,7 +2307,7 @@ Write out the current server config as YAML to stdout.`,
22492307
Value: &c.Notifications.MaxSendAttempts,
22502308
Default: "5",
22512309
Group: &deploymentGroupNotifications,
2252-
YAML: "max-send-attempts",
2310+
YAML: "maxSendAttempts",
22532311
},
22542312
{
22552313
Name: "Notifications: Retry Interval",
@@ -2259,7 +2317,7 @@ Write out the current server config as YAML to stdout.`,
22592317
Value: &c.Notifications.RetryInterval,
22602318
Default: (time.Minute * 5).String(),
22612319
Group: &deploymentGroupNotifications,
2262-
YAML: "retry-interval",
2320+
YAML: "retryInterval",
22632321
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
22642322
Hidden: true, // Hidden because most operators should not need to modify this.
22652323
},

0 commit comments

Comments
 (0)