-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcontainer-met.py
More file actions
executable file
·61 lines (51 loc) · 1.64 KB
/
container-met.py
File metadata and controls
executable file
·61 lines (51 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
import sys
import os
import json
import requests
import osaka.main
if __name__ == "__main__":
if len(sys.argv) < 7:
print("[ERROR] Metadata requires: ident version product repo digest mozart_url [product_arm64]", file=sys.stderr)
sys.exit(-1)
# Read arguments
ident = sys.argv[1]
version = sys.argv[2]
product = sys.argv[3]
repo = sys.argv[4]
digest = sys.argv[5]
mozart_rest_url = sys.argv[6]
product_arm64 = sys.argv[7] if len(sys.argv) > 7 else None
# Upload x86_64 tarball (backwards compatible)
if product:
url = os.path.join(repo, os.path.basename(product))
osaka.main.put("./" + product, url)
else:
url = ""
# Upload arm64 tarball
url_arm64 = ""
if product_arm64:
url_arm64 = os.path.join(repo, os.path.basename(product_arm64))
osaka.main.put("./" + product_arm64, url_arm64)
# Build metadata with backwards compatibility
metadata = {
"name": ident,
"version": version,
"url": url,
"resource": "container",
"digest": digest
}
# Add architecture-specific URLs if available
if url or url_arm64:
urls_dict = {}
if url:
urls_dict["x86_64"] = url
urls_dict["amd64"] = url
if url_arm64:
urls_dict["arm64"] = url_arm64
urls_dict["aarch64"] = url_arm64
metadata["urls"] = json.dumps(urls_dict)
add_container_endpoint = os.path.join(mozart_rest_url, "container/add")
r = requests.post(add_container_endpoint, data=metadata, verify=False)
r.raise_for_status()
sys.exit(0)