Do not trim Ecto.Enum values in docs generator (#1495)

Closes #1494
This commit is contained in:
Andrew Dryga
2023-03-09 17:44:43 -06:00
committed by GitHub
parent 0eeeee0ab2
commit 08ef4518b4
3 changed files with 35 additions and 4 deletions

View File

@@ -67,6 +67,17 @@ defmodule FzHttp.ConfigTest do
|> FzHttp.Validator.normalize_url(key)
end
)
defconfig(
:enum,
{:parameterized, Ecto.Enum, Ecto.Enum.init(values: [:value1, :value2, __MODULE__])},
default: :value1,
dump: fn
:value1 -> :foo
:value2 -> __MODULE__
other -> other
end
)
end
describe "fetch_source_and_config!/1" do
@@ -327,6 +338,28 @@ defmodule FzHttp.ConfigTest do
compile_config!(Test, :sensitive, %{"SENSITIVE" => "foo"})
end
end
test "returns error on invalid enum values" do
message = """
Invalid configuration for 'enum' retrieved from environment variable ENUM.
Errors:
- `"foo"`: is invalid\
"""
assert_raise RuntimeError, message, fn ->
compile_config!(Test, :enum, %{"ENUM" => "foo"})
end
end
test "casts module name enums" do
assert compile_config!(Test, :enum, %{"ENUM" => "value1"}) == :foo
assert compile_config!(Test, :enum, %{"ENUM" => "value2"}) == FzHttp.ConfigTest.Test
assert compile_config!(Test, :enum, %{"ENUM" => "Elixir.FzHttp.ConfigTest.Test"}) ==
FzHttp.ConfigTest.Test
end
end
describe "validate_runtime_config!/0" do

View File

@@ -105,13 +105,11 @@ defmodule DocsGenerator do
# DEPRECATION 0.8: We remove legacy keys here to prevent people from using it in new installs
|> Kernel.--([:smtp, :mailgun, :mandrill, :sendgrid, :post_mark, :sendmail])
|> Enum.map(&to_string/1)
|> Enum.map(&String.trim_leading(&1, "Elixir."))
|> Enum.map_join(", ", &"`#{&1}`")
default =
default
|> Atom.to_string()
|> String.trim_leading("Elixir.")
{"One of #{values}", "`#{default}`"}
end

View File

@@ -41,7 +41,7 @@ default). Required fields in **bold**.
| **EXTERNAL_URL** | The external URL the web UI will be accessible at.<br /> <br />Must be a valid and public FQDN for ACME SSL issuance to function.<br /> <br />You can add a path suffix if you want to serve firezone from a non-root path, eg: `https://firezone.mycorp.com/vpn`. | string | |
| PHOENIX_SECURE_COOKIES | Enable or disable requiring secure cookies. Required for HTTPS. | boolean | true |
| PHOENIX_HTTP_PORT | Internal port to listen on for the Phoenix web server. | integer | 13000 |
| PHOENIX_HTTP_PROTOCOL_OPTIONS | Allows to override Cowboy HTTP server options.<br /> <br />Keep in mind though changing those limits can pose a security risk. Other times, browsers and proxies along the way may have equally strict limits, which means the request will still fail or the URL will be pruned.<br /> <br />You can see all supported options at https://ninenines.eu/docs/en/cowboy/2.5/manual/cowboy_http/. | JSON-encoded map | `"[]"` |
| PHOENIX_HTTP_PROTOCOL_OPTIONS | Allows to override Cowboy HTTP server options.<br /> <br />Keep in mind though changing those limits can pose a security risk. Other times, browsers and proxies along the way may have equally strict limits, which means the request will still fail or the URL will be pruned.<br /> <br />You can see all supported options at https://ninenines.eu/docs/en/cowboy/2.5/manual/cowboy_http/. | JSON-encoded map | `{}` |
| PHOENIX_EXTERNAL_TRUSTED_PROXIES | List of trusted reverse proxies.<br /> <br />This is used to determine the correct IP address of the client when the application is behind a reverse proxy by skipping a trusted proxy IP from a list of possible source IPs. | JSON-encoded list | `"[]"` |
| PHOENIX_PRIVATE_CLIENTS | List of trusted clients.<br /> <br />This is used to determine the correct IP address of the client when the application is behind a reverse proxy by picking a trusted client IP from a list of possible source IPs. | JSON-encoded list | `"[]"` |
@@ -123,7 +123,7 @@ All secrets should be a **base64-encoded string**.
| Env Key | Description | Format | Default |
| ------ | --------------- | ------ | ------- |
| OUTBOUND_EMAIL_FROM | From address to use for sending outbound emails. If not set, sending email will be disabled (default). | string | generated |
| OUTBOUND_EMAIL_ADAPTER | Method to use for sending outbound email. | One of `Swoosh.Adapters.AmazonSES`, `Swoosh.Adapters.CustomerIO`, `Swoosh.Adapters.Dyn`, `Swoosh.Adapters.ExAwsAmazonSES`, `Swoosh.Adapters.Gmail`, `Swoosh.Adapters.MailPace`, `Swoosh.Adapters.Mailgun`, `Swoosh.Adapters.Mailjet`, `Swoosh.Adapters.Mandrill`, `Swoosh.Adapters.Postmark`, `Swoosh.Adapters.ProtonBridge`, `Swoosh.Adapters.SMTP`, `Swoosh.Adapters.SMTP2GO`, `Swoosh.Adapters.Sendgrid`, `Swoosh.Adapters.Sendinblue`, `Swoosh.Adapters.Sendmail`, `Swoosh.Adapters.SocketLabs`, `Swoosh.Adapters.SparkPost`, `FzHttpWeb.Mailer.NoopAdapter` | `FzHttpWeb.Mailer.NoopAdapter` |
| OUTBOUND_EMAIL_ADAPTER | Method to use for sending outbound email. | One of `Elixir.Swoosh.Adapters.AmazonSES`, `Elixir.Swoosh.Adapters.CustomerIO`, `Elixir.Swoosh.Adapters.Dyn`, `Elixir.Swoosh.Adapters.ExAwsAmazonSES`, `Elixir.Swoosh.Adapters.Gmail`, `Elixir.Swoosh.Adapters.MailPace`, `Elixir.Swoosh.Adapters.Mailgun`, `Elixir.Swoosh.Adapters.Mailjet`, `Elixir.Swoosh.Adapters.Mandrill`, `Elixir.Swoosh.Adapters.Postmark`, `Elixir.Swoosh.Adapters.ProtonBridge`, `Elixir.Swoosh.Adapters.SMTP`, `Elixir.Swoosh.Adapters.SMTP2GO`, `Elixir.Swoosh.Adapters.Sendgrid`, `Elixir.Swoosh.Adapters.Sendinblue`, `Elixir.Swoosh.Adapters.Sendmail`, `Elixir.Swoosh.Adapters.SocketLabs`, `Elixir.Swoosh.Adapters.SparkPost`, `Elixir.FzHttpWeb.Mailer.NoopAdapter` | `Elixir.FzHttpWeb.Mailer.NoopAdapter` |
| OUTBOUND_EMAIL_ADAPTER_OPTS | Adapter configuration, for list of options see [Swoosh Adapters](https://github.com/swoosh/swoosh#adapters). | JSON-encoded map | `{}` |
### Connectivity Checks