Skip to content

Commit 2917af8

Browse files
authored
Provide support for patching TOML files (#2512)
1 parent 9d7232c commit 2917af8

File tree

4 files changed

+32
-34
lines changed

4 files changed

+32
-34
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
4949
--var version=${MC_SERVER_RUNNER_VERSION} --var app=mc-server-runner --file {{.app}} \
5050
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
5151

52-
ARG MC_HELPER_VERSION=1.36.12
52+
ARG MC_HELPER_VERSION=1.37.0
5353
ARG MC_HELPER_BASE_URL=${GITHUB_BASEURL}/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
5454
# used for cache busting local copy of mc-image-helper
5555
ARG MC_HELPER_REV=1

docs/configuration/interpolating.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ secrets:
101101

102102
## Patching existing files
103103

104-
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).
104+
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).
105105

106-
Variable placeholders in the patch values can be restricted by setting `REPLACE_ENV_VARIABLE_PREFIX`, which defaults to "CFG_".
106+
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_".
107107

108-
The following example shows a patch-set file were various fields in the `paper.yaml` configuration file can be modified and added:
108+
The following example shows a patch-set file where various fields in the `paper.yaml` configuration file can be modified and added:
109109

110110
```json
111111
{
@@ -139,4 +139,8 @@ The following example shows a patch-set file were various fields in the `paper.y
139139
}
140140
```
141141

142-
> **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.
142+
Supports the file formats:
143+
- JSON
144+
- JSON5
145+
- Yaml
146+
- TOML, but processed output is not pretty

scripts/start-setupModconfig

Lines changed: 0 additions & 28 deletions
This file was deleted.

scripts/start-setupModpack

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,26 @@ if usesMods || usesPlugins; then
299299
handleCurseForgeFiles
300300
fi
301301

302-
exec "${SCRIPTS:-/}start-setupModconfig" "$@"
302+
# If supplied with a URL for a config (simple zip of configurations), download it and unpack
303+
if [[ "$MODCONFIG" ]]; then
304+
case "X$MODCONFIG" in
305+
X[Hh][Tt][Tt][Pp]*[Zz][iI][pP])
306+
log "Downloading mod/plugin configs via HTTP"
307+
log " from $MODCONFIG ..."
308+
curl -sSL -o /tmp/modconfig.zip "$MODCONFIG"
309+
if [ "$FAMILY" = "SPIGOT" ]; then
310+
mkdir -p /data/plugins
311+
unzip -o -d /data/plugins /tmp/modconfig.zip
312+
else
313+
mkdir -p /data/config
314+
unzip -o -d /data/config /tmp/modconfig.zip
315+
fi
316+
rm -f /tmp/modconfig.zip
317+
;;
318+
*)
319+
log "Invalid URL given for modconfig: Must be HTTP or HTTPS and a ZIP file"
320+
;;
321+
esac
322+
fi
323+
324+
exec "${SCRIPTS:-/}start-setupMounts" "$@"

0 commit comments

Comments
 (0)