From 564459c9adfdf4b580676dea2b7a5625b44d899c Mon Sep 17 00:00:00 2001 From: danielsalvador Date: Wed, 18 Oct 2023 00:11:40 +0300 Subject: [PATCH] Allow for scret SQL registry pass --- .../contrib/postgres/postgres_registry_store.py | 4 ++-- sdk/python/feast/infra/registry/sql.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sdk/python/feast/infra/registry/contrib/postgres/postgres_registry_store.py b/sdk/python/feast/infra/registry/contrib/postgres/postgres_registry_store.py index f990e151d7..0fa4c63b66 100644 --- a/sdk/python/feast/infra/registry/contrib/postgres/postgres_registry_store.py +++ b/sdk/python/feast/infra/registry/contrib/postgres/postgres_registry_store.py @@ -31,8 +31,8 @@ def __init__(self, config: PostgresRegistryConfig, registry_path: str): port=config.port, database=config.database, db_schema=config.db_schema, - user=os.environ.get("FEAST_REGISTRY_PSQL_USER", config.user), - password=os.environ.get("FEAST_REGISTRY_PSQL_PASSWORD", config.password), + user=config.user, + password=config.password, sslmode=getattr(config, "sslmode", None), sslkey_path=getattr(config, "sslkey_path", None), sslcert_path=getattr(config, "sslcert_path", None), diff --git a/sdk/python/feast/infra/registry/sql.py b/sdk/python/feast/infra/registry/sql.py index d57bcc7c0a..06abd1b6e7 100644 --- a/sdk/python/feast/infra/registry/sql.py +++ b/sdk/python/feast/infra/registry/sql.py @@ -1,4 +1,5 @@ import logging +import os import uuid from datetime import datetime, timedelta from enum import Enum @@ -199,7 +200,16 @@ def __init__( repo_path: Optional[Path], ): assert registry_config is not None, "SqlRegistry needs a valid registry_config" - self.engine: Engine = create_engine(registry_config.path, echo=False) + + sqlalchemy_url = registry_config.path + if "__placeholder_password__" in sqlalchemy_url: + secret_password = os.getenv("FEAST_SQL_REGISTRY_PASSWORD") + if secret_password: + sqlalchemy_url = sqlalchemy_url.replace("__placeholder_password__", secret_password) + else: + raise ValueError("'FEAST_SQL_REGISTRY_PASSWORD' is not set!") + + self.engine: Engine = create_engine(sqlalchemy_url, echo=False) metadata.create_all(self.engine) self.cached_registry_proto = self.proto() proto_registry_utils.init_project_metadata(self.cached_registry_proto, project)