Import CI enrollment into private NAS runtime during bootstrap
This commit is contained in:
@@ -14,21 +14,23 @@ import tarfile
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SOURCE = Path(__file__).resolve().parent
|
||||
ENTRIES = ("docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v1.json")
|
||||
V2_ENTRIES = ("docker-compose.gitea-ci.yml", "runner.yaml", "deployment/bootstrap-v2.json")
|
||||
|
||||
|
||||
def bundle(patch_id, source=SOURCE):
|
||||
if not re.fullmatch(r"gitea-ci-bootstrap-v1-[a-zA-Z0-9._-]{1,65}", patch_id):
|
||||
if not re.fullmatch(r"gitea-ci-bootstrap-v[12]-[a-zA-Z0-9._-]{1,65}", patch_id):
|
||||
raise ValueError("invalid_bootstrap_identity")
|
||||
descriptor = json.loads((source / "bootstrap-v1.json").read_text())
|
||||
entries = V2_ENTRIES if patch_id.startswith("gitea-ci-bootstrap-v2-") else ENTRIES
|
||||
descriptor = json.loads((source / Path(entries[2]).name).read_text())
|
||||
if descriptor["releaseId"] != "__PATCH_ID__":
|
||||
raise ValueError("bootstrap_template_identity_mismatch")
|
||||
descriptor["releaseId"] = patch_id
|
||||
files = {
|
||||
"manifest.env": ("id=" + patch_id + "\ncomponent=gitea-ci\ntype=app-overlay\n").encode(),
|
||||
"files.txt": ("\n".join(ENTRIES) + "\n").encode(),
|
||||
"files.txt": ("\n".join(entries) + "\n").encode(),
|
||||
"payload/docker-compose.gitea-ci.yml": (source / ENTRIES[0]).read_bytes(),
|
||||
"payload/runner.yaml": (source / ENTRIES[1]).read_bytes(),
|
||||
"payload/deployment/bootstrap-v1.json": (json.dumps(descriptor, indent=2) + "\n").encode(),
|
||||
"payload/" + entries[2]: (json.dumps(descriptor, indent=2) + "\n").encode(),
|
||||
}
|
||||
result = io.BytesIO()
|
||||
with gzip.GzipFile(fileobj=result, mode="wb", filename="", mtime=0) as compressed:
|
||||
@@ -62,7 +64,8 @@ def main():
|
||||
print(json.dumps({
|
||||
"artifact": str(path.resolve()), "patchId": args.patch_id,
|
||||
"component": "gitea-ci", "sourceCommit": actual,
|
||||
"sha256": hashlib.sha256(data).hexdigest(), "entries": ENTRIES,
|
||||
"sha256": hashlib.sha256(data).hexdigest(),
|
||||
"entries": V2_ENTRIES if args.patch_id.startswith("gitea-ci-bootstrap-v2-") else ENTRIES,
|
||||
"services": ["build-runner"], "publishedPorts": [],
|
||||
"productionDeployEnabled": False,
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user