From c69ba0c8d8a353ba0e295071280d1d4f074e83ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Bara=C3=BAna?= Date: Fri, 22 Nov 2024 10:25:30 -0300 Subject: [PATCH] Accepts 'auto' as value for LIVEBOOK_CLUSTER env var --- lib/livebook/config.ex | 5 ++++- test/livebook/config_test.exs | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/livebook/config.ex b/lib/livebook/config.ex index 9a8b9e97c2f..51ad1386891 100644 --- a/lib/livebook/config.ex +++ b/lib/livebook/config.ex @@ -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 diff --git a/test/livebook/config_test.exs b/test/livebook/config_test.exs index a55b13a7629..a03029b48df 100644 --- a/test/livebook/config_test.exs +++ b/test/livebook/config_test.exs @@ -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} ->