Skip to content
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
2 changes: 1 addition & 1 deletion changelog/+utils-refactor.changed.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Refactored the GitHub API interaction layer into reusable per-entity modules below `saltext.github.utils.github`. These raise `GitHubApiError`/`GitHubNotFoundError` (subclasses of `CommandExecutionError`) instead of returning error indicators. Existing execution module functions behave as before, except that unhandled API errors now surface as the above exceptions instead of raw PyGithub ones.
Refactored the GitHub API interaction layer into reusable per-entity modules below `saltext.github.utils.gh`. These raise `GitHubApiError`/`GitHubNotFoundError` (subclasses of `CommandExecutionError`) instead of returning error indicators. Existing execution module functions behave as before, except that unhandled API errors now surface as the above exceptions instead of raw PyGithub ones.
20 changes: 10 additions & 10 deletions docs/ref/utils/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ _________
:toctree:

utils
utils.github
utils.github.client
utils.github.exceptions
utils.github.issues
utils.github.milestones
utils.github.pulls
utils.github.repos
utils.github.rulesets
utils.github.teams
utils.github.users
utils.gh
utils.gh.client
utils.gh.exceptions
utils.gh.issues
utils.gh.milestones
utils.gh.pulls
utils.gh.repos
utils.gh.rulesets
utils.gh.teams
utils.gh.users
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.client.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh.client
==============================

.. automodule:: saltext.github.utils.gh.client
:members:
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.exceptions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh.exceptions
==================================

.. automodule:: saltext.github.utils.gh.exceptions
:members:
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.issues.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh.issues
==============================

.. automodule:: saltext.github.utils.gh.issues
:members:
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.milestones.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh.milestones
==================================

.. automodule:: saltext.github.utils.gh.milestones
:members:
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.pulls.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh.pulls
=============================

.. automodule:: saltext.github.utils.gh.pulls
:members:
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.repos.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh.repos
=============================

.. automodule:: saltext.github.utils.gh.repos
:members:
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh
=======================

.. automodule:: saltext.github.utils.gh
:members:
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.rulesets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh.rulesets
================================

.. automodule:: saltext.github.utils.gh.rulesets
:members:
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.teams.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh.teams
=============================

.. automodule:: saltext.github.utils.gh.teams
:members:
5 changes: 5 additions & 0 deletions docs/ref/utils/saltext.github.utils.gh.users.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
saltext.github.utils.gh.users
=============================

.. automodule:: saltext.github.utils.gh.users
:members:
5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.client.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.exceptions.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.issues.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.milestones.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.pulls.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.repos.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.rulesets.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.teams.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/ref/utils/saltext.github.utils.github.users.rst

This file was deleted.

20 changes: 10 additions & 10 deletions src/saltext/github/modules/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@
from saltext.github.utils import filter_unset

try:
from saltext.github.utils.github import client as gh_client
from saltext.github.utils.github import issues as gh_issues
from saltext.github.utils.github import milestones as gh_milestones
from saltext.github.utils.github import pulls as gh_pulls
from saltext.github.utils.github import repos as gh_repos
from saltext.github.utils.github import rulesets as gh_rulesets
from saltext.github.utils.github import teams as gh_teams
from saltext.github.utils.github import users as gh_users
from saltext.github.utils.github.exceptions import GitHubApiError
from saltext.github.utils.github.exceptions import GitHubNotFoundError
from saltext.github.utils.gh import client as gh_client
from saltext.github.utils.gh import issues as gh_issues
from saltext.github.utils.gh import milestones as gh_milestones
from saltext.github.utils.gh import pulls as gh_pulls
from saltext.github.utils.gh import repos as gh_repos
from saltext.github.utils.gh import rulesets as gh_rulesets
from saltext.github.utils.gh import teams as gh_teams
from saltext.github.utils.gh import users as gh_users
from saltext.github.utils.gh.exceptions import GitHubApiError
from saltext.github.utils.gh.exceptions import GitHubNotFoundError

HAS_LIBS = True
except ImportError: # pragma: no cover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

The submodules of this package provide reusable primitives for talking
to the GitHub API on behalf of an organization, built around
:class:`~saltext.github.utils.github.client.GitHubConnection`.
They raise :class:`~saltext.github.utils.github.exceptions.GitHubApiError`
:class:`~saltext.github.utils.gh.client.GitHubConnection`.
They raise :class:`~saltext.github.utils.gh.exceptions.GitHubApiError`
(or its more specific subclass
:class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError`)
:class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError`)
on API errors.
"""

Expand All @@ -15,8 +15,8 @@
import salt.utils.http
import salt.utils.json

from saltext.github.utils.github.exceptions import GitHubApiError # noqa: F401
from saltext.github.utils.github.exceptions import GitHubNotFoundError # noqa: F401
from saltext.github.utils.gh.exceptions import GitHubApiError # noqa: F401
from saltext.github.utils.gh.exceptions import GitHubNotFoundError # noqa: F401

log = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Shared plumbing for talking to the GitHub v3 API via PyGithub.

The functions in this package operate on a :class:`GitHubConnection` and
raise :class:`~saltext.github.utils.github.exceptions.GitHubApiError`
(or its :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError`
raise :class:`~saltext.github.utils.gh.exceptions.GitHubApiError`
(or its :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError`
subclass) on API errors. They are shared between the classic ``github``
execution module and future resource modules.
"""
Expand All @@ -17,8 +17,8 @@
from github.GithubException import UnknownObjectException
from salt.exceptions import CommandExecutionError

from saltext.github.utils.github.exceptions import GitHubApiError
from saltext.github.utils.github.exceptions import GitHubNotFoundError
from saltext.github.utils.gh.exceptions import GitHubApiError
from saltext.github.utils.gh.exceptions import GitHubNotFoundError

log = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging

from saltext.github.utils.github import client
from saltext.github.utils.gh import client

log = logging.getLogger(__name__)

Expand All @@ -14,7 +14,7 @@ def get(conn, repo_name, number):
Return the raw data of a single issue.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

repo_name
The name of the repository the issue belongs to.
Expand All @@ -30,7 +30,7 @@ def get_comments(conn, repo_name, number, since=None):
Return the raw comment data for a single issue.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

repo_name
The name of the repository the issue belongs to.
Expand Down Expand Up @@ -70,7 +70,7 @@ def list_all(
options. Pull requests are excluded.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

repo_name
The name of the repository whose issues to list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging

from saltext.github.utils.github import client
from saltext.github.utils.gh import client

log = logging.getLogger(__name__)

Expand All @@ -14,7 +14,7 @@ def get(conn, repo_name, number):
Return the raw data of a single milestone.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

repo_name
The name of the repository the milestone belongs to.
Expand All @@ -39,7 +39,7 @@ def list_all(
search options.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

repo_name
The name of the repository whose milestones to list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging

from saltext.github.utils.github import client
from saltext.github.utils.gh import client

log = logging.getLogger(__name__)

Expand All @@ -25,7 +25,7 @@ def list_all(
search options.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

repo_name
The name of the repository whose pull requests to list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from salt.exceptions import CommandExecutionError

from saltext.github.utils import filter_unset
from saltext.github.utils.github.client import api_request
from saltext.github.utils.github.exceptions import GitHubNotFoundError
from saltext.github.utils.gh.client import api_request
from saltext.github.utils.gh.exceptions import GitHubNotFoundError

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -50,7 +50,7 @@ def list_all(conn, ignore_cache=False):
objects (cached).

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

ignore_cache
Bypass the cached repository list.
Expand All @@ -71,15 +71,15 @@ def get_info(conn, name, ignore_cache=False):
Return information about a single repository as a dictionary (cached).

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

name
The name of the repository.

ignore_cache
Bypass the cached repository information.

Raises :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError`
Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError`
if the repository does not exist.
"""
key = ("repo_info", name.lower())
Expand All @@ -106,12 +106,12 @@ def get_teams(conn, name):
Return the teams a repository belongs to.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

name
The name of the repository.

Raises :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError`
Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError`
if the repository does not exist.
"""
try:
Expand Down Expand Up @@ -146,7 +146,7 @@ def create(
Create a new repository in the organization.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

name
The name of the repository to create.
Expand Down Expand Up @@ -187,7 +187,7 @@ def update(
Update an existing repository in the organization.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

name
The name of the repository to update.
Expand Down Expand Up @@ -225,7 +225,7 @@ def delete(conn, name):
Delete a repository from the organization.

conn
The :class:`~saltext.github.utils.github.client.GitHubConnection` to use.
The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use.

name
The name of the repository to delete.
Expand Down
Loading
Loading