ip_port_migration 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/python3
  2. import os
  3. import sys
  4. import yaml
  5. def migrate(values):
  6. values["network"]["web_port"] = {
  7. "port_number": values["network"]["web_port"],
  8. "bind_mode": "published",
  9. "host_ips": [],
  10. }
  11. values["network"]["http_port"] = {
  12. "port_number": values["network"]["http_port"],
  13. "bind_mode": "published",
  14. "host_ips": [],
  15. }
  16. values["network"]["https_port"] = {
  17. "port_number": values["network"]["https_port"],
  18. "bind_mode": "published",
  19. "host_ips": [],
  20. }
  21. values["network"]["additional_ports"] = [
  22. {
  23. "bind_mode": "published",
  24. "port_number": p["published"],
  25. "container_port": p["target"],
  26. "protocol": p["protocol"],
  27. "host_ips": [],
  28. }
  29. for p in values["network"].get("additional_ports", [])
  30. ]
  31. return values
  32. if __name__ == "__main__":
  33. if len(sys.argv) != 2:
  34. exit(1)
  35. if os.path.exists(sys.argv[1]):
  36. with open(sys.argv[1], "r") as f:
  37. print(yaml.dump(migrate(yaml.safe_load(f.read()))))