-
Notifications
You must be signed in to change notification settings - Fork 169
/
cmd-list
executable file
·50 lines (41 loc) · 1.48 KB
/
cmd-list
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
#!/usr/bin/env python3
import datetime
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from cosalib.builds import Builds
from cosalib.cmdlib import parse_date_string
def main():
builds = Builds()
if len(builds.get_builds()) == 0:
print("No builds!")
return
tags = {}
for tag in builds.get_tags():
tags[tag['target']] = tags.get(tag['target'], []) + [tag['name']]
for build in builds.get_builds():
try:
m = builds.get_build_meta(build['id'])
except FileNotFoundError:
print("<missing builds locally>")
break
print(f"{build['id']}")
ts = m['coreos-assembler.build-timestamp']
d = parse_date_string(ts)
delta = datetime.datetime.now(datetime.timezone.utc) - d
# chop off the microseconds in the delta; don't need that precise
print(f" Timestamp: {ts} ({str(delta).split('.')[0]} ago)")
print(f" Artifacts: {' '.join(list(m['images']))}")
git = m.get('coreos-assembler.container-config-git')
if git:
config = git['commit']
if 'branch' in git:
config = f"{git['branch']} ({config[:12]})"
if git['dirty'] != "false":
config += " (dirty)"
print(f" Config: {config}")
if build['id'] in tags:
print(f" Tags: {' '.join(tags[build['id']])}")
print()
if __name__ == "__main__":
sys.exit(main())