Skip to content

Commit

Permalink
patch katello apidoc to allow unsetting content credentials before 4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Aug 15, 2023
1 parent 29af81c commit 2581555
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions plugins/module_utils/foreman_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,21 @@ def _patch_organization_ignore_types_api(self):
_organization_create['params'].append(_ignore_types_param)
_organization_update['params'].append(_ignore_types_param)

@_check_patch_needed(fixed_version='3.8.0', plugins=['katello'])
def _patch_products_repositories_allow_nil_credential(self):
"""
This is a workaround for the missing allow_nil: true in the Products and Repositories controllers
See https://projects.theforeman.org/issues/36497
"""

for resource in ['products', 'repositories']:
methods = self.foremanapi.apidoc['docs']['resources'][resource]['methods']
for action in ['create', 'update']:
resource_action = next(x for x in methods if x['name'] == action)
for param in ['gpg_key_id', 'ssl_ca_cert_id', 'ssl_client_cert_id', 'ssl_client_key_id']:
resource_param = next(x for x in resource_action['params'] if x['name'] == param)
resource_param['allow_nil'] = True

def check_requirements(self):
if not HAS_APYPIE:
self.fail_json(msg=missing_required_lib("requests"), exception=APYPIE_IMP_ERR)
Expand Down Expand Up @@ -620,6 +635,7 @@ def apply_apidoc_patches(self):
self._patch_cv_filter_rule_api()
self._patch_ak_product_content_per_page()
self._patch_organization_ignore_types_api()
self._patch_products_repositories_allow_nil_credential()

@_exception2fail_json(msg="Failed to connect to Foreman server: {0}")
def status(self):
Expand Down

0 comments on commit 2581555

Please sign in to comment.