fix: render registry workspaces for harness
This commit is contained in:
+24
-2
@@ -162,6 +162,11 @@ class PathsConfig(BaseModel):
|
||||
sessions: Path = Path("sessions")
|
||||
|
||||
|
||||
class RuntimeIdentityConfig(BaseModel):
|
||||
workspace_id: str = Field(pattern=r"^[a-z][a-z0-9-]{2,62}$")
|
||||
workspace_revision: str = Field(pattern=r"^[0-9a-f]{40}$")
|
||||
|
||||
|
||||
class WorkspaceRoots(PathsConfig):
|
||||
pass
|
||||
|
||||
@@ -305,7 +310,9 @@ class ExecutionConfig(BaseModel):
|
||||
|
||||
class Config(BaseModel):
|
||||
_workspace_id: str = PrivateAttr(default="default")
|
||||
_workspace_revision: str | None = PrivateAttr(default=None)
|
||||
_config_source: str = PrivateAttr(default="direct")
|
||||
runtime_identity: RuntimeIdentityConfig | None = None
|
||||
dwh: DwhResourceConfig
|
||||
vectors: VectorResourceConfig | None = None
|
||||
session_storage: SessionStorageConfig | None = None
|
||||
@@ -354,10 +361,20 @@ def workspace_id_from_path(path: Path) -> str:
|
||||
return path.resolve().stem.lower().replace(".", "-").replace("_", "-")
|
||||
|
||||
|
||||
def workspace_id_for_config(config: Config, path: Path) -> str:
|
||||
"""Return the canonical runtime identity, falling back for legacy configs."""
|
||||
if config.runtime_identity is not None:
|
||||
return config.runtime_identity.workspace_id
|
||||
return workspace_id_from_path(path)
|
||||
|
||||
|
||||
def load_config(path: Path) -> Config:
|
||||
if not path.exists():
|
||||
raise ConfigError(f"File di configurazione non trovato: {path}")
|
||||
raw = yaml.safe_load(path.read_text())
|
||||
try:
|
||||
raw = yaml.safe_load(path.read_text())
|
||||
except yaml.YAMLError as exc:
|
||||
raise ConfigError(f"Configurazione YAML non valida: {path}") from exc
|
||||
if not isinstance(raw, dict):
|
||||
raise ConfigError(f"Configurazione non valida (atteso un mapping YAML): {path}")
|
||||
expanded = _resolve_secret_files(_expand_env(raw))
|
||||
@@ -407,7 +424,12 @@ def load_config(path: Path) -> Config:
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
cfg._workspace_id = workspace_id_from_path(path)
|
||||
cfg._workspace_id = workspace_id_for_config(cfg, path)
|
||||
cfg._workspace_revision = (
|
||||
cfg.runtime_identity.workspace_revision
|
||||
if cfg.runtime_identity is not None
|
||||
else None
|
||||
)
|
||||
cfg._config_source = path.resolve().as_posix()
|
||||
return cfg
|
||||
|
||||
|
||||
Reference in New Issue
Block a user