Initial commit: VMware vSphere API simulator scaffold.
Add the FastAPI app, PostgreSQL migrations, Docker/Helm packaging, API contracts, docs, client examples, and the unit/integration/compatibility test suite for local client and tooling labs without a real vCenter.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
"""Non-empty output validation for pulumi-vsphere stack results."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
def _is_empty(value: Any) -> bool:
|
||||
if value is None:
|
||||
return True
|
||||
if isinstance(value, str) and not value.strip():
|
||||
return True
|
||||
if isinstance(value, (list, dict, tuple, set)) and len(value) == 0:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def assert_nonempty(outputs: dict[str, Any], *, required: list[str] | None = None) -> list[str]:
|
||||
"""Return list of error messages for empty/missing outputs."""
|
||||
|
||||
errors: list[str] = []
|
||||
keys = required if required is not None else list(outputs)
|
||||
if not keys:
|
||||
errors.append("no outputs exported")
|
||||
return errors
|
||||
for key in keys:
|
||||
if key not in outputs:
|
||||
errors.append(f"missing output: {key}")
|
||||
continue
|
||||
if _is_empty(outputs[key]):
|
||||
errors.append(f"empty output: {key}={outputs[key]!r}")
|
||||
return errors
|
||||
Reference in New Issue
Block a user