Browse Source

wgeasy - fix migration order (#2628)

* wgeasy - fix migration order

* add another failsafe
Stavros Kois 1 năm trước cách đây
mục cha
commit
57cb4093fa

+ 1 - 1
library/ix-dev/charts/wg-easy/Chart.yaml

@@ -3,7 +3,7 @@ description: WG-Easy is the easiest way to install & manage WireGuard!
 annotations:
   title: WG Easy
 type: application
-version: 2.0.18
+version: 2.0.19
 apiVersion: v2
 appVersion: '13'
 kubeVersion: '>=1.16.0-0'

+ 10 - 4
library/ix-dev/charts/wg-easy/migrations/migrate

@@ -37,6 +37,7 @@ def migrate_common_lib(values):
         # Migrate Config
         'wgConfig': {
             'host': values['wgeasy']['host'],
+            'externalPort': values.get('wgUDPPort', 30057),
             'password': values['wgeasy'].get('password', ''),
             'keepAlive': values['wgeasy']['keep_alive'],
             'clientMTU': values['wgeasy']['client_mtu'],
@@ -74,17 +75,22 @@ def migrate_common_lib(values):
 
     return values
 
+
 def migrate(values):
-    if not 'wgeasy' in values.keys():
+    # If we have migrated...
+    if 'wgConfig' in values.keys():
+        # Make sure the externalPort is not missing.
+        if not values['wgConfig'].get('externalPort', None):
+            values['wgConfig']['externalPort'] = values['wgNetwork'].get('udpPort', 30057)
         return values
 
-    if not values['wgConfig'].get('externalPort', None):
-        values['wgConfig']['externalPort'] = values['wgNetwork'].get('udpPort', 30057)
+    # If this key is missing, we have already migrated.
+    if 'wgeasy' not in values.keys():
+        return values
 
     return migrate_common_lib(values)
 
 
-
 if __name__ == '__main__':
     if len(sys.argv) != 2:
         exit(1)