mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-04 20:14:57 +08:00
Escape quotes in generated dockerfile env vars
This commit is contained in:
parent
e6676cca58
commit
ab182ffecb
2 changed files with 7 additions and 3 deletions
|
@ -247,7 +247,9 @@ defmodule Livebook.Hubs.Dockerfile do
|
|||
defp format_envs([]), do: nil
|
||||
|
||||
defp format_envs(list) do
|
||||
Enum.map_join(list, fn {key, value} -> ~s/ENV #{key} "#{value}"\n/ end)
|
||||
Enum.map_join(list, fn {key, value} ->
|
||||
~s/ENV #{key} "#{String.replace(value, ~S["], ~S[\"])}"\n/
|
||||
end)
|
||||
end
|
||||
|
||||
defp encrypt_secrets_to_dockerfile(secrets, hub) do
|
||||
|
|
|
@ -210,7 +210,8 @@ defmodule Livebook.Hubs.DockerfileTest do
|
|||
dockerfile_config()
|
||||
| environment_variables: [
|
||||
{"LIVEBOOK_IDENTITY_PROVIDER", "cloudflare:foobar"},
|
||||
{"LIVEBOOK_TEAMS_URL", "http://localhost:8000"}
|
||||
{"LIVEBOOK_TEAMS_URL", "http://localhost:8000"},
|
||||
{"MY_JSON", ~S|{"foo": "bar"}|}
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -222,7 +223,8 @@ defmodule Livebook.Hubs.DockerfileTest do
|
|||
assert dockerfile =~ """
|
||||
# Deployment group environment variables
|
||||
ENV LIVEBOOK_IDENTITY_PROVIDER "cloudflare:foobar"
|
||||
ENV LIVEBOOK_TEAMS_URL "http://localhost:8000"\
|
||||
ENV LIVEBOOK_TEAMS_URL "http://localhost:8000"
|
||||
ENV MY_JSON "{\\"foo\\": \\"bar\\"}"\
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue