mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Smarter merging of metadata and extra_metadata, closes #724
This commit is contained in:
parent
d55fe8cdfc
commit
d349d57cdf
3 changed files with 21 additions and 6 deletions
|
|
@ -4,6 +4,7 @@ import base64
|
||||||
import click
|
import click
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
import mergedeep
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
|
@ -363,9 +364,11 @@ def temporary_docker_directory(
|
||||||
metadata_content = parse_metadata(metadata.read())
|
metadata_content = parse_metadata(metadata.read())
|
||||||
else:
|
else:
|
||||||
metadata_content = {}
|
metadata_content = {}
|
||||||
for key, value in extra_metadata.items():
|
# Merge in the non-null values in extra_metadata
|
||||||
if value:
|
mergedeep.merge(
|
||||||
metadata_content[key] = value
|
metadata_content,
|
||||||
|
{key: value for key, value in extra_metadata.items() if value is not None},
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
dockerfile = make_dockerfile(
|
dockerfile = make_dockerfile(
|
||||||
file_names,
|
file_names,
|
||||||
|
|
|
||||||
1
setup.py
1
setup.py
|
|
@ -46,6 +46,7 @@ setup(
|
||||||
"aiofiles~=0.4.0",
|
"aiofiles~=0.4.0",
|
||||||
"janus~=0.4.0",
|
"janus~=0.4.0",
|
||||||
"PyYAML~=5.3",
|
"PyYAML~=5.3",
|
||||||
|
"mergedeep~=1.1.1",
|
||||||
],
|
],
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[console_scripts]
|
[console_scripts]
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
from datasette import cli
|
from datasette import cli
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
import pytest
|
|
||||||
import json
|
import json
|
||||||
|
import pytest
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
|
||||||
@mock.patch("shutil.which")
|
@mock.patch("shutil.which")
|
||||||
|
|
@ -146,7 +147,16 @@ def test_publish_cloudrun_plugin_secrets(mock_call, mock_output, mock_which):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
with runner.isolated_filesystem():
|
with runner.isolated_filesystem():
|
||||||
open("test.db", "w").write("data")
|
open("test.db", "w").write("data")
|
||||||
open("metadata.yml", "w").write("title: Hello from metadata YAML")
|
open("metadata.yml", "w").write(
|
||||||
|
textwrap.dedent(
|
||||||
|
"""
|
||||||
|
title: Hello from metadata YAML
|
||||||
|
plugins:
|
||||||
|
datasette-auth-github:
|
||||||
|
foo: bar
|
||||||
|
"""
|
||||||
|
).strip()
|
||||||
|
)
|
||||||
result = runner.invoke(
|
result = runner.invoke(
|
||||||
cli.cli,
|
cli.cli,
|
||||||
[
|
[
|
||||||
|
|
@ -189,7 +199,8 @@ CMD datasette serve --host 0.0.0.0 -i test.db --cors --inspect-file inspect-data
|
||||||
"title": "Hello from metadata YAML",
|
"title": "Hello from metadata YAML",
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"datasette-auth-github": {
|
"datasette-auth-github": {
|
||||||
"client_id": {"$env": "DATASETTE_AUTH_GITHUB_CLIENT_ID"}
|
"foo": "bar",
|
||||||
|
"client_id": {"$env": "DATASETTE_AUTH_GITHUB_CLIENT_ID"},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
} == json.loads(metadata)
|
} == json.loads(metadata)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue