mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-22 22:05:03 +08:00
Validate agent name and set default (#2483)
This commit is contained in:
parent
efc17fb01f
commit
17634f9be7
2 changed files with 10 additions and 2 deletions
|
@ -25,7 +25,7 @@ config :mime, :types, %{
|
||||||
|
|
||||||
config :livebook,
|
config :livebook,
|
||||||
teams_url: "https://teams.livebook.dev",
|
teams_url: "https://teams.livebook.dev",
|
||||||
agent_name: nil,
|
agent_name: "livebook-agent",
|
||||||
app_service_name: nil,
|
app_service_name: nil,
|
||||||
app_service_url: nil,
|
app_service_url: nil,
|
||||||
authentication_mode: :token,
|
authentication_mode: :token,
|
||||||
|
|
|
@ -594,7 +594,15 @@ defmodule Livebook.Config do
|
||||||
Parses agent name from env.
|
Parses agent name from env.
|
||||||
"""
|
"""
|
||||||
def agent_name!(env) do
|
def agent_name!(env) do
|
||||||
System.get_env(env)
|
if agent_name = System.get_env(env) do
|
||||||
|
unless agent_name =~ ~r/^[a-z0-9_\-]+$/ do
|
||||||
|
abort!(
|
||||||
|
"expected #{env} to consist of lowercase alphanumeric characters, dashes and underscores, got: #{agent_name}"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
agent_name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
Loading…
Reference in a new issue