Skip to content

Commit 01a154c

Browse files
fix: remove dbaas configuration (#527)
## 📝 Description **What does this PR do and why is this change necessary?** Removing dbaas configuraiton steps as dbaas is now opt-in only. ## ✔️ How to Test **How do I run the relevant unit/integration tests?** `pytest -v tests/unit/test_configuration.py`
1 parent bcb3ba0 commit 01a154c

File tree

5 files changed

+11
-94
lines changed

5 files changed

+11
-94
lines changed

linodecli/api_request.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ def _build_request_body(ctx, operation, parsed_args) -> Optional[str]:
206206

207207
# Merge defaults into body if applicable
208208
if ctx.defaults:
209-
parsed_args = ctx.config.update(
210-
parsed_args, operation.allowed_defaults, operation.action
211-
)
209+
parsed_args = ctx.config.update(parsed_args, operation.allowed_defaults)
212210

213211
to_json = {}
214212

linodecli/configuration/__init__.py

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def plugin_get_value(self, key):
216216
# might be better to move this to argparsing during refactor and just have
217217
# configuration return defaults or keys or something
218218
def update(
219-
self, namespace, allowed_defaults, action=None
219+
self, namespace, allowed_defaults
220220
): # pylint: disable=too-many-branches
221221
"""
222222
This updates a Namespace (as returned by ArgumentParser) with config values
@@ -247,17 +247,6 @@ def update(
247247
value = None
248248
if self.config.has_option(username, key):
249249
value = self.config.get(username, key)
250-
# different types of database creation use different endpoints,
251-
# so we need to set the default engine value based on the type
252-
elif key == "engine":
253-
if action == "mysql-create" and self.config.has_option(
254-
username, "mysql_engine"
255-
):
256-
value = self.config.get(username, "mysql_engine")
257-
elif action == "postgresql-create" and self.config.has_option(
258-
username, "postgresql_engine"
259-
):
260-
value = self.config.get(username, "postgresql_engine")
261250
else:
262251
value = ns_dict[key]
263252

@@ -354,15 +343,6 @@ def configure(
354343
images = [
355344
i["id"] for i in _do_get_request(self.base_url, "/images")["data"]
356345
]
357-
engines_list = _do_get_request(self.base_url, "/databases/engines")[
358-
"data"
359-
]
360-
mysql_engines = [
361-
e["id"] for e in engines_list if e["engine"] == "mysql"
362-
]
363-
postgresql_engines = [
364-
e["id"] for e in engines_list if e["engine"] == "postgresql"
365-
]
366346

367347
is_full_access = _check_full_access(self.base_url, token)
368348

@@ -414,26 +394,6 @@ def configure(
414394
),
415395
)
416396

417-
config["mysql_engine"] = _default_thing_input(
418-
"Default Engine to create a Managed MySQL Database.",
419-
mysql_engines,
420-
"Default Engine (Optional): ",
421-
"Please select a valid MySQL Database Engine, or press Enter to skip",
422-
current_value=_config_get_with_default(
423-
self.config, username, "mysql_engine"
424-
),
425-
)
426-
427-
config["postgresql_engine"] = _default_thing_input(
428-
"Default Engine to create a Managed PostgreSQL Database.",
429-
postgresql_engines,
430-
"Default Engine (Optional): ",
431-
"Please select a valid PostgreSQL Database Engine, or press Enter to skip",
432-
current_value=_config_get_with_default(
433-
self.config, username, "postgresql_engine"
434-
),
435-
)
436-
437397
if auth_users:
438398
config["authorized_users"] = _default_thing_input(
439399
"Select the user that should be given default SSH access to new Linodes.",

tests/unit/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
image = linode/ubuntu21.10
1818
token = notafaketoken
1919
type = g6-nanode-1
20-
mysql_engine = mysql/8.0.26
2120
"""
2221

2322
LOADED_FILES = {}

tests/unit/test_api_request.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,39 +56,37 @@ def test_request_debug_info(self):
5656
assert "> " in output
5757

5858
def test_build_request_body(self, mock_cli, create_operation):
59-
create_operation.allowed_defaults = ["region", "engine"]
60-
create_operation.action = "mysql-create"
59+
create_operation.allowed_defaults = ["region", "image"]
6160

6261
result = api_request._build_request_body(
6362
mock_cli,
6463
create_operation,
6564
SimpleNamespace(
6665
generic_arg="foo",
6766
region=None,
68-
engine=None,
67+
image=None,
6968
),
7069
)
7170
assert (
7271
json.dumps(
7372
{
7473
"generic_arg": "foo",
7574
"region": "us-southeast",
76-
"engine": "mysql/8.0.26",
75+
"image": "linode/ubuntu21.10",
7776
}
7877
)
7978
== result
8079
)
8180

8281
def test_build_request_body_null_field(self, mock_cli, create_operation):
83-
create_operation.allowed_defaults = ["region", "engine"]
84-
create_operation.action = "mysql-create"
82+
create_operation.allowed_defaults = ["region", "image"]
8583
result = api_request._build_request_body(
8684
mock_cli,
8785
create_operation,
8886
SimpleNamespace(
8987
generic_arg="foo",
9088
region=None,
91-
engine=None,
89+
image=None,
9290
nullable_int=ExplicitNullValue(),
9391
),
9492
)
@@ -97,7 +95,7 @@ def test_build_request_body_null_field(self, mock_cli, create_operation):
9795
{
9896
"generic_arg": "foo",
9997
"region": "us-southeast",
100-
"engine": "mysql/8.0.26",
98+
"image": "linode/ubuntu21.10",
10199
"nullable_int": None,
102100
}
103101
)
@@ -107,15 +105,14 @@ def test_build_request_body_null_field(self, mock_cli, create_operation):
107105
def test_build_request_body_non_null_field(
108106
self, mock_cli, create_operation
109107
):
110-
create_operation.allowed_defaults = ["region", "engine"]
111-
create_operation.action = "mysql-create"
108+
create_operation.allowed_defaults = ["region", "image"]
112109
result = api_request._build_request_body(
113110
mock_cli,
114111
create_operation,
115112
SimpleNamespace(
116113
generic_arg="foo",
117114
region=None,
118-
engine=None,
115+
image=None,
119116
nullable_int=12345,
120117
),
121118
)
@@ -124,7 +121,7 @@ def test_build_request_body_non_null_field(
124121
{
125122
"generic_arg": "foo",
126123
"region": "us-southeast",
127-
"engine": "mysql/8.0.26",
124+
"image": "linode/ubuntu21.10",
128125
"nullable_int": 12345,
129126
}
130127
)

tests/unit/test_configuration.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,6 @@ def test_update(self):
234234

235235
assert "--no-defaults" not in f.getvalue()
236236

237-
# test that update default engine value correctly when creating database
238-
create_db_action = "mysql-create"
239-
f = io.StringIO()
240-
with contextlib.redirect_stdout(f):
241-
result = vars(conf.update(ns, allowed_defaults, create_db_action))
242-
assert result.get("engine") == "mysql/new-test-engine"
243-
244237
def test_write_config(self):
245238
"""
246239
Test CLIConfig.write_config()
@@ -302,18 +295,6 @@ def mock_input(prompt):
302295
m.get(
303296
f"{self.base_url}/images", json={"data": [{"id": "test-image"}]}
304297
)
305-
m.get(
306-
f"{self.base_url}/databases/engines",
307-
json={
308-
"data": [
309-
{"id": "mysql/test-engine", "engine": "mysql"},
310-
{
311-
"id": "postgresql/test-engine",
312-
"engine": "postgresql",
313-
},
314-
]
315-
},
316-
)
317298
m.get(
318299
f"{self.base_url}/account/users",
319300
json={"data": [{"username": "cli-dev", "ssh_keys": "testkey"}]},
@@ -325,9 +306,6 @@ def mock_input(prompt):
325306
assert conf.get_value("image") == "test-image"
326307
assert conf.get_value("region") == "test-region"
327308
assert conf.get_value("authorized_users") == "cli-dev"
328-
# make sure that we set the default engine value according to type of database
329-
assert conf.get_value("mysql_engine") == "mysql/test-engine"
330-
assert conf.get_value("postgresql_engine") == "postgresql/test-engine"
331309
assert conf.get_value("api_host") == "foobar.linode.com"
332310
assert conf.get_value("api_version") == "v4beta"
333311
assert conf.get_value("api_scheme") == "https"
@@ -368,18 +346,6 @@ def mock_input(prompt):
368346
m.get(
369347
f"{self.base_url}/images", json={"data": [{"id": "test-image"}]}
370348
)
371-
m.get(
372-
f"{self.base_url}/databases/engines",
373-
json={
374-
"data": [
375-
{"id": "mysql/test-engine", "engine": "mysql"},
376-
{
377-
"id": "postgresql/test-engine",
378-
"engine": "postgresql",
379-
},
380-
]
381-
},
382-
)
383349
m.get(
384350
f"{self.base_url}/account/users",
385351
json={"data": [{"username": "cli-dev", "ssh_keys": "testkey"}]},
@@ -391,9 +357,6 @@ def mock_input(prompt):
391357
assert conf.get_value("region") == "test-region"
392358
assert conf.get_value("authorized_users") == "cli-dev"
393359
assert conf.config.get("DEFAULT", "default-user") == "DEFAULT"
394-
# make sure that we set the default engine value according to type of database
395-
assert conf.get_value("mysql_engine") == "mysql/test-engine"
396-
assert conf.get_value("postgresql_engine") == "postgresql/test-engine"
397360

398361
def test_default_thing_input_no_current(self, monkeypatch):
399362
stdout_buf = io.StringIO()

0 commit comments

Comments
 (0)