migrate 781 B

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