From 734292bfe1a2301720bbdb526baed7f9561eb368 Mon Sep 17 00:00:00 2001 From: Nicola Lorenz Date: Mon, 9 Sep 2024 09:36:38 +0200 Subject: [PATCH] Add option to dump current schemas to bundle loader --- changes/TI-948.other | 1 + docker/core/Dockerfile | 6 +++++- opengever/bundle/console.py | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changes/TI-948.other diff --git a/changes/TI-948.other b/changes/TI-948.other new file mode 100644 index 0000000000..a822b7664c --- /dev/null +++ b/changes/TI-948.other @@ -0,0 +1 @@ +Add option to regenerate bundle schemas on bundle import [TI-948](https://4teamwork.atlassian.net/browse/TI-948) diff --git a/docker/core/Dockerfile b/docker/core/Dockerfile index 043ed57742..f9637ec505 100644 --- a/docker/core/Dockerfile +++ b/docker/core/Dockerfile @@ -69,6 +69,10 @@ RUN --mount=type=cache,target=/root/.cache \ RUN find /app/opengever -name "*.po" | xargs -I@ sh -c 'msgfmt @ -o "$(dirname @)/$(basename @ .po)".mo' && \ find /app/plonetheme -name "*.po" | xargs -I@ sh -c 'msgfmt @ -o "$(dirname @)/$(basename @ .po)".mo' +# Plone needs permissions to update bundle schemas on import +RUN chown plone:plone /app/opengever/bundle/schemas && \ + chown plone:plone /app/opengever/bundle/schemas/* + COPY ./docker/core/etc /app/etc RUN chown -R plone:plone /app/etc COPY ./docker/core/entrypoint.d /app/entrypoint.d @@ -88,7 +92,7 @@ RUN mkdir -p /app/var/log /app/var/instance \ RUN ln -sf /dev/null /app/var/log/upgrade_stats.csv -# Patch cacert.pem with a recent version to address CVE-2023-37920 +# Patch cacert.pem with a recent version to address CVE-2023-37920 RUN wget -O /app/lib/python2.7/site-packages/certifi/cacert.pem https://raw.githubusercontent.com/certifi/python-certifi/2024.02.02/certifi/cacert.pem # Patch ftw.bumblebee to use time.time() for timestamp generation diff --git a/opengever/bundle/console.py b/opengever/bundle/console.py index 2f25432d71..8e43d4a1e9 100644 --- a/opengever/bundle/console.py +++ b/opengever/bundle/console.py @@ -2,6 +2,8 @@ from Products.Archetypes import atapi # noqa # isort:skip from opengever.base.interfaces import IOpengeverBaseLayer from opengever.base.pathfinder import PathFinder +from opengever.base.schemadump.schema import dump_oggbundle_schemas +from opengever.base.schemadump.schema import OGGBundleJSONSchemaDumpWriter from opengever.bundle.config.importer import ConfigImporter from opengever.bundle.importer import BundleImporter from opengever.core.debughelpers import get_first_plone_site @@ -33,6 +35,8 @@ def parse_args(argv): help="Don't to intermediate commits") parser.add_argument('--no-check-unique-principals', action='store_true', help="Don't to check for OGDS principal name uniqueness") + parser.add_argument('--rebuild-schemas', action='store_true', + help="Rebuild schemas with current schemas") args = parser.parse_args(argv) return args @@ -60,6 +64,11 @@ def import_oggbundle(app, args): import_config_from_bundle(app, args) + if args.rebuild_schemas: + log.info('Generating and dumping latest OGGBundle JSON Schemas') + writer = OGGBundleJSONSchemaDumpWriter() + writer.dump() + importer = BundleImporter( plone, args.bundle_path,