Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix project_name parameter #332

Merged
merged 4 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelogs/fragments/326-project-name-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bugfixes:
- The C(project_name) parameter for many modules was used by alias C(project) internally in the
codebase, but to work properly C(project_name) must be used in the code. Replace
self.module.params.get("project") with self.module.params.get("project_name")
(https://github.com/ansible-collections/community.digitalocean/issues/326).
4 changes: 2 additions & 2 deletions plugins/modules/digital_ocean_block_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class DOBlockStorage(object):
def __init__(self, module):
self.module = module
self.rest = DigitalOceanHelper(module)
if self.module.params.get("project"):
if self.module.params.get("project_name"):
# only load for non-default project assignments
self.projects = DigitalOceanProjects(module, self.rest)

Expand Down Expand Up @@ -295,7 +295,7 @@ def create_block_storage(self):
status = response.status_code
json = response.json
if status == 201:
project_name = self.module.params.get("project")
project_name = self.module.params.get("project_name")
if (
project_name
): # empty string is the default project, skip project assignment
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/digital_ocean_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class DODatabase(object):
def __init__(self, module):
self.module = module
self.rest = DigitalOceanHelper(module)
if self.module.params.get("project"):
if self.module.params.get("project_name"):
# only load for non-default project assignments
self.projects = DigitalOceanProjects(module, self.rest)
# pop wait and wait_timeout so we don't include it in the POST data
Expand Down Expand Up @@ -335,7 +335,7 @@ def create(self):
if self.wait:
json_data = self.ensure_online(database_id)

project_name = self.module.params.get("project")
project_name = self.module.params.get("project_name")
if project_name: # empty string is the default project, skip project assignment
urn = "do:dbaas:{0}".format(database_id)
assign_status, error_message, resources = self.projects.assign_to_project(
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/digital_ocean_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def run(module):
do_manager = DoManager(module)
state = module.params.get("state")

if module.params.get("project"):
if module.params.get("project_name"):
# only load for non-default project assignments
projects = DigitalOceanProjects(module, do_manager)

Expand All @@ -214,7 +214,7 @@ def run(module):
# few times before giving up and returning null.

domain_name = module.params.get("name")
project_name = module.params.get("project")
project_name = module.params.get("project_name")
urn = "do:domain:{0}".format(domain_name)

for i in range(ZONE_FILE_ATTEMPTS):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/digital_ocean_droplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def __init__(self, module):
self.name = None
self.size = None
self.status = None
if self.module.params.get("project"):
if self.module.params.get("project_name"):
# only load for non-default project assignments
self.projects = DigitalOceanProjects(module, self.rest)
self.firewalls = self.get_firewalls()
Expand Down Expand Up @@ -779,7 +779,7 @@ def create(self, state):
if json_data:
droplet = json_data.get("droplet", droplet)

project_name = self.module.params.get("project")
project_name = self.module.params.get("project_name")
if project_name: # empty string is the default project, skip project assignment
urn = "do:droplet:{0}".format(droplet_id)
assign_status, error_message, resources = self.projects.assign_to_project(
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/digital_ocean_floating_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,11 @@ def create_floating_ips(module, rest):
json_data = response.json
if status_code == 202:
if module.params.get(
"project"
"project_name"
): # only load for non-default project assignments
rest = DigitalOceanHelper(module)
projects = DigitalOceanProjects(module, rest)
project_name = module.params.get("project")
project_name = module.params.get("project_name")
if (
project_name
): # empty string is the default project, skip project assignment
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/digital_ocean_load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
self.module.params.pop("oauth_token")
self.wait = self.module.params.pop("wait", True)
self.wait_timeout = self.module.params.pop("wait_timeout", 600)
if self.module.params.get("project"):
if self.module.params.get("project_name"):
# only load for non-default project assignments
self.projects = DigitalOceanProjects(module, self.rest)

Expand Down Expand Up @@ -716,7 +716,7 @@
if self.wait:
self.ensure_active()

project_name = self.module.params.get("project")
project_name = self.module.params.get("project_name")

Check warning on line 719 in plugins/modules/digital_ocean_load_balancer.py

View check run for this annotation

Codecov / codecov/patch

plugins/modules/digital_ocean_load_balancer.py#L719

Added line #L719 was not covered by tests
if project_name: # empty string is the default project, skip project assignment
urn = "do:loadbalancer:{0}".format(self.id)
(
Expand Down
Loading