Commit ca1280fe by Felix Abecassis

lxc-oci: rely on jq instead of sed to transform values

parent 4b42266d
...@@ -63,7 +63,7 @@ getconfigpath() { ...@@ -63,7 +63,7 @@ getconfigpath() {
basedir="$1" basedir="$1"
q="$2" q="$2"
digest=`cat "${basedir}/index.json" | jq --arg q "$q" '.manifests[] | if .annotations."org.opencontainers.image.ref.name" == $q then .digest else null end' | sed -e 's/"//g'` digest=`cat "${basedir}/index.json" | jq -c -r --arg q "$q" '.manifests[] | if .annotations."org.opencontainers.image.ref.name" == $q then .digest else null end'`
if [ -z "${digest}" ]; then if [ -z "${digest}" ]; then
echo "$q not found in index.json" >&2 echo "$q not found in index.json" >&2
return return
...@@ -71,7 +71,7 @@ getconfigpath() { ...@@ -71,7 +71,7 @@ getconfigpath() {
# Ok we have the image config digest, now get the config from that, # Ok we have the image config digest, now get the config from that,
d=${digest:7} d=${digest:7}
cdigest=`cat "${basedir}/blobs/sha256/${d}" | jq '.config.digest' | sed -e 's/"//g'` cdigest=`cat "${basedir}/blobs/sha256/${d}" | jq -c -r '.config.digest'`
if [ -z "${cdigest}" ]; then if [ -z "${cdigest}" ]; then
echo "container config not found" >&2 echo "container config not found" >&2
return return
...@@ -91,22 +91,18 @@ getep() { ...@@ -91,22 +91,18 @@ getep() {
configpath="$1" configpath="$1"
ep=`cat "${configpath}" | jq -c '.config.Entrypoint' | sed -e 's/^\[//; s/\]$//; s/","/" "/'` ep=`cat "${configpath}" | jq -c -r '.config.Entrypoint[]?'`
cmd=`cat "${configpath}" | jq -c '.config.Cmd' | sed -e 's/^\[//; s/\]$//; s/","/" "/'` cmd=`cat "${configpath}" | jq -c -r '.config.Cmd[]?'`
if [ "${ep}" = "null" ]; then if [ -z "${ep}" ]; then
ep="${cmd}" ep="${cmd}"
if [ "${ep}" = "null" ]; then if [ -z "${ep}" ]; then
ep="/bin/sh" ep="/bin/sh"
fi fi
elif [ "${cmd}" != "null" ]; then elif [ -n "${cmd}" ]; then
ep="${ep} ${cmd}" ep="${ep} ${cmd}"
fi fi
if [ -z "${ep}" ]; then echo ${ep}
echo "/bin/sh"
return
fi
echo "${ep}"
return return
} }
...@@ -118,8 +114,7 @@ getenv() { ...@@ -118,8 +114,7 @@ getenv() {
configpath="$1" configpath="$1"
cat "${configpath}" > /tmp/config env=`cat "${configpath}" | jq -c -r '.config.Env[]'`
env=`cat "${configpath}" | jq -c '.config.Env[]'`
echo "${env}" echo "${env}"
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment