@@ -47,6 +47,30 @@ def inner(func):
4747 return inner
4848
4949
50+ @output_override ("databases" , "mysql-config-view" , OutputMode .table )
51+ def handle_databases_mysql_config_view (
52+ operation , output_handler , json_data
53+ ) -> bool :
54+ # pylint: disable=unused-argument
55+ """
56+ Override the output of 'linode-cli databases mysql-config-view'
57+ to properly display the mysql engine config.
58+ """
59+ return databases_mysql_config_view_output (json_data )
60+
61+
62+ @output_override ("databases" , "postgres-config-view" , OutputMode .table )
63+ def handle_databases_postgres_config_view (
64+ operation , output_handler , json_data
65+ ) -> bool :
66+ # pylint: disable=unused-argument
67+ """
68+ Override the output of 'linode-cli databases postgres-config-view'
69+ to properly display the postgresql engine config.
70+ """
71+ return databases_postgres_config_view_output (json_data )
72+
73+
5074@output_override ("domains" , "zone-file" , OutputMode .delimited )
5175def handle_domains_zone_file (operation , output_handler , json_data ) -> bool :
5276 # pylint: disable=unused-argument
@@ -291,3 +315,97 @@ def pg_view_output(json_data) -> bool:
291315 console .print (output )
292316
293317 return False
318+
319+
320+ def add_param_row (output , param_name , param_data ):
321+ """
322+ Construct and add a row to the output table for DB Config view overrides.
323+ """
324+ param_type = str (param_data .get ("type" , "" ))
325+ example = str (param_data .get ("example" , "" ))
326+ minimum = str (param_data .get ("minimum" , "" ))
327+ maximum = str (param_data .get ("maximum" , "" ))
328+ min_length = str (param_data .get ("minLength" , "" ))
329+ max_length = str (param_data .get ("maxLength" , "" ))
330+ pattern = str (param_data .get ("pattern" , "" ))
331+ requires_restart = "YES" if param_data .get ("requires_restart" ) else "NO"
332+ description = param_data .get ("description" , "" )
333+
334+ output .add_row (
335+ param_name ,
336+ param_type ,
337+ example ,
338+ minimum ,
339+ maximum ,
340+ min_length ,
341+ max_length ,
342+ pattern ,
343+ requires_restart ,
344+ Align (description , align = "left" ),
345+ )
346+
347+
348+ def databases_mysql_config_view_output (json_data ) -> bool :
349+ """
350+ Parse and format the MySQL configuration output table.
351+ """
352+ output = Table (header_style = "bold" , show_lines = True )
353+
354+ output .add_column ("Parameter" , style = "bold" )
355+ output .add_column ("Type" , justify = "center" )
356+ output .add_column ("Example" , justify = "center" )
357+ output .add_column ("Min" , justify = "center" )
358+ output .add_column ("Max" , justify = "center" )
359+ output .add_column ("Min Length" , justify = "center" )
360+ output .add_column ("Max Length" , justify = "center" )
361+ output .add_column ("Pattern" , justify = "center" )
362+ output .add_column ("Requires Restart" , justify = "center" )
363+ output .add_column ("Description" , style = "dim" )
364+
365+ for field , params in json_data .items ():
366+ if field in ["binlog_retention_period" ]:
367+ add_param_row (output , field , params )
368+ else :
369+ for key , val in params .items ():
370+ param_name = f"{ field } .{ key } "
371+ add_param_row (output , param_name , val )
372+
373+ console = Console ()
374+ console .print (output )
375+
376+ return False
377+
378+
379+ def databases_postgres_config_view_output (json_data ) -> bool :
380+ """
381+ Parse and format the PostgreSQL configuration output table.
382+ """
383+ output = Table (header_style = "bold" , show_lines = True )
384+
385+ output .add_column ("Parameter" , style = "bold" )
386+ output .add_column ("Type" , justify = "center" )
387+ output .add_column ("Example" , justify = "center" )
388+ output .add_column ("Min" , justify = "center" )
389+ output .add_column ("Max" , justify = "center" )
390+ output .add_column ("Min Length" , justify = "center" )
391+ output .add_column ("Max Length" , justify = "center" )
392+ output .add_column ("Pattern" , justify = "center" )
393+ output .add_column ("Requires Restart" , justify = "center" )
394+ output .add_column ("Description" , style = "dim" )
395+
396+ for field , params in json_data .items ():
397+ if field in [
398+ "pg_stat_monitor_enable" ,
399+ "shared_buffers_percentage" ,
400+ "work_mem" ,
401+ ]:
402+ add_param_row (output , field , params )
403+ else :
404+ for key , val in params .items ():
405+ param_name = f"{ field } .{ key } "
406+ add_param_row (output , param_name , val )
407+
408+ console = Console ()
409+ console .print (output )
410+
411+ return False
0 commit comments