gen-matrix-repoconfig.py 997 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python3
  2. import json
  3. from ruamel.yaml import YAML
  4. yaml = YAML(typ='safe')
  5. entries = list()
  6. with open('.github/data/distros.yml') as f:
  7. data = yaml.load(f)
  8. for i, v in enumerate(data['include']):
  9. if 'packages' in data['include'][i]:
  10. entries.append({
  11. 'distro': data['include'][i]['distro'],
  12. 'version': data['include'][i]['version'],
  13. 'pkgclouddistro': data['include'][i]['packages']['repo_distro'],
  14. 'format': data['include'][i]['packages']['type'],
  15. 'base_image': data['include'][i]['base_image'] if 'base_image' in data['include'][i] else ':'.join([data['include'][i]['distro'], data['include'][i]['version']]),
  16. 'platform': data['platform_map']['amd64'],
  17. 'arches': ' '.join(['"' + x + '"' for x in data['include'][i]['packages']['arches']])
  18. })
  19. entries.sort(key=lambda k: (k['distro'], k['version']))
  20. matrix = json.dumps({'include': entries}, sort_keys=True)
  21. print(matrix)