Skip to content

Commit

Permalink
planka - migrate storage section (#1768)
Browse files Browse the repository at this point in the history
* planka - migrate storage section

* reduce diff

* typo

* add missing key

* remove test snippet

* optimize

* remove empty lines

* restore immutable flag
  • Loading branch information
stavros-k authored Nov 22, 2023
1 parent 72ed16d commit c2b4e17
Show file tree
Hide file tree
Showing 11 changed files with 512 additions and 196 deletions.
6 changes: 3 additions & 3 deletions library/ix-dev/community/planka/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: file://../../../common
version: 1.2.2
digest: sha256:fb077cb81f6acecd5c9e6adc22a18e156f780cd78f27198cdb47810f95364b56
generated: "2023-11-09T15:43:04.016439777+02:00"
version: 1.2.3
digest: sha256:e6ff49b06bf5d4d159e505ae6d153f36cd46170bb519caf90462cd5caebfd0fb
generated: "2023-11-20T10:17:20.436068522+02:00"
6 changes: 3 additions & 3 deletions library/ix-dev/community/planka/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ description: Planka is an Elegant open source project tracking
annotations:
title: Planka
type: application
version: 1.1.4
version: 1.2.0
apiVersion: v2
appVersion: 1.14.3
appVersion: 1.15.0
kubeVersion: '>=1.16.0-0'
maintainers:
- name: truenas
Expand All @@ -14,7 +14,7 @@ maintainers:
dependencies:
- name: common
repository: file://../../../common
version: 1.2.2
version: 1.2.3
home: https://github.com/plankanban/planka
icon: https://media.sys.truenas.net/apps/planka/icons/icon.png
sources:
Expand Down
Binary file not shown.
Binary file not shown.
15 changes: 5 additions & 10 deletions library/ix-dev/community/planka/ci/basic-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ plankaConfig:

plankaStorage:
avatars:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/avatars
type: pvc
backgroundImages:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/bg-img
type: pvc
attachments:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/attachments
type: pvc
pgData:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/pgData
type: pvc
pgBackup:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/pgBackup
type: emptyDir
21 changes: 7 additions & 14 deletions library/ix-dev/community/planka/ci/extra-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,17 @@ plankaConfig:

plankaStorage:
avatars:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/avatars
type: pvc
backgroundImages:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/bg-img
type: pvc
attachments:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/attachments
type: pvc
pgData:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/pgData
type: pvc
pgBackup:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/pgBackup
type: emptyDir
additionalStorages:
- type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/data1
- type: pvc
mountPath: /data1
- type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/data2
- type: pvc
mountPath: /data2
15 changes: 5 additions & 10 deletions library/ix-dev/community/planka/ci/hostNet-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ plankaConfig:

plankaStorage:
avatars:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/avatars
type: pvc
backgroundImages:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/bg-img
type: pvc
attachments:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/attachments
type: pvc
pgData:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/pgData
type: pvc
pgBackup:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/pgBackup
type: emptyDir
76 changes: 76 additions & 0 deletions library/ix-dev/community/planka/migrations/migrate
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/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':
# Fixes an invalid key carried from values.yaml
storage.pop('hostPath', None)

# 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 = 'plankaStorage'
storages = ['avatars', 'backgroundImages', 'attachments', 'pgData', 'pgBackup']

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 c2b4e17

Please sign in to comment.