Merge one or more ``KubeConfig`` objects.

    :param list[KubeConfig] configs: The configurations to merge.

    :return KubeConfig: A single configuration object with the merged
        configuration.

def _merge_configs(configs):
    """
    Merge one or more ``KubeConfig`` objects.

    :param list[KubeConfig] configs: The configurations to merge.

    :return KubeConfig: A single configuration object with the merged
        configuration.
    """
    result = {
        u"contexts": [],
        u"users": [],
        u"clusters": [],
        u"current-context": None,
    }
    for config in configs:
        for k in {u"contexts", u"users", u"clusters"}:
            try:
                values = config.doc[k]
            except KeyError:
                pass
            else:
                result[k].extend(values)

        if result[u"current-context"] is None:
            try:
                result[u"current-context"] = config.doc[u"current-context"]
            except KeyError:
                pass

    return KubeConfig(result)