Skip to content

Commit

Permalink
Move schema definition under src
Browse files Browse the repository at this point in the history
This moves the schema to `src/` to allow for bind bind mounting
`/usr/lib/coreos-assembler` to allow for developer overrides.

Signed-off-by: Ben Howard <ben.howard@redhat.com>
  • Loading branch information
Ben Howard authored and darkmuggle committed Jul 21, 2021
1 parent 33125d5 commit 9185dd0
Show file tree
Hide file tree
Showing 10 changed files with 844 additions and 11 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tests_checked:=$(patsubst tests/%,tests/.%.shellchecked,${tests})
cwd:=$(shell find . -maxdepth 1 -type f -executable -print)
cwd_checked:=$(patsubst ./%,.%.shellchecked,${cwd})
GOARCH:=$(shell uname -m)
export COSA_META_SCHEMA:=$(shell pwd)/src/v1.json
ifeq ($(GOARCH),x86_64)
GOARCH="amd64"
else ifeq ($(GOARCH),aarch64)
Expand All @@ -46,7 +47,6 @@ flake8:

unittest:
COSA_TEST_META_PATH=`pwd`/fixtures \
COSA_META_SCHEMA=`pwd`/src/schema/v1.json \
PYTHONPATH=`pwd`/src python3 -m pytest tests/

clean:
Expand Down Expand Up @@ -83,8 +83,6 @@ install:
cp -df -t $(DESTDIR)$(PREFIX)/lib/coreos-assembler $$(find src/ -maxdepth 1 -type l)
install -d $(DESTDIR)$(PREFIX)/lib/coreos-assembler/cosalib
install -D -t $(DESTDIR)$(PREFIX)/lib/coreos-assembler/cosalib $$(find src/cosalib/ -maxdepth 1 -type f)
install -d $(DESTDIR)$(PREFIX)/lib/coreos-assembler/schema
install -D -t $(DESTDIR)$(PREFIX)/lib/coreos-assembler/schema $$(find src/schema/ -maxdepth 1 -type f)
install -d $(DESTDIR)$(PREFIX)/bin
ln -sf ../lib/coreos-assembler/coreos-assembler $(DESTDIR)$(PREFIX)/bin/
ln -sf ../lib/coreos-assembler/cp-reflink $(DESTDIR)$(PREFIX)/bin/
Expand Down
2 changes: 1 addition & 1 deletion schema/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
}
},
"$schema":"http://json-schema.org/draft-07/schema#",
"$id":"http://github.com/coreos/coreos-assembler/blob/main/schema/v1.json",
"$id":"http://github.com/coreos/coreos-assembler/blob/main/v1.json.json",
"type":"object",
"title":"CoreOS Assember v1 meta.json schema",
"required": [
Expand Down
2 changes: 1 addition & 1 deletion src/cmd-meta
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def new_cli():
action='store_true')
parser.add_argument('--schema', help='location of meta.json schema',
default=os.environ.get("COSA_META_SCHEMA",
f'{COSA_PATH}/schema/v1.json'))
f'{COSA_PATH}/v1.json.json'))
parser.add_argument('--true', dest='bool', default=None,
help='set a field', action='store_true')
parser.add_argument('--false', dest='bool', default=None,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd-oc-adm-release
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ if __name__ == '__main__':
parser.add_argument('--build', default='latest')
parser.add_argument('--schema', help='location of meta.json schema',
default=os.environ.get("COSA_META_SCHEMA",
f'{COSA_PATH}/schema/v1.json'))
f'{COSA_PATH}/v1.json.json'))
parser.add_argument("--authfile", action="store", required=True,
help="Pull secret")
parser.add_argument("--arch", action='store',
Expand Down
2 changes: 1 addition & 1 deletion src/coreos-assembler
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if [ -z "${cmd}" ]; then
fi
shift

COSA_META_SCHEMA="${COSA_META_SCHEMA:-/usr/lib/coreos-assembler/schema/v1.json}"
COSA_META_SCHEMA="${COSA_META_SCHEMA:-/usr/lib/coreos-assembler/v1.json}"
schema_override="${PWD}/src/config/schema.json"
if [ -e "${schema_override}" ]; then
COSA_META_SCHEMA=$(realpath "${schema_override}")
Expand Down
2 changes: 1 addition & 1 deletion src/cosalib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,5 @@ def __init__(self, *args, **kwargs):
help='Dump the manfiest and exit')
self.add_argument(
'--schema', env_var="META_SCHEMA",
default='/usr/lib/coreos-assembler/schema/v1.json',
default='/usr/lib/coreos-assembler/v1.json',
help='Schema to use. Set to NONE to skip all validation')
2 changes: 1 addition & 1 deletion src/cosalib/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
COSA_VER_STAMP = "coreos-assembler.meta-stamp"

SCHEMA_PATH = os.environ.get("COSA_META_SCHEMA",
"/usr/lib/coreos-assembler/schema/v1.json")
"/usr/lib/coreos-assembler/v1.json")


class COSAMergeError(Exception):
Expand Down
1 change: 0 additions & 1 deletion src/schema

This file was deleted.

Loading

0 comments on commit 9185dd0

Please sign in to comment.