(namespace, source, branch, commit, [(filename, sha256)]) per vendor, for every .cddl file in its directory.
()
| 265 | |
| 266 | |
| 267 | def pin_vendors(): |
| 268 | """(namespace, source, branch, commit, [(filename, sha256)]) per vendor, for every .cddl file in its directory.""" |
| 269 | pinned = [] |
| 270 | for namespace, source in VENDOR_CDDL_SOURCES.items(): |
| 271 | repo, path = source["repo"], source["path"] |
| 272 | branch, commit = resolve_path_commit_for(repo, source["branches"], path) |
| 273 | listing = json.loads(get(f"https://api.github.com/repos/{repo}/contents/{path}?ref={commit}", API_HEADERS)) |
| 274 | filenames = sorted(e["name"] for e in listing if e["type"] == "file" and e["name"].endswith(".cddl")) |
| 275 | if not filenames: |
| 276 | raise RuntimeError(f"No CDDL files in {repo}@{commit} under {path}") |
| 277 | base_url = VENDOR_RAW.format(repo=repo, commit=commit, path=path) |
| 278 | files = [(filename, sha256_of(get(f"{base_url}/{filename}"))) for filename in filenames] |
| 279 | pinned.append((namespace, source, branch, commit, files)) |
| 280 | return pinned |
| 281 | |
| 282 | |
| 283 | def vendor_repo_names(vendors): |