Skip to content

Commit d84d377

Browse files
committed
update to main
1 parent bb494dc commit d84d377

File tree

2 files changed

+81
-19
lines changed

2 files changed

+81
-19
lines changed

cli/deployment/config.go

Lines changed: 78 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,24 @@ import (
2222
func newConfig() codersdk.DeploymentConfig {
2323
return codersdk.DeploymentConfig{
2424
AccessURL: codersdk.DeploymentConfigField[string]{
25+
Name: "Access URL",
2526
Usage: "External URL to access your deployment. This must be accessible by all provisioned workspaces.",
2627
Flag: "access-url",
2728
},
2829
WildcardAccessURL: codersdk.DeploymentConfigField[string]{
30+
Name: "Wildcard Access URL",
2931
Usage: "Specifies the wildcard hostname to use for workspace applications in the form \"*.example.com\".",
3032
Flag: "wildcard-access-url",
3133
},
3234
Address: codersdk.DeploymentConfigField[string]{
35+
Name: "Address",
3336
Usage: "Bind address of the server.",
3437
Flag: "address",
3538
Shorthand: "a",
3639
Value: "127.0.0.1:3000",
3740
},
3841
AutobuildPollInterval: codersdk.DeploymentConfigField[time.Duration]{
42+
Name: "Autobuild Poll Interval",
3943
Usage: "Interval to poll for scheduled workspace builds.",
4044
Flag: "autobuild-poll-interval",
4145
Hidden: true,
@@ -44,143 +48,177 @@ func newConfig() codersdk.DeploymentConfig {
4448
DERP: codersdk.DERP{
4549
Server: codersdk.DERPServerConfig{
4650
Enable: codersdk.DeploymentConfigField[bool]{
51+
Name: "DERP Server Enable",
4752
Usage: "Whether to enable or disable the embedded DERP relay server.",
4853
Flag: "derp-server-enable",
4954
Value: true,
5055
},
5156
RegionID: codersdk.DeploymentConfigField[int]{
57+
Name: "DERP Server Region ID",
5258
Usage: "Region ID to use for the embedded DERP server.",
5359
Flag: "derp-server-region-id",
5460
Value: 999,
5561
},
5662
RegionCode: codersdk.DeploymentConfigField[string]{
63+
Name: "DERP Server Region Code",
5764
Usage: "Region code to use for the embedded DERP server.",
5865
Flag: "derp-server-region-code",
5966
Value: "coder",
6067
},
6168
RegionName: codersdk.DeploymentConfigField[string]{
69+
Name: "DERP Server Region Name",
6270
Usage: "Region name that for the embedded DERP server.",
6371
Flag: "derp-server-region-name",
6472
Value: "Coder Embedded Relay",
6573
},
6674
STUNAddresses: codersdk.DeploymentConfigField[[]string]{
75+
Name: "DERP Server STUN Addresses",
6776
Usage: "Addresses for STUN servers to establish P2P connections. Set empty to disable P2P connections.",
6877
Flag: "derp-server-stun-addresses",
6978
Value: []string{"stun.l.google.com:19302"},
7079
},
71-
RelayAddress: codersdk.DeploymentConfigField[string]{
72-
Usage: "An HTTP address that is accessible by other replicas to relay DERP traffic. Required for high availability.",
73-
Flag: "derp-server-relay-address",
80+
RelayURL: codersdk.DeploymentConfigField[string]{
81+
Name: "DERP Server Relay URL",
82+
Usage: "An HTTP URL that is accessible by other replicas to relay DERP traffic. Required for high availability.",
83+
Flag: "derp-server-relay-url",
7484
Enterprise: true,
7585
},
7686
},
7787
Config: codersdk.DERPConfig{
7888
URL: codersdk.DeploymentConfigField[string]{
89+
Name: "DERP Config URL",
7990
Usage: "URL to fetch a DERP mapping on startup. See: https://tailscale.com/kb/1118/custom-derp-servers/",
8091
Flag: "derp-config-url",
8192
},
8293
Path: codersdk.DeploymentConfigField[string]{
94+
Name: "DERP Config Path",
8395
Usage: "Path to read a DERP mapping from. See: https://tailscale.com/kb/1118/custom-derp-servers/",
8496
Flag: "derp-config-path",
8597
},
8698
},
8799
},
88100
Prometheus: codersdk.PrometheusConfig{
89101
Enable: codersdk.DeploymentConfigField[bool]{
102+
Name: "Prometheus Enable",
90103
Usage: "Serve prometheus metrics on the address defined by prometheus address.",
91104
Flag: "prometheus-enable",
92105
},
93106
Address: codersdk.DeploymentConfigField[string]{
107+
Name: "Prometheus Address",
94108
Usage: "The bind address to serve prometheus metrics.",
95109
Flag: "prometheus-address",
96110
Value: "127.0.0.1:2112",
97111
},
98112
},
99113
Pprof: codersdk.PprofConfig{
100114
Enable: codersdk.DeploymentConfigField[bool]{
115+
Name: "Pprof Enable",
101116
Usage: "Serve pprof metrics on the address defined by pprof address.",
102117
Flag: "pprof-enable",
103118
},
104119
Address: codersdk.DeploymentConfigField[string]{
120+
Name: "Pprof Address",
105121
Usage: "The bind address to serve pprof.",
106122
Flag: "pprof-address",
107123
Value: "127.0.0.1:6060",
108124
},
109125
},
126+
ProxyTrustedHeaders: codersdk.DeploymentConfigField[[]string]{
127+
Name: "Proxy Trusted Headers",
128+
Flag: "proxy-trusted-headers",
129+
Usage: "Headers to trust for forwarding IP addresses. e.g. Cf-Connecting-IP True-Client-Ip, X-Forwarded-for",
130+
},
131+
ProxyTrustedOrigins: codersdk.DeploymentConfigField[[]string]{
132+
Name: "Proxy Trusted Origins",
133+
Flag: "proxy-trusted-origins",
134+
Usage: "Origin addresses to respect \"proxy-trusted-headers\". e.g. example.com",
135+
},
110136
CacheDirectory: codersdk.DeploymentConfigField[string]{
111-
137+
Name: "Cache Directory",
112138
Usage: "The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with systemd.",
113139
Flag: "cache-dir",
114140
Value: defaultCacheDir(),
115141
},
116142
InMemoryDatabase: codersdk.DeploymentConfigField[bool]{
117-
143+
Name: "In Memory Database",
118144
Usage: "Controls whether data will be stored in an in-memory database.",
119145
Flag: "in-memory",
120146
Hidden: true,
121147
},
122148
ProvisionerDaemons: codersdk.DeploymentConfigField[int]{
123-
149+
Name: "Provisioner Daemons",
124150
Usage: "Number of provisioner daemons to create on start. If builds are stuck in queued state for a long time, consider increasing this.",
125151
Flag: "provisioner-daemons",
126152
Value: 3,
127153
},
128154
PostgresURL: codersdk.DeploymentConfigField[string]{
129-
155+
Name: "Postgres Connection URL",
130156
Usage: "URL of a PostgreSQL database. If empty, PostgreSQL binaries will be downloaded from Maven (https://repo1.maven.org/maven2) and store all data in the config root. Access the built-in database with \"coder server postgres-builtin-url\".",
131157
Flag: "postgres-url",
132158
},
133159
OAuth2: codersdk.OAuth2Config{
134160
Github: codersdk.OAuth2GithubConfig{
135161
ClientID: codersdk.DeploymentConfigField[string]{
162+
Name: "OAuth2 GitHub Client ID",
136163
Usage: "Client ID for Login with GitHub.",
137164
Flag: "oauth2-github-client-id",
138165
},
139166
ClientSecret: codersdk.DeploymentConfigField[string]{
167+
Name: "OAuth2 GitHub Client Secret",
140168
Usage: "Client secret for Login with GitHub.",
141169
Flag: "oauth2-github-client-secret",
142170
},
143171
AllowedOrganizations: codersdk.DeploymentConfigField[[]string]{
172+
Name: "OAuth2 GitHub Allowed Orgs",
144173
Usage: "Organizations the user must be a member of to Login with GitHub.",
145174
Flag: "oauth2-github-allowed-orgs",
146175
},
147176
AllowedTeams: codersdk.DeploymentConfigField[[]string]{
177+
Name: "OAuth2 GitHub Allowed Teams",
148178
Usage: "Teams inside organizations the user must be a member of to Login with GitHub. Structured as: <organization-name>/<team-slug>.",
149179
Flag: "oauth2-github-allowed-teams",
150180
},
151181
AllowSignups: codersdk.DeploymentConfigField[bool]{
182+
Name: "OAuth2 GitHub Allow Signups",
152183
Usage: "Whether new users can sign up with GitHub.",
153184
Flag: "oauth2-github-allow-signups",
154185
},
155186
EnterpriseBaseURL: codersdk.DeploymentConfigField[string]{
187+
Name: "OAuth2 GitHub Enterprise Base URL",
156188
Usage: "Base URL of a GitHub Enterprise deployment to use for Login with GitHub.",
157189
Flag: "oauth2-github-enterprise-base-url",
158190
},
159191
},
160192
},
161193
OIDC: codersdk.OIDCConfig{
162194
AllowSignups: codersdk.DeploymentConfigField[bool]{
195+
Name: "OIDC Allow Signups",
163196
Usage: "Whether new users can sign up with OIDC.",
164197
Flag: "oidc-allow-signups",
165198
Value: true,
166199
},
167200
ClientID: codersdk.DeploymentConfigField[string]{
201+
Name: "OIDC Client ID",
168202
Usage: "Client ID to use for Login with OIDC.",
169203
Flag: "oidc-client-id",
170204
},
171205
ClientSecret: codersdk.DeploymentConfigField[string]{
206+
Name: "OIDC Client Secret",
172207
Usage: "Client secret to use for Login with OIDC.",
173208
Flag: "oidc-client-secret",
174209
},
175210
EmailDomain: codersdk.DeploymentConfigField[string]{
211+
Name: "OIDC Email Domain",
176212
Usage: "Email domain that clients logging in with OIDC must match.",
177213
Flag: "oidc-email-domain",
178214
},
179215
IssuerURL: codersdk.DeploymentConfigField[string]{
216+
Name: "OIDC Issuer URL",
180217
Usage: "Issuer URL to use for Login with OIDC.",
181218
Flag: "oidc-issuer-url",
182219
},
183220
Scopes: codersdk.DeploymentConfigField[[]string]{
221+
Name: "OIDC Scopes",
184222
Usage: "Scopes to grant when authenticating with OIDC.",
185223
Flag: "oidc-scopes",
186224
Value: []string{oidc.ScopeOpenID, "profile", "email"},
@@ -189,16 +227,19 @@ func newConfig() codersdk.DeploymentConfig {
189227

190228
Telemetry: codersdk.TelemetryConfig{
191229
Enable: codersdk.DeploymentConfigField[bool]{
230+
Name: "Telemetry Enable",
192231
Usage: "Whether telemetry is enabled or not. Coder collects anonymized usage data to help improve our product.",
193232
Flag: "telemetry",
194233
Value: flag.Lookup("test.v") == nil,
195234
},
196235
Trace: codersdk.DeploymentConfigField[bool]{
236+
Name: "Telemetry Trace",
197237
Usage: "Whether Opentelemetry traces are sent to Coder. Coder collects anonymized application tracing to help improve our product. Disabling telemetry also disables this option.",
198238
Flag: "telemetry-trace",
199239
Value: flag.Lookup("test.v") == nil,
200240
},
201241
URL: codersdk.DeploymentConfigField[string]{
242+
Name: "Telemetry URL",
202243
Usage: "URL to send telemetry.",
203244
Flag: "telemetry-url",
204245
Hidden: true,
@@ -207,88 +248,95 @@ func newConfig() codersdk.DeploymentConfig {
207248
},
208249
TLS: codersdk.TLSConfig{
209250
Enable: codersdk.DeploymentConfigField[bool]{
251+
Name: "TLS Enable",
210252
Usage: "Whether TLS will be enabled.",
211253
Flag: "tls-enable",
212254
},
213255
CertFiles: codersdk.DeploymentConfigField[[]string]{
256+
Name: "TLS Certificate Files",
214257
Usage: "Path to each certificate for TLS. It requires a PEM-encoded file. To configure the listener to use a CA certificate, concatenate the primary certificate and the CA certificate together. The primary certificate should appear first in the combined file.",
215258
Flag: "tls-cert-file",
216259
},
217260
ClientCAFile: codersdk.DeploymentConfigField[string]{
261+
Name: "TLS Client CA Files",
218262
Usage: "PEM-encoded Certificate Authority file used for checking the authenticity of client",
219263
Flag: "tls-client-ca-file",
220264
},
221265
ClientAuth: codersdk.DeploymentConfigField[string]{
266+
Name: "TLS Client Auth",
222267
Usage: "Policy the server will follow for TLS Client Authentication. Accepted values are \"none\", \"request\", \"require-any\", \"verify-if-given\", or \"require-and-verify\".",
223268
Flag: "tls-client-auth",
224269
Value: "request",
225270
},
226271
KeyFiles: codersdk.DeploymentConfigField[[]string]{
272+
Name: "TLS Key Files",
227273
Usage: "Paths to the private keys for each of the certificates. It requires a PEM-encoded file.",
228274
Flag: "tls-key-file",
229275
},
230276
MinVersion: codersdk.DeploymentConfigField[string]{
277+
Name: "TLS Minimum Version",
231278
Usage: "Minimum supported version of TLS. Accepted values are \"tls10\", \"tls11\", \"tls12\" or \"tls13\"",
232279
Flag: "tls-min-version",
233280
Value: "tls12",
234281
},
235282
},
236283
TraceEnable: codersdk.DeploymentConfigField[bool]{
237-
284+
Name: "Trace Enable",
238285
Usage: "Whether application tracing data is collected.",
239286
Flag: "trace",
240287
},
241288
SecureAuthCookie: codersdk.DeploymentConfigField[bool]{
242-
289+
Name: "Secure Auth Cookie",
243290
Usage: "Controls if the 'Secure' property is set on browser session cookies.",
244291
Flag: "secure-auth-cookie",
245292
},
246293
SSHKeygenAlgorithm: codersdk.DeploymentConfigField[string]{
247-
294+
Name: "SSH Keygen Algorithm",
248295
Usage: "The algorithm to use for generating ssh keys. Accepted values are \"ed25519\", \"ecdsa\", or \"rsa4096\".",
249296
Flag: "ssh-keygen-algorithm",
250297
Value: "ed25519",
251298
},
252299
AutoImportTemplates: codersdk.DeploymentConfigField[[]string]{
253-
300+
Name: "Auto Import Templates",
254301
Usage: "Templates to auto-import. Available auto-importable templates are: kubernetes",
255302
Flag: "auto-import-template",
256303
Hidden: true,
257304
},
258305
MetricsCacheRefreshInterval: codersdk.DeploymentConfigField[time.Duration]{
259-
306+
Name: "Metrics Cache Refresh Interval",
260307
Usage: "How frequently metrics are refreshed",
261308
Flag: "metrics-cache-refresh-interval",
262309
Hidden: true,
263310
Value: time.Hour,
264311
},
265312
AgentStatRefreshInterval: codersdk.DeploymentConfigField[time.Duration]{
266-
313+
Name: "Agent Stat Refresh Interval",
267314
Usage: "How frequently agent stats are recorded",
268315
Flag: "agent-stats-refresh-interval",
269316
Hidden: true,
270317
Value: 10 * time.Minute,
271318
},
272319
AuditLogging: codersdk.DeploymentConfigField[bool]{
273-
320+
Name: "Audit Logging",
274321
Usage: "Specifies whether audit logging is enabled.",
275322
Flag: "audit-logging",
276323
Value: true,
277324
Enterprise: true,
278325
},
279326
BrowserOnly: codersdk.DeploymentConfigField[bool]{
280-
327+
Name: "Browser Only",
281328
Usage: "Whether Coder only allows connections to workspaces via the browser.",
282329
Flag: "browser-only",
283330
Enterprise: true,
284331
},
285332
SCIMAPIKey: codersdk.DeploymentConfigField[string]{
333+
Name: "SCIM API Key",
286334
Usage: "Enables SCIM and sets the authentication header for the built-in SCIM server. New users are automatically created with OIDC authentication.",
287335
Flag: "scim-auth-header",
288336
Enterprise: true,
289337
},
290338
UserWorkspaceQuota: codersdk.DeploymentConfigField[int]{
291-
339+
Name: "User Workspace Quota",
292340
Usage: "Enables and sets a limit on how many workspaces each user can create.",
293341
Flag: "user-workspace-quota",
294342
Enterprise: true,
@@ -334,7 +382,19 @@ func setConfig(prefix string, vip *viper.Viper, target interface{}) {
334382
case time.Duration:
335383
val.FieldByName("Value").SetInt(int64(vip.GetDuration(prefix)))
336384
case []string:
337-
val.FieldByName("Value").Set(reflect.ValueOf(vip.GetStringSlice(prefix)))
385+
// As of October 21st, 2022 we supported delimiting a string
386+
// with a comma, but Viper only supports with a space. This
387+
// is a small hack around it!
388+
rawSlice := reflect.ValueOf(vip.GetStringSlice(prefix)).Interface()
389+
slice, ok := rawSlice.([]string)
390+
if !ok {
391+
panic(fmt.Sprintf("string slice is of type %T", rawSlice))
392+
}
393+
value := make([]string, 0, len(slice))
394+
for _, entry := range slice {
395+
value = append(value, strings.Split(entry, ",")...)
396+
}
397+
val.FieldByName("Value").Set(reflect.ValueOf(value))
338398
default:
339399
panic(fmt.Sprintf("unsupported type %T", value))
340400
}
@@ -372,6 +432,7 @@ func NewViper() *viper.Viper {
372432
vip := viper.New()
373433
vip.SetEnvPrefix("coder")
374434
vip.AutomaticEnv()
435+
vip.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_"))
375436

376437
setViperDefaults("", vip, dc)
377438

codersdk/deploymentconfig.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ type DeploymentConfig struct {
1919
DERP DERP `json:"derp"`
2020
Prometheus PrometheusConfig `json:"prometheus"`
2121
Pprof PprofConfig `json:"pprof"`
22+
ProxyTrustedHeaders DeploymentConfigField[[]string] `json:"proxy_trusted_headers"`
23+
ProxyTrustedOrigins DeploymentConfigField[[]string] `json:"proxy_trusted_origin"`
2224
CacheDirectory DeploymentConfigField[string] `json:"cache_directory"`
2325
InMemoryDatabase DeploymentConfigField[bool] `json:"in_memory_database"`
2426
ProvisionerDaemons DeploymentConfigField[int] `json:"provisioner_daemon_count"`
@@ -50,7 +52,7 @@ type DERPServerConfig struct {
5052
RegionCode DeploymentConfigField[string] `json:"region_code"`
5153
RegionName DeploymentConfigField[string] `json:"region_name"`
5254
STUNAddresses DeploymentConfigField[[]string] `json:"stun_address"`
53-
RelayAddress DeploymentConfigField[string] `json:"relay_address"`
55+
RelayURL DeploymentConfigField[string] `json:"relay_address"`
5456
}
5557

5658
type DERPConfig struct {
@@ -110,7 +112,6 @@ type Flaggable interface {
110112
}
111113

112114
type DeploymentConfigField[T Flaggable] struct {
113-
// Key string `json:"key"`
114115
Name string `json:"name"`
115116
Usage string `json:"usage"`
116117
Flag string `json:"flag"`

0 commit comments

Comments
 (0)