Skip to content

Commit 0030664

Browse files
authored
Merge pull request #71 from bcgov/dev
Fix potential issue with plugins being applied
2 parents f271ac4 + aa81b7e commit 0030664

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

microservices/gatewayApi/clients/portal.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@ def record_gateway_event(event_id, action, result, namespace, message="", blob="
4545
'name': 'N/A',
4646
'message': message,
4747
'refId': '',
48-
'namespace': namespace
48+
'namespace': namespace,
49+
'context': {
50+
'message': 'GatewayConfig {action} {result} : {message}',
51+
'params': {
52+
'result': result,
53+
'message': message,
54+
'action': action
55+
}
56+
},
57+
'filterKey1': 'namespace:%s' % namespace
4958
}
5059

5160
if not blob == "" and not blob == None:

microservices/gatewayApi/v1/routes/gateway.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ def write_config(namespace: str) -> object:
246246

247247
# Validate that the every object is tagged with the namespace
248248
try:
249+
validate_base_entities(gw_config)
249250
validate_tags(gw_config, selectTag)
250251
except Exception as ex:
251252
traceback.print_exc()
@@ -391,7 +392,12 @@ def cleanup(dir_path):
391392
except OSError as e:
392393
log.error("Error: %s : %s" % (dir_path, e.strerror))
393394

394-
395+
def validate_base_entities(yaml):
396+
traversables = ['__plugin_configs', 'services', 'upstreams', 'certificates', 'caCertificates']
397+
for k in yaml:
398+
if k not in traversables:
399+
raise Exception("Invalid base entity %s" % k)
400+
395401
def validate_tags(yaml, required_tag):
396402
# throw an exception if there are invalid tags
397403
errors = []

microservices/gatewayApi/v2/routes/gateway.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ def write_config(namespace: str) -> object:
249249

250250
# Validate that the every object is tagged with the namespace
251251
try:
252+
validate_base_entities(gw_config)
252253
validate_tags(gw_config, selectTag)
253254
except Exception as ex:
254255
traceback.print_exc()
@@ -395,6 +396,11 @@ def cleanup(dir_path):
395396
except OSError as e:
396397
log.error("Error: %s : %s" % (dir_path, e.strerror))
397398

399+
def validate_base_entities(yaml):
400+
traversables = ['__plugin_configs', 'services', 'upstreams', 'certificates', 'caCertificates']
401+
for k in yaml:
402+
if k not in traversables:
403+
raise Exception("Invalid base entity %s" % k)
398404

399405
def validate_tags(yaml, required_tag):
400406
# throw an exception if there are invalid tags

0 commit comments

Comments
 (0)