Page MenuHomeDevCentral

D3671.id9506.diff
No OneTemporary

D3671.id9506.diff

diff --git a/tools/nasqueron-reports/Dockerfile b/tools/nasqueron-reports/Dockerfile
new file mode 100644
--- /dev/null
+++ b/tools/nasqueron-reports/Dockerfile
@@ -0,0 +1,41 @@
+# -------------------------------------------------------------
+# Nasqueron Reports :: Docker image
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: BSD-2-Clause
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Build Python package
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+FROM debian:trixie AS build
+
+COPY . /app
+WORKDIR /app
+RUN apt-get update && apt install -y python3-pip python3-build git && \
+ git clone https://devcentral.nasqueron.org/source/reports.git /usr/src/reports && \
+ python3 -m build
+
+# -------------------------------------------------------------
+# Final image
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+FROM debian:trixie AS runner
+
+COPY --from=build /app/dist/nasqueron_reports-0.1.0-py3-none-any.whl /app/
+COPY --from=build /usr/src/reports/sql /usr/share/nasqueron-reports/sql
+COPY conf/reports.yaml /etc/reports.yaml
+
+RUN apt-get update && \
+ apt install -y python3-pip locales --no-install-recommends && \
+ rm -r /var/lib/apt/lists/* && \
+ sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
+ echo 'LANG="en_US.UTF-8"' > /etc/default/locale && \
+ dpkg-reconfigure --frontend=noninteractive locales && \
+ update-locale LANG=en_US.UTF-8 && \
+ pip install /app/nasqueron_reports-0.1.0-py3-none-any.whl --break-system-packages
+
+WORKDIR /app
+ENV LANG=en_US.UTF-8
+CMD ["run-report"]
diff --git a/tools/nasqueron-reports/conf/reports.yaml b/tools/nasqueron-reports/conf/reports.yaml
--- a/tools/nasqueron-reports/conf/reports.yaml
+++ b/tools/nasqueron-reports/conf/reports.yaml
@@ -5,10 +5,21 @@
# -------------------------------------------------------------
services:
+ acquisitariat:
+ connector: MySQL
+ hostname: mysql
+ credentials:
+ driver: env
+ variables:
+ username: DB_USERNAME
+ password: DB_PASSWORD
+
db-B:
connector: MariaDB
hostname: db-B-001
- credentials: ops/secrets/dbserver/cluster-B/users/rhyne-wyse
+ credentials:
+ driver: vault
+ secret: ops/secrets/dbserver/cluster-B/users/rhyne-wyse
reports:
agora-operations-grimoire-older-pages:
@@ -21,3 +32,17 @@
cols:
page_link: Article
age: Age (days)
+
+ devcentral-tokens-language-models:
+ path: sql/acquisitariat/devcentral/tokens-language-models.sql
+ service: acquisitariat
+
+ format: mediawiki
+ format_options:
+ # Mapping between query columns and table headings
+ cols:
+ revision: Revision
+ title: Commit title
+ date: Date
+ userName: Author
+ repository: Repository
diff --git a/tools/nasqueron-reports/src/nasqueron_reports/config.py b/tools/nasqueron-reports/src/nasqueron_reports/config.py
--- a/tools/nasqueron-reports/src/nasqueron_reports/config.py
+++ b/tools/nasqueron-reports/src/nasqueron_reports/config.py
@@ -11,7 +11,7 @@
import yaml
-from nasqueron_reports.credentials import vault
+from nasqueron_reports.credentials import resolve_credentials
from nasqueron_reports.errors import NasqueronReportConfigError
@@ -90,8 +90,7 @@
)
if "credentials" in report_config["service_options"]:
- secret_path = report_config["service_options"]["credentials"]
- credentials = vault.fetch_credentials(secret_path)
+ credentials = resolve_credentials(report_config["service_options"]["credentials"])
else:
credentials = {}
diff --git a/tools/nasqueron-reports/src/nasqueron_reports/credentials/__init__.py b/tools/nasqueron-reports/src/nasqueron_reports/credentials/__init__.py
--- a/tools/nasqueron-reports/src/nasqueron_reports/credentials/__init__.py
+++ b/tools/nasqueron-reports/src/nasqueron_reports/credentials/__init__.py
@@ -5,4 +5,5 @@
# License: BSD-2-Clause
# -------------------------------------------------------------
+from .credentials import resolve_credentials
from . import vault
diff --git a/tools/nasqueron-reports/src/nasqueron_reports/credentials/credentials.py b/tools/nasqueron-reports/src/nasqueron_reports/credentials/credentials.py
new file mode 100644
--- /dev/null
+++ b/tools/nasqueron-reports/src/nasqueron_reports/credentials/credentials.py
@@ -0,0 +1,38 @@
+# -------------------------------------------------------------
+# Nasqueron Reports :: Credentials :: Vault
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Description: Read credentials from Vault or OpenBao
+# License: BSD-2-Clause
+# -------------------------------------------------------------
+
+
+import os
+
+from nasqueron_reports.credentials import vault
+from nasqueron_reports.errors import NasqueronReportConfigError
+
+
+# -------------------------------------------------------------
+# Credentials wiring
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def resolve_credentials(config):
+ if config["driver"] == "vault":
+ return vault.fetch_credentials(config["secret"])
+
+ if config["driver"] == "env":
+ variables = config.get("variables", {})
+ return read_environment(variables)
+
+ raise NasqueronReportConfigError("Credentials driver parameter is missing")
+
+
+# -------------------------------------------------------------
+# Environment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def read_environment(variables):
+ return {k:os.environ.get(v, "") for k, v in variables.items()}

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 15, 17:27 (18 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2987030
Default Alt Text
D3671.id9506.diff (5 KB)

Event Timeline