@@ -212,7 +212,7 @@ def plugin_get_value(self, key):
212212 # might be better to move this to argparsing during refactor and just have
213213 # configuration return defaults or keys or something
214214 def update (
215- self , namespace , allowed_defaults
215+ self , namespace , allowed_defaults , action = None
216216 ): # pylint: disable=too-many-branches
217217 """
218218 This updates a Namespace (as returned by ArgumentParser) with config values
@@ -242,6 +242,17 @@ def update(
242242 continue
243243 if self .config .has_option (username , key ):
244244 value = self .config .get (username , key )
245+ # different types of database creation use different endpoints,
246+ # so we need to set the default engine value based on the type
247+ elif key == "engine" :
248+ if action == "mysql-create" and self .config .has_option (
249+ username , "mysql_engine"
250+ ):
251+ value = self .config .get (username , "mysql_engine" )
252+ elif action == "postgresql-create" and self .config .has_option (
253+ username , "postgresql_engine"
254+ ):
255+ value = self .config .get (username , "postgresql_engine" )
245256 else :
246257 value = ns_dict [key ]
247258 if not value :
@@ -275,7 +286,7 @@ def write_config(self):
275286
276287 def configure (
277288 self ,
278- ): # pylint: disable=too-many-branches,too-many-statements
289+ ): # pylint: disable=too-many-branches,too-many-statements,too-many-locals
279290 """
280291 This assumes we're running interactively, and prompts the user
281292 for a series of defaults in order to make future CLI calls
@@ -336,6 +347,15 @@ def configure(
336347 images = [
337348 i ["id" ] for i in _do_get_request (self .base_url , "/images" )["data" ]
338349 ]
350+ engines_list = _do_get_request (self .base_url , "/databases/engines" )[
351+ "data"
352+ ]
353+ mysql_engines = [
354+ e ["id" ] for e in engines_list if e ["engine" ] == "mysql"
355+ ]
356+ postgresql_engines = [
357+ e ["id" ] for e in engines_list if e ["engine" ] == "postgresql"
358+ ]
339359
340360 is_full_access = _check_full_access (self .base_url , token )
341361
@@ -378,6 +398,20 @@ def configure(
378398 "Please select a valid Image, or press Enter to skip" ,
379399 )
380400
401+ config ["mysql_engine" ] = _default_thing_input (
402+ "Default Engine to create a Managed MySQL Database." ,
403+ mysql_engines ,
404+ "Default Engine (Optional): " ,
405+ "Please select a valid MySQL Database Engine, or press Enter to skip" ,
406+ )
407+
408+ config ["postgresql_engine" ] = _default_thing_input (
409+ "Default Engine to create a Managed PostgreSQL Database." ,
410+ postgresql_engines ,
411+ "Default Engine (Optional): " ,
412+ "Please select a valid PostgreSQL Database Engine, or press Enter to skip" ,
413+ )
414+
381415 if auth_users :
382416 config ["authorized_users" ] = _default_thing_input (
383417 "Select the user that should be given default SSH access to new Linodes." ,
0 commit comments