saltext.github 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- saltext/github/__init__.py +31 -0
- saltext/github/modules/__init__.py +0 -0
- saltext/github/modules/github.py +1873 -0
- saltext/github/modules/github_org.py +667 -0
- saltext/github/modules/github_repo.py +1658 -0
- saltext/github/modules/github_user.py +75 -0
- saltext/github/resources/__init__.py +0 -0
- saltext/github/resources/github/__init__.py +251 -0
- saltext/github/resources/github/modules/__init__.py +0 -0
- saltext/github/resources/github/modules/actions.py +175 -0
- saltext/github/resources/github/modules/config.py +69 -0
- saltext/github/resources/github/modules/deploy_key.py +122 -0
- saltext/github/resources/github/modules/environment.py +241 -0
- saltext/github/resources/github/modules/grains.py +18 -0
- saltext/github/resources/github/modules/issue.py +157 -0
- saltext/github/resources/github/modules/label.py +161 -0
- saltext/github/resources/github/modules/milestone.py +103 -0
- saltext/github/resources/github/modules/pages.py +149 -0
- saltext/github/resources/github/modules/pull.py +90 -0
- saltext/github/resources/github/modules/repo.py +155 -0
- saltext/github/resources/github/modules/ruleset.py +144 -0
- saltext/github/resources/github/modules/saltutil.py +24 -0
- saltext/github/resources/github/modules/state.py +116 -0
- saltext/github/resources/github/modules/test.py +29 -0
- saltext/github/resources/github/states/__init__.py +0 -0
- saltext/github/resources/github/states/actions.py +117 -0
- saltext/github/resources/github/states/deploy_key.py +130 -0
- saltext/github/resources/github/states/environment.py +99 -0
- saltext/github/resources/github/states/label.py +71 -0
- saltext/github/resources/github/states/pages.py +92 -0
- saltext/github/resources/github/states/repo.py +108 -0
- saltext/github/resources/github/states/ruleset.py +81 -0
- saltext/github/states/__init__.py +0 -0
- saltext/github/states/github.py +966 -0
- saltext/github/states/github_org.py +369 -0
- saltext/github/states/github_repo.py +722 -0
- saltext/github/utils/__init__.py +72 -0
- saltext/github/utils/gh/__init__.py +14 -0
- saltext/github/utils/gh/actions.py +195 -0
- saltext/github/utils/gh/cache.py +126 -0
- saltext/github/utils/gh/client.py +534 -0
- saltext/github/utils/gh/deploy_keys.py +121 -0
- saltext/github/utils/gh/environments.py +271 -0
- saltext/github/utils/gh/exceptions.py +28 -0
- saltext/github/utils/gh/grains_files.py +366 -0
- saltext/github/utils/gh/issues.py +193 -0
- saltext/github/utils/gh/labels.py +142 -0
- saltext/github/utils/gh/members.py +157 -0
- saltext/github/utils/gh/milestones.py +122 -0
- saltext/github/utils/gh/pages.py +128 -0
- saltext/github/utils/gh/profile.py +458 -0
- saltext/github/utils/gh/pulls.py +99 -0
- saltext/github/utils/gh/repos.py +465 -0
- saltext/github/utils/gh/resource.py +35 -0
- saltext/github/utils/gh/rulesets.py +191 -0
- saltext/github/utils/gh/statecores/__init__.py +70 -0
- saltext/github/utils/gh/statecores/actions.py +180 -0
- saltext/github/utils/gh/statecores/deploy_keys.py +241 -0
- saltext/github/utils/gh/statecores/environments.py +212 -0
- saltext/github/utils/gh/statecores/labels.py +116 -0
- saltext/github/utils/gh/statecores/pages.py +177 -0
- saltext/github/utils/gh/statecores/repo.py +249 -0
- saltext/github/utils/gh/statecores/rulesets.py +115 -0
- saltext/github/utils/gh/teams.py +375 -0
- saltext/github/utils/gh/users.py +87 -0
- saltext/github/version.py +1 -0
- saltext_github-1.1.0.dist-info/METADATA +151 -0
- saltext_github-1.1.0.dist-info/RECORD +73 -0
- saltext_github-1.1.0.dist-info/WHEEL +5 -0
- saltext_github-1.1.0.dist-info/entry_points.txt +2 -0
- saltext_github-1.1.0.dist-info/licenses/LICENSE +201 -0
- saltext_github-1.1.0.dist-info/licenses/NOTICE +10 -0
- saltext_github-1.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage the targeted repository's GitHub Pages site.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
Part of the :py:mod:`github <saltext.github.resources.github>` resource type: all functions operate on the
|
|
7
|
+
repository the job was dispatched to. The ``profile`` parameter
|
|
8
|
+
defaults to the :ghconf:`profile <resource:profile>` named in the resource declaration.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import logging
|
|
12
|
+
|
|
13
|
+
from salt.utils.functools import namespaced_function
|
|
14
|
+
|
|
15
|
+
from saltext.github.utils.gh import pages as gh_pages
|
|
16
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
17
|
+
|
|
18
|
+
log = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get(*, profile=None):
|
|
25
|
+
"""
|
|
26
|
+
Return information about the GitHub Pages site of the targeted
|
|
27
|
+
repository.
|
|
28
|
+
|
|
29
|
+
CLI Example:
|
|
30
|
+
|
|
31
|
+
.. code-block:: bash
|
|
32
|
+
|
|
33
|
+
salt 'my-org/my-repo' pages.get
|
|
34
|
+
|
|
35
|
+
profile
|
|
36
|
+
Profile configuration name to use. Defaults to the resource
|
|
37
|
+
declaration's profile.
|
|
38
|
+
"""
|
|
39
|
+
conn, owner, repo_name = _core_args(profile)
|
|
40
|
+
return gh_pages.get(conn, repo_name, owner=owner)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def setup(*, build_type=None, source_branch=None, source_path=None, profile=None):
|
|
44
|
+
"""
|
|
45
|
+
Configure a GitHub Pages site for the targeted repository.
|
|
46
|
+
Returns the data of the created site.
|
|
47
|
+
|
|
48
|
+
CLI Example:
|
|
49
|
+
|
|
50
|
+
.. code-block:: bash
|
|
51
|
+
|
|
52
|
+
salt 'my-org/my-repo' pages.setup build_type=workflow
|
|
53
|
+
|
|
54
|
+
build_type
|
|
55
|
+
Process by which the site is built, either ``legacy``
|
|
56
|
+
(deploy from a branch) or ``workflow`` (GitHub Actions).
|
|
57
|
+
|
|
58
|
+
source_branch
|
|
59
|
+
For ``legacy`` builds, the repository branch to publish from.
|
|
60
|
+
|
|
61
|
+
source_path
|
|
62
|
+
For ``legacy`` builds, the repository directory to publish from,
|
|
63
|
+
either ``/`` or ``/docs``.
|
|
64
|
+
|
|
65
|
+
profile
|
|
66
|
+
Profile configuration name to use. Defaults to the resource
|
|
67
|
+
declaration's profile.
|
|
68
|
+
"""
|
|
69
|
+
conn, owner, repo_name = _core_args(profile)
|
|
70
|
+
return gh_pages.create(
|
|
71
|
+
conn,
|
|
72
|
+
repo_name,
|
|
73
|
+
build_type=build_type,
|
|
74
|
+
source=gh_pages.build_source(source_branch, source_path),
|
|
75
|
+
owner=owner,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def update(
|
|
80
|
+
*,
|
|
81
|
+
build_type=None,
|
|
82
|
+
source_branch=None,
|
|
83
|
+
source_path=None,
|
|
84
|
+
cname=...,
|
|
85
|
+
https_enforced=None,
|
|
86
|
+
profile=None,
|
|
87
|
+
):
|
|
88
|
+
"""
|
|
89
|
+
Update the GitHub Pages site configuration of the targeted
|
|
90
|
+
repository.
|
|
91
|
+
|
|
92
|
+
CLI Example:
|
|
93
|
+
|
|
94
|
+
.. code-block:: bash
|
|
95
|
+
|
|
96
|
+
salt 'my-org/my-repo' pages.update build_type=workflow
|
|
97
|
+
|
|
98
|
+
build_type
|
|
99
|
+
Process by which the site is built, either ``legacy``
|
|
100
|
+
(deploy from a branch) or ``workflow`` (GitHub Actions).
|
|
101
|
+
|
|
102
|
+
source_branch
|
|
103
|
+
For ``legacy`` builds, the repository branch to publish from.
|
|
104
|
+
|
|
105
|
+
source_path
|
|
106
|
+
For ``legacy`` builds, the repository directory to publish from,
|
|
107
|
+
either ``/`` or ``/docs``.
|
|
108
|
+
|
|
109
|
+
cname
|
|
110
|
+
Custom domain for the site. Pass ``null`` explicitly to remove it,
|
|
111
|
+
omit to leave it unchanged.
|
|
112
|
+
|
|
113
|
+
https_enforced
|
|
114
|
+
Enforce HTTPS for the site.
|
|
115
|
+
|
|
116
|
+
profile
|
|
117
|
+
Profile configuration name to use. Defaults to the resource
|
|
118
|
+
declaration's profile.
|
|
119
|
+
"""
|
|
120
|
+
conn, owner, repo_name = _core_args(profile)
|
|
121
|
+
gh_pages.update(
|
|
122
|
+
conn,
|
|
123
|
+
repo_name,
|
|
124
|
+
build_type=build_type,
|
|
125
|
+
source=gh_pages.build_source(source_branch, source_path),
|
|
126
|
+
cname=cname,
|
|
127
|
+
https_enforced=https_enforced,
|
|
128
|
+
owner=owner,
|
|
129
|
+
)
|
|
130
|
+
return True
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def remove(*, profile=None):
|
|
134
|
+
"""
|
|
135
|
+
Delete the GitHub Pages site of the targeted repository.
|
|
136
|
+
|
|
137
|
+
CLI Example:
|
|
138
|
+
|
|
139
|
+
.. code-block:: bash
|
|
140
|
+
|
|
141
|
+
salt 'my-org/my-repo' pages.remove
|
|
142
|
+
|
|
143
|
+
profile
|
|
144
|
+
Profile configuration name to use. Defaults to the resource
|
|
145
|
+
declaration's profile.
|
|
146
|
+
"""
|
|
147
|
+
conn, owner, repo_name = _core_args(profile)
|
|
148
|
+
gh_pages.delete(conn, repo_name, owner=owner)
|
|
149
|
+
return True
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Inspect the targeted repository's pull requests (read-only).
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
Part of the :py:mod:`github <saltext.github.resources.github>` resource type: all functions operate on the
|
|
7
|
+
repository the job was dispatched to. The ``profile`` parameter
|
|
8
|
+
defaults to the :ghconf:`profile <resource:profile>` named in the resource declaration.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import logging
|
|
12
|
+
|
|
13
|
+
from salt.utils.functools import namespaced_function
|
|
14
|
+
|
|
15
|
+
from saltext.github.utils import filter_fields
|
|
16
|
+
from saltext.github.utils.gh import pulls as gh_pulls
|
|
17
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
18
|
+
|
|
19
|
+
log = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
__func_alias__ = {"list_": "list"}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def list_(
|
|
28
|
+
*,
|
|
29
|
+
state="open",
|
|
30
|
+
head=None,
|
|
31
|
+
base=None,
|
|
32
|
+
sort="created",
|
|
33
|
+
direction="desc",
|
|
34
|
+
per_page=None,
|
|
35
|
+
fields=None,
|
|
36
|
+
profile=None,
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
Return the pull requests in the targeted repository, based on the
|
|
40
|
+
search options.
|
|
41
|
+
|
|
42
|
+
CLI Example:
|
|
43
|
+
|
|
44
|
+
.. code-block:: bash
|
|
45
|
+
|
|
46
|
+
salt 'my-org/my-repo' pull.list
|
|
47
|
+
|
|
48
|
+
state
|
|
49
|
+
Filter returned pull requests by their state. Can be either
|
|
50
|
+
``open``, ``closed``, or ``all``. Default is ``open``.
|
|
51
|
+
|
|
52
|
+
head
|
|
53
|
+
Filter pull requests by head user and branch name in the format
|
|
54
|
+
``user:ref-name``.
|
|
55
|
+
|
|
56
|
+
base
|
|
57
|
+
Filter pulls by base branch name, e.g. ``gh-pages``.
|
|
58
|
+
|
|
59
|
+
sort
|
|
60
|
+
Field to sort results by. Either ``created``, ``updated``,
|
|
61
|
+
``popularity`` (comment count), or ``long-running`` (age, filtering
|
|
62
|
+
by pull requests updated within the last month). Default is ``created``.
|
|
63
|
+
|
|
64
|
+
direction
|
|
65
|
+
Sort direction. Either ``asc`` or ``desc``. Default is ``desc``.
|
|
66
|
+
|
|
67
|
+
per_page
|
|
68
|
+
Pagination size, maximum 100.
|
|
69
|
+
|
|
70
|
+
fields
|
|
71
|
+
Only include these fields in the output. A single field name
|
|
72
|
+
reduces each entry to the field's value.
|
|
73
|
+
|
|
74
|
+
profile
|
|
75
|
+
Profile configuration name to use. Defaults to the resource
|
|
76
|
+
declaration's profile.
|
|
77
|
+
"""
|
|
78
|
+
conn, owner, repo_name = _core_args(profile)
|
|
79
|
+
pulls = gh_pulls.list_all(
|
|
80
|
+
conn,
|
|
81
|
+
repo_name,
|
|
82
|
+
state=state,
|
|
83
|
+
head=head,
|
|
84
|
+
base=base,
|
|
85
|
+
sort=sort,
|
|
86
|
+
direction=direction,
|
|
87
|
+
per_page=per_page,
|
|
88
|
+
owner=owner,
|
|
89
|
+
)
|
|
90
|
+
return filter_fields(pulls, fields)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage the targeted repository's settings and inspect its identity
|
|
3
|
+
and team associations.
|
|
4
|
+
|
|
5
|
+
.. versionadded:: 1.1.0
|
|
6
|
+
|
|
7
|
+
Part of the :py:mod:`github <saltext.github.resources.github>` resource type: all functions operate on the
|
|
8
|
+
repository the job was dispatched to. The ``profile`` parameter
|
|
9
|
+
defaults to the :ghconf:`profile <resource:profile>` named in the resource declaration.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
from salt.utils.functools import namespaced_function
|
|
15
|
+
|
|
16
|
+
from saltext.github.utils import filter_fields
|
|
17
|
+
from saltext.github.utils.gh import profile as gh_profile
|
|
18
|
+
from saltext.github.utils.gh import repos as gh_repos
|
|
19
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
20
|
+
|
|
21
|
+
log = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def ident():
|
|
28
|
+
"""
|
|
29
|
+
Return the identity of the targeted repository as a mapping with
|
|
30
|
+
``id`` (the resource ID), ``owner`` and ``repo``. Does not contact
|
|
31
|
+
the API.
|
|
32
|
+
|
|
33
|
+
CLI Example:
|
|
34
|
+
|
|
35
|
+
.. code-block:: bash
|
|
36
|
+
|
|
37
|
+
salt 'my-org/my-repo' repo.ident
|
|
38
|
+
"""
|
|
39
|
+
owner, _, repo_name = __resource__["id"].partition("/")
|
|
40
|
+
return {"id": __resource__["id"], "owner": owner, "repo": repo_name}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def info(*, ignore_cache=False, profile=None):
|
|
44
|
+
"""
|
|
45
|
+
Return information about the targeted repository.
|
|
46
|
+
|
|
47
|
+
CLI Example:
|
|
48
|
+
|
|
49
|
+
.. code-block:: bash
|
|
50
|
+
|
|
51
|
+
salt 'my-org/my-repo' repo.info
|
|
52
|
+
|
|
53
|
+
ignore_cache
|
|
54
|
+
Bypass the use of cached repository information.
|
|
55
|
+
|
|
56
|
+
profile
|
|
57
|
+
Profile configuration name to use. Defaults to the resource
|
|
58
|
+
declaration's profile.
|
|
59
|
+
"""
|
|
60
|
+
conn, owner, repo_name = _core_args(profile)
|
|
61
|
+
return gh_repos.get_info(conn, repo_name, owner=owner, ignore_cache=ignore_cache)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def get_teams(*, fields=None, profile=None):
|
|
65
|
+
"""
|
|
66
|
+
Return the teams the targeted repository belongs to, as a mapping
|
|
67
|
+
of team name to details.
|
|
68
|
+
|
|
69
|
+
CLI Example:
|
|
70
|
+
|
|
71
|
+
.. code-block:: bash
|
|
72
|
+
|
|
73
|
+
salt 'my-org/my-repo' repo.get_teams
|
|
74
|
+
|
|
75
|
+
fields
|
|
76
|
+
Only include these fields in the output. A single field name
|
|
77
|
+
reduces each entry to the field's value.
|
|
78
|
+
|
|
79
|
+
profile
|
|
80
|
+
Profile configuration name to use. Defaults to the resource
|
|
81
|
+
declaration's profile.
|
|
82
|
+
"""
|
|
83
|
+
conn, owner, repo_name = _core_args(profile)
|
|
84
|
+
teams = gh_repos.get_teams(conn, repo_name, owner=owner)
|
|
85
|
+
return filter_fields({team["name"]: team for team in teams}, fields)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def update(
|
|
89
|
+
*,
|
|
90
|
+
description=None,
|
|
91
|
+
homepage=None,
|
|
92
|
+
private=None,
|
|
93
|
+
has_issues=None,
|
|
94
|
+
has_wiki=None,
|
|
95
|
+
has_downloads=None,
|
|
96
|
+
default_branch=None,
|
|
97
|
+
profile=None,
|
|
98
|
+
):
|
|
99
|
+
"""
|
|
100
|
+
Update the targeted repository's settings.
|
|
101
|
+
Returns the refreshed repository information.
|
|
102
|
+
|
|
103
|
+
CLI Example:
|
|
104
|
+
|
|
105
|
+
.. code-block:: bash
|
|
106
|
+
|
|
107
|
+
salt 'my-org/my-repo' repo.update description='Managed by Salt'
|
|
108
|
+
|
|
109
|
+
description
|
|
110
|
+
Repository description.
|
|
111
|
+
|
|
112
|
+
homepage
|
|
113
|
+
URL with more information about the repository, e.g. rendered docs.
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
Repository visibility. Changing this requires :ghconf:`allow_repo_privacy_changes`
|
|
117
|
+
to be enabled in the profile.
|
|
118
|
+
|
|
119
|
+
has_issues
|
|
120
|
+
Enable issues for this repository.
|
|
121
|
+
|
|
122
|
+
has_wiki
|
|
123
|
+
Enable the wiki for this repository.
|
|
124
|
+
|
|
125
|
+
has_downloads
|
|
126
|
+
Enable downloads for this repository.
|
|
127
|
+
|
|
128
|
+
default_branch
|
|
129
|
+
Default branch of the repository. Must already exist.
|
|
130
|
+
|
|
131
|
+
profile
|
|
132
|
+
Profile configuration name to use. Defaults to the resource
|
|
133
|
+
declaration's profile.
|
|
134
|
+
"""
|
|
135
|
+
conn, owner, repo_name = _core_args(profile)
|
|
136
|
+
allow_privacy_change = gh_profile.get_config_value(
|
|
137
|
+
profile or gh_profile.resource_owner_profile(__opts__, owner),
|
|
138
|
+
"allow_repo_privacy_changes",
|
|
139
|
+
opts=__opts__,
|
|
140
|
+
context=__context__,
|
|
141
|
+
default=False,
|
|
142
|
+
)
|
|
143
|
+
return gh_repos.update(
|
|
144
|
+
conn,
|
|
145
|
+
repo_name,
|
|
146
|
+
owner=owner,
|
|
147
|
+
description=description,
|
|
148
|
+
homepage=homepage,
|
|
149
|
+
private=private,
|
|
150
|
+
has_issues=has_issues,
|
|
151
|
+
has_wiki=has_wiki,
|
|
152
|
+
has_downloads=has_downloads,
|
|
153
|
+
default_branch=default_branch,
|
|
154
|
+
allow_privacy_change=allow_privacy_change,
|
|
155
|
+
)
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage the targeted repository's rulesets.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
Part of the :py:mod:`github <saltext.github.resources.github>` resource type: all functions operate on the
|
|
7
|
+
repository the job was dispatched to. The ``profile`` parameter
|
|
8
|
+
defaults to the :ghconf:`profile <resource:profile>` named in the resource declaration.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import logging
|
|
12
|
+
|
|
13
|
+
from salt.utils.functools import namespaced_function
|
|
14
|
+
|
|
15
|
+
from saltext.github.utils import filter_fields
|
|
16
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
17
|
+
from saltext.github.utils.gh import rulesets as gh_rulesets
|
|
18
|
+
|
|
19
|
+
log = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
__func_alias__ = {"list_": "list"}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def list_(*, per_page=None, fields=None, profile=None):
|
|
28
|
+
"""
|
|
29
|
+
List all rulesets of the targeted repository.
|
|
30
|
+
|
|
31
|
+
CLI Example:
|
|
32
|
+
|
|
33
|
+
.. code-block:: bash
|
|
34
|
+
|
|
35
|
+
salt 'my-org/my-repo' ruleset.list
|
|
36
|
+
|
|
37
|
+
per_page
|
|
38
|
+
Pagination size, maximum 100.
|
|
39
|
+
|
|
40
|
+
fields
|
|
41
|
+
Only include these fields in the output. A single field name
|
|
42
|
+
reduces each entry to the field's value.
|
|
43
|
+
|
|
44
|
+
profile
|
|
45
|
+
Profile configuration name to use. Defaults to the resource
|
|
46
|
+
declaration's profile.
|
|
47
|
+
"""
|
|
48
|
+
conn, owner, repo_name = _core_args(profile)
|
|
49
|
+
rulesets = gh_rulesets.list_all(
|
|
50
|
+
conn, "repo", owner=owner, repo_name=repo_name, per_page=per_page
|
|
51
|
+
)
|
|
52
|
+
return filter_fields(rulesets, fields)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def get(ruleset_id, *, profile=None):
|
|
56
|
+
"""
|
|
57
|
+
Return the data of a single ruleset of the targeted repository.
|
|
58
|
+
|
|
59
|
+
CLI Example:
|
|
60
|
+
|
|
61
|
+
.. code-block:: bash
|
|
62
|
+
|
|
63
|
+
salt 'my-org/my-repo' ruleset.get 1234
|
|
64
|
+
|
|
65
|
+
ruleset_id
|
|
66
|
+
ID of the ruleset.
|
|
67
|
+
|
|
68
|
+
profile
|
|
69
|
+
Profile configuration name to use. Defaults to the resource
|
|
70
|
+
declaration's profile.
|
|
71
|
+
"""
|
|
72
|
+
conn, owner, repo_name = _core_args(profile)
|
|
73
|
+
return gh_rulesets.get(conn, ruleset_id, "repo", owner=owner, repo_name=repo_name)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def add(ruleset_params, *, profile=None):
|
|
77
|
+
"""
|
|
78
|
+
Create a new ruleset in the targeted repository.
|
|
79
|
+
Returns the data of the created ruleset.
|
|
80
|
+
|
|
81
|
+
CLI Example:
|
|
82
|
+
|
|
83
|
+
.. code-block:: bash
|
|
84
|
+
|
|
85
|
+
salt 'my-org/my-repo' ruleset.add '{name: test, enforcement: active}'
|
|
86
|
+
|
|
87
|
+
ruleset_params
|
|
88
|
+
Ruleset definition. Must contain at least ``name`` and ``enforcement``.
|
|
89
|
+
|
|
90
|
+
profile
|
|
91
|
+
Profile configuration name to use. Defaults to the resource
|
|
92
|
+
declaration's profile.
|
|
93
|
+
"""
|
|
94
|
+
conn, owner, repo_name = _core_args(profile)
|
|
95
|
+
return gh_rulesets.create(conn, ruleset_params, "repo", owner=owner, repo_name=repo_name)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def update(ruleset_id, ruleset_params, *, profile=None):
|
|
99
|
+
"""
|
|
100
|
+
Update an existing ruleset of the targeted repository.
|
|
101
|
+
Returns the data of the updated ruleset.
|
|
102
|
+
|
|
103
|
+
CLI Example:
|
|
104
|
+
|
|
105
|
+
.. code-block:: bash
|
|
106
|
+
|
|
107
|
+
salt 'my-org/my-repo' ruleset.update 1234 '{enforcement: disabled}'
|
|
108
|
+
|
|
109
|
+
ruleset_id
|
|
110
|
+
ID of the ruleset.
|
|
111
|
+
|
|
112
|
+
ruleset_params
|
|
113
|
+
Updated ruleset definition.
|
|
114
|
+
|
|
115
|
+
profile
|
|
116
|
+
Profile configuration name to use. Defaults to the resource
|
|
117
|
+
declaration's profile.
|
|
118
|
+
"""
|
|
119
|
+
conn, owner, repo_name = _core_args(profile)
|
|
120
|
+
return gh_rulesets.update(
|
|
121
|
+
conn, ruleset_id, ruleset_params, "repo", owner=owner, repo_name=repo_name
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def remove(ruleset_id, *, profile=None):
|
|
126
|
+
"""
|
|
127
|
+
Delete a ruleset from the targeted repository.
|
|
128
|
+
|
|
129
|
+
CLI Example:
|
|
130
|
+
|
|
131
|
+
.. code-block:: bash
|
|
132
|
+
|
|
133
|
+
salt 'my-org/my-repo' ruleset.remove 1234
|
|
134
|
+
|
|
135
|
+
ruleset_id
|
|
136
|
+
ID of the ruleset.
|
|
137
|
+
|
|
138
|
+
profile
|
|
139
|
+
Profile configuration name to use. Defaults to the resource
|
|
140
|
+
declaration's profile.
|
|
141
|
+
"""
|
|
142
|
+
conn, owner, repo_name = _core_args(profile)
|
|
143
|
+
gh_rulesets.delete(conn, ruleset_id, "repo", owner=owner, repo_name=repo_name)
|
|
144
|
+
return True
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Inspect running jobs on the managing minion.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
The stock :py:mod:`state <salt.modules.state>` execution module
|
|
7
|
+
(re-exported for this resource type) performs conflict detection via
|
|
8
|
+
``saltutil.is_running``. State runs for resources execute inline on the
|
|
9
|
+
managing minion, so its job table is the correct one to consult. Both
|
|
10
|
+
functions only need ``__opts__``, so the stock implementations are
|
|
11
|
+
re-exported unchanged.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import logging
|
|
15
|
+
|
|
16
|
+
import salt.modules.saltutil as _stock
|
|
17
|
+
from salt.utils.functools import namespaced_function
|
|
18
|
+
|
|
19
|
+
log = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
running = namespaced_function(_stock.running, globals())
|
|
22
|
+
is_running = namespaced_function(_stock.is_running, globals())
|
|
23
|
+
|
|
24
|
+
__load__ = ["running", "is_running"]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Apply states to the targeted repository.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
Salt's per-resource execution loader is deny-by-default, so a resource
|
|
7
|
+
type must provide the ``state`` slot itself for ``state.apply`` and
|
|
8
|
+
friends to be dispatchable to its resources. This module re-exports the
|
|
9
|
+
stock :py:mod:`state <salt.modules.state>` execution module into the
|
|
10
|
+
per-type loader via ``namespaced_function`` (the pattern recommended in
|
|
11
|
+
Salt's resource state-authoring docs). The state engine then compiles
|
|
12
|
+
and runs on the managing minion while every module call inside the
|
|
13
|
+
rendered states dispatches through the per-resource loader — and thus
|
|
14
|
+
through this extension's ``resources/github/states/`` overrides.
|
|
15
|
+
|
|
16
|
+
Unlike the ``ssh`` resource type, no custom transport is needed: the
|
|
17
|
+
GitHub API is reachable from the managing minion, so the stock
|
|
18
|
+
implementations work unchanged. Only a few helpers that assume
|
|
19
|
+
managing-minion dunders (``__pillar__``, grains-backed state disabling)
|
|
20
|
+
are overridden below.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
import inspect
|
|
24
|
+
import logging
|
|
25
|
+
|
|
26
|
+
import salt.modules.state as _stock
|
|
27
|
+
from salt.utils.functools import namespaced_function
|
|
28
|
+
|
|
29
|
+
log = logging.getLogger(__name__)
|
|
30
|
+
|
|
31
|
+
__func_alias__ = {"apply_": "apply"}
|
|
32
|
+
|
|
33
|
+
# Only these functions are exposed as ``state.*`` for the github
|
|
34
|
+
# resource type. Everything else from the stock module is namespaced
|
|
35
|
+
# below purely so internal helper calls resolve against this module's
|
|
36
|
+
# (loader-packed) globals, but stays unexposed. Notably absent:
|
|
37
|
+
# queue/pause plumbing, ``disable``/``enable`` (grains-backed),
|
|
38
|
+
# ``pkg`` (salt-thin transport) and ``event``.
|
|
39
|
+
__load__ = [
|
|
40
|
+
"apply_",
|
|
41
|
+
"highstate",
|
|
42
|
+
"id_exists",
|
|
43
|
+
"running",
|
|
44
|
+
"show_highstate",
|
|
45
|
+
"show_low_sls",
|
|
46
|
+
"show_lowstate",
|
|
47
|
+
"show_sls",
|
|
48
|
+
"show_states",
|
|
49
|
+
"show_top",
|
|
50
|
+
"single",
|
|
51
|
+
"sls",
|
|
52
|
+
"sls_exists",
|
|
53
|
+
"sls_id",
|
|
54
|
+
"test",
|
|
55
|
+
"top",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _namespace_stock():
|
|
60
|
+
"""
|
|
61
|
+
Re-export every function defined in the stock module under this
|
|
62
|
+
module's globals. The public entry points call module-level helpers
|
|
63
|
+
(``_check_queue``, ``_get_test_value``, …) which access ``__salt__``
|
|
64
|
+
and friends — those helpers must be namespaced too, or they would
|
|
65
|
+
resolve dunders against the raw (unpacked) ``salt.modules.state``
|
|
66
|
+
module and fail with a ``NameError``.
|
|
67
|
+
"""
|
|
68
|
+
for fname, func in list(vars(_stock).items()):
|
|
69
|
+
if inspect.isfunction(func) and func.__module__ == _stock.__name__:
|
|
70
|
+
globals()[fname] = namespaced_function(func, globals())
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
_namespace_stock()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# ---------------------------------------------------------------------------
|
|
77
|
+
# Resource-context adjustments. Defined after the re-export so they
|
|
78
|
+
# shadow the stock implementations.
|
|
79
|
+
# ---------------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _get_initial_pillar(opts):
|
|
83
|
+
"""
|
|
84
|
+
Use the managing minion's in-memory pillar when it matches the
|
|
85
|
+
requested pillarenv.
|
|
86
|
+
|
|
87
|
+
The stock implementation reads ``__pillar__``, which is not packed
|
|
88
|
+
into per-resource loaders. The managing minion's pillar contains the
|
|
89
|
+
resource declarations anyway, and reusing it avoids recompiling
|
|
90
|
+
pillar once per targeted repository.
|
|
91
|
+
"""
|
|
92
|
+
pillar = __opts__.get("pillar")
|
|
93
|
+
if pillar and opts.get("pillarenv") == __opts__.get("pillarenv"):
|
|
94
|
+
try:
|
|
95
|
+
return pillar.value()
|
|
96
|
+
except AttributeError:
|
|
97
|
+
return pillar
|
|
98
|
+
return None
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _get_pillar_errors(kwargs, pillar=None):
|
|
102
|
+
"""
|
|
103
|
+
Stock implementation minus the in-memory ``__pillar__`` fallback,
|
|
104
|
+
which is not packed into per-resource loaders.
|
|
105
|
+
"""
|
|
106
|
+
if kwargs.get("force"):
|
|
107
|
+
return None
|
|
108
|
+
return (pillar or {}).get("_errors")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _disabled(funs): # pylint: disable=unused-argument
|
|
112
|
+
"""
|
|
113
|
+
``state.disable``/``state.enable`` (grains-backed) are not exposed
|
|
114
|
+
for the github resource type, so state runs can never be disabled.
|
|
115
|
+
"""
|
|
116
|
+
return []
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Provide the ``test`` execution module for the ``github`` resource type.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
Its location in the per-type override directory makes it visible only
|
|
7
|
+
to the ``github`` resource loader, so no ``__virtual__`` gate is needed.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
|
|
12
|
+
log = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def ping():
|
|
16
|
+
"""
|
|
17
|
+
Return whether the targeted repository is reachable via the API.
|
|
18
|
+
|
|
19
|
+
Delegates to the connection module's ``ping()`` via
|
|
20
|
+
``__resource_funcs__`` so the result reflects the actual state of
|
|
21
|
+
the resource rather than the managing minion.
|
|
22
|
+
|
|
23
|
+
CLI Example:
|
|
24
|
+
|
|
25
|
+
.. code-block:: bash
|
|
26
|
+
|
|
27
|
+
salt 'my-org/my-repo' test.ping
|
|
28
|
+
"""
|
|
29
|
+
return __resource_funcs__["github.ping"]()
|
|
File without changes
|