summaryrefslogtreecommitdiffstats
path: root/.github/scripts/gen-matrix-repoconfig.py
blob: 264cd53e764be97f5b3d95b448b9494dfa8c05a8 (plain)
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
#!/usr/bin/env python3

import json

from ruamel.yaml import YAML

yaml = YAML(typ='safe')
entries = list()

with open('.github/data/distros.yml') as f:
    data = yaml.load(f)

for i, v in enumerate(data['include']):
    if 'packages' in data['include'][i]:
        entries.append({
            'distro': data['include'][i]['distro'],
            'version': data['include'][i]['version'],
            'pkgclouddistro': data['include'][i]['packages']['repo_distro'],
            'format': data['include'][i]['packages']['type'],
            'base_image': data['include'][i]['base_image'] if 'base_image' in data['include'][i] else ':'.join([data['include'][i]['distro'], data['include'][i]['version']]),
            'platform': data['platform_map']['amd64'],
            'arches': ' '.join(['"' + x + '"' for x in data['include'][i]['packages']['arches']])
        })

entries.sort(key=lambda k: (k['distro'], k['version']))
matrix = json.dumps({'include': entries}, sort_keys=True)
print(matrix)