def from_cluster(self, cluster: Optional['Cluster']) -> 'GlobalConfig':
        """Return :class:`GlobalConfig` instance from the provided :class:`Cluster` object view.

        .. note::
            If the provided *cluster* object doesn't have a valid global configuration we return
            the last known valid state of the :class:`GlobalConfig` object.

            This method is used when we need to have the most up-to-date values in the global configuration,
            but we don't want to update the global object.

        :param cluster: the currently known cluster state from DCS.

        :returns: :class:`GlobalConfig` object.
        """
        if not self._cluster_has_valid_config(cluster):
            return self

        ret = GlobalConfig()
        ret.update(cluster)
        return ret
Return :class:`GlobalConfig` instance from the provided :class:`Cluster` object view.

        .. note::
            If the provided *cluster* object doesn't have a valid global configuration we return
            the last known valid state of the :class:`GlobalConfig` object.

            This method is used when we need to have the most up-to-date values in the global configuration,
            but we don't want to update the global object.

        :param cluster: the currently known cluster state from DCS.

        :returns: :class:`GlobalConfig` object.
        
patroni/global_config.py