Example #1
0
    def parse_config_file(self):
        try:
            config = TOMLFile(Cesi.__config_file_path).read()
        except Exception as e:
            sys.exit("Failed to open/find {0} file. {1}".format(
                Cesi.__config_file_path, e))

        self._check_config_file(config)
        self.__cesi = config.get("cesi", None)
        if self.__cesi is None:
            sys.exit(
                "Failed to read {0} configuration file. You must write cesi section."
                .format(Cesi.__config_file_path))
        self.nodes = []

        for node in config.get("nodes", []):
            _environment = node["environment"] or "default"
            _node = Node(
                name=node["name"],
                environment=_environment,
                host=node["host"],
                port=node["port"],
                username=node["username"],
                password=node["password"],
            )
            self.nodes.append(_node)
Example #2
0
def sam_cli_configuration():
    if skip_discovery():
        return None

    config_file_path = os.environ.get("SAM_CONFIG_FILE", "samconfig.toml")
    assert os.path.exists(config_file_path)
    config = TOMLFile(config_file_path).read()

    config_env = os.environ.get("SAM_LAMBDA_CONFIG_ENV", "default")
    assert config.get(config_env)
    return config[config_env]