-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drawio - migrate storage section (adds acl) (#1926)
* bump version * add migration * update ui * update template * update template
- Loading branch information
Showing
5 changed files
with
178 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/python3 | ||
import json | ||
import os | ||
import sys | ||
|
||
|
||
def storage_migrate(storage): | ||
delete_keys = [] | ||
if storage['type'] == 'hostPath': | ||
# Check if the key exists, if not we have already migrated | ||
if not storage.get('hostPath'): | ||
return storage | ||
|
||
storage['hostPathConfig'] = {'hostPath': storage['hostPath']} | ||
delete_keys.append('hostPath') | ||
|
||
elif storage['type'] == 'ixVolume': | ||
# Check if the key exists, if not we have already migrated | ||
if not storage.get('datasetName'): | ||
return storage | ||
|
||
storage['ixVolumeConfig'] = {'datasetName': storage['datasetName']} | ||
delete_keys.append('datasetName') | ||
|
||
elif storage['type'] == 'smb-pv-pvc': | ||
# Check if the key exists, if not we have already migrated | ||
if not storage.get('server'): | ||
return storage | ||
|
||
storage['smbConfig'] = { | ||
'server': storage['server'], | ||
'share': storage['share'], | ||
'domain': storage['domain'], | ||
'username': storage['username'], | ||
'password': storage['password'], | ||
'size': storage['size'], | ||
} | ||
delete_keys.extend(['server', 'share', 'domain', 'username', 'password', 'size']) | ||
|
||
for key in delete_keys: | ||
storage.pop(key, None) | ||
|
||
return storage | ||
|
||
|
||
def migrate(values): | ||
storage_key = 'drawioStorage' | ||
|
||
additionalStorages = values.get(storage_key, {}).get('additionalStorages', []) | ||
for idx, storage in enumerate(additionalStorages): | ||
if not isinstance(storage, dict) or not storage: | ||
raise Exception(f'Item {idx} in additionalStorages is malformed') | ||
|
||
values[storage_key]['additionalStorages'][idx] = storage_migrate(storage) | ||
|
||
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(json.dumps(migrate(json.loads(f.read())))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters