def write_pgpass(self, record: Dict[str, Any]) -> Dict[str, str]:
        """Maybe creates :attr:`_passfile` based on connection parameters.

        :param record: :class:`dict` object with connection parameters.

        :returns: a copy of environment variables, that will include ``PGPASSFILE`` in case if the file was written.
        """
        content = self._pgpass_content(record)
        if not content:
            return os.environ.copy()

        with open(self._pgpass, 'w') as f:
            os.chmod(self._pgpass, stat.S_IWRITE | stat.S_IREAD)
            f.write(content)

        return {**os.environ, 'PGPASSFILE': self._pgpass}
Maybe creates :attr:`_passfile` based on connection parameters.

        :param record: :class:`dict` object with connection parameters.

        :returns: a copy of environment variables, that will include ``PGPASSFILE`` in case if the file was written.
        
patroni/postgresql/config.py