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 hashlib
|
||||
import json
|
||||
import mergedeep
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
|
|
@ -363,9 +364,11 @@ def temporary_docker_directory(
|
|||
metadata_content = parse_metadata(metadata.read())
|
||||
else:
|
||||
metadata_content = {}
|
||||
for key, value in extra_metadata.items():
|
||||
if value:
|
||||
metadata_content[key] = value
|
||||
# Merge in the non-null values in extra_metadata
|
||||
mergedeep.merge(
|
||||
metadata_content,
|
||||
{key: value for key, value in extra_metadata.items() if value is not None},
|
||||
)
|
||||
try:
|
||||
dockerfile = make_dockerfile(
|
||||
file_names,
|
||||
|
|
|
|||
1
setup.py
1
setup.py
|
|
@ -46,6 +46,7 @@ setup(
|
|||
"aiofiles~=0.4.0",
|
||||
"janus~=0.4.0",
|
||||
"PyYAML~=5.3",
|
||||
"mergedeep~=1.1.1",
|
||||
],
|
||||
entry_points="""
|
||||
[console_scripts]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
from click.testing import CliRunner
|
||||
from datasette import cli
|
||||
from unittest import mock
|
||||
import pytest
|
||||
import json
|
||||
import pytest
|
||||
import textwrap
|
||||
|
||||
|
||||
@mock.patch("shutil.which")
|
||||
|
|
@ -146,7 +147,16 @@ def test_publish_cloudrun_plugin_secrets(mock_call, mock_output, mock_which):
|
|||
runner = CliRunner()
|
||||
with runner.isolated_filesystem():
|
||||
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(
|
||||
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",
|
||||
"plugins": {
|
||||
"datasette-auth-github": {
|
||||
"client_id": {"$env": "DATASETTE_AUTH_GITHUB_CLIENT_ID"}
|
||||
"foo": "bar",
|
||||
"client_id": {"$env": "DATASETTE_AUTH_GITHUB_CLIENT_ID"},
|
||||
}
|
||||
},
|
||||
} == json.loads(metadata)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue