Skip to content

Commit

Permalink
Accepts 'auto' as value for LIVEBOOK_CLUSTER env var
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobarauna committed Nov 22, 2024
1 parent 692251d commit c69ba0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/livebook/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,11 @@ defmodule Livebook.Config do
"dns:" <> query ->
query

"auto" ->
"auto"

other ->
abort!(~s{expected #{env} to be "dns:query", got: #{inspect(other)}})
abort!(~s{expected #{env} to be either "dns:query" or "auto", got: #{inspect(other)}})
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions test/livebook/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ defmodule Livebook.ConfigTest do
end
end

describe "dns_cluster_query!/1" do
test "parses DNS query" do
with_env([TEST_LIVEBOOK_CLUSTER: "dns:myapp.internal"], fn ->
assert Config.dns_cluster_query!("TEST_LIVEBOOK_CLUSTER") == "myapp.internal"
end)
end

test "parses auto mode" do
with_env([TEST_LIVEBOOK_CLUSTER: "auto"], fn ->
assert Config.dns_cluster_query!("TEST_LIVEBOOK_CLUSTER") == "auto"
end)
end
end

defp with_env(env_vars, fun) do
existing =
Enum.map(env_vars, fn {env, _value} ->
Expand Down

0 comments on commit c69ba0c

Please sign in to comment.