Skip to content

Commit

Permalink
deluge - migrate storage section (adds acl) (#1892)
Browse files Browse the repository at this point in the history
* bump version

* update values

* update template

* update ui

* add migration
  • Loading branch information
stavros-k authored Dec 17, 2023
1 parent bf1df81 commit 7d73323
Show file tree
Hide file tree
Showing 7 changed files with 302 additions and 111 deletions.
2 changes: 1 addition & 1 deletion library/ix-dev/community/deluge/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Deluge is a lightweight, Free Software, cross-platform BitTorrent c
annotations:
title: Deluge
type: application
version: 1.1.5
version: 1.2.0
apiVersion: v2
appVersion: '9.5.3'
kubeVersion: '>=1.16.0-0'
Expand Down
6 changes: 2 additions & 4 deletions library/ix-dev/community/deluge/ci/basic-values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
delugeStorage:
config:
type: hostPath
hostPath: /mnt/{{ .Release.Name }}/config
type: pvc
downloads:
type: hostPath
hostPath: /mnt/{{ .Release.Name }}/downloads
type: pvc

delugeNetwork:
exposeDaemon: true
Expand Down
6 changes: 2 additions & 4 deletions library/ix-dev/community/deluge/ci/hostnet-values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
delugeStorage:
config:
type: hostPath
hostPath: /mnt/{{ .Release.Name }}/config
type: pvc
downloads:
type: hostPath
hostPath: /mnt/{{ .Release.Name }}/downloads
type: pvc

delugeNetwork:
hostNetwork: true
73 changes: 73 additions & 0 deletions library/ix-dev/community/deluge/migrations/migrate
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/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 = 'delugeStorage'
storages = ['config', 'downloads']

for storage in storages:
check_val = values.get(storage_key, {}).get(storage, {})
if not isinstance(check_val, dict) or not check_val:
raise Exception(f'Storage section {storage} is malformed')

values[storage_key][storage] = storage_migrate(check_val)

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()))))
Loading

0 comments on commit 7d73323

Please sign in to comment.