From 2917af8ca4ce42b01b2232b5a6e61ac3039aa8c0 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 25 Nov 2023 18:44:45 -0600 Subject: [PATCH] Provide support for patching TOML files (#2512) --- Dockerfile | 2 +- docs/configuration/interpolating.md | 12 ++++++++---- scripts/start-setupModconfig | 28 ---------------------------- scripts/start-setupModpack | 24 +++++++++++++++++++++++- 4 files changed, 32 insertions(+), 34 deletions(-) delete mode 100755 scripts/start-setupModconfig diff --git a/Dockerfile b/Dockerfile index 2d4ebe3754f..e699e35f4f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,7 +49,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \ --var version=${MC_SERVER_RUNNER_VERSION} --var app=mc-server-runner --file {{.app}} \ --from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz -ARG MC_HELPER_VERSION=1.36.12 +ARG MC_HELPER_VERSION=1.37.0 ARG MC_HELPER_BASE_URL=${GITHUB_BASEURL}/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION} # used for cache busting local copy of mc-image-helper ARG MC_HELPER_REV=1 diff --git a/docs/configuration/interpolating.md b/docs/configuration/interpolating.md index fd6647e92bf..66273413914 100644 --- a/docs/configuration/interpolating.md +++ b/docs/configuration/interpolating.md @@ -101,11 +101,11 @@ secrets: ## Patching existing files -JSON path based patches can be applied to one or more existing files by setting the variable `PATCH_DEFINITIONS` to the path of a directory that contains one or more [patch definition json files](https://github.com/itzg/mc-image-helper#patchdefinition) or a [patch set json file](https://github.com/itzg/mc-image-helper#patchset). +JSON path based patches can be applied to one or more existing files by setting the variable `PATCH_DEFINITIONS` to the path of a directory that contains one or more [patch definition json files](https://github.com/itzg/mc-image-helper#patchdefinition) or a [patch set json file](https://github.com/itzg/mc-image-helper#patchset). -Variable placeholders in the patch values can be restricted by setting `REPLACE_ENV_VARIABLE_PREFIX`, which defaults to "CFG_". +The `file` and `value` fields of the patch definitions may contain `${...}` variable placeholders. The allowed environment variables in placeholders can be restricted by setting `REPLACE_ENV_VARIABLE_PREFIX`, which defaults to "CFG_". -The following example shows a patch-set file were various fields in the `paper.yaml` configuration file can be modified and added: +The following example shows a patch-set file where various fields in the `paper.yaml` configuration file can be modified and added: ```json { @@ -139,4 +139,8 @@ The following example shows a patch-set file were various fields in the `paper.y } ``` -> **NOTES:** Only JSON and Yaml files can be patched at this time. TOML support is planned to be added next. Removal of comments and other cosmetic changes will occur when patched files are processed. +Supports the file formats: +- JSON +- JSON5 +- Yaml +- TOML, but processed output is not pretty diff --git a/scripts/start-setupModconfig b/scripts/start-setupModconfig deleted file mode 100755 index aeab818daae..00000000000 --- a/scripts/start-setupModconfig +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# shellcheck source=start-utils -. "${SCRIPTS:-/}start-utils" - -# If supplied with a URL for a config (simple zip of configurations), download it and unpack -if [[ "$MODCONFIG" ]]; then -case "X$MODCONFIG" in - X[Hh][Tt][Tt][Pp]*[Zz][iI][pP]) - log "Downloading mod/plugin configs via HTTP" - log " from $MODCONFIG ..." - curl -sSL -o /tmp/modconfig.zip "$MODCONFIG" - if [ "$FAMILY" = "SPIGOT" ]; then - mkdir -p /data/plugins - unzip -o -d /data/plugins /tmp/modconfig.zip - else - mkdir -p /data/config - unzip -o -d /data/config /tmp/modconfig.zip - fi - rm -f /tmp/modconfig.zip - ;; - *) - log "Invalid URL given for modconfig: Must be HTTP or HTTPS and a ZIP file" - ;; -esac -fi - -exec "${SCRIPTS:-/}start-setupMounts" "$@" diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index c78e9270b24..e20d73f16b1 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -299,4 +299,26 @@ if usesMods || usesPlugins; then handleCurseForgeFiles fi -exec "${SCRIPTS:-/}start-setupModconfig" "$@" +# If supplied with a URL for a config (simple zip of configurations), download it and unpack +if [[ "$MODCONFIG" ]]; then +case "X$MODCONFIG" in + X[Hh][Tt][Tt][Pp]*[Zz][iI][pP]) + log "Downloading mod/plugin configs via HTTP" + log " from $MODCONFIG ..." + curl -sSL -o /tmp/modconfig.zip "$MODCONFIG" + if [ "$FAMILY" = "SPIGOT" ]; then + mkdir -p /data/plugins + unzip -o -d /data/plugins /tmp/modconfig.zip + else + mkdir -p /data/config + unzip -o -d /data/config /tmp/modconfig.zip + fi + rm -f /tmp/modconfig.zip + ;; + *) + log "Invalid URL given for modconfig: Must be HTTP or HTTPS and a ZIP file" + ;; +esac +fi + +exec "${SCRIPTS:-/}start-setupMounts" "$@"