Fixed error handling in github_issue module (#39652)

* Fixed error handling in github_issue module

Due to recent changes in github3.py library module stopped working.
This fix adds extra error handling for new changes in library.

Fixes: #39627

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>

* Check version

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>

* Refactor github_issue

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2019-05-15 12:05:11 +05:30 committed by ansibot
parent 107d9efef3
commit 5ef2c5314e
8 changed files with 34 additions and 97 deletions

View file

@ -1,3 +1,2 @@
destructive
shippable/posix/group1
disabled

View file

@ -1,3 +0,0 @@
- name: install py27-requests to avoid install via pip later
package:
name: py27-requests

View file

@ -1 +0,0 @@
# nothing to do here, allow requests to be installed by pip later

View file

@ -1,3 +0,0 @@
- name: install python-requests to avoid install via pip later
package:
name: python-requests

View file

@ -1,3 +0,0 @@
- name: install python3-requests to avoid install via pip later
package:
name: python3-requests

View file

@ -1,56 +1,8 @@
# Test code for the github_issue module.
# (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright: (c) 2017-2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: make sure github3.py is not installed
pip:
name: github3.py
state: absent
# Testcase 0001: Check if dependency is installed
- name: Check if github3.py is installed or not
github_issue:
organization: "{{ organization }}"
repo: "{{ repo }}"
issue: "{{ non_existent_issue }}"
action: get_status
register: lib_missing
ignore_errors: True
- assert:
that:
- "{{ lib_missing.failed == True }}"
- "{{ lib_missing.changed == False }}"
- "{{ 'Missing required github3 module.' in lib_missing.msg }}"
- include: '{{ item }}'
with_first_found:
- files:
- '{{ ansible_distribution }}-{{ ansible_distribution_version }}-python{{ ansible_python_version.split(".")[0] }}.yml'
- '{{ ansible_distribution }}-python{{ ansible_python_version.split(".")[0] }}.yml'
- '{{ ansible_os_family }}-python{{ ansible_python_version.split(".")[0] }}.yml'
- 'default-python{{ ansible_python_version.split(".")[0] }}.yml'
- name: make sure github3.py is installed
pip:
name: github3.py
# Testcase 0002: Check if issue exists
- name: Check if GitHub issue is closed or not
github_issue:
organization: "{{ organization }}"
@ -64,7 +16,6 @@
- "{{ get_status_0002.changed == True }}"
- "{{ get_status_0002.issue_status == 'closed' }}"
# Testcase 0003: Check non-existent issue status
- name: Check if GitHub issue is closed or not
github_issue:
organization: "{{ organization }}"

View file

@ -738,8 +738,6 @@ lib/ansible/modules/remote_management/ucs/ucs_vsans.py E322
lib/ansible/modules/remote_management/ucs/ucs_wwn_pool.py E322
lib/ansible/modules/remote_management/ucs/ucs_wwn_pool.py E323
lib/ansible/modules/source_control/github_deploy_key.py E336
lib/ansible/modules/source_control/github_issue.py E324
lib/ansible/modules/source_control/github_issue.py E326
lib/ansible/modules/source_control/subversion.py E322
lib/ansible/modules/storage/infinidat/infini_export.py E323
lib/ansible/modules/storage/infinidat/infini_export.py E324
@ -800,4 +798,4 @@ lib/ansible/modules/web_infrastructure/gunicorn.py E322
lib/ansible/modules/web_infrastructure/htpasswd.py E326
lib/ansible/modules/web_infrastructure/jenkins_plugin.py E322
lib/ansible/modules/web_infrastructure/jenkins_plugin.py E324
lib/ansible/modules/web_infrastructure/jira.py E322
lib/ansible/modules/web_infrastructure/jira.py E322