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,722 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage a single GitHub repository within an organization or user
|
|
3
|
+
account: the repository itself, its rulesets, deploy keys, Actions
|
|
4
|
+
secrets and settings, environments, labels and Pages.
|
|
5
|
+
|
|
6
|
+
.. versionadded:: 1.1.0
|
|
7
|
+
|
|
8
|
+
All states default ``repo_name`` to the value configured in the profile.
|
|
9
|
+
For the states managing per-repository singletons (:py:func:`present
|
|
10
|
+
<saltext.github.states.github_repo.present>`, :py:func:`absent
|
|
11
|
+
<saltext.github.states.github_repo.absent>`, :py:func:`pages_present
|
|
12
|
+
<saltext.github.states.github_repo.pages_present>`, ...), ``name``
|
|
13
|
+
doubles as the repository name instead.
|
|
14
|
+
|
|
15
|
+
All states accept an ``owner`` argument (defaulting to the profile's
|
|
16
|
+
``owner``) to manage repositories of other owners, including user-owned
|
|
17
|
+
ones. The ``teams`` parameter of :py:func:`present
|
|
18
|
+
<saltext.github.states.github_repo.present>` only applies to
|
|
19
|
+
organization-owned repositories (teams belong to the owning
|
|
20
|
+
organization), and repository creation is only supported for
|
|
21
|
+
organizations and the authenticated user, a GitHub API limitation.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
import logging
|
|
25
|
+
|
|
26
|
+
from salt.exceptions import CommandExecutionError
|
|
27
|
+
|
|
28
|
+
from saltext.github.utils.gh import profile as gh_profile
|
|
29
|
+
from saltext.github.utils.gh.statecores import actions as sc_actions
|
|
30
|
+
from saltext.github.utils.gh.statecores import catch_errors
|
|
31
|
+
from saltext.github.utils.gh.statecores import deploy_keys as sc_deploy_keys
|
|
32
|
+
from saltext.github.utils.gh.statecores import environments as sc_environments
|
|
33
|
+
from saltext.github.utils.gh.statecores import labels as sc_labels
|
|
34
|
+
from saltext.github.utils.gh.statecores import pages as sc_pages
|
|
35
|
+
from saltext.github.utils.gh.statecores import repo as sc_repo
|
|
36
|
+
from saltext.github.utils.gh.statecores import rulesets as sc_rulesets
|
|
37
|
+
|
|
38
|
+
log = logging.getLogger(__name__)
|
|
39
|
+
|
|
40
|
+
__virtualname__ = "github_repo"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _get_conn(profile):
|
|
44
|
+
return gh_profile.get_conn(profile, opts=__opts__, context=__context__)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _resolve_repo_name(repo_name, profile):
|
|
48
|
+
"""
|
|
49
|
+
Default ``repo_name`` to the profile configuration when unset.
|
|
50
|
+
"""
|
|
51
|
+
if repo_name is None:
|
|
52
|
+
return gh_profile.get_config_value(profile, "repo_name", opts=__opts__, context=__context__)
|
|
53
|
+
return repo_name
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _allow_privacy_change(profile):
|
|
57
|
+
"""
|
|
58
|
+
Resolve the profile's ``allow_repo_privacy_changes``, defaulting
|
|
59
|
+
to false.
|
|
60
|
+
"""
|
|
61
|
+
return gh_profile.get_config_value(
|
|
62
|
+
profile, "allow_repo_privacy_changes", opts=__opts__, context=__context__, default=False
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@catch_errors
|
|
67
|
+
def present(
|
|
68
|
+
name,
|
|
69
|
+
description=None,
|
|
70
|
+
homepage=None,
|
|
71
|
+
private=None,
|
|
72
|
+
has_issues=None,
|
|
73
|
+
has_wiki=None,
|
|
74
|
+
has_downloads=None,
|
|
75
|
+
auto_init=False,
|
|
76
|
+
gitignore_template=None,
|
|
77
|
+
license_template=None,
|
|
78
|
+
default_branch=None,
|
|
79
|
+
teams=None,
|
|
80
|
+
owner=None,
|
|
81
|
+
profile="github",
|
|
82
|
+
):
|
|
83
|
+
"""
|
|
84
|
+
Ensure a repository is present and configured as specified.
|
|
85
|
+
Unspecified settings are left unmanaged.
|
|
86
|
+
|
|
87
|
+
name
|
|
88
|
+
Name of the repository.
|
|
89
|
+
|
|
90
|
+
description
|
|
91
|
+
Repository description.
|
|
92
|
+
|
|
93
|
+
homepage
|
|
94
|
+
URL with more information about the repository, e.g. rendered docs.
|
|
95
|
+
|
|
96
|
+
private
|
|
97
|
+
Repository visibility. Changing this on an existing repository
|
|
98
|
+
requires :ghconf:`allow_repo_privacy_changes` to be enabled in the profile.
|
|
99
|
+
|
|
100
|
+
has_issues
|
|
101
|
+
Enable issues for this repository.
|
|
102
|
+
|
|
103
|
+
has_wiki
|
|
104
|
+
Enable the wiki for this repository.
|
|
105
|
+
|
|
106
|
+
has_downloads
|
|
107
|
+
Enable downloads for this repository.
|
|
108
|
+
|
|
109
|
+
auto_init
|
|
110
|
+
Create an initial commit with an empty README when creating
|
|
111
|
+
the repository.
|
|
112
|
+
|
|
113
|
+
gitignore_template
|
|
114
|
+
Desired language or platform for a .gitignore, e.g. "Haskell".
|
|
115
|
+
Only applies when creating the repository.
|
|
116
|
+
|
|
117
|
+
license_template
|
|
118
|
+
Desired LICENSE template to apply, e.g. "mit" or "mozilla".
|
|
119
|
+
Only applies when creating the repository.
|
|
120
|
+
|
|
121
|
+
default_branch
|
|
122
|
+
Default branch of the repository. The branch must already exist,
|
|
123
|
+
so this is not applied when the repository is newly created.
|
|
124
|
+
|
|
125
|
+
teams
|
|
126
|
+
Teams this repo should belong to, specified as a dict of team
|
|
127
|
+
name to permission (``pull``, ``push`` or ``admin``).
|
|
128
|
+
Unlisted teams are removed from the repository. The teams
|
|
129
|
+
belong to the repository's owning organization, so this is
|
|
130
|
+
only supported for organization-owned repositories.
|
|
131
|
+
|
|
132
|
+
owner
|
|
133
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
134
|
+
Repository creation is only supported for organizations and
|
|
135
|
+
the authenticated user.
|
|
136
|
+
|
|
137
|
+
profile
|
|
138
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
139
|
+
"""
|
|
140
|
+
return sc_repo.present(
|
|
141
|
+
_get_conn(profile),
|
|
142
|
+
name,
|
|
143
|
+
owner=owner,
|
|
144
|
+
description=description,
|
|
145
|
+
homepage=homepage,
|
|
146
|
+
private=private,
|
|
147
|
+
has_issues=has_issues,
|
|
148
|
+
has_wiki=has_wiki,
|
|
149
|
+
has_downloads=has_downloads,
|
|
150
|
+
auto_init=auto_init,
|
|
151
|
+
gitignore_template=gitignore_template,
|
|
152
|
+
license_template=license_template,
|
|
153
|
+
default_branch=default_branch,
|
|
154
|
+
teams=teams,
|
|
155
|
+
allow_privacy_change=_allow_privacy_change(profile),
|
|
156
|
+
test=__opts__["test"],
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
@catch_errors
|
|
161
|
+
def absent(name, owner=None, profile="github"):
|
|
162
|
+
"""
|
|
163
|
+
Ensure a repository is absent.
|
|
164
|
+
|
|
165
|
+
name
|
|
166
|
+
Name of the repository.
|
|
167
|
+
|
|
168
|
+
owner
|
|
169
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
170
|
+
|
|
171
|
+
profile
|
|
172
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
173
|
+
"""
|
|
174
|
+
return sc_repo.absent(_get_conn(profile), name, owner=owner, test=__opts__["test"])
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
@catch_errors
|
|
178
|
+
def ruleset_present(name, ruleset_params=None, repo_name=None, owner=None, profile="github"):
|
|
179
|
+
"""
|
|
180
|
+
Ensure a repository ruleset is present and configured as specified.
|
|
181
|
+
Only the parameters included in ``ruleset_params`` are compared,
|
|
182
|
+
server-populated fields are ignored.
|
|
183
|
+
|
|
184
|
+
Example:
|
|
185
|
+
|
|
186
|
+
.. code-block:: yaml
|
|
187
|
+
|
|
188
|
+
Ensure ruleset test is present in my-repo:
|
|
189
|
+
github_repo.ruleset_present:
|
|
190
|
+
- name: test
|
|
191
|
+
- repo_name: my-repo
|
|
192
|
+
- ruleset_params:
|
|
193
|
+
target: branch
|
|
194
|
+
enforcement: active
|
|
195
|
+
|
|
196
|
+
name
|
|
197
|
+
Ruleset name to manage.
|
|
198
|
+
|
|
199
|
+
ruleset_params
|
|
200
|
+
Ruleset definition. Must contain at least ``enforcement``
|
|
201
|
+
when the ruleset needs to be created. ``name`` is pulled from
|
|
202
|
+
this state's ``name``.
|
|
203
|
+
|
|
204
|
+
repo_name
|
|
205
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
206
|
+
|
|
207
|
+
owner
|
|
208
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
209
|
+
|
|
210
|
+
profile
|
|
211
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
212
|
+
"""
|
|
213
|
+
return sc_rulesets.present(
|
|
214
|
+
_get_conn(profile),
|
|
215
|
+
name,
|
|
216
|
+
_resolve_repo_name(repo_name, profile),
|
|
217
|
+
ruleset_params=ruleset_params,
|
|
218
|
+
owner=owner,
|
|
219
|
+
test=__opts__["test"],
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@catch_errors
|
|
224
|
+
def ruleset_absent(name, repo_name=None, owner=None, profile="github"):
|
|
225
|
+
"""
|
|
226
|
+
Ensure a repository ruleset is absent.
|
|
227
|
+
|
|
228
|
+
name
|
|
229
|
+
Ruleset name to manage.
|
|
230
|
+
|
|
231
|
+
repo_name
|
|
232
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
233
|
+
|
|
234
|
+
owner
|
|
235
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
236
|
+
|
|
237
|
+
profile
|
|
238
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
239
|
+
"""
|
|
240
|
+
return sc_rulesets.absent(
|
|
241
|
+
_get_conn(profile),
|
|
242
|
+
name,
|
|
243
|
+
_resolve_repo_name(repo_name, profile),
|
|
244
|
+
owner=owner,
|
|
245
|
+
test=__opts__["test"],
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
@catch_errors
|
|
250
|
+
def deploy_key_present(name, key, read_only=False, repo_name=None, owner=None, profile="github"):
|
|
251
|
+
"""
|
|
252
|
+
Ensure a deploy key with this title and public key is present
|
|
253
|
+
in a repository.
|
|
254
|
+
|
|
255
|
+
Since deploy keys are immutable in the GitHub API, a key whose
|
|
256
|
+
``key`` or ``read_only`` setting differs is replaced (removed
|
|
257
|
+
and recreated).
|
|
258
|
+
|
|
259
|
+
Example:
|
|
260
|
+
|
|
261
|
+
.. code-block:: yaml
|
|
262
|
+
|
|
263
|
+
Autorelease deploy key is present:
|
|
264
|
+
github_repo.deploy_key_present:
|
|
265
|
+
- name: autorelease
|
|
266
|
+
- key: ssh-ed25519 AAAA...
|
|
267
|
+
- repo_name: my-repo
|
|
268
|
+
|
|
269
|
+
name
|
|
270
|
+
Display title of the deploy key.
|
|
271
|
+
|
|
272
|
+
key
|
|
273
|
+
SSH public key.
|
|
274
|
+
|
|
275
|
+
read_only
|
|
276
|
+
Deny write access to the repository for this key. Defaults to false.
|
|
277
|
+
|
|
278
|
+
repo_name
|
|
279
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
280
|
+
|
|
281
|
+
owner
|
|
282
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
283
|
+
|
|
284
|
+
profile
|
|
285
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
286
|
+
"""
|
|
287
|
+
return sc_deploy_keys.present(
|
|
288
|
+
_get_conn(profile),
|
|
289
|
+
name,
|
|
290
|
+
key,
|
|
291
|
+
_resolve_repo_name(repo_name, profile),
|
|
292
|
+
read_only=read_only,
|
|
293
|
+
owner=owner,
|
|
294
|
+
test=__opts__["test"],
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
@catch_errors
|
|
299
|
+
def deploy_key_absent(name, repo_name=None, owner=None, profile="github"):
|
|
300
|
+
"""
|
|
301
|
+
Ensure no deploy key with this title is present in a repository.
|
|
302
|
+
|
|
303
|
+
name
|
|
304
|
+
Display title of the deploy key.
|
|
305
|
+
|
|
306
|
+
repo_name
|
|
307
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
308
|
+
|
|
309
|
+
owner
|
|
310
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
311
|
+
|
|
312
|
+
profile
|
|
313
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
314
|
+
"""
|
|
315
|
+
return sc_deploy_keys.absent(
|
|
316
|
+
_get_conn(profile),
|
|
317
|
+
name,
|
|
318
|
+
_resolve_repo_name(repo_name, profile),
|
|
319
|
+
owner=owner,
|
|
320
|
+
test=__opts__["test"],
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
@catch_errors
|
|
325
|
+
def deploy_key_actions_present(
|
|
326
|
+
name, secret_name, read_only=False, rotate=False, repo_name=None, owner=None, profile="github"
|
|
327
|
+
):
|
|
328
|
+
"""
|
|
329
|
+
Ensure a generated SSH keypair is distributed to a repository:
|
|
330
|
+
the public half as a deploy key with this title, the private half
|
|
331
|
+
as an Actions secret. The ed25519 keypair is generated in memory
|
|
332
|
+
via :py:func:`ssh_pki.create_private_key
|
|
333
|
+
<salt.modules.ssh_pki.create_private_key>` (requires Salt 3008+)
|
|
334
|
+
and never persisted; only the public key's fingerprint is reported.
|
|
335
|
+
|
|
336
|
+
Since secret values are write-only in the GitHub API, an existing
|
|
337
|
+
pair cannot be verified to match and is left untouched unless
|
|
338
|
+
``rotate`` is set. A pair with a missing half is regenerated.
|
|
339
|
+
|
|
340
|
+
name
|
|
341
|
+
Display title of the deploy key.
|
|
342
|
+
|
|
343
|
+
secret_name
|
|
344
|
+
Name of the Actions secret holding the private key. GitHub
|
|
345
|
+
treats secret names case-insensitively.
|
|
346
|
+
|
|
347
|
+
read_only
|
|
348
|
+
Deny write access to the repository for this key. Defaults to false.
|
|
349
|
+
|
|
350
|
+
rotate
|
|
351
|
+
Generate and distribute a new keypair even when both halves
|
|
352
|
+
are present. Defaults to false.
|
|
353
|
+
|
|
354
|
+
repo_name
|
|
355
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
356
|
+
|
|
357
|
+
owner
|
|
358
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
359
|
+
|
|
360
|
+
profile
|
|
361
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
362
|
+
"""
|
|
363
|
+
if "ssh_pki.create_private_key" not in __salt__:
|
|
364
|
+
raise CommandExecutionError(
|
|
365
|
+
"This state requires the ssh_pki execution module, available since Salt 3008"
|
|
366
|
+
)
|
|
367
|
+
return sc_deploy_keys.actions_present(
|
|
368
|
+
_get_conn(profile),
|
|
369
|
+
name,
|
|
370
|
+
secret_name,
|
|
371
|
+
_resolve_repo_name(repo_name, profile),
|
|
372
|
+
keygen=lambda: __salt__["ssh_pki.create_private_key"](algo="ed25519"),
|
|
373
|
+
read_only=read_only,
|
|
374
|
+
rotate=rotate,
|
|
375
|
+
owner=owner,
|
|
376
|
+
test=__opts__["test"],
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
@catch_errors
|
|
381
|
+
def actions_secret_present(
|
|
382
|
+
name, value=None, force=False, repo_name=None, owner=None, profile="github"
|
|
383
|
+
):
|
|
384
|
+
"""
|
|
385
|
+
Ensure an Actions secret is present in a repository.
|
|
386
|
+
|
|
387
|
+
Secret values are write-only in the GitHub API, so this state cannot
|
|
388
|
+
detect value drift. By default, an existing secret is left untouched.
|
|
389
|
+
Set ``force`` to push the value on every run.
|
|
390
|
+
|
|
391
|
+
name
|
|
392
|
+
Name of the secret. GitHub treats secret names
|
|
393
|
+
case-insensitively.
|
|
394
|
+
|
|
395
|
+
value
|
|
396
|
+
Plaintext secret value. It is encrypted to the repository
|
|
397
|
+
public key before leaving the minion and never appears in the
|
|
398
|
+
state output. Required when the secret does not exist yet or
|
|
399
|
+
``force`` is set.
|
|
400
|
+
|
|
401
|
+
force
|
|
402
|
+
Push the value even when the secret already exists.
|
|
403
|
+
Defaults to false.
|
|
404
|
+
|
|
405
|
+
repo_name
|
|
406
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
407
|
+
|
|
408
|
+
owner
|
|
409
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
410
|
+
|
|
411
|
+
profile
|
|
412
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
413
|
+
"""
|
|
414
|
+
return sc_actions.secret_present(
|
|
415
|
+
_get_conn(profile),
|
|
416
|
+
name,
|
|
417
|
+
_resolve_repo_name(repo_name, profile),
|
|
418
|
+
value=value,
|
|
419
|
+
force=force,
|
|
420
|
+
owner=owner,
|
|
421
|
+
test=__opts__["test"],
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
@catch_errors
|
|
426
|
+
def actions_secret_absent(name, repo_name=None, owner=None, profile="github"):
|
|
427
|
+
"""
|
|
428
|
+
Ensure an Actions secret is absent from a repository.
|
|
429
|
+
|
|
430
|
+
name
|
|
431
|
+
Name of the secret. GitHub treats secret names
|
|
432
|
+
case-insensitively.
|
|
433
|
+
|
|
434
|
+
repo_name
|
|
435
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
436
|
+
|
|
437
|
+
owner
|
|
438
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
439
|
+
|
|
440
|
+
profile
|
|
441
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
442
|
+
"""
|
|
443
|
+
return sc_actions.secret_absent(
|
|
444
|
+
_get_conn(profile),
|
|
445
|
+
name,
|
|
446
|
+
_resolve_repo_name(repo_name, profile),
|
|
447
|
+
owner=owner,
|
|
448
|
+
test=__opts__["test"],
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
@catch_errors
|
|
453
|
+
def workflow_permissions_managed(
|
|
454
|
+
name,
|
|
455
|
+
default_workflow_permissions=None,
|
|
456
|
+
can_approve_pull_request_reviews=None,
|
|
457
|
+
repo_name=None,
|
|
458
|
+
owner=None,
|
|
459
|
+
profile="github",
|
|
460
|
+
):
|
|
461
|
+
"""
|
|
462
|
+
Manage the default workflow permissions granted to the ``GITHUB_TOKEN``
|
|
463
|
+
in a repository.
|
|
464
|
+
|
|
465
|
+
name
|
|
466
|
+
Name of the repository, unless ``repo_name`` is passed.
|
|
467
|
+
|
|
468
|
+
default_workflow_permissions
|
|
469
|
+
Default permissions for the ``GITHUB_TOKEN``, either ``read``
|
|
470
|
+
or ``write``.
|
|
471
|
+
|
|
472
|
+
can_approve_pull_request_reviews
|
|
473
|
+
Allow GitHub Actions to approve pull requests.
|
|
474
|
+
|
|
475
|
+
repo_name
|
|
476
|
+
Name of the repository, if it differs from ``name``.
|
|
477
|
+
|
|
478
|
+
owner
|
|
479
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
480
|
+
|
|
481
|
+
profile
|
|
482
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
483
|
+
"""
|
|
484
|
+
return sc_actions.workflow_permissions_managed(
|
|
485
|
+
_get_conn(profile),
|
|
486
|
+
name,
|
|
487
|
+
repo_name or name,
|
|
488
|
+
default_workflow_permissions=default_workflow_permissions,
|
|
489
|
+
can_approve_pull_request_reviews=can_approve_pull_request_reviews,
|
|
490
|
+
owner=owner,
|
|
491
|
+
test=__opts__["test"],
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
@catch_errors
|
|
496
|
+
def environment_present(
|
|
497
|
+
name,
|
|
498
|
+
wait_timer=None,
|
|
499
|
+
prevent_self_review=None,
|
|
500
|
+
reviewers=None,
|
|
501
|
+
deployment_branches=None,
|
|
502
|
+
repo_name=None,
|
|
503
|
+
owner=None,
|
|
504
|
+
profile="github",
|
|
505
|
+
):
|
|
506
|
+
"""
|
|
507
|
+
Ensure an environment is present in a repository and configured
|
|
508
|
+
as specified. Unspecified settings are left unmanaged.
|
|
509
|
+
|
|
510
|
+
name
|
|
511
|
+
Name of the environment.
|
|
512
|
+
|
|
513
|
+
wait_timer
|
|
514
|
+
Amount of time to delay a job after it is initially triggered,
|
|
515
|
+
in minutes.
|
|
516
|
+
|
|
517
|
+
prevent_self_review
|
|
518
|
+
Prevent a user who created a job from approving it.
|
|
519
|
+
|
|
520
|
+
reviewers
|
|
521
|
+
People or teams that may review jobs that reference the
|
|
522
|
+
environment, as a list of mappings with ``type`` (``User`` or
|
|
523
|
+
``Team``) and ``id``.
|
|
524
|
+
|
|
525
|
+
deployment_branches
|
|
526
|
+
Which branches can deploy to this environment. Either ``all``,
|
|
527
|
+
``protected`` (branches with branch protection rules) or a list
|
|
528
|
+
of branch name patterns.
|
|
529
|
+
|
|
530
|
+
repo_name
|
|
531
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
532
|
+
|
|
533
|
+
owner
|
|
534
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
535
|
+
|
|
536
|
+
profile
|
|
537
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
538
|
+
"""
|
|
539
|
+
return sc_environments.present(
|
|
540
|
+
_get_conn(profile),
|
|
541
|
+
name,
|
|
542
|
+
_resolve_repo_name(repo_name, profile),
|
|
543
|
+
wait_timer=wait_timer,
|
|
544
|
+
prevent_self_review=prevent_self_review,
|
|
545
|
+
reviewers=reviewers,
|
|
546
|
+
deployment_branches=deployment_branches,
|
|
547
|
+
owner=owner,
|
|
548
|
+
test=__opts__["test"],
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
@catch_errors
|
|
553
|
+
def environment_absent(name, repo_name=None, owner=None, profile="github"):
|
|
554
|
+
"""
|
|
555
|
+
Ensure an environment is absent from a repository.
|
|
556
|
+
|
|
557
|
+
name
|
|
558
|
+
Name of the environment.
|
|
559
|
+
|
|
560
|
+
repo_name
|
|
561
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
562
|
+
|
|
563
|
+
owner
|
|
564
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
565
|
+
|
|
566
|
+
profile
|
|
567
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
568
|
+
"""
|
|
569
|
+
return sc_environments.absent(
|
|
570
|
+
_get_conn(profile),
|
|
571
|
+
name,
|
|
572
|
+
_resolve_repo_name(repo_name, profile),
|
|
573
|
+
owner=owner,
|
|
574
|
+
test=__opts__["test"],
|
|
575
|
+
)
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
@catch_errors
|
|
579
|
+
def label_present(name, color=None, description=None, repo_name=None, owner=None, profile="github"):
|
|
580
|
+
"""
|
|
581
|
+
Ensure a label is present in a repository and configured as
|
|
582
|
+
specified. Unspecified settings are left unmanaged.
|
|
583
|
+
|
|
584
|
+
name
|
|
585
|
+
Name of the label.
|
|
586
|
+
|
|
587
|
+
color
|
|
588
|
+
Hexadecimal color code for the label. A leading ``#``
|
|
589
|
+
is accepted.
|
|
590
|
+
|
|
591
|
+
description
|
|
592
|
+
Short description of the label.
|
|
593
|
+
|
|
594
|
+
repo_name
|
|
595
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
596
|
+
|
|
597
|
+
owner
|
|
598
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
599
|
+
|
|
600
|
+
profile
|
|
601
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
602
|
+
"""
|
|
603
|
+
return sc_labels.present(
|
|
604
|
+
_get_conn(profile),
|
|
605
|
+
name,
|
|
606
|
+
_resolve_repo_name(repo_name, profile),
|
|
607
|
+
color=color,
|
|
608
|
+
description=description,
|
|
609
|
+
owner=owner,
|
|
610
|
+
test=__opts__["test"],
|
|
611
|
+
)
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
@catch_errors
|
|
615
|
+
def label_absent(name, repo_name=None, owner=None, profile="github"):
|
|
616
|
+
"""
|
|
617
|
+
Ensure a label is absent from a repository.
|
|
618
|
+
|
|
619
|
+
name
|
|
620
|
+
Name of the label.
|
|
621
|
+
|
|
622
|
+
repo_name
|
|
623
|
+
Name of the repository. Defaults to the profile's :ghconf:`repo_name`.
|
|
624
|
+
|
|
625
|
+
owner
|
|
626
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
627
|
+
|
|
628
|
+
profile
|
|
629
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
630
|
+
"""
|
|
631
|
+
return sc_labels.absent(
|
|
632
|
+
_get_conn(profile),
|
|
633
|
+
name,
|
|
634
|
+
_resolve_repo_name(repo_name, profile),
|
|
635
|
+
owner=owner,
|
|
636
|
+
test=__opts__["test"],
|
|
637
|
+
)
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
@catch_errors
|
|
641
|
+
def pages_present(
|
|
642
|
+
name,
|
|
643
|
+
build_type=None,
|
|
644
|
+
source_branch=None,
|
|
645
|
+
source_path=None,
|
|
646
|
+
cname=None,
|
|
647
|
+
https_enforced=None,
|
|
648
|
+
repo_name=None,
|
|
649
|
+
owner=None,
|
|
650
|
+
profile="github",
|
|
651
|
+
):
|
|
652
|
+
"""
|
|
653
|
+
Ensure GitHub Pages are enabled for a repository and configured as
|
|
654
|
+
specified. Unspecified settings are left unmanaged.
|
|
655
|
+
|
|
656
|
+
name
|
|
657
|
+
Name of the repository, unless ``repo_name`` is passed.
|
|
658
|
+
|
|
659
|
+
build_type
|
|
660
|
+
Process by which the site is built, either ``legacy``
|
|
661
|
+
(deploy from a branch) or ``workflow`` (GitHub Actions).
|
|
662
|
+
|
|
663
|
+
source_branch
|
|
664
|
+
For ``legacy`` builds, the repository branch to publish from.
|
|
665
|
+
|
|
666
|
+
source_path
|
|
667
|
+
For ``legacy`` builds, the repository directory to publish from,
|
|
668
|
+
either ``/`` or ``/docs``.
|
|
669
|
+
|
|
670
|
+
cname
|
|
671
|
+
Custom domain for the site.
|
|
672
|
+
|
|
673
|
+
https_enforced
|
|
674
|
+
Enforce HTTPS for the site.
|
|
675
|
+
|
|
676
|
+
repo_name
|
|
677
|
+
Name of the repository, if it differs from ``name``.
|
|
678
|
+
|
|
679
|
+
owner
|
|
680
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
681
|
+
|
|
682
|
+
profile
|
|
683
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
684
|
+
"""
|
|
685
|
+
return sc_pages.present(
|
|
686
|
+
_get_conn(profile),
|
|
687
|
+
name,
|
|
688
|
+
repo_name or name,
|
|
689
|
+
build_type=build_type,
|
|
690
|
+
source_branch=source_branch,
|
|
691
|
+
source_path=source_path,
|
|
692
|
+
cname=cname,
|
|
693
|
+
https_enforced=https_enforced,
|
|
694
|
+
owner=owner,
|
|
695
|
+
test=__opts__["test"],
|
|
696
|
+
)
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
@catch_errors
|
|
700
|
+
def pages_absent(name, repo_name=None, owner=None, profile="github"):
|
|
701
|
+
"""
|
|
702
|
+
Ensure GitHub Pages are disabled for a repository.
|
|
703
|
+
|
|
704
|
+
name
|
|
705
|
+
Name of the repository, unless ``repo_name`` is passed.
|
|
706
|
+
|
|
707
|
+
repo_name
|
|
708
|
+
Name of the repository, if it differs from ``name``.
|
|
709
|
+
|
|
710
|
+
owner
|
|
711
|
+
Owner of the repository. Defaults to the profile's :ghconf:`owner`.
|
|
712
|
+
|
|
713
|
+
profile
|
|
714
|
+
Profile configuration name to use. Defaults to ``github``.
|
|
715
|
+
"""
|
|
716
|
+
return sc_pages.absent(
|
|
717
|
+
_get_conn(profile),
|
|
718
|
+
name,
|
|
719
|
+
repo_name or name,
|
|
720
|
+
owner=owner,
|
|
721
|
+
test=__opts__["test"],
|
|
722
|
+
)
|