Files
truenas-apps/ix-dev/community/opencloud/migrations/fix_csp
truenasbot efd88182c0 chore(deps): update updates-patch-minor (#3740)
* chore(deps): update updates-patch-minor

* devbox (#3726)

* bump devbox

* order

* another

* more scripts

* opencloud: fix csp (#3741)

* opencloud: fix csp

* better

---------

Co-authored-by: bugclerk <bugclerk@ixsystems.com>
Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
2025-11-30 21:10:19 +02:00

29 lines
755 B
Python
Executable File

#!/usr/bin/python3
import os
import sys
import yaml
def migrate(values):
new_csp = []
for x in values["opencloud"]["additional_csp"]:
new_item = {"directive": x["directive"], "items": []}
for i in x["items"]:
if isinstance(i, str):
new_item["items"].append({"value": i, "placeholder": ""})
else:
new_item["items"].append(i)
new_csp.append(new_item) # ← This line was missing!
values["opencloud"]["additional_csp"] = new_csp
return values
if __name__ == "__main__":
if len(sys.argv) != 2:
exit(1)
if os.path.exists(sys.argv[1]):
with open(sys.argv[1], "r") as f:
print(yaml.dump(migrate(yaml.safe_load(f.read()))))