Esempio n. 1
0
def make_container(envvars_str=None,
                   host_port=None,
                   allow_insecure_ssl=False,
                   pathconfig=PathConfig):
    """
    Factory function for making a container or multicontainer.
    :param envvars_str: str: key=val str of environment variables
    :param host_port: str: optional host port mapped to container port
    :param allow_insecure_ssl: bool: allow insecure connection to docker registry
    :param pathconfig: PathConfig: Holds path/existence info
    :return Container/MultiContainer
    """

    soln_stk = _determine_platform()
    container_cfg = containerops.get_configuration()
    opt_env = EnvvarCollector.from_str(envvars_str)

    if containerops.is_multi(soln_stk, container_cfg):
        return MultiContainer(
            fs_handler=make_multicontainer_fs_handler(pathconfig),
            opt_env=opt_env,
            allow_insecure_ssl=allow_insecure_ssl,
            soln_stk=soln_stk)

    elif containerops.is_generic(soln_stk, container_cfg):
        return GenericContainer(
            fs_handler=make_container_fs_handler(pathconfig),
            soln_stk=soln_stk,
            container_cfg=container_cfg,
            opt_env=opt_env,
            host_port=host_port)

    elif containerops.is_preconfigured(soln_stk, container_cfg):
        return PreconfiguredContainer(
            fs_handler=make_container_fs_handler(pathconfig),
            soln_stk=soln_stk,
            container_cfg=container_cfg,
            opt_env=opt_env,
            host_port=host_port)

    else:
        raise NotSupportedError(strings['local.unsupported'])
 def test_get_configuration(self, get_json_dict):
     get_json_dict.return_value = {}
     self.assertEqual({}, cops.get_configuration())
     get_json_dict.assert_called_once_with(cops.CONTAINER_CONFIG_PATH)
 def setUp(self):
     self.config = cops.get_configuration()