#!/usr/bin/python3

# Wrapper for "perfact-dbschema add" that checks for an allowed path - because
# this is allowed to be called via sudo, we do not allow just any path to be
# passed.

import sys
import subprocess as sp

if __name__ == '__main__':
    # For now, only the default path is allowed. We might want to read layer
    # definitions once we allow creating code for different layers
    if sys.argv[1] != '/opt/perfact/dbutils-zoperepo/__schema__':
        raise ValueError("Path not allowed")
    sp.run(['/usr/bin/perfact-dbschema', 'add']
           + sys.argv[1:], check=True)
