import logging
import logging.config
import os

from pygluu.containerlib import get_manager
from pygluu.containerlib import wait_for
from pygluu.containerlib.validators import validate_persistence_ldap_mapping

from settings import LOGGING_CONFIG

logging.config.dictConfig(LOGGING_CONFIG)
logger = logging.getLogger("wait")


def main():
    persistence_type = os.environ.get("GLUU_PERSISTENCE_TYPE", "ldap")
    if persistence_type not in ("ldap", "hybrid"):
        raise ValueError("Unsupported persistence type; please choose one of 'ldap', 'hybrid'")

    ldap_mapping = os.environ.get("GLUU_PERSISTENCE_LDAP_MAPPING", "default")
    validate_persistence_ldap_mapping(persistence_type, ldap_mapping)

    manager = get_manager()
    deps = ["config", "secret"]
    wait_for(manager, deps)


if __name__ == "__main__":
    main()

import logging
import logging.config
import os

from pygluu.containerlib import get_manager
from pygluu.containerlib import wait_for
from pygluu.containerlib.validators import validate_persistence_ldap_mapping

from settings import LOGGING_CONFIG

logging.config.dictConfig(LOGGING_CONFIG)
logger = logging.getLogger("wait")


def main():
    persistence_type = os.environ.get("GLUU_PERSISTENCE_TYPE", "ldap")
    if persistence_type not in ("ldap", "hybrid"):
        raise ValueError("Unsupported persistence type; please choose one of 'ldap', 'hybrid'")

    ldap_mapping = os.environ.get("GLUU_PERSISTENCE_LDAP_MAPPING", "default")
    validate_persistence_ldap_mapping(persistence_type, ldap_mapping)

    manager = get_manager()
    deps = ["config", "secret"]
    wait_for(manager, deps)


if __name__ == "__main__":
    main()
