2626from clients .ocp_gateway_secret import prep_submitted_config , prep_and_apply_secret , write_submitted_config
2727
2828from utils .validators import host_valid , validate_upstream
29- from utils .transforms import plugins_transformations
29+ from utils .transforms import plugins_transformations , add_version_if_missing
3030from utils .masking import mask
31+ from utils .deck import deck_cmd_sync_diff , deck_cmd_validate
3132
3233gw = Blueprint ('gwa' , 'gateway' )
3334
@@ -67,11 +68,12 @@ def delete_config(namespace: str, qualifier="") -> object:
6768
6869 # Call the 'deck' command
6970 cmd = "sync"
71+ deck_cli = app .config ['deckCLI' ]
72+
73+
74+ log .info ("[%s] (%s) %s action using %s" % (namespace , deck_cli , cmd , selectTag ))
75+ args = deck_cmd_sync_diff (deck_cli , cmd , selectTag , tempFolder )
7076
71- log .info ("[%s] %s action using %s" % (namespace , cmd , selectTag ))
72- args = [
73- "deck" , cmd , "--config" , "/tmp/deck.yaml" , "--skip-consumers" , "--select-tag" , selectTag , "--state" , tempFolder
74- ]
7577 log .debug ("[%s] Running %s" % (namespace , args ))
7678 deck_run = Popen (args , stdout = PIPE , stderr = STDOUT )
7779 out , err = deck_run .communicate ()
@@ -235,6 +237,9 @@ def write_config(namespace: str) -> object:
235237 # Enrichments
236238 #######################
237239
240+ # Add format version if its missing - needed in Kong v3+
241+ add_version_if_missing (gw_config )
242+
238243 # Transformation route hosts if in non-prod environment (HOST_TRANSFORM_ENABLED)
239244 host_transformation (namespace , gw_config )
240245
@@ -246,19 +251,21 @@ def write_config(namespace: str) -> object:
246251 # Enrich the rate-limiting plugin with the appropriate Redis details
247252 plugins_transformations (namespace , gw_config )
248253
249- # Check Kong 3 compatibility
250- is_compatible , compatibility_message , failed_routes , kong2_config = check_kong3_compatibility (namespace , gw_config )
251- if not is_compatible :
252- warning_message = compatibility_message
254+ # Disabled:
255+ #
256+ # # Check Kong 3 compatibility
257+ # is_compatible, compatibility_message, failed_routes, kong2_config = check_kong3_compatibility(namespace, gw_config)
258+ # if not is_compatible:
259+ # warning_message = compatibility_message
253260
254- # Track incompatible routes
255- if not is_compatible :
256- has_incompatible_routes = True
257- all_failed_routes .extend (failed_routes )
261+ # # Track incompatible routes
262+ # if not is_compatible:
263+ # has_incompatible_routes = True
264+ # all_failed_routes.extend(failed_routes)
258265
259- # Use kong2_config (which has compatibility tags) regardless of compatibility status
260- if kong2_config :
261- gw_config = kong2_config
266+ # # Use kong2_config (which has compatibility tags) regardless of compatibility status
267+ # if kong2_config:
268+ # gw_config = kong2_config
262269
263270 with open ("%s/%s" % (tempFolder , 'config-%02d.yaml' % index ), 'w' ) as file :
264271 yaml .dump (gw_config , file )
@@ -320,12 +327,12 @@ def write_config(namespace: str) -> object:
320327 selectTag = ns_qualifier
321328
322329 # Call the 'deck' command
330+ deck_cli = app .config ['deckCLI' ]
331+
332+ log .info ("[%s] (%s) %s action using %s" % (namespace , deck_cli , cmd , selectTag ))
323333
324- log . info ( "[%s] %s action using %s" % ( namespace , cmd , selectTag ) )
334+ args = deck_cmd_validate ( deck_cli , tempFolder )
325335
326- args = [
327- "deck" , "validate" , "--config" , "/tmp/deck.yaml" , "--state" , tempFolder
328- ]
329336 log .debug ("[%s] Running %s" % (namespace , args ))
330337 deck_validate = Popen (args , stdout = PIPE , stderr = STDOUT )
331338 out , err = deck_validate .communicate ()
@@ -335,9 +342,8 @@ def write_config(namespace: str) -> object:
335342 abort_early (event_id , 'validate' , namespace , jsonify (
336343 error = "Validation Failed." , results = mask (out .decode ('utf-8' ))))
337344
338- args = [
339- "deck" , cmd , "--config" , "/tmp/deck.yaml" , "--skip-consumers" , "--select-tag" , selectTag , "--state" , tempFolder
340- ]
345+ args = deck_cmd_sync_diff (deck_cli , cmd , selectTag , tempFolder )
346+
341347 log .debug ("[%s] Running %s" % (namespace , args ))
342348 deck_run = Popen (args , stdout = PIPE , stderr = STDOUT )
343349 out , err = deck_run .communicate ()
0 commit comments