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,375 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Operations on GitHub organization teams.
|
|
3
|
+
|
|
4
|
+
Most functions take a ``team_info`` parameter, which is the team's entry
|
|
5
|
+
in the (cached) mapping returned by :func:`list_all`. Team-scoped caches
|
|
6
|
+
(repositories, members) are attached to this entry.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
|
|
11
|
+
from saltext.github.utils import filter_unset
|
|
12
|
+
from saltext.github.utils.gh.client import api_request
|
|
13
|
+
from saltext.github.utils.gh.exceptions import GitHubApiError
|
|
14
|
+
from saltext.github.utils.gh.exceptions import GitHubNotFoundError
|
|
15
|
+
|
|
16
|
+
log = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@api_request
|
|
20
|
+
def list_all(conn, *, owner=None, ignore_cache=False):
|
|
21
|
+
"""
|
|
22
|
+
Return all teams of an organization as a mapping of team name to
|
|
23
|
+
team details (cached).
|
|
24
|
+
|
|
25
|
+
conn
|
|
26
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
27
|
+
|
|
28
|
+
owner
|
|
29
|
+
Organization owning the teams. Defaults to the connection's owner.
|
|
30
|
+
|
|
31
|
+
ignore_cache
|
|
32
|
+
Bypass the cached team list.
|
|
33
|
+
"""
|
|
34
|
+
owner = owner or conn.owner
|
|
35
|
+
key = ("teams", owner.lower())
|
|
36
|
+
if key not in conn.cache or ignore_cache:
|
|
37
|
+
teams = {}
|
|
38
|
+
for team in conn.get_org(owner).get_teams():
|
|
39
|
+
# These attributes are all present in the list response. Take care
|
|
40
|
+
# not to access any lazily completable attributes missing from it
|
|
41
|
+
# here since each one would trigger a separate request per team.
|
|
42
|
+
teams[team.name] = {
|
|
43
|
+
"id": team.id,
|
|
44
|
+
"name": team.name,
|
|
45
|
+
"slug": team.slug,
|
|
46
|
+
"description": team.description,
|
|
47
|
+
"permission": team.permission,
|
|
48
|
+
"privacy": team.privacy,
|
|
49
|
+
}
|
|
50
|
+
conn.cache[key] = teams
|
|
51
|
+
return conn.cache[key]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def get(conn, name, *, owner=None):
|
|
55
|
+
"""
|
|
56
|
+
Return the (cached) details of a single team, or None if it does
|
|
57
|
+
not exist.
|
|
58
|
+
|
|
59
|
+
conn
|
|
60
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
61
|
+
|
|
62
|
+
name
|
|
63
|
+
Team name.
|
|
64
|
+
|
|
65
|
+
owner
|
|
66
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
67
|
+
"""
|
|
68
|
+
return list_all(conn, owner=owner).get(name)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def find(conn, name, *, owner=None):
|
|
72
|
+
"""
|
|
73
|
+
Return a team's cached details, raising when it does not exist.
|
|
74
|
+
Teams are matched by exact display name first, then by slug and
|
|
75
|
+
case-insensitive display name since GitHub derives team identity
|
|
76
|
+
(the slug) case-insensitively.
|
|
77
|
+
|
|
78
|
+
conn
|
|
79
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
80
|
+
|
|
81
|
+
name
|
|
82
|
+
Team name or slug.
|
|
83
|
+
|
|
84
|
+
owner
|
|
85
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
86
|
+
|
|
87
|
+
Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError`
|
|
88
|
+
if the team does not exist.
|
|
89
|
+
"""
|
|
90
|
+
team = get(conn, name, owner=owner)
|
|
91
|
+
if team is None:
|
|
92
|
+
for candidate in list_all(conn, owner=owner).values():
|
|
93
|
+
if name == candidate["slug"] or name.lower() == candidate["name"].lower():
|
|
94
|
+
return candidate
|
|
95
|
+
raise GitHubNotFoundError(
|
|
96
|
+
f"Team {name} does not exist in organization {owner or conn.owner}."
|
|
97
|
+
)
|
|
98
|
+
return team
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@api_request
|
|
102
|
+
def create(
|
|
103
|
+
conn, name, *, description=None, repo_names=None, privacy=None, permission=None, owner=None
|
|
104
|
+
):
|
|
105
|
+
"""
|
|
106
|
+
Create a new team in the organization.
|
|
107
|
+
|
|
108
|
+
conn
|
|
109
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
110
|
+
|
|
111
|
+
name
|
|
112
|
+
Name of team to create.
|
|
113
|
+
|
|
114
|
+
description
|
|
115
|
+
Team description.
|
|
116
|
+
|
|
117
|
+
repo_names
|
|
118
|
+
List of repository names to add the team to.
|
|
119
|
+
|
|
120
|
+
privacy
|
|
121
|
+
Privacy level for the team, either ``secret`` or ``closed``.
|
|
122
|
+
|
|
123
|
+
permission
|
|
124
|
+
Default permission for new repositories added to the team, either
|
|
125
|
+
``pull``, ``push`` or ``admin``.
|
|
126
|
+
|
|
127
|
+
owner
|
|
128
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
129
|
+
"""
|
|
130
|
+
parameters = filter_unset(
|
|
131
|
+
{
|
|
132
|
+
"description": description,
|
|
133
|
+
"permission": permission,
|
|
134
|
+
"privacy": privacy,
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
org = conn.get_org(owner)
|
|
138
|
+
if repo_names is not None:
|
|
139
|
+
# create_team expects Repository objects, resolve the (full) names
|
|
140
|
+
parameters["repo_names"] = [
|
|
141
|
+
conn.client.get_repo(repo) if "/" in repo else org.get_repo(repo) for repo in repo_names
|
|
142
|
+
]
|
|
143
|
+
org.create_team(name, **parameters)
|
|
144
|
+
list_all(conn, owner=owner, ignore_cache=True) # Refresh cache
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@api_request
|
|
148
|
+
def update(conn, team_info, name, *, description=None, privacy=None, permission=None, owner=None):
|
|
149
|
+
"""
|
|
150
|
+
Update an existing team.
|
|
151
|
+
|
|
152
|
+
conn
|
|
153
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
154
|
+
|
|
155
|
+
team_info
|
|
156
|
+
Team's entry from :func:`list_all`.
|
|
157
|
+
|
|
158
|
+
name
|
|
159
|
+
Team name.
|
|
160
|
+
|
|
161
|
+
description
|
|
162
|
+
Team description.
|
|
163
|
+
|
|
164
|
+
privacy
|
|
165
|
+
Privacy level for the team, either ``secret`` or ``closed``.
|
|
166
|
+
|
|
167
|
+
permission
|
|
168
|
+
Default permission for new repositories added to the team, either
|
|
169
|
+
``pull``, ``push`` or ``admin``.
|
|
170
|
+
|
|
171
|
+
owner
|
|
172
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
173
|
+
"""
|
|
174
|
+
team = conn.get_org(owner).get_team_by_slug(team_info["slug"])
|
|
175
|
+
team.edit(
|
|
176
|
+
name,
|
|
177
|
+
**filter_unset(
|
|
178
|
+
{
|
|
179
|
+
"description": description,
|
|
180
|
+
"privacy": privacy,
|
|
181
|
+
"permission": permission,
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
)
|
|
185
|
+
list_all(conn, owner=owner, ignore_cache=True) # Refresh cache
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
@api_request
|
|
189
|
+
def delete(conn, team_info, *, owner=None):
|
|
190
|
+
"""
|
|
191
|
+
Delete a team from the organization.
|
|
192
|
+
|
|
193
|
+
conn
|
|
194
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
195
|
+
|
|
196
|
+
team_info
|
|
197
|
+
Team's entry from :func:`list_all`.
|
|
198
|
+
|
|
199
|
+
owner
|
|
200
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
201
|
+
"""
|
|
202
|
+
team = conn.get_org(owner).get_team_by_slug(team_info["slug"])
|
|
203
|
+
team.delete()
|
|
204
|
+
list_all(conn, owner=owner, ignore_cache=True) # Refresh cache
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
@api_request
|
|
208
|
+
def list_repos(conn, team_info, *, owner=None, ignore_cache=False):
|
|
209
|
+
"""
|
|
210
|
+
Return the repositories of a team as a mapping of (lowercase) repository
|
|
211
|
+
name to repository details (cached).
|
|
212
|
+
|
|
213
|
+
conn
|
|
214
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
215
|
+
|
|
216
|
+
team_info
|
|
217
|
+
Team's entry from :func:`list_all`.
|
|
218
|
+
|
|
219
|
+
owner
|
|
220
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
221
|
+
|
|
222
|
+
ignore_cache
|
|
223
|
+
Bypass the cached team repositories.
|
|
224
|
+
"""
|
|
225
|
+
if team_info.get("repos") and not ignore_cache:
|
|
226
|
+
return team_info["repos"]
|
|
227
|
+
|
|
228
|
+
team = conn.get_org(owner).get_team_by_slug(team_info["slug"])
|
|
229
|
+
repos = {}
|
|
230
|
+
for repo in team.get_repos():
|
|
231
|
+
permission = "pull"
|
|
232
|
+
if repo.permissions.admin:
|
|
233
|
+
permission = "admin"
|
|
234
|
+
elif repo.permissions.push:
|
|
235
|
+
permission = "push"
|
|
236
|
+
|
|
237
|
+
repos[repo.name.lower()] = {"name": repo.name, "permission": permission}
|
|
238
|
+
team_info["repos"] = repos
|
|
239
|
+
return repos
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
@api_request
|
|
243
|
+
def add_repo(conn, team_info, repo_name, permission=None, *, owner=None):
|
|
244
|
+
"""
|
|
245
|
+
Add a repository to a team, or update the permission the team has
|
|
246
|
+
on it. Raises when updating the permission failed.
|
|
247
|
+
|
|
248
|
+
conn
|
|
249
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
250
|
+
|
|
251
|
+
team_info
|
|
252
|
+
Team's entry from :func:`list_all`.
|
|
253
|
+
|
|
254
|
+
repo_name
|
|
255
|
+
Repository name to add.
|
|
256
|
+
|
|
257
|
+
permission
|
|
258
|
+
Permission for team members within the repository. Either ``pull``,
|
|
259
|
+
``push`` or ``admin``. Defaults to the default permission on the team.
|
|
260
|
+
|
|
261
|
+
owner
|
|
262
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
263
|
+
"""
|
|
264
|
+
org = conn.get_org(owner)
|
|
265
|
+
team = org.get_team_by_slug(team_info["slug"])
|
|
266
|
+
repo = org.get_repo(repo_name)
|
|
267
|
+
if permission is None:
|
|
268
|
+
team.add_to_repos(repo)
|
|
269
|
+
elif not team.update_team_repository(repo, permission):
|
|
270
|
+
raise GitHubApiError(
|
|
271
|
+
f"Failed setting permission {permission} on repo {repo_name} "
|
|
272
|
+
f"for team {team_info['name']}."
|
|
273
|
+
)
|
|
274
|
+
list_repos(conn, team_info, owner=owner, ignore_cache=True) # Refresh cache
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@api_request
|
|
278
|
+
def remove_repo(conn, team_info, repo_name, *, owner=None):
|
|
279
|
+
"""
|
|
280
|
+
Remove a repository from a team.
|
|
281
|
+
|
|
282
|
+
conn
|
|
283
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
284
|
+
|
|
285
|
+
team_info
|
|
286
|
+
Team's entry from :func:`list_all`.
|
|
287
|
+
|
|
288
|
+
repo_name
|
|
289
|
+
Repository name to remove.
|
|
290
|
+
|
|
291
|
+
owner
|
|
292
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
293
|
+
"""
|
|
294
|
+
org = conn.get_org(owner)
|
|
295
|
+
team = org.get_team_by_slug(team_info["slug"])
|
|
296
|
+
repo = org.get_repo(repo_name)
|
|
297
|
+
team.remove_from_repos(repo)
|
|
298
|
+
if team_info.get("repos"):
|
|
299
|
+
team_info["repos"].pop(repo_name.lower(), None)
|
|
300
|
+
return True
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
@api_request
|
|
304
|
+
def list_members(conn, team_info, *, owner=None, ignore_cache=False):
|
|
305
|
+
"""
|
|
306
|
+
Return the (lowercase) logins of a team's members (cached).
|
|
307
|
+
|
|
308
|
+
conn
|
|
309
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
310
|
+
|
|
311
|
+
team_info
|
|
312
|
+
Team's entry from :func:`list_all`.
|
|
313
|
+
|
|
314
|
+
owner
|
|
315
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
316
|
+
|
|
317
|
+
ignore_cache
|
|
318
|
+
Bypass the cached team members.
|
|
319
|
+
"""
|
|
320
|
+
if team_info.get("members") and not ignore_cache:
|
|
321
|
+
return team_info["members"]
|
|
322
|
+
|
|
323
|
+
team = conn.get_org(owner).get_team_by_slug(team_info["slug"])
|
|
324
|
+
team_info["members"] = [member.login.lower() for member in team.get_members()]
|
|
325
|
+
return team_info["members"]
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
@api_request
|
|
329
|
+
def add_member(conn, team_info, login, *, owner=None):
|
|
330
|
+
"""
|
|
331
|
+
Add an organization member to a team.
|
|
332
|
+
|
|
333
|
+
conn
|
|
334
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
335
|
+
|
|
336
|
+
team_info
|
|
337
|
+
Team's entry from :func:`list_all`.
|
|
338
|
+
|
|
339
|
+
login
|
|
340
|
+
User handle to invite.
|
|
341
|
+
|
|
342
|
+
owner
|
|
343
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
344
|
+
"""
|
|
345
|
+
team = conn.get_org(owner).get_team_by_slug(team_info["slug"])
|
|
346
|
+
member = conn.client.get_user(login)
|
|
347
|
+
team.add_membership(member, "member")
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
@api_request
|
|
351
|
+
def remove_member(conn, team_info, login, *, owner=None):
|
|
352
|
+
"""
|
|
353
|
+
Remove a member from a team.
|
|
354
|
+
|
|
355
|
+
conn
|
|
356
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
357
|
+
|
|
358
|
+
team_info
|
|
359
|
+
Team's entry from :func:`list_all`.
|
|
360
|
+
|
|
361
|
+
login
|
|
362
|
+
User handle to remove.
|
|
363
|
+
|
|
364
|
+
owner
|
|
365
|
+
Organization owning the team. Defaults to the connection's owner.
|
|
366
|
+
|
|
367
|
+
Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError`
|
|
368
|
+
if the team or user does not exist.
|
|
369
|
+
"""
|
|
370
|
+
team = conn.get_org(owner).get_team_by_slug(team_info["slug"])
|
|
371
|
+
member = conn.client.get_user(login)
|
|
372
|
+
team.remove_membership(member)
|
|
373
|
+
if team_info.get("members"):
|
|
374
|
+
team_info["members"] = [mem for mem in team_info["members"] if mem != login.lower()]
|
|
375
|
+
return True
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Operations on arbitrary GitHub user accounts, independent of any
|
|
3
|
+
organization membership.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
from saltext.github.utils.gh.client import api_request
|
|
9
|
+
from saltext.github.utils.gh.exceptions import GitHubNotFoundError
|
|
10
|
+
|
|
11
|
+
log = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
# Public profile fields returned by get_info. Rendered via .get() since
|
|
14
|
+
# organization accounts miss some of them.
|
|
15
|
+
INFO_FIELDS = (
|
|
16
|
+
"avatar_url",
|
|
17
|
+
"bio",
|
|
18
|
+
"blog",
|
|
19
|
+
"company",
|
|
20
|
+
"created_at",
|
|
21
|
+
"email",
|
|
22
|
+
"followers",
|
|
23
|
+
"following",
|
|
24
|
+
"html_url",
|
|
25
|
+
"id",
|
|
26
|
+
"location",
|
|
27
|
+
"login",
|
|
28
|
+
"name",
|
|
29
|
+
"public_gists",
|
|
30
|
+
"public_repos",
|
|
31
|
+
"type",
|
|
32
|
+
"updated_at",
|
|
33
|
+
"url",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@api_request
|
|
38
|
+
def get_info(conn, login=None, *, expect=None):
|
|
39
|
+
"""
|
|
40
|
+
Return the public profile of any user or organization account
|
|
41
|
+
(distinguished via the returned ``type`` field).
|
|
42
|
+
|
|
43
|
+
conn
|
|
44
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
45
|
+
|
|
46
|
+
login
|
|
47
|
+
Account handle to look up. Defaults to the connection's owner,
|
|
48
|
+
or to the token's user when ``expect`` is ``User``.
|
|
49
|
+
|
|
50
|
+
expect
|
|
51
|
+
Required account type, either ``User`` or ``Organization``.
|
|
52
|
+
By default, both types are allowed.
|
|
53
|
+
|
|
54
|
+
Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError`
|
|
55
|
+
if the account does not exist or is not of the ``expect``-ed type.
|
|
56
|
+
"""
|
|
57
|
+
if expect not in (None, "User", "Organization"): # pragma: no cover
|
|
58
|
+
raise ValueError(f"Invalid {expect=}. Valid: None, 'User', 'Organization'")
|
|
59
|
+
if login is None and expect == "User":
|
|
60
|
+
user = conn.auth_user
|
|
61
|
+
else:
|
|
62
|
+
# The /users/{login} endpoint resolves both account types
|
|
63
|
+
user = conn.client.get_user(login or conn.owner)
|
|
64
|
+
if expect is not None and user.type != expect:
|
|
65
|
+
raise GitHubNotFoundError(f"{user.login} is not of type {expect}")
|
|
66
|
+
data = user.raw_data
|
|
67
|
+
return {fld: data.get(fld) for fld in INFO_FIELDS}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@api_request
|
|
71
|
+
def list_keys(conn, login=None):
|
|
72
|
+
"""
|
|
73
|
+
Return the verified public SSH keys of any user as a list of
|
|
74
|
+
mappings with ``id`` and ``key`` fields.
|
|
75
|
+
|
|
76
|
+
conn
|
|
77
|
+
:class:`~saltext.github.utils.gh.client.GitHubConnection` to use.
|
|
78
|
+
|
|
79
|
+
login
|
|
80
|
+
User handle whose keys to list. Defaults to the user the
|
|
81
|
+
connection's token belongs to.
|
|
82
|
+
|
|
83
|
+
Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError`
|
|
84
|
+
if the user does not exist.
|
|
85
|
+
"""
|
|
86
|
+
user = conn.client.get_user(login or conn.auth_user.login)
|
|
87
|
+
return [{"id": key.id, "key": key.key} for key in user.get_keys()]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.1.0"
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: saltext.github
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Salt Extension for interacting with GitHub
|
|
5
|
+
Author-email: "EITR Technologies, LLC" <devops@eitr.tech>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/salt-extensions/saltext-github
|
|
8
|
+
Project-URL: Documentation, https://salt-extensions.github.io/saltext-github/
|
|
9
|
+
Project-URL: Source, https://github.com/salt-extensions/saltext-github
|
|
10
|
+
Project-URL: Tracker, https://github.com/salt-extensions/saltext-github/issues
|
|
11
|
+
Keywords: salt-extension
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Development Status :: 4 - Beta
|
|
20
|
+
Classifier: Intended Audience :: Developers
|
|
21
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
22
|
+
Classifier: Operating System :: MacOS
|
|
23
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
License-File: NOTICE
|
|
28
|
+
Requires-Dist: PyGithub>=2.2
|
|
29
|
+
Requires-Dist: pynacl>=1.4
|
|
30
|
+
Provides-Extra: salt
|
|
31
|
+
Requires-Dist: salt>=3006; extra == "salt"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# Salt Extension for GitHub
|
|
35
|
+
|
|
36
|
+
Salt Extension for interacting with GitHub
|
|
37
|
+
|
|
38
|
+
## Security
|
|
39
|
+
|
|
40
|
+
If you discover a security vulnerability, please refer to
|
|
41
|
+
[Salt's security guide][security].
|
|
42
|
+
|
|
43
|
+
## User Documentation
|
|
44
|
+
|
|
45
|
+
For setup and usage instructions, please refer to the
|
|
46
|
+
[User Documentation][docs].
|
|
47
|
+
|
|
48
|
+
## Contributing
|
|
49
|
+
|
|
50
|
+
The saltext-github project welcomes contributions from anyone!
|
|
51
|
+
|
|
52
|
+
The [Salt Extensions guide][salt-extensions-guide] provides
|
|
53
|
+
comprehensive instructions on all aspects of Salt extension
|
|
54
|
+
development, including [writing tests][writing-tests],
|
|
55
|
+
[running tests][running-tests], [writing documentation][writing-docs]
|
|
56
|
+
and [rendering the docs][rendering-docs].
|
|
57
|
+
|
|
58
|
+
### Quickstart
|
|
59
|
+
|
|
60
|
+
To get started contributing, first clone this repository (or your
|
|
61
|
+
fork):
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Clone the repo
|
|
65
|
+
git clone --origin upstream git@github.com:salt-extensions/saltext-github.git
|
|
66
|
+
|
|
67
|
+
# Change to the repo dir
|
|
68
|
+
cd saltext-github
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### Automatic
|
|
72
|
+
|
|
73
|
+
If you have installed [direnv], copying the included `.envrc.example`
|
|
74
|
+
to `.envrc` and allowing it to run ensures a proper development
|
|
75
|
+
environment is present and the virtual environment is active.
|
|
76
|
+
|
|
77
|
+
Without `direnv`, you can still run the automation explicitly:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
make dev # or python3 tools/initialize.py
|
|
81
|
+
source .venv/bin/activate
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Manual
|
|
85
|
+
|
|
86
|
+
Please follow the [first steps][first-steps], skipping the repository
|
|
87
|
+
initialization and first commit.
|
|
88
|
+
|
|
89
|
+
### Pull request
|
|
90
|
+
|
|
91
|
+
Always make changes in a feature branch:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git switch -c my-feature-branch
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Please ensure you include a
|
|
98
|
+
[news fragment](https://salt-extensions.github.io/salt-extension-copier/topics/documenting/changelog.html#procedure)
|
|
99
|
+
describing your changes. This is a requirement for all user-facing
|
|
100
|
+
changes (bug fixes, new features), with the exception of documentation
|
|
101
|
+
changes.
|
|
102
|
+
|
|
103
|
+
To [submit a Pull Request][submitting-pr], you'll need a fork of this
|
|
104
|
+
repository in your own GitHub account. If you followed the
|
|
105
|
+
instructions above, set your fork as the `origin` remote now:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
git remote add origin git@github.com:<your_fork>.git
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Ensure you followed the [first steps][first-steps] and commit your
|
|
112
|
+
changes, fixing any failing `pre-commit` hooks. Then push the feature
|
|
113
|
+
branch to your fork and submit a PR.
|
|
114
|
+
|
|
115
|
+
### Ways to contribute
|
|
116
|
+
|
|
117
|
+
Contributions come in many forms, and they’re all valuable! Here are
|
|
118
|
+
some ways you can help without writing code:
|
|
119
|
+
|
|
120
|
+
- **Documentation**: Especially examples showing how to use this
|
|
121
|
+
project to solve specific problems.
|
|
122
|
+
- **Triaging issues**: Help manage [issues] and participate in
|
|
123
|
+
[discussions].
|
|
124
|
+
- **Reviewing [Pull Requests][prs]**: We especially appreciate reviews
|
|
125
|
+
using [Conventional Comments][comments].
|
|
126
|
+
|
|
127
|
+
You can also contribute by:
|
|
128
|
+
|
|
129
|
+
- Writing blog posts
|
|
130
|
+
- Sharing your experiences using Salt + GitHub on social media
|
|
131
|
+
- Giving talks at conferences
|
|
132
|
+
- Publishing videos
|
|
133
|
+
- Engaging in IRC, Discord or email groups
|
|
134
|
+
|
|
135
|
+
Any of these things are super valuable to our community, and we
|
|
136
|
+
sincerely appreciate every contribution!
|
|
137
|
+
|
|
138
|
+
[comments]: https://conventionalcomments.org/
|
|
139
|
+
[direnv]: https://direnv.net
|
|
140
|
+
[discussions]: https://github.com/salt-extensions/saltext-github/discussions
|
|
141
|
+
[docs]: https://salt-extensions.github.io/saltext-github/
|
|
142
|
+
[first-steps]: https://salt-extensions.github.io/salt-extension-copier/topics/creation.html#initialize-the-python-virtual-environment
|
|
143
|
+
[issues]: https://github.com/salt-extensions/saltext-github/issues
|
|
144
|
+
[prs]: https://github.com/salt-extensions/saltext-github/pulls
|
|
145
|
+
[rendering-docs]: https://salt-extensions.github.io/salt-extension-copier/topics/documenting/building.html
|
|
146
|
+
[running-tests]: https://salt-extensions.github.io/salt-extension-copier/topics/testing/running.html
|
|
147
|
+
[salt-extensions-guide]: https://salt-extensions.github.io/salt-extension-copier/
|
|
148
|
+
[security]: https://github.com/saltstack/salt/blob/master/SECURITY.md
|
|
149
|
+
[submitting-pr]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork
|
|
150
|
+
[writing-docs]: https://salt-extensions.github.io/salt-extension-copier/topics/documenting/writing.html
|
|
151
|
+
[writing-tests]: https://salt-extensions.github.io/salt-extension-copier/topics/testing/writing.html
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
saltext/github/__init__.py,sha256=jF_0FR6RUG-bObZ6K4JlQyABIamD3ustPh_bHPN4UDs,933
|
|
2
|
+
saltext/github/version.py,sha256=LGVQyDsWifdACo7qztwb8RWWHds1E7uQ-ZqD8SAjyw4,22
|
|
3
|
+
saltext/github/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
saltext/github/modules/github.py,sha256=NVTyEZZVBHsaTqPmEFWzBFoaNrSB6o5Bfd65MK-Jjks,54569
|
|
5
|
+
saltext/github/modules/github_org.py,sha256=Hcng88LggTaDNFq6A5JRhHr224qRYHqjVro6cC4ijm4,17354
|
|
6
|
+
saltext/github/modules/github_repo.py,sha256=C--0yRqInlLEZH1uGhuga3PFB2wKDKzZnC6i1_SvCB8,45308
|
|
7
|
+
saltext/github/modules/github_user.py,sha256=Z6zY0J9FD2mOPk7o01f9TSqVfGIwa0LB2rXYLxEghKM,2100
|
|
8
|
+
saltext/github/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
saltext/github/resources/github/__init__.py,sha256=6N_ru2FdQIN8oXSn2vCT3O8Vg7jPjuvztw117hbT6r4,8543
|
|
10
|
+
saltext/github/resources/github/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
saltext/github/resources/github/modules/actions.py,sha256=zL06Ar0RBwlOYfW4u3Yo5D-rebiGs5FSYBxsxmW-IL8,4962
|
|
12
|
+
saltext/github/resources/github/modules/config.py,sha256=NEpAeL6cmAVqawZghtQhH7xh1R-k_uDgujDfYKkTaj8,2055
|
|
13
|
+
saltext/github/resources/github/modules/deploy_key.py,sha256=WDRSiQoFhG6I0rjKKO0mLOsRqPoJAYs0xlnGLOHRSRc,3141
|
|
14
|
+
saltext/github/resources/github/modules/environment.py,sha256=QmzF2tupMLsplZsqk5t31seNuY7D5ZHrioVAgvW2Mx4,6720
|
|
15
|
+
saltext/github/resources/github/modules/grains.py,sha256=eYQ1t6mNgb4QKUilJAxZHb5fX0FMNSY05jaqFO-oCUE,699
|
|
16
|
+
saltext/github/resources/github/modules/issue.py,sha256=EmnA2JpwqtjjAzwqqevXO4YKcwLNW9Q-a7kz2lrJr14,4128
|
|
17
|
+
saltext/github/resources/github/modules/label.py,sha256=cvZsbg2kNoJ5KiqdKzfVhVo7KZ6hqeNvN56x2oxwu6U,3965
|
|
18
|
+
saltext/github/resources/github/modules/milestone.py,sha256=rbKSic1DkVtK0g779Mn6wLDutuIR64lRGJ8VhwDn4eU,2843
|
|
19
|
+
saltext/github/resources/github/modules/pages.py,sha256=ndKoZVATHxidYwiwQtix_L0bOQ6XgbDvgwwRknlyLjo,3802
|
|
20
|
+
saltext/github/resources/github/modules/pull.py,sha256=dlyXpzBhy7MEsj29rXnfRJOee_WZVbNhvCMOvjyuFKU,2336
|
|
21
|
+
saltext/github/resources/github/modules/repo.py,sha256=dMwjqeOZI7blBE0zPYXoWicbK5UM09mn76ukl_6xZNQ,4114
|
|
22
|
+
saltext/github/resources/github/modules/ruleset.py,sha256=LM74vdCX0uN37qsqcO1WWoWxnfYcz5oGKnsKAXIHicI,3760
|
|
23
|
+
saltext/github/resources/github/modules/saltutil.py,sha256=bMenUq_EYVCclcKPZ_1Pax1Mqo7B_Ea1cBDf_FejyS4,747
|
|
24
|
+
saltext/github/resources/github/modules/state.py,sha256=CMwtB34JFQ1rImsXqvdko6TouQjwPItS54eV9FrDKlw,3880
|
|
25
|
+
saltext/github/resources/github/modules/test.py,sha256=xy04wKRfqpLSUW0f5Jr-N4mE3P5Eg73i-AK5ID0FQwc,708
|
|
26
|
+
saltext/github/resources/github/states/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
saltext/github/resources/github/states/actions.py,sha256=sib4o73UJ9ZoRlNEz-700iZ-JNHG15_TsL0Xs7VhICk,3452
|
|
28
|
+
saltext/github/resources/github/states/deploy_key.py,sha256=mvSWKgeW61EbF4n2QNZ7vNJcN-qPOwHFvs4xB2GSZzE,3837
|
|
29
|
+
saltext/github/resources/github/states/environment.py,sha256=4ysx0nSJtXhkHUGdhdzx9pNWPx_6QurEbM65Cn__ZtA,2738
|
|
30
|
+
saltext/github/resources/github/states/label.py,sha256=M6xJaR1DgSJ7OGu63T1YHEJLy6rhRLzSxVvNMOJV-Wk,1917
|
|
31
|
+
saltext/github/resources/github/states/pages.py,sha256=o1xaA1l6z3ZDA0tjPkrJ_NFYMJVAFjDwaxvGqCk3L2k,2517
|
|
32
|
+
saltext/github/resources/github/states/repo.py,sha256=n_t1gGjcoVKR1i8Ilio5uiAGMfZYYqw91yrpH5argDo,3154
|
|
33
|
+
saltext/github/resources/github/states/ruleset.py,sha256=4qUsC5z_1h7Ciqm_6O6um-y_YrdXhF7tWu_KDDbjbdE,2252
|
|
34
|
+
saltext/github/states/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
|
+
saltext/github/states/github.py,sha256=GVM8fD3UY7lpVYeCymDJ208TZQexNJ78241_YncPaiA,33575
|
|
36
|
+
saltext/github/states/github_org.py,sha256=C3rKvbVmjleIF4mYkQV2z-fgAhapcf6kUHZh7BWOEHc,12446
|
|
37
|
+
saltext/github/states/github_repo.py,sha256=BD8qPmhDD8_-xjynUet_FX-idn6v5BEvXneSaZQkoC8,20423
|
|
38
|
+
saltext/github/utils/__init__.py,sha256=lWcIHEgXg3Y8VculOdkILBTs-EjpJsx_aQqd53CUIJ8,2023
|
|
39
|
+
saltext/github/utils/gh/__init__.py,sha256=qTo67u6-YEFhPhnIRiXhXwqYI4OzZ_eHmAne37VM89A,572
|
|
40
|
+
saltext/github/utils/gh/actions.py,sha256=f3eIAEgOGuMYopnz3CRQ8Z6irx3ApFfaYK-ueAGsDFY,5184
|
|
41
|
+
saltext/github/utils/gh/cache.py,sha256=fk6whF5Szkwsa4v-CtuJClcuvu_Wxw9GiZ6WkYZBoug,4545
|
|
42
|
+
saltext/github/utils/gh/client.py,sha256=9lKF5TYRR2JlwJnfNFeZPblOjZmppscqpK38cka-sRU,18631
|
|
43
|
+
saltext/github/utils/gh/deploy_keys.py,sha256=Wb0RpBrsxdZ77lBXYgSLdgZEcQnYSOm8CoSGqKiksiU,2749
|
|
44
|
+
saltext/github/utils/gh/environments.py,sha256=q_OBU084UQz8vrg3HA2dBpu_VYSgqg1R0g_pmjt5A0E,7471
|
|
45
|
+
saltext/github/utils/gh/exceptions.py,sha256=uBrny8BlXOmOp-V0EAV_WhL5LwWD3feOavGcWfGGzbM,602
|
|
46
|
+
saltext/github/utils/gh/grains_files.py,sha256=Cu_zQkk6rTIPnXuvgAk3Wp6dcSe-v-3DZTlNjja3NXU,12880
|
|
47
|
+
saltext/github/utils/gh/issues.py,sha256=k2E56Vk0yZUKYPqbVJC0BNBi1ncELRcHnKo1-BqSd_8,4929
|
|
48
|
+
saltext/github/utils/gh/labels.py,sha256=MM4ZyToHxKBkTWID1Rt-cPaQoDDxZ4hc3SwGnKo0Jxg,3485
|
|
49
|
+
saltext/github/utils/gh/members.py,sha256=Afed-9CRra6ZDvWL0JdsZSaNQbT_a3XEv7XliIKdp3Q,4077
|
|
50
|
+
saltext/github/utils/gh/milestones.py,sha256=-ksNV6NvqkGSIkuWFUm4sFXzvrXwYAfFCicXlGabSGU,3101
|
|
51
|
+
saltext/github/utils/gh/pages.py,sha256=XLmPlZecq38ufx5yGFWjK1BdFNdv5lS4ZlzKh_Go6oE,3301
|
|
52
|
+
saltext/github/utils/gh/profile.py,sha256=ljHNGM8sZttqADnrUcjgTEdsULK8O_p182zM_PW0NzM,16142
|
|
53
|
+
saltext/github/utils/gh/pulls.py,sha256=sLbV25__71KNZ1vfjd5WVbOrKQklqNgTwqqUVcIH1ww,2441
|
|
54
|
+
saltext/github/utils/gh/repos.py,sha256=UYugGFWrRhpVjQGmIijidkhxAjnerf9fZGSBZpnUJok,14599
|
|
55
|
+
saltext/github/utils/gh/resource.py,sha256=uS24AhagMIYvBrJZsCW7XAeRaHKwVY4L5ld5Hxu7Dm0,1246
|
|
56
|
+
saltext/github/utils/gh/rulesets.py,sha256=rUwgOdYFakdLw-z_r128xoY3UgDp2iO21eOgQHqJwgA,5292
|
|
57
|
+
saltext/github/utils/gh/teams.py,sha256=oVkitFGbTh5XImMLJf_PtLmvD8kzR9huQc5OZSu6Lzs,10766
|
|
58
|
+
saltext/github/utils/gh/users.py,sha256=_X5xKyxA30JFyqYBNkRznXyzvUIkq0FEXWpmLdNhKXg,2556
|
|
59
|
+
saltext/github/utils/gh/statecores/__init__.py,sha256=SkKsmt4LhXGyR6KpqIUED-LFo0DvAVqx9-Ha2VueEV4,2240
|
|
60
|
+
saltext/github/utils/gh/statecores/actions.py,sha256=HvIKATRUIlUVIJ62MVEg4Axde2PKU_je5UngIstSvBI,5415
|
|
61
|
+
saltext/github/utils/gh/statecores/deploy_keys.py,sha256=lGz7ARE510POIYL3QQwU0oALfn_WngZw_eMviQ3b4cI,8525
|
|
62
|
+
saltext/github/utils/gh/statecores/environments.py,sha256=f-8bRdOV0rNUJcZg0gTb941ZLb855Za3j_yD6VNFWow,6928
|
|
63
|
+
saltext/github/utils/gh/statecores/labels.py,sha256=uk2QhoIXLnDCbMRhVjHuE2B7sfPv16Ix6t7QuQZBf3U,3285
|
|
64
|
+
saltext/github/utils/gh/statecores/pages.py,sha256=4upOfyrZji0d6gekq_Nos2LrFuDrOjWjSd1a88ki7xE,5286
|
|
65
|
+
saltext/github/utils/gh/statecores/repo.py,sha256=XW2XZ4_eohN90om8zQtIrEbkJelECKaXW94tJkq5mLs,8172
|
|
66
|
+
saltext/github/utils/gh/statecores/rulesets.py,sha256=NPnAUZO5s52frjYy3-XB8YHY1N5Vq1GzkbTPfxt4SSs,3710
|
|
67
|
+
saltext_github-1.1.0.dist-info/licenses/LICENSE,sha256=CqI5a4iiIahNnJvB_0xOZq5IWTNjpT3OPeSN799rcA0,11352
|
|
68
|
+
saltext_github-1.1.0.dist-info/licenses/NOTICE,sha256=9DS4Ym195w_ILqjTFTkKJN6D5NHEkx_k6dW8OXkdBeU,465
|
|
69
|
+
saltext_github-1.1.0.dist-info/METADATA,sha256=riidpQ8pFGrrGA_SBpjftmxOJIlOD1ORuc4lyw0k9u0,5523
|
|
70
|
+
saltext_github-1.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
71
|
+
saltext_github-1.1.0.dist-info/entry_points.txt,sha256=Dgz2Cy3Ljfh5EceuWND0IHMudnVEYsF2f_-jOwXL2Zk,46
|
|
72
|
+
saltext_github-1.1.0.dist-info/top_level.txt,sha256=6cynQgWBWnAPoXMnUaVitGzM6k7PzacwjLBPgrjOfi4,8
|
|
73
|
+
saltext_github-1.1.0.dist-info/RECORD,,
|