_http = OCIRegHTTP {
    address = "0.0.0.0",
    port = 5000
    realm = "zot"
    tls = OCIRegTLS {
        cert = "/etc/zot/ssl/fullchain.pem",
        key = "/etc/zot/ssl/privkey.pem"
    }
    auth = OCIRegAuth {
        htpasswd = OCIRegHtpasswd { path = "/etc/zot/htpasswd" }
        failDelay = 5
    }
}
_log = OCIRegLog {
    level = "debug",
    output = "/var/log/zot/zot.log",
    audit = "/var/log/zot/zot-audit.log"
}

if _kys != Undefined and _kys.oci_reg_s3.accesskey != Undefined and _kys.oci_reg_s3.accesskey == "":
#if _kys.storageDriver == Undefined:
    _oci_config = OCIRegConfig {
        storage = OCIRegStorage {
            rootDirectory = "/data/zot/"
            dedupe = True
            storageDriver = OCIRegStorageDriver {
                name = "s3",
                rootdirectory = "/zot",
                region = "europe-1",
                bucket = "termas",
                secure = True,
                regionendpoint ="https://50bv2.upcloudobjects.com",
                accesskey = "_kys.oci_reg_s3.accesskey",
                secretkey = "_kys.oci_reg_s3.secretkey",
                skipverify = False
            }
        }
        http = _http
        log = _log
    }
else:
    _oci_config = OCIRegConfig {
        storage = OCIRegStorage {
            rootDirectory = "/data/zot/"
            gc = True
            gcDelay = "1h"
            gcInterval = "6h"
        }
        http = _http
        log = _log
        extensions = OCIRegExtensions {
            ui: OCIRegExtUI { enable: True }
            search: OCIRegExtSearch { enable: True }
        }
    }

taskserv = OCIReg {
    version = "{{version}}"
    name = "oci_reg"
    oci_memory_high = 15
    oci_memory_max = 16
    copy_paths = ["reg-ssl|ssl", "oci_reg/htpasswd|htpasswd"]
    config = _oci_config
}
