INNER CODE UNIT · Python
sync_nomad_secrets
phasehq/console · backend/api/utils/syncing/nomad/main.py:42
def sync_nomad_secrets(secrets, credential_id, path, namespace="default"):
results = {}
if not secrets or len(secrets) == 0:
results["error"] = "Error: No secrets to sync."
return False, results
try:
secrets_dict = {k: v for k, v, _ in secrets}
# Regex to validate the path
path_regex = re.compile(r"^[a-zA-Z0-9-_~/]{1,128}$")
# Normalize and check the path
safe_path = path.strip("/").replace("//", "/")
if not path_regex.match(safe_path):
raise ValueError(
f"Invalid path: {safe_path}. Path must match the pattern [a-zA-Z0-9-_~/]{{1,128}}."