migrate 727 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/python3
  2. import json
  3. import os
  4. import sys
  5. def migrate(values):
  6. storageKey = 'jellyfinStorage'
  7. storages = ['config', 'cache', 'transcodes']
  8. for storage in storages:
  9. check_val = values.get(storageKey, {}).get(storage, {})
  10. if not isinstance(check_val, dict) or not check_val or check_val.get('type', 'hostPath') == 'hostPath':
  11. continue
  12. values[storageKey][storage] = {key: value for key, value in check_val.items() if key != 'hostPath'}
  13. return values
  14. if __name__ == '__main__':
  15. if len(sys.argv) != 2:
  16. exit(1)
  17. if os.path.exists(sys.argv[1]):
  18. with open(sys.argv[1], 'r') as f:
  19. print(json.dumps(migrate(json.loads(f.read()))))