@@ -18,6 +18,17 @@ class Meta:
18
18
def __str__ (self ):
19
19
return "{}-{}" .format (self .app .id , str (self .uuid )[:7 ])
20
20
21
+ def _load_service_config (self , app , component ):
22
+ config = super ()._load_service_config (app , component )
23
+
24
+ # See if the ssl.enforce annotation is available
25
+ if 'ssl' not in config :
26
+ config ['ssl' ] = {}
27
+ if 'enforce' not in config ['ssl' ]:
28
+ config ['ssl' ]['enforce' ] = 'false'
29
+
30
+ return config
31
+
21
32
def _check_previous_tls_settings (self ):
22
33
try :
23
34
previous_tls_settings = self .app .tls_set .latest ()
@@ -40,16 +51,24 @@ def save(self, *args, **kwargs):
40
51
# get config for the service
41
52
config = self ._load_service_config (app , 'router' )
42
53
43
- # See if the ssl.enforce annotation is available
44
- if 'ssl' not in config :
45
- config ['ssl' ] = {}
46
- if 'enforce' not in config ['ssl' ]:
47
- config ['ssl' ]['enforce' ] = 'false'
48
-
49
54
# convert from bool to string
50
55
config ['ssl' ]['enforce' ] = str (https_enforced )
51
56
52
57
self ._save_service_config (app , 'router' , config )
53
58
54
59
# Save to DB
55
60
return super (TLS , self ).save (* args , ** kwargs )
61
+
62
+ def sync (self ):
63
+ try :
64
+ app = str (self .app )
65
+
66
+ config = self ._load_service_config (app , 'router' )
67
+ if (
68
+ config ['ssl' ]['enforce' ] != str (self .https_enforced ) and
69
+ self .https_enforced is not None
70
+ ):
71
+ config ['ssl' ]['enforce' ] = str (self .https_enforced )
72
+ self ._save_service_config (app , 'router' , config )
73
+ except TLS .DoesNotExist :
74
+ pass
0 commit comments