gen-docker-imagetool-args.py 544 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python3
  2. import sys
  3. from pathlib import Path
  4. DIGEST_PATH = Path(sys.argv[1])
  5. TAG_PREFIX = sys.argv[2]
  6. TAGS = sys.argv[3]
  7. if TAG_PREFIX:
  8. PUSH_TAGS = tuple([
  9. t for t in TAGS.split(',') if t.startswith(TAG_PREFIX)
  10. ])
  11. else:
  12. PUSH_TAGS = tuple([
  13. t for t in TAGS.split(',') if t.startswith('netdata/')
  14. ])
  15. IMAGE_NAME = PUSH_TAGS[0].split(':')[0]
  16. images = []
  17. for f in DIGEST_PATH.glob('*'):
  18. images.append(f'{IMAGE_NAME}@sha256:{f.name}')
  19. print(f'-t {" -t ".join(PUSH_TAGS)} {" ".join(images)}')