mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
--plugin-secret option, refs #543
This commit is contained in:
parent
fcfcae21e6
commit
c207453e03
8 changed files with 52 additions and 9 deletions
|
|
@ -33,6 +33,7 @@ def publish_subcommand(publish):
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
plugin_secret,
|
||||
version_note,
|
||||
title,
|
||||
license,
|
||||
|
|
|
|||
|
|
@ -41,6 +41,13 @@ def add_common_publish_arguments_and_options(subcommand):
|
|||
help="Additional packages (e.g. plugins) to install",
|
||||
multiple=True,
|
||||
),
|
||||
click.option(
|
||||
"--plugin-secret",
|
||||
nargs=3,
|
||||
type=str,
|
||||
multiple=True,
|
||||
help="Secrets to pass to plugins, e.g. --plugin-secret datasette-auth-github client_id xxx",
|
||||
),
|
||||
click.option(
|
||||
"--version-note", help="Additional note to show on /-/versions"
|
||||
),
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ def publish_subcommand(publish):
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
plugin_secret,
|
||||
version_note,
|
||||
title,
|
||||
license,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ def publish_subcommand(publish):
|
|||
plugins_dir,
|
||||
static,
|
||||
install,
|
||||
plugin_secret,
|
||||
version_note,
|
||||
title,
|
||||
license,
|
||||
|
|
@ -54,6 +55,30 @@ def publish_subcommand(publish):
|
|||
extra_options = ""
|
||||
extra_options += "--config force_https_urls:on"
|
||||
|
||||
extra_metadata = {
|
||||
"title": title,
|
||||
"license": license,
|
||||
"license_url": license_url,
|
||||
"source": source,
|
||||
"source_url": source_url,
|
||||
"about": about,
|
||||
"about_url": about_url,
|
||||
}
|
||||
|
||||
environment_variables = {}
|
||||
if plugin_secret:
|
||||
extra_metadata["plugins"] = {}
|
||||
for plugin_name, plugin_setting, setting_value in plugin_secret:
|
||||
environment_variable = (
|
||||
"{}_{}".format(plugin_name, plugin_setting)
|
||||
.upper()
|
||||
.replace("-", "_")
|
||||
)
|
||||
environment_variables[environment_variable] = setting_value
|
||||
extra_metadata["plugins"].setdefault(plugin_name, {})[
|
||||
plugin_setting
|
||||
] = {"$env": environment_variable}
|
||||
|
||||
with temporary_docker_directory(
|
||||
files,
|
||||
name,
|
||||
|
|
@ -66,15 +91,8 @@ def publish_subcommand(publish):
|
|||
install,
|
||||
spatialite,
|
||||
version_note,
|
||||
{
|
||||
"title": title,
|
||||
"license": license,
|
||||
"license_url": license_url,
|
||||
"source": source,
|
||||
"source_url": source_url,
|
||||
"about": about,
|
||||
"about_url": about_url,
|
||||
},
|
||||
extra_metadata,
|
||||
environment_variables,
|
||||
):
|
||||
now_json = {"version": 1}
|
||||
open("now.json", "w").write(json.dumps(now_json, indent=4))
|
||||
|
|
|
|||
|
|
@ -272,6 +272,7 @@ def make_dockerfile(
|
|||
install,
|
||||
spatialite,
|
||||
version_note,
|
||||
environment_variables=None,
|
||||
):
|
||||
cmd = ["datasette", "serve", "--host", "0.0.0.0"]
|
||||
for filename in files:
|
||||
|
|
@ -307,11 +308,18 @@ FROM python:3.6
|
|||
COPY . /app
|
||||
WORKDIR /app
|
||||
{spatialite_extras}
|
||||
{environment_variables}
|
||||
RUN pip install -U {install_from}
|
||||
RUN datasette inspect {files} --inspect-file inspect-data.json
|
||||
ENV PORT 8001
|
||||
EXPOSE 8001
|
||||
CMD {cmd}""".format(
|
||||
environment_variables="\n".join(
|
||||
[
|
||||
"ENV {} {}".format(key, value)
|
||||
for key, value in (environment_variables or {}).items()
|
||||
]
|
||||
),
|
||||
files=" ".join(files),
|
||||
cmd=cmd,
|
||||
install_from=" ".join(install),
|
||||
|
|
@ -333,6 +341,7 @@ def temporary_docker_directory(
|
|||
spatialite,
|
||||
version_note,
|
||||
extra_metadata=None,
|
||||
environment_variables=None,
|
||||
):
|
||||
extra_metadata = extra_metadata or {}
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
|
|
@ -361,6 +370,7 @@ def temporary_docker_directory(
|
|||
install,
|
||||
spatialite,
|
||||
version_note,
|
||||
environment_variables,
|
||||
)
|
||||
os.chdir(datasette_dir)
|
||||
if metadata_content:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ Options:
|
|||
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
||||
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
||||
--install TEXT Additional packages (e.g. plugins) to install
|
||||
--plugin-secret TEXT... Secrets to pass to plugins, e.g. --plugin-secret datasette-
|
||||
auth-github client_id xxx
|
||||
--version-note TEXT Additional note to show on /-/versions
|
||||
--title TEXT Title for metadata
|
||||
--license TEXT License label for metadata
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ Options:
|
|||
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
||||
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
||||
--install TEXT Additional packages (e.g. plugins) to install
|
||||
--plugin-secret TEXT... Secrets to pass to plugins, e.g. --plugin-secret datasette-
|
||||
auth-github client_id xxx
|
||||
--version-note TEXT Additional note to show on /-/versions
|
||||
--title TEXT Title for metadata
|
||||
--license TEXT License label for metadata
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ Options:
|
|||
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
||||
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
||||
--install TEXT Additional packages (e.g. plugins) to install
|
||||
--plugin-secret TEXT... Secrets to pass to plugins, e.g. --plugin-secret datasette-
|
||||
auth-github client_id xxx
|
||||
--version-note TEXT Additional note to show on /-/versions
|
||||
--title TEXT Title for metadata
|
||||
--license TEXT License label for metadata
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue