Use xq for XML parsing instead of inline python

This commit is contained in:
crazymanjinn 2019-07-12 21:02:10 -04:00
parent 1531e38ab6
commit 511912acc1
2 changed files with 3 additions and 15 deletions

View File

@ -18,7 +18,7 @@ RUN apk add --no-cache -U \
nano \
python python-dev py2-pip
RUN pip install mcstatus
RUN pip install mcstatus yq
HEALTHCHECK CMD mcstatus localhost:$SERVER_PORT ping

View File

@ -10,20 +10,8 @@ if [[ -z $FABRIC_INSTALLER && -z $FABRIC_INSTALLER_URL ]]; then
echo "Checking Fabric version information."
case $FABRICVERSION in
LATEST)
FABRIC_VERSION=$(python - << 'EOF'
import sys
import xml.etree.ElementTree as ET
from contextlib import closing
from urllib2 import urlopen
with closing(urlopen('https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml')) as resp:
xml = resp.read()
root = ET.fromstring(xml)
version = root.find('*/release').text
print version
EOF
)
curl -fsSL https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml | xq -c . > /tmp/fabric.json
FABRIC_VERSION=$(< /tmp/fabric.json jq -r ".metadata.versioning.release")
;;
*)