driver/driver_config_builder.py
def from_env_vars(self):
        """build config options from environment variables"""
        db_name = os.getenv("POSTGRES_OTTERTUNE_DB_NAME", None)

        if not self.has_determined_db_type:
            msg = "Builder must know db type before from_env_vars, try running from_rds first"
            raise DriverConfigException(msg)

        if self.config["db_type"] == "postgres":
            if not db_name:
                msg = ("Must supply database name for Postgres via environment variable: "
                       "POSTGRES_OTTERTUNE_DB_NAME")
                raise DriverConfigException(msg)
        elif self.config["db_type"] == "mysql":
            if db_name:
                msg = "Ignoring POSTGRES_OTTERTUNE_DB_NAME as this agent is connected to a MySql db"
                logging.warning(msg)
                db_name = None

        config_from_env = {
            "db_name": db_name
        }

        try:
            partial_config_from_env: PartialConfigFromEnvironment = (
                PartialConfigFromEnvironment(**config_from_env)
            )
        except ValidationError as ex:
            msg = (
                "Invalid driver configuration the driver option from env vars is missing or invalid"
            )
            raise DriverConfigException(msg, ex) from ex

        self.config.update(partial_config_from_env)
        return self
build config options from environment variables
build config options from environment variables
build config options from environment variables
def from_env_vars(self):
        db_name = os.getenv("POSTGRES_OTTERTUNE_DB_NAME", None)
        if not self.has_determined_db_type:
            msg = "Builder must know db type before from_env_vars, try running from_rds first"
            raise DriverConfigException(msg)
        if self.config["db_type"] == "postgres":
            if not db_name:
                msg = ("Must supply database name for Postgres via environment variable: "
                       "POSTGRES_OTTERTUNE_DB_NAME")
                raise DriverConfigException(msg)
        elif self.config["db_type"] == "mysql":
            if db_name:
                msg = "Ignoring POSTGRES_OTTERTUNE_DB_NAME as this agent is connected to a MySql db"
                logging.warning(msg)
                db_name = None
        config_from_env = {
            "db_name": db_name
        }
        try:
            partial_config_from_env: PartialConfigFromEnvironment = (
                PartialConfigFromEnvironment(**config_from_env)
            )
        except ValidationError as ex:
            msg = (
                "Invalid driver configuration the driver option from env vars is missing or invalid"
            )
            raise DriverConfigException(msg, ex) from ex
        self.config.update(partial_config_from_env)
        return self
def from_env_vars ( self ) : db_name = os . getenv ( "POSTGRES_OTTERTUNE_DB_NAME" , None ) if not self . has_determined_db_type : msg = "Builder must know db type before from_env_vars, try running from_rds first" raise DriverConfigException ( msg ) if self . config [ "db_type" ] == "postgres" : if not db_name : msg = ( "Must supply database name for Postgres via environment variable: " "POSTGRES_OTTERTUNE_DB_NAME" ) raise DriverConfigException ( msg ) elif self . config [ "db_type" ] == "mysql" : if db_name : msg = "Ignoring POSTGRES_OTTERTUNE_DB_NAME as this agent is connected to a MySql db" logging . warning ( msg ) db_name = None config_from_env = { "db_name" : db_name } try : partial_config_from_env : PartialConfigFromEnvironment = ( PartialConfigFromEnvironment ( ** config_from_env ) ) except ValidationError as ex : msg = ( "Invalid driver configuration the driver option from env vars is missing or invalid" ) raise DriverConfigException ( msg , ex ) from ex self . config . update ( partial_config_from_env ) return self
build config options from environment variables
build config options from environment variables
"""build config options from environment variables"""
self