import yaml
import json


def load_config_file(config_file: str, child_name="dockerConfiguration") -> dict:
    """
    Load OSDF configuration from a file -- currently only yaml/json are supported
    :param config_file:  path to config file (.yaml or .json).
    :param child_name: if present, return only that child node
    :return: config (all or specific child node)
    """
    with open(config_file, 'r') as fid:
        res = {}
        if config_file.endswith(".yaml"):
            res = yaml.safe_load(fid)
        elif config_file.endswith(".json") or config_file.endswith("json"):
            res = json.load(fid)
    return res.get(child_name, res) if child_name else res