feat: support nested structs, structured arrays, and better secret value handling in config (#4727)

This commit is contained in:
Garrett Delfosse
2022-10-25 00:11:00 +00:00
committed by GitHub
parent f9c6220263
commit 585045b359
11 changed files with 728 additions and 548 deletions
+88 -33
View File
@@ -245,54 +245,53 @@ export interface DAUEntry {
readonly amount: number
}
// From codersdk/deploymentconfig.go
export interface DERP {
readonly server: DERPServerConfig
readonly config: DERPConfig
}
// From codersdk/deploymentconfig.go
export interface DERPConfig {
readonly url: DeploymentConfigField<string>
readonly path: DeploymentConfigField<string>
}
// From codersdk/workspaceagents.go
export interface DERPRegion {
readonly preferred: boolean
readonly latency_ms: number
}
// From codersdk/deploymentconfig.go
export interface DERPServerConfig {
readonly enable: DeploymentConfigField<boolean>
readonly region_id: DeploymentConfigField<number>
readonly region_code: DeploymentConfigField<string>
readonly region_name: DeploymentConfigField<string>
readonly stun_addresses: DeploymentConfigField<string[]>
readonly relay_url: DeploymentConfigField<string>
}
// From codersdk/deploymentconfig.go
export interface DeploymentConfig {
readonly access_url: DeploymentConfigField<string>
readonly wildcard_access_url: DeploymentConfigField<string>
readonly address: DeploymentConfigField<string>
readonly autobuild_poll_interval: DeploymentConfigField<number>
readonly derp_server_enabled: DeploymentConfigField<boolean>
readonly derp_server_region_id: DeploymentConfigField<number>
readonly derp_server_region_code: DeploymentConfigField<string>
readonly derp_server_region_name: DeploymentConfigField<string>
readonly derp_server_stun_address: DeploymentConfigField<string[]>
readonly derp_server_relay_address: DeploymentConfigField<string>
readonly derp_config_url: DeploymentConfigField<string>
readonly derp_config_path: DeploymentConfigField<string>
readonly prometheus_enabled: DeploymentConfigField<boolean>
readonly prometheus_address: DeploymentConfigField<string>
readonly pprof_enabled: DeploymentConfigField<boolean>
readonly pprof_address: DeploymentConfigField<string>
readonly derp: DERP
readonly prometheus: PrometheusConfig
readonly pprof: PprofConfig
readonly proxy_trusted_headers: DeploymentConfigField<string[]>
readonly proxy_trusted_origins: DeploymentConfigField<string[]>
readonly cache_directory: DeploymentConfigField<string>
readonly in_memory_database: DeploymentConfigField<boolean>
readonly provisioner_daemon_count: DeploymentConfigField<number>
readonly oauth2_github_client_id: DeploymentConfigField<string>
readonly oauth2_github_allowed_orgs: DeploymentConfigField<string[]>
readonly oauth2_github_allowed_teams: DeploymentConfigField<string[]>
readonly oauth2_github_allow_signups: DeploymentConfigField<boolean>
readonly oauth2_github_enterprise_base_url: DeploymentConfigField<string>
readonly oidc_allow_signups: DeploymentConfigField<boolean>
readonly oidc_client_id: DeploymentConfigField<string>
readonly oidc_email_domain: DeploymentConfigField<string>
readonly oidc_issuer_url: DeploymentConfigField<string>
readonly oidc_scopes: DeploymentConfigField<string[]>
readonly telemetry_enable: DeploymentConfigField<boolean>
readonly telemetry_trace_enable: DeploymentConfigField<boolean>
readonly telemetry_url: DeploymentConfigField<string>
readonly tls_enable: DeploymentConfigField<boolean>
readonly tls_cert_files: DeploymentConfigField<string[]>
readonly tls_client_ca_file: DeploymentConfigField<string>
readonly tls_client_auth: DeploymentConfigField<string>
readonly tls_key_files: DeploymentConfigField<string[]>
readonly tls_min_version: DeploymentConfigField<string>
readonly provisioner_daemons: DeploymentConfigField<number>
readonly pg_connection_url: DeploymentConfigField<string>
readonly oauth2: OAuth2Config
readonly oidc: OIDCConfig
readonly telemetry: TelemetryConfig
readonly tls: TLSConfig
readonly trace_enable: DeploymentConfigField<boolean>
readonly secure_auth_cookie: DeploymentConfigField<boolean>
readonly ssh_keygen_algorithm: DeploymentConfigField<string>
@@ -301,18 +300,20 @@ export interface DeploymentConfig {
readonly agent_stat_refresh_interval: DeploymentConfigField<number>
readonly audit_logging: DeploymentConfigField<boolean>
readonly browser_only: DeploymentConfigField<boolean>
readonly scim_api_key: DeploymentConfigField<string>
readonly user_workspace_quota: DeploymentConfigField<number>
}
// From codersdk/deploymentconfig.go
export interface DeploymentConfigField<T extends Flaggable> {
readonly key: string
readonly name: string
readonly usage: string
readonly flag: string
readonly shorthand: string
readonly enterprise: boolean
readonly hidden: boolean
readonly secret: boolean
readonly default: T
readonly value: T
}
@@ -399,6 +400,31 @@ export interface LoginWithPasswordResponse {
readonly session_token: string
}
// From codersdk/deploymentconfig.go
export interface OAuth2Config {
readonly github: OAuth2GithubConfig
}
// From codersdk/deploymentconfig.go
export interface OAuth2GithubConfig {
readonly client_id: DeploymentConfigField<string>
readonly client_secret: DeploymentConfigField<string>
readonly allowed_orgs: DeploymentConfigField<string[]>
readonly allowed_teams: DeploymentConfigField<string[]>
readonly allow_signups: DeploymentConfigField<boolean>
readonly enterprise_base_url: DeploymentConfigField<string>
}
// From codersdk/deploymentconfig.go
export interface OIDCConfig {
readonly allow_signups: DeploymentConfigField<boolean>
readonly client_id: DeploymentConfigField<string>
readonly client_secret: DeploymentConfigField<string>
readonly email_domain: DeploymentConfigField<string>
readonly issuer_url: DeploymentConfigField<string>
readonly scopes: DeploymentConfigField<string[]>
}
// From codersdk/organizations.go
export interface Organization {
readonly id: string
@@ -464,6 +490,18 @@ export interface PatchGroupRequest {
readonly avatar_url?: string
}
// From codersdk/deploymentconfig.go
export interface PprofConfig {
readonly enable: DeploymentConfigField<boolean>
readonly address: DeploymentConfigField<string>
}
// From codersdk/deploymentconfig.go
export interface PrometheusConfig {
readonly enable: DeploymentConfigField<boolean>
readonly address: DeploymentConfigField<string>
}
// From codersdk/provisionerdaemons.go
export interface ProvisionerDaemon {
readonly id: string
@@ -532,6 +570,23 @@ export interface ServerSentEvent {
readonly data: any
}
// From codersdk/deploymentconfig.go
export interface TLSConfig {
readonly enable: DeploymentConfigField<boolean>
readonly cert_file: DeploymentConfigField<string[]>
readonly client_auth: DeploymentConfigField<string>
readonly client_ca_file: DeploymentConfigField<string>
readonly key_file: DeploymentConfigField<string[]>
readonly min_version: DeploymentConfigField<string>
}
// From codersdk/deploymentconfig.go
export interface TelemetryConfig {
readonly enable: DeploymentConfigField<boolean>
readonly trace: DeploymentConfigField<boolean>
readonly url: DeploymentConfigField<string>
}
// From codersdk/templates.go
export interface Template {
readonly id: string
@@ -5,7 +5,7 @@ import TableCell from "@material-ui/core/TableCell"
import TableContainer from "@material-ui/core/TableContainer"
import TableHead from "@material-ui/core/TableHead"
import TableRow from "@material-ui/core/TableRow"
import { DeploymentConfig } from "api/typesGenerated"
import { DeploymentConfigField, Flaggable } from "api/typesGenerated"
import {
OptionDescription,
OptionName,
@@ -13,9 +13,9 @@ import {
} from "components/DeploySettingsLayout/Option"
import React from "react"
const OptionsTable: React.FC<{ options: Partial<DeploymentConfig> }> = ({
options,
}) => {
const OptionsTable: React.FC<{
options: Record<string, DeploymentConfigField<Flaggable>>
}> = ({ options }) => {
const styles = useStyles()
return (
@@ -32,7 +32,7 @@ const AuthSettingsPage: React.FC = () => {
/>
<Badges>
{deploymentConfig.oidc_client_id.value ? (
{deploymentConfig.oidc.client_id.value ? (
<EnabledBadge />
) : (
<DisabledBadge />
@@ -41,11 +41,11 @@ const AuthSettingsPage: React.FC = () => {
<OptionsTable
options={{
oidc_client_id: deploymentConfig.oidc_client_id,
oidc_allow_signups: deploymentConfig.oidc_allow_signups,
oidc_email_domain: deploymentConfig.oidc_email_domain,
oidc_issuer_url: deploymentConfig.oidc_issuer_url,
oidc_scopes: deploymentConfig.oidc_scopes,
client_id: deploymentConfig.oidc.client_id,
allow_signups: deploymentConfig.oidc.allow_signups,
email_domain: deploymentConfig.oidc.email_domain,
issuer_url: deploymentConfig.oidc.issuer_url,
scopes: deploymentConfig.oidc.scopes,
}}
/>
</div>
@@ -59,7 +59,7 @@ const AuthSettingsPage: React.FC = () => {
/>
<Badges>
{deploymentConfig.oauth2_github_client_id.value ? (
{deploymentConfig.oauth2.github.client_id.value ? (
<EnabledBadge />
) : (
<DisabledBadge />
@@ -68,15 +68,12 @@ const AuthSettingsPage: React.FC = () => {
<OptionsTable
options={{
oauth2_github_client_id: deploymentConfig.oauth2_github_client_id,
oauth2_github_allow_signups:
deploymentConfig.oauth2_github_allow_signups,
oauth2_github_allowed_orgs:
deploymentConfig.oauth2_github_allowed_orgs,
oauth2_github_allowed_teams:
deploymentConfig.oauth2_github_allowed_teams,
oauth2_github_enterprise_base_url:
deploymentConfig.oauth2_github_enterprise_base_url,
client_id: deploymentConfig.oauth2.github.client_id,
allow_signups: deploymentConfig.oauth2.github.allow_signups,
allowed_orgs: deploymentConfig.oauth2.github.allowed_orgs,
allowed_teams: deploymentConfig.oauth2.github.allowed_teams,
enterprise_base_url:
deploymentConfig.oauth2.github.enterprise_base_url,
}}
/>
</div>
@@ -22,10 +22,11 @@ const NetworkSettingsPage: React.FC = () => {
<OptionsTable
options={{
derp_server_enabled: deploymentConfig.derp_server_enabled,
derp_server_region_name: deploymentConfig.derp_server_region_name,
derp_server_stun_address: deploymentConfig.derp_server_stun_address,
derp_config_url: deploymentConfig.derp_config_url,
derp_server_enable: deploymentConfig.derp.server.enable,
derp_server_region_name: deploymentConfig.derp.server.region_name,
derp_server_stun_addresses:
deploymentConfig.derp.server.stun_addresses,
derp_config_url: deploymentConfig.derp.config.url,
}}
/>
</>
@@ -89,10 +89,10 @@ const SecuritySettingsPage: React.FC = () => {
<OptionsTable
options={{
tls_enable: deploymentConfig.tls_enable,
tls_cert_files: deploymentConfig.tls_cert_files,
tls_key_files: deploymentConfig.tls_key_files,
tls_min_version: deploymentConfig.tls_min_version,
tls_enable: deploymentConfig.tls.enable,
tls_cert_files: deploymentConfig.tls.cert_file,
tls_key_files: deploymentConfig.tls.key_file,
tls_min_version: deploymentConfig.tls.min_version,
}}
/>
</div>