479406e6a5
Let's modernize and start supporting YAML treefiles. I'll dare make the sweeping generalization that most people would prefer reading and writing YAML over JSON. This takes bits from coreos-assembler[1] that know how to serialize a YAML file and spit it back out as a JSON and makes it into a shared lib that we can link against. We could use this eventually for JSON inputs as well to force a validation check before composing. If we go this route, we could then turn on `--enable-rust` in FAHC for now and drop the duplicate code in coreos-assembler. [1] https://github.com/cgwalters/coreos-assembler Closes: #1377 Approved by: cgwalters
47 lines
1.3 KiB
Bash
Executable File
47 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -xeuo pipefail
|
|
|
|
dn=$(cd $(dirname $0) && pwd)
|
|
. ${dn}/libcomposetest.sh
|
|
|
|
prepare_compose_test "basic"
|
|
# Test metadata json with objects, arrays, numbers
|
|
cat > metadata.json <<EOF
|
|
{
|
|
"exampleos.gitrepo": {
|
|
"rev": "97ec21c614689e533d294cdae464df607b526ab9",
|
|
"src": "https://gitlab.com/exampleos/custom-atomic-host"
|
|
},
|
|
"exampleos.tests": ["smoketested", "e2e"]
|
|
}
|
|
EOF
|
|
runcompose --add-metadata-from-json metadata.json
|
|
|
|
. ${dn}/libbasic-test.sh
|
|
basic_test
|
|
|
|
# This one is done by postprocessing /var
|
|
ostree --repo=${repobuild} cat ${treeref} /usr/lib/tmpfiles.d/rpm-ostree-1-autovar.conf > autovar.txt
|
|
# Picked this one at random as an example of something that won't likely be
|
|
# converted to tmpfiles.d upstream. But if it is, we can change this test.
|
|
assert_file_has_content_literal autovar.txt 'd /var/cache 0755 root root - -'
|
|
# And this one has a non-root uid
|
|
assert_file_has_content_literal autovar.txt 'd /var/log/chrony 0755 chrony chrony - -'
|
|
echo "ok autovar"
|
|
|
|
if ! rpm-ostree --version | grep -q rust; then
|
|
echo "ok yaml (SKIP)"
|
|
else
|
|
prepare_compose_test "from-yaml"
|
|
python <<EOF
|
|
import json, yaml
|
|
jd=json.load(open("$treefile"))
|
|
with open("$treefile.yaml", "w") as f:
|
|
f.write(yaml.dump(jd))
|
|
EOF
|
|
export treefile=$treefile.yaml
|
|
runcompose
|
|
echo "ok yaml"
|
|
fi
|