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,
|
plugins_dir,
|
||||||
static,
|
static,
|
||||||
install,
|
install,
|
||||||
|
plugin_secret,
|
||||||
version_note,
|
version_note,
|
||||||
title,
|
title,
|
||||||
license,
|
license,
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,13 @@ def add_common_publish_arguments_and_options(subcommand):
|
||||||
help="Additional packages (e.g. plugins) to install",
|
help="Additional packages (e.g. plugins) to install",
|
||||||
multiple=True,
|
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(
|
click.option(
|
||||||
"--version-note", help="Additional note to show on /-/versions"
|
"--version-note", help="Additional note to show on /-/versions"
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ def publish_subcommand(publish):
|
||||||
plugins_dir,
|
plugins_dir,
|
||||||
static,
|
static,
|
||||||
install,
|
install,
|
||||||
|
plugin_secret,
|
||||||
version_note,
|
version_note,
|
||||||
title,
|
title,
|
||||||
license,
|
license,
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ def publish_subcommand(publish):
|
||||||
plugins_dir,
|
plugins_dir,
|
||||||
static,
|
static,
|
||||||
install,
|
install,
|
||||||
|
plugin_secret,
|
||||||
version_note,
|
version_note,
|
||||||
title,
|
title,
|
||||||
license,
|
license,
|
||||||
|
|
@ -54,6 +55,30 @@ def publish_subcommand(publish):
|
||||||
extra_options = ""
|
extra_options = ""
|
||||||
extra_options += "--config force_https_urls:on"
|
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(
|
with temporary_docker_directory(
|
||||||
files,
|
files,
|
||||||
name,
|
name,
|
||||||
|
|
@ -66,15 +91,8 @@ def publish_subcommand(publish):
|
||||||
install,
|
install,
|
||||||
spatialite,
|
spatialite,
|
||||||
version_note,
|
version_note,
|
||||||
{
|
extra_metadata,
|
||||||
"title": title,
|
environment_variables,
|
||||||
"license": license,
|
|
||||||
"license_url": license_url,
|
|
||||||
"source": source,
|
|
||||||
"source_url": source_url,
|
|
||||||
"about": about,
|
|
||||||
"about_url": about_url,
|
|
||||||
},
|
|
||||||
):
|
):
|
||||||
now_json = {"version": 1}
|
now_json = {"version": 1}
|
||||||
open("now.json", "w").write(json.dumps(now_json, indent=4))
|
open("now.json", "w").write(json.dumps(now_json, indent=4))
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,7 @@ def make_dockerfile(
|
||||||
install,
|
install,
|
||||||
spatialite,
|
spatialite,
|
||||||
version_note,
|
version_note,
|
||||||
|
environment_variables=None,
|
||||||
):
|
):
|
||||||
cmd = ["datasette", "serve", "--host", "0.0.0.0"]
|
cmd = ["datasette", "serve", "--host", "0.0.0.0"]
|
||||||
for filename in files:
|
for filename in files:
|
||||||
|
|
@ -307,11 +308,18 @@ FROM python:3.6
|
||||||
COPY . /app
|
COPY . /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
{spatialite_extras}
|
{spatialite_extras}
|
||||||
|
{environment_variables}
|
||||||
RUN pip install -U {install_from}
|
RUN pip install -U {install_from}
|
||||||
RUN datasette inspect {files} --inspect-file inspect-data.json
|
RUN datasette inspect {files} --inspect-file inspect-data.json
|
||||||
ENV PORT 8001
|
ENV PORT 8001
|
||||||
EXPOSE 8001
|
EXPOSE 8001
|
||||||
CMD {cmd}""".format(
|
CMD {cmd}""".format(
|
||||||
|
environment_variables="\n".join(
|
||||||
|
[
|
||||||
|
"ENV {} {}".format(key, value)
|
||||||
|
for key, value in (environment_variables or {}).items()
|
||||||
|
]
|
||||||
|
),
|
||||||
files=" ".join(files),
|
files=" ".join(files),
|
||||||
cmd=cmd,
|
cmd=cmd,
|
||||||
install_from=" ".join(install),
|
install_from=" ".join(install),
|
||||||
|
|
@ -333,6 +341,7 @@ def temporary_docker_directory(
|
||||||
spatialite,
|
spatialite,
|
||||||
version_note,
|
version_note,
|
||||||
extra_metadata=None,
|
extra_metadata=None,
|
||||||
|
environment_variables=None,
|
||||||
):
|
):
|
||||||
extra_metadata = extra_metadata or {}
|
extra_metadata = extra_metadata or {}
|
||||||
tmp = tempfile.TemporaryDirectory()
|
tmp = tempfile.TemporaryDirectory()
|
||||||
|
|
@ -361,6 +370,7 @@ def temporary_docker_directory(
|
||||||
install,
|
install,
|
||||||
spatialite,
|
spatialite,
|
||||||
version_note,
|
version_note,
|
||||||
|
environment_variables,
|
||||||
)
|
)
|
||||||
os.chdir(datasette_dir)
|
os.chdir(datasette_dir)
|
||||||
if metadata_content:
|
if metadata_content:
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ Options:
|
||||||
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
||||||
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
||||||
--install TEXT Additional packages (e.g. plugins) to install
|
--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
|
--version-note TEXT Additional note to show on /-/versions
|
||||||
--title TEXT Title for metadata
|
--title TEXT Title for metadata
|
||||||
--license TEXT License label for metadata
|
--license TEXT License label for metadata
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ Options:
|
||||||
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
||||||
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
||||||
--install TEXT Additional packages (e.g. plugins) to install
|
--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
|
--version-note TEXT Additional note to show on /-/versions
|
||||||
--title TEXT Title for metadata
|
--title TEXT Title for metadata
|
||||||
--license TEXT License label for metadata
|
--license TEXT License label for metadata
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ Options:
|
||||||
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
--plugins-dir DIRECTORY Path to directory containing custom plugins
|
||||||
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
--static STATIC MOUNT mountpoint:path-to-directory for serving static files
|
||||||
--install TEXT Additional packages (e.g. plugins) to install
|
--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
|
--version-note TEXT Additional note to show on /-/versions
|
||||||
--title TEXT Title for metadata
|
--title TEXT Title for metadata
|
||||||
--license TEXT License label for metadata
|
--license TEXT License label for metadata
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue