Skip to content

Commit

Permalink
Allow for scret SQL registry pass
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsalvador committed Oct 17, 2023
1 parent e93434e commit 564459c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
12 changes: 11 additions & 1 deletion sdk/python/feast/infra/registry/sql.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import uuid
from datetime import datetime, timedelta
from enum import Enum
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 564459c

Please sign in to comment.