Skip to content

Commit

Permalink
Provide support for patching TOML files (#2512)
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg authored Nov 26, 2023
1 parent 9d7232c commit 2917af8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions docs/configuration/interpolating.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
28 changes: 0 additions & 28 deletions scripts/start-setupModconfig

This file was deleted.

24 changes: 23 additions & 1 deletion scripts/start-setupModpack
Original file line number Diff line number Diff line change
Expand Up @@ -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" "$@"

0 comments on commit 2917af8

Please sign in to comment.