chore(deps): update ansible-core requirement from <2.13,>=2.11 to >=2.12,<2.14 (#115)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mohamed El Mouctar HAIDARA <elmhaidara@gmail.com>
This commit is contained in:
dependabot[bot] 2022-10-09 14:12:57 +02:00 committed by GitHub
parent a8dfd02434
commit 0b1124b8f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 43 deletions

View file

@ -17,7 +17,7 @@ jobs:
matrix:
python-version: [ 3.8, 3.9 ]
# See https://www.ansible.com/blog/ansible-3.0.0-qa and https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html
ansible-version: [ 2.11.8, 2.12.2 ]
ansible-version: [ 2.12.9, 2.13.4 ]
steps:
- name: Checkout code

View file

@ -16,7 +16,6 @@ import json
import ntpath
import os
import sys
from abc import ABC
from ansible.cli import CLI
from ansible.cli.arguments import option_helpers
@ -37,19 +36,20 @@ from ansibleplaybookgrapher.postprocessor import GraphVizPostProcessor
display = Display()
def get_cli_class():
class PlaybookGrapherCLI(CLI):
"""
Utility function to return the class to use as CLI
:return:
The dedicated playbook grapher CLI
"""
return PlaybookGrapherCLI
name = __prog__
class GrapherCLI(CLI, ABC):
"""
An abstract class to be implemented by the different Grapher CLIs.
"""
def __init__(self, args, callback=None):
super().__init__(args=args, callback=callback)
# We keep the old options as instance attribute for backward compatibility for the grapher CLI.
# From Ansible 2.8, they remove this instance attribute 'options' and use a global context instead.
# But this may change in the future:
# https://github.com/ansible/ansible/blob/bcb64054edaa7cf636bd38b8ab0259f6fb93f3f9/lib/ansible/context.py#L8
self.options = None
def run(self):
super().run()
@ -91,20 +91,6 @@ class GrapherCLI(CLI, ABC):
return svg_path
class PlaybookGrapherCLI(GrapherCLI):
"""
The dedicated playbook grapher CLI
"""
def __init__(self, args, callback=None):
super().__init__(args=args, callback=callback)
# We keep the old options as instance attribute for backward compatibility for the grapher CLI.
# From Ansible 2.8, they remove this instance attribute 'options' and use a global context instead.
# But this may change in the future:
# https://github.com/ansible/ansible/blob/bcb64054edaa7cf636bd38b8ab0259f6fb93f3f9/lib/ansible/context.py#L8
self.options = None
def _add_my_options(self):
"""
Add some of my options to the parser
@ -264,7 +250,7 @@ class PlaybookGrapherCLI(GrapherCLI):
def main(args=None):
args = args or sys.argv
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
cli.run()

View file

@ -1,4 +1,4 @@
ansible-core>=2.11,<2.13
ansible-core>=2.12,<2.14
graphviz>=0.18,<1
colour<1
lxml<5

View file

@ -3,7 +3,7 @@ from ansible.errors import AnsibleOptionsError
from ansible.release import __version__ as ansible_version
from ansibleplaybookgrapher import __prog__, __version__
from ansibleplaybookgrapher.cli import get_cli_class
from ansibleplaybookgrapher.cli import PlaybookGrapherCLI
@pytest.mark.parametrize("help_option", ["-h", "--help"])
@ -16,7 +16,7 @@ def test_cli_help(help_option, capfd):
"""
args = [__prog__, help_option]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
with pytest.raises(SystemExit) as exception_info:
cli.parse()
@ -31,7 +31,7 @@ def test_cli_version(capfd):
Test version printing
:return:
"""
cli = get_cli_class()([__prog__, "--version"])
cli = PlaybookGrapherCLI([__prog__, "--version"])
with pytest.raises(SystemExit) as exception_info:
cli.parse()
@ -53,7 +53,7 @@ def test_cli_save_dot_file(save_dot_file_option, expected):
"""
args = [__prog__] + save_dot_file_option + ["playbook.yml"]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
cli.parse()
@ -78,7 +78,7 @@ def test_cli_output_filename(output_filename_option, expected):
"""
args = [__prog__] + output_filename_option + ["playbook.yml"]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
cli.parse()
@ -100,7 +100,7 @@ def test_cli_include_role_tasks(include_role_tasks_option, expected):
args = [__prog__] + include_role_tasks_option + ["playboook.yml"]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
cli.parse()
@ -126,7 +126,7 @@ def test_cli_tags(tags_option, expected):
"""
args = [__prog__] + tags_option + ["playbook.yml"]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
cli.parse()
@ -159,7 +159,7 @@ def test_skip_tags(skip_tags_option, expected):
"""
args = [__prog__] + skip_tags_option + ["playbook.yml"]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
cli.parse()
@ -175,7 +175,7 @@ def test_cli_no_playbook():
"""
args = [__prog__]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
with pytest.raises((AnsibleOptionsError, SystemExit)) as exception_info:
cli.parse()
@ -188,7 +188,7 @@ def test_cli_multiple_playbooks():
"""
args = [__prog__, "playbook1.yml", "playbook2.yml"]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
cli.parse()
assert cli.options.playbook_filenames == ["playbook1.yml", "playbook2.yml"]
@ -205,7 +205,7 @@ def test_cli_verbosity_options(verbosity, verbosity_number):
"""
args = [__prog__, verbosity, "playbook1.yml"]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
cli.parse()
assert cli.options.verbosity == verbosity_number
@ -226,7 +226,7 @@ def test_cli_open_protocol_custom_formats():
"playbook1.yml",
]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
cli.parse()
assert cli.options.open_protocol_custom_formats == {
"file": "{path}",
@ -241,7 +241,7 @@ def test_cli_open_protocol_custom_formats_not_provided():
"""
args = [__prog__, "--open-protocol-handler", "custom", "playbook1.yml"]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
with pytest.raises(AnsibleOptionsError) as exception_info:
cli.parse()
@ -274,7 +274,7 @@ def test_cli_open_protocol_custom_formats_invalid_inputs(
"playbook1.yml",
]
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
with pytest.raises(SystemExit) as exception_info:
cli.parse()

View file

@ -6,7 +6,7 @@ import pytest
from pyquery import PyQuery
from ansibleplaybookgrapher import __prog__
from ansibleplaybookgrapher.cli import get_cli_class
from ansibleplaybookgrapher.cli import PlaybookGrapherCLI
from tests import FIXTURES_DIR
# This file directory abspath
@ -48,7 +48,7 @@ def run_grapher(
args.extend(playbook_paths)
cli = get_cli_class()(args)
cli = PlaybookGrapherCLI(args)
return cli.run(), playbook_paths