feat: add YAML support to server (#6934)

This commit is contained in:
Ammar Bandukwala
2023-04-07 17:58:21 -05:00
committed by GitHub
parent a3c6cb1768
commit 4b99e2d07e
32 changed files with 1605 additions and 468 deletions

View File

@ -163,8 +163,8 @@ type DeploymentValues struct {
SSHConfig SSHConfig `json:"config_ssh,omitempty" typescript:",notnull"`
WgtunnelHost clibase.String `json:"wgtunnel_host,omitempty" typescript:",notnull"`
Config clibase.String `json:"config,omitempty" typescript:",notnull"`
WriteConfig clibase.Bool `json:"write_config,omitempty" typescript:",notnull"`
Config clibase.YAMLConfigPath `json:"config,omitempty" typescript:",notnull"`
WriteConfig clibase.Bool `json:"write_config,omitempty" typescript:",notnull"`
// DEPRECATED: Use HTTPAddress or TLS.Address instead.
Address clibase.HostPort `json:"address,omitempty" typescript:",notnull"`
@ -368,6 +368,7 @@ func (c *DeploymentValues) Options() clibase.OptionSet {
var (
deploymentGroupNetworking = clibase.Group{
Name: "Networking",
YAML: "networking",
}
deploymentGroupNetworkingTLS = clibase.Group{
Parent: &deploymentGroupNetworking,
@ -375,10 +376,12 @@ func (c *DeploymentValues) Options() clibase.OptionSet {
Description: `Configure TLS / HTTPS for your Coder deployment. If you're running
Coder behind a TLS-terminating reverse proxy or are accessing Coder over a
secure link, you can safely ignore these settings.`,
YAML: "tls",
}
deploymentGroupNetworkingHTTP = clibase.Group{
Parent: &deploymentGroupNetworking,
Name: "HTTP",
YAML: "http",
}
deploymentGroupNetworkingDERP = clibase.Group{
Parent: &deploymentGroupNetworking,
@ -387,40 +390,50 @@ func (c *DeploymentValues) Options() clibase.OptionSet {
between workspaces and users are peer-to-peer. However, when Coder cannot establish
a peer to peer connection, Coder uses a distributed relay network backed by
Tailscale and WireGuard.`,
YAML: "derp",
}
deploymentGroupIntrospection = clibase.Group{
Name: "Introspection",
Description: `Configure logging, tracing, and metrics exporting.`,
YAML: "introspection",
}
deploymentGroupIntrospectionPPROF = clibase.Group{
Parent: &deploymentGroupIntrospection,
Name: "pprof",
YAML: "pprof",
}
deploymentGroupIntrospectionPrometheus = clibase.Group{
Parent: &deploymentGroupIntrospection,
Name: "Prometheus",
YAML: "prometheus",
}
deploymentGroupIntrospectionTracing = clibase.Group{
Parent: &deploymentGroupIntrospection,
Name: "Tracing",
YAML: "tracing",
}
deploymentGroupIntrospectionLogging = clibase.Group{
Parent: &deploymentGroupIntrospection,
Name: "Logging",
YAML: "logging",
}
deploymentGroupOAuth2 = clibase.Group{
Name: "OAuth2",
Description: `Configure login and user-provisioning with GitHub via oAuth2.`,
YAML: "oauth2",
}
deploymentGroupOAuth2GitHub = clibase.Group{
Parent: &deploymentGroupOAuth2,
Name: "GitHub",
YAML: "github",
}
deploymentGroupOIDC = clibase.Group{
Name: "OIDC",
YAML: "oidc",
}
deploymentGroupTelemetry = clibase.Group{
Name: "Telemetry",
YAML: "telemetry",
Description: `Telemetry is critical to our ability to improve Coder. We strip all personal
information before sending data to our servers. Please only disable telemetry
when required by your organization's security policy.`,
@ -428,14 +441,17 @@ when required by your organization's security policy.`,
deploymentGroupProvisioning = clibase.Group{
Name: "Provisioning",
Description: `Tune the behavior of the provisioner, which is responsible for creating, updating, and deleting workspace resources.`,
YAML: "provisioning",
}
deploymentGroupDangerous = clibase.Group{
Name: "⚠️ Dangerous",
YAML: "dangerous",
}
deploymentGroupClient = clibase.Group{
Name: "Client",
Description: "These options change the behavior of how clients interact with the Coder. " +
"Clients include the coder cli, vs code extension, and the web UI.",
YAML: "client",
}
deploymentGroupConfig = clibase.Group{
Name: "Config",
@ -1340,11 +1356,9 @@ when required by your organization's security policy.`,
Flag: "config",
Env: "CODER_CONFIG_PATH",
FlagShorthand: "c",
// The config parameters are hidden until they are tested and
// documented.
Hidden: true,
Group: &deploymentGroupConfig,
Value: &c.Config,
Hidden: false,
Group: &deploymentGroupConfig,
Value: &c.Config,
},
{
Name: "SSH Host Prefix",
@ -1372,11 +1386,10 @@ when required by your organization's security policy.`,
{
Name: "Write Config",
Description: `
Write out the current server configuration to the path specified by --config.`,
Write out the current server config as YAML to stdout.`,
Flag: "write-config",
Env: "CODER_WRITE_CONFIG",
Group: &deploymentGroupConfig,
Hidden: true,
Hidden: false,
Value: &c.WriteConfig,
},
{
@ -1392,9 +1405,11 @@ Write out the current server configuration to the path specified by --config.`,
// Env handling is done in cli.ReadGitAuthFromEnvironment
Name: "Git Auth Providers",
Description: "Git Authentication providers.",
YAML: "gitAuthProviders",
Value: &c.GitAuthProviders,
Hidden: true,
// We need extra scrutiny to ensure this works, is documented, and
// tested before enabling.
// YAML: "gitAuthProviders",
Value: &c.GitAuthProviders,
Hidden: true,
},
{
Name: "Custom wgtunnel Host",

View File

@ -30,6 +30,7 @@ func TestDeploymentValues_HighlyConfigurable(t *testing.T) {
},
"Write Config": {
yaml: true,
env: true,
},
// Dangerous values? Not sure we should help users
// persistent their configuration.