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,117 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage the targeted repository's Actions secrets and workflow
|
|
3
|
+
permissions.
|
|
4
|
+
|
|
5
|
+
.. versionadded:: 1.1.0
|
|
6
|
+
|
|
7
|
+
Part of the :py:mod:`github <saltext.github.resources.github>` resource type: states operate on the repository
|
|
8
|
+
the state run was dispatched to, so there is no ``repo_name``/``owner``
|
|
9
|
+
parameter. The ``profile`` parameter defaults to the :ghconf:`profile <resource:profile>` named in
|
|
10
|
+
the resource declaration.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import logging
|
|
14
|
+
|
|
15
|
+
from salt.utils.functools import namespaced_function
|
|
16
|
+
|
|
17
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
18
|
+
from saltext.github.utils.gh.statecores import actions as sc_actions
|
|
19
|
+
from saltext.github.utils.gh.statecores import catch_errors
|
|
20
|
+
|
|
21
|
+
log = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@catch_errors
|
|
28
|
+
def secret_present(name, value=None, force=False, profile=None):
|
|
29
|
+
"""
|
|
30
|
+
Ensure an Actions secret is present in the targeted repository.
|
|
31
|
+
|
|
32
|
+
Secret values are write-only in the GitHub API, so this state cannot
|
|
33
|
+
detect value drift. By default, an existing secret is left untouched.
|
|
34
|
+
Set ``force`` to push the value on every run.
|
|
35
|
+
|
|
36
|
+
name
|
|
37
|
+
Name of the secret. GitHub treats secret names
|
|
38
|
+
case-insensitively.
|
|
39
|
+
|
|
40
|
+
value
|
|
41
|
+
Plaintext secret value. It is encrypted to the repository
|
|
42
|
+
public key before leaving the minion and never appears in the
|
|
43
|
+
state output. Required when the secret does not exist yet or
|
|
44
|
+
``force`` is set.
|
|
45
|
+
|
|
46
|
+
force
|
|
47
|
+
Push the value even when the secret already exists.
|
|
48
|
+
Defaults to false.
|
|
49
|
+
|
|
50
|
+
profile
|
|
51
|
+
Profile configuration name to use. Defaults to the resource
|
|
52
|
+
declaration's profile.
|
|
53
|
+
"""
|
|
54
|
+
conn, owner, repo_name = _core_args(profile)
|
|
55
|
+
return sc_actions.secret_present(
|
|
56
|
+
conn,
|
|
57
|
+
name,
|
|
58
|
+
repo_name,
|
|
59
|
+
value=value,
|
|
60
|
+
force=force,
|
|
61
|
+
owner=owner,
|
|
62
|
+
test=__opts__["test"],
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@catch_errors
|
|
67
|
+
def secret_absent(name, profile=None):
|
|
68
|
+
"""
|
|
69
|
+
Ensure an Actions secret is absent from the targeted repository.
|
|
70
|
+
|
|
71
|
+
name
|
|
72
|
+
Name of the secret. GitHub treats secret names
|
|
73
|
+
case-insensitively.
|
|
74
|
+
|
|
75
|
+
profile
|
|
76
|
+
Profile configuration name to use. Defaults to the resource
|
|
77
|
+
declaration's profile.
|
|
78
|
+
"""
|
|
79
|
+
conn, owner, repo_name = _core_args(profile)
|
|
80
|
+
return sc_actions.secret_absent(conn, name, repo_name, owner=owner, test=__opts__["test"])
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@catch_errors
|
|
84
|
+
def workflow_permissions_managed(
|
|
85
|
+
name,
|
|
86
|
+
default_workflow_permissions=None,
|
|
87
|
+
can_approve_pull_request_reviews=None,
|
|
88
|
+
profile=None,
|
|
89
|
+
):
|
|
90
|
+
"""
|
|
91
|
+
Manage the default workflow permissions granted to the ``GITHUB_TOKEN``
|
|
92
|
+
in the targeted repository.
|
|
93
|
+
|
|
94
|
+
name
|
|
95
|
+
State name (the repository is implied by the resource).
|
|
96
|
+
|
|
97
|
+
default_workflow_permissions
|
|
98
|
+
Default permissions for the ``GITHUB_TOKEN``, either ``read``
|
|
99
|
+
or ``write``.
|
|
100
|
+
|
|
101
|
+
can_approve_pull_request_reviews
|
|
102
|
+
Allow GitHub Actions to approve pull requests.
|
|
103
|
+
|
|
104
|
+
profile
|
|
105
|
+
Profile configuration name to use. Defaults to the resource
|
|
106
|
+
declaration's profile.
|
|
107
|
+
"""
|
|
108
|
+
conn, owner, repo_name = _core_args(profile)
|
|
109
|
+
return sc_actions.workflow_permissions_managed(
|
|
110
|
+
conn,
|
|
111
|
+
name,
|
|
112
|
+
repo_name,
|
|
113
|
+
default_workflow_permissions=default_workflow_permissions,
|
|
114
|
+
can_approve_pull_request_reviews=can_approve_pull_request_reviews,
|
|
115
|
+
owner=owner,
|
|
116
|
+
test=__opts__["test"],
|
|
117
|
+
)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage the targeted repository's deploy keys.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
Part of the :py:mod:`github <saltext.github.resources.github>` resource type: states operate on the repository
|
|
7
|
+
the state run was dispatched to, so there is no ``repo_name``/``owner``
|
|
8
|
+
parameter. The ``profile`` parameter defaults to the :ghconf:`profile <resource:profile>` named in
|
|
9
|
+
the resource declaration.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
from salt.utils.functools import namespaced_function
|
|
15
|
+
|
|
16
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
17
|
+
from saltext.github.utils.gh.statecores import catch_errors
|
|
18
|
+
from saltext.github.utils.gh.statecores import deploy_keys as sc_deploy_keys
|
|
19
|
+
|
|
20
|
+
log = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@catch_errors
|
|
27
|
+
def present(name, key, read_only=False, profile=None):
|
|
28
|
+
"""
|
|
29
|
+
Ensure a deploy key with this title and public key is present
|
|
30
|
+
in the targeted repository.
|
|
31
|
+
|
|
32
|
+
Since deploy keys are immutable in the GitHub API, a key whose
|
|
33
|
+
``key`` or ``read_only`` setting differs is replaced (removed
|
|
34
|
+
and recreated).
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
|
|
38
|
+
.. code-block:: yaml
|
|
39
|
+
|
|
40
|
+
Autorelease deploy key is present:
|
|
41
|
+
deploy_key.present:
|
|
42
|
+
- name: autorelease
|
|
43
|
+
- key: ssh-ed25519 AAAA...
|
|
44
|
+
|
|
45
|
+
name
|
|
46
|
+
Display title of the deploy key.
|
|
47
|
+
|
|
48
|
+
key
|
|
49
|
+
SSH public key.
|
|
50
|
+
|
|
51
|
+
read_only
|
|
52
|
+
Deny write access to the repository for this key. Defaults to false.
|
|
53
|
+
|
|
54
|
+
profile
|
|
55
|
+
Profile configuration name to use. Defaults to the resource
|
|
56
|
+
declaration's profile.
|
|
57
|
+
"""
|
|
58
|
+
conn, owner, repo_name = _core_args(profile)
|
|
59
|
+
return sc_deploy_keys.present(
|
|
60
|
+
conn,
|
|
61
|
+
name,
|
|
62
|
+
key,
|
|
63
|
+
repo_name,
|
|
64
|
+
read_only=read_only,
|
|
65
|
+
owner=owner,
|
|
66
|
+
test=__opts__["test"],
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@catch_errors
|
|
71
|
+
def actions_present(name, secret_name, read_only=False, rotate=False, profile=None):
|
|
72
|
+
"""
|
|
73
|
+
Ensure a generated SSH keypair is distributed to the targeted
|
|
74
|
+
repository: the public half as a deploy key with this title, the
|
|
75
|
+
private half as an Actions secret. The ed25519 keypair is generated
|
|
76
|
+
in memory on the managing minion via :py:func:`ssh_pki.create_private_key
|
|
77
|
+
<salt.modules.ssh_pki.create_private_key>` and never persisted;
|
|
78
|
+
only the public key's fingerprint is reported.
|
|
79
|
+
|
|
80
|
+
Since secret values are write-only in the GitHub API, an existing
|
|
81
|
+
pair cannot be verified to match and is left untouched unless
|
|
82
|
+
``rotate`` is set. A pair with a missing half is regenerated.
|
|
83
|
+
|
|
84
|
+
name
|
|
85
|
+
Display title of the deploy key.
|
|
86
|
+
|
|
87
|
+
secret_name
|
|
88
|
+
Name of the Actions secret holding the private key. GitHub
|
|
89
|
+
treats secret names case-insensitively.
|
|
90
|
+
|
|
91
|
+
read_only
|
|
92
|
+
Deny write access to the repository for this key. Defaults to false.
|
|
93
|
+
|
|
94
|
+
rotate
|
|
95
|
+
Generate and distribute a new keypair even when both halves
|
|
96
|
+
are present. Defaults to false.
|
|
97
|
+
|
|
98
|
+
profile
|
|
99
|
+
Profile configuration name to use. Defaults to the resource
|
|
100
|
+
declaration's profile.
|
|
101
|
+
"""
|
|
102
|
+
conn, owner, repo_name = _core_args(profile)
|
|
103
|
+
return sc_deploy_keys.actions_present(
|
|
104
|
+
conn,
|
|
105
|
+
name,
|
|
106
|
+
secret_name,
|
|
107
|
+
repo_name,
|
|
108
|
+
keygen=lambda: __minion__["ssh_pki.create_private_key"](algo="ed25519"),
|
|
109
|
+
read_only=read_only,
|
|
110
|
+
rotate=rotate,
|
|
111
|
+
owner=owner,
|
|
112
|
+
test=__opts__["test"],
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@catch_errors
|
|
117
|
+
def absent(name, profile=None):
|
|
118
|
+
"""
|
|
119
|
+
Ensure no deploy key with this title is present in the targeted
|
|
120
|
+
repository.
|
|
121
|
+
|
|
122
|
+
name
|
|
123
|
+
Display title of the deploy key.
|
|
124
|
+
|
|
125
|
+
profile
|
|
126
|
+
Profile configuration name to use. Defaults to the resource
|
|
127
|
+
declaration's profile.
|
|
128
|
+
"""
|
|
129
|
+
conn, owner, repo_name = _core_args(profile)
|
|
130
|
+
return sc_deploy_keys.absent(conn, name, repo_name, owner=owner, test=__opts__["test"])
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage the targeted repository's (deployment) environments.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
Part of the :py:mod:`github <saltext.github.resources.github>` resource type: states operate on the repository
|
|
7
|
+
the state run was dispatched to, so there is no ``repo_name``/``owner``
|
|
8
|
+
parameter. The ``profile`` parameter defaults to the :ghconf:`profile <resource:profile>` named in
|
|
9
|
+
the resource declaration.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
from salt.utils.functools import namespaced_function
|
|
15
|
+
|
|
16
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
17
|
+
from saltext.github.utils.gh.statecores import catch_errors
|
|
18
|
+
from saltext.github.utils.gh.statecores import environments as sc_environments
|
|
19
|
+
|
|
20
|
+
log = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@catch_errors
|
|
27
|
+
def present(
|
|
28
|
+
name,
|
|
29
|
+
wait_timer=None,
|
|
30
|
+
prevent_self_review=None,
|
|
31
|
+
reviewers=None,
|
|
32
|
+
deployment_branches=None,
|
|
33
|
+
profile=None,
|
|
34
|
+
):
|
|
35
|
+
"""
|
|
36
|
+
Ensure an environment is present in the targeted repository and
|
|
37
|
+
configured as specified. Unspecified settings are left unmanaged.
|
|
38
|
+
|
|
39
|
+
Example:
|
|
40
|
+
|
|
41
|
+
.. code-block:: yaml
|
|
42
|
+
|
|
43
|
+
release:
|
|
44
|
+
environment.present:
|
|
45
|
+
- deployment_branches:
|
|
46
|
+
- main
|
|
47
|
+
|
|
48
|
+
name
|
|
49
|
+
Name of the environment.
|
|
50
|
+
|
|
51
|
+
wait_timer
|
|
52
|
+
Amount of time to delay a job after it is initially triggered,
|
|
53
|
+
in minutes.
|
|
54
|
+
|
|
55
|
+
prevent_self_review
|
|
56
|
+
Prevent a user who created a job from approving it.
|
|
57
|
+
|
|
58
|
+
reviewers
|
|
59
|
+
People or teams that may review jobs that reference the
|
|
60
|
+
environment, as a list of mappings with ``type`` (``User`` or
|
|
61
|
+
``Team``) and ``id``.
|
|
62
|
+
|
|
63
|
+
deployment_branches
|
|
64
|
+
Which branches can deploy to this environment. Either ``all``,
|
|
65
|
+
``protected`` (branches with branch protection rules) or a list
|
|
66
|
+
of branch name patterns.
|
|
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 sc_environments.present(
|
|
74
|
+
conn,
|
|
75
|
+
name,
|
|
76
|
+
repo_name,
|
|
77
|
+
wait_timer=wait_timer,
|
|
78
|
+
prevent_self_review=prevent_self_review,
|
|
79
|
+
reviewers=reviewers,
|
|
80
|
+
deployment_branches=deployment_branches,
|
|
81
|
+
owner=owner,
|
|
82
|
+
test=__opts__["test"],
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@catch_errors
|
|
87
|
+
def absent(name, profile=None):
|
|
88
|
+
"""
|
|
89
|
+
Ensure an environment is absent from the targeted repository.
|
|
90
|
+
|
|
91
|
+
name
|
|
92
|
+
Name of the environment.
|
|
93
|
+
|
|
94
|
+
profile
|
|
95
|
+
Profile configuration name to use. Defaults to the resource
|
|
96
|
+
declaration's profile.
|
|
97
|
+
"""
|
|
98
|
+
conn, owner, repo_name = _core_args(profile)
|
|
99
|
+
return sc_environments.absent(conn, name, repo_name, owner=owner, test=__opts__["test"])
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage the targeted repository's labels.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
Part of the :py:mod:`github <saltext.github.resources.github>` resource type: states operate on the repository
|
|
7
|
+
the state run was dispatched to, so there is no ``repo_name``/``owner``
|
|
8
|
+
parameter. The ``profile`` parameter defaults to the :ghconf:`profile <resource:profile>` named in
|
|
9
|
+
the resource declaration.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
from salt.utils.functools import namespaced_function
|
|
15
|
+
|
|
16
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
17
|
+
from saltext.github.utils.gh.statecores import catch_errors
|
|
18
|
+
from saltext.github.utils.gh.statecores import labels as sc_labels
|
|
19
|
+
|
|
20
|
+
log = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@catch_errors
|
|
27
|
+
def present(name, color=None, description=None, profile=None):
|
|
28
|
+
"""
|
|
29
|
+
Ensure a label is present in the targeted repository and configured
|
|
30
|
+
as specified. Unspecified settings are left unmanaged.
|
|
31
|
+
|
|
32
|
+
name
|
|
33
|
+
Name of the label.
|
|
34
|
+
|
|
35
|
+
color
|
|
36
|
+
Hexadecimal color code for the label. A leading ``#``
|
|
37
|
+
is accepted.
|
|
38
|
+
|
|
39
|
+
description
|
|
40
|
+
Short description of the label.
|
|
41
|
+
|
|
42
|
+
profile
|
|
43
|
+
Profile configuration name to use. Defaults to the resource
|
|
44
|
+
declaration's profile.
|
|
45
|
+
"""
|
|
46
|
+
conn, owner, repo_name = _core_args(profile)
|
|
47
|
+
return sc_labels.present(
|
|
48
|
+
conn,
|
|
49
|
+
name,
|
|
50
|
+
repo_name,
|
|
51
|
+
color=color,
|
|
52
|
+
description=description,
|
|
53
|
+
owner=owner,
|
|
54
|
+
test=__opts__["test"],
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@catch_errors
|
|
59
|
+
def absent(name, profile=None):
|
|
60
|
+
"""
|
|
61
|
+
Ensure a label is absent from the targeted repository.
|
|
62
|
+
|
|
63
|
+
name
|
|
64
|
+
Name of the label.
|
|
65
|
+
|
|
66
|
+
profile
|
|
67
|
+
Profile configuration name to use. Defaults to the resource
|
|
68
|
+
declaration's profile.
|
|
69
|
+
"""
|
|
70
|
+
conn, owner, repo_name = _core_args(profile)
|
|
71
|
+
return sc_labels.absent(conn, name, repo_name, owner=owner, test=__opts__["test"])
|
|
@@ -0,0 +1,92 @@
|
|
|
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: states operate on the repository
|
|
7
|
+
the state run was dispatched to, so there is no ``repo_name``/``owner``
|
|
8
|
+
parameter. The ``profile`` parameter defaults to the :ghconf:`profile <resource:profile>` named in
|
|
9
|
+
the resource declaration.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
from salt.utils.functools import namespaced_function
|
|
15
|
+
|
|
16
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
17
|
+
from saltext.github.utils.gh.statecores import catch_errors
|
|
18
|
+
from saltext.github.utils.gh.statecores import pages as sc_pages
|
|
19
|
+
|
|
20
|
+
log = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@catch_errors
|
|
27
|
+
def present(
|
|
28
|
+
name,
|
|
29
|
+
build_type=None,
|
|
30
|
+
source_branch=None,
|
|
31
|
+
source_path=None,
|
|
32
|
+
cname=None,
|
|
33
|
+
https_enforced=None,
|
|
34
|
+
profile=None,
|
|
35
|
+
):
|
|
36
|
+
"""
|
|
37
|
+
Ensure GitHub Pages are enabled for the targeted repository and
|
|
38
|
+
configured as specified. Unspecified settings are left unmanaged.
|
|
39
|
+
|
|
40
|
+
name
|
|
41
|
+
State name (the repository is implied by the resource).
|
|
42
|
+
|
|
43
|
+
build_type
|
|
44
|
+
Process by which the site is built, either ``legacy``
|
|
45
|
+
(deploy from a branch) or ``workflow`` (GitHub Actions).
|
|
46
|
+
|
|
47
|
+
source_branch
|
|
48
|
+
For ``legacy`` builds, the repository branch to publish from.
|
|
49
|
+
|
|
50
|
+
source_path
|
|
51
|
+
For ``legacy`` builds, the repository directory to publish from,
|
|
52
|
+
either ``/`` or ``/docs``.
|
|
53
|
+
|
|
54
|
+
cname
|
|
55
|
+
Custom domain for the site.
|
|
56
|
+
|
|
57
|
+
https_enforced
|
|
58
|
+
Enforce HTTPS for the site.
|
|
59
|
+
|
|
60
|
+
profile
|
|
61
|
+
Profile configuration name to use. Defaults to the resource
|
|
62
|
+
declaration's profile.
|
|
63
|
+
"""
|
|
64
|
+
conn, owner, repo_name = _core_args(profile)
|
|
65
|
+
return sc_pages.present(
|
|
66
|
+
conn,
|
|
67
|
+
name,
|
|
68
|
+
repo_name,
|
|
69
|
+
build_type=build_type,
|
|
70
|
+
source_branch=source_branch,
|
|
71
|
+
source_path=source_path,
|
|
72
|
+
cname=cname,
|
|
73
|
+
https_enforced=https_enforced,
|
|
74
|
+
owner=owner,
|
|
75
|
+
test=__opts__["test"],
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@catch_errors
|
|
80
|
+
def absent(name, profile=None):
|
|
81
|
+
"""
|
|
82
|
+
Ensure GitHub Pages are disabled for the targeted repository.
|
|
83
|
+
|
|
84
|
+
name
|
|
85
|
+
State name (the repository is implied by the resource).
|
|
86
|
+
|
|
87
|
+
profile
|
|
88
|
+
Profile configuration name to use. Defaults to the resource
|
|
89
|
+
declaration's profile.
|
|
90
|
+
"""
|
|
91
|
+
conn, owner, repo_name = _core_args(profile)
|
|
92
|
+
return sc_pages.absent(conn, name, repo_name, owner=owner, test=__opts__["test"])
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Manage the targeted repository's settings and team associations.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 1.1.0
|
|
5
|
+
|
|
6
|
+
Part of the :py:mod:`github <saltext.github.resources.github>` resource type: states operate on the repository
|
|
7
|
+
the state run was dispatched to, so there is no ``repo_name``/``owner``
|
|
8
|
+
parameter. The ``profile`` parameter defaults to the :ghconf:`profile <resource:profile>` named in
|
|
9
|
+
the resource declaration.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
from salt.utils.functools import namespaced_function
|
|
15
|
+
|
|
16
|
+
from saltext.github.utils.gh import profile as gh_profile
|
|
17
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
18
|
+
from saltext.github.utils.gh.statecores import catch_errors
|
|
19
|
+
from saltext.github.utils.gh.statecores import repo as sc_repo
|
|
20
|
+
|
|
21
|
+
log = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@catch_errors
|
|
28
|
+
def managed(
|
|
29
|
+
name,
|
|
30
|
+
description=None,
|
|
31
|
+
homepage=None,
|
|
32
|
+
private=None,
|
|
33
|
+
has_issues=None,
|
|
34
|
+
has_wiki=None,
|
|
35
|
+
has_downloads=None,
|
|
36
|
+
default_branch=None,
|
|
37
|
+
teams=None,
|
|
38
|
+
profile=None,
|
|
39
|
+
):
|
|
40
|
+
"""
|
|
41
|
+
Ensure the targeted repository is configured as specified.
|
|
42
|
+
Unspecified settings are left unmanaged.
|
|
43
|
+
|
|
44
|
+
Unlike the classic ``github_repo.present`` state, this never
|
|
45
|
+
creates the repository — the resource's existence is a given.
|
|
46
|
+
|
|
47
|
+
name
|
|
48
|
+
State name (the repository is implied by the resource).
|
|
49
|
+
|
|
50
|
+
description
|
|
51
|
+
Repository description.
|
|
52
|
+
|
|
53
|
+
homepage
|
|
54
|
+
URL with more information about the repository, e.g. rendered docs.
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
Repository visibility. Changing this requires :ghconf:`allow_repo_privacy_changes`
|
|
58
|
+
to be enabled in the profile.
|
|
59
|
+
|
|
60
|
+
has_issues
|
|
61
|
+
Enable issues for this repository.
|
|
62
|
+
|
|
63
|
+
has_wiki
|
|
64
|
+
Enable the wiki for this repository.
|
|
65
|
+
|
|
66
|
+
has_downloads
|
|
67
|
+
Enable downloads for this repository.
|
|
68
|
+
|
|
69
|
+
default_branch
|
|
70
|
+
Default branch of the repository. The branch must already exist.
|
|
71
|
+
|
|
72
|
+
teams
|
|
73
|
+
Teams this repo should belong to, specified as a dict of team
|
|
74
|
+
name to permission (``pull``, ``push`` or ``admin``).
|
|
75
|
+
Unlisted teams are removed from the repository. The teams
|
|
76
|
+
belong to the repository's owning organization, so this is
|
|
77
|
+
only supported for organization-owned repositories.
|
|
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
|
+
allow_privacy_change = gh_profile.get_config_value(
|
|
85
|
+
profile or gh_profile.resource_owner_profile(__opts__, owner),
|
|
86
|
+
"allow_repo_privacy_changes",
|
|
87
|
+
opts=__opts__,
|
|
88
|
+
context=__context__,
|
|
89
|
+
default=False,
|
|
90
|
+
)
|
|
91
|
+
ret = sc_repo.present(
|
|
92
|
+
conn,
|
|
93
|
+
repo_name,
|
|
94
|
+
owner=owner,
|
|
95
|
+
description=description,
|
|
96
|
+
homepage=homepage,
|
|
97
|
+
private=private,
|
|
98
|
+
has_issues=has_issues,
|
|
99
|
+
has_wiki=has_wiki,
|
|
100
|
+
has_downloads=has_downloads,
|
|
101
|
+
default_branch=default_branch,
|
|
102
|
+
teams=teams,
|
|
103
|
+
allow_privacy_change=allow_privacy_change,
|
|
104
|
+
allow_create=False,
|
|
105
|
+
test=__opts__["test"],
|
|
106
|
+
)
|
|
107
|
+
ret["name"] = name
|
|
108
|
+
return ret
|
|
@@ -0,0 +1,81 @@
|
|
|
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: states operate on the repository
|
|
7
|
+
the state run was dispatched to, so there is no ``repo_name``/``owner``
|
|
8
|
+
parameter. The ``profile`` parameter defaults to the :ghconf:`profile <resource:profile>` named in
|
|
9
|
+
the resource declaration.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
from salt.utils.functools import namespaced_function
|
|
15
|
+
|
|
16
|
+
from saltext.github.utils.gh import resource as gh_resource
|
|
17
|
+
from saltext.github.utils.gh.statecores import catch_errors
|
|
18
|
+
from saltext.github.utils.gh.statecores import rulesets as sc_rulesets
|
|
19
|
+
|
|
20
|
+
log = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_core_args = namespaced_function(gh_resource.core_args, globals())
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@catch_errors
|
|
27
|
+
def present(name, ruleset_params=None, profile=None):
|
|
28
|
+
"""
|
|
29
|
+
Ensure a ruleset is present in the targeted repository and
|
|
30
|
+
configured as specified. Only the parameters included in
|
|
31
|
+
``ruleset_params`` are compared, server-populated fields are
|
|
32
|
+
ignored.
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
|
|
36
|
+
.. code-block:: yaml
|
|
37
|
+
|
|
38
|
+
Ensure ruleset test is present:
|
|
39
|
+
ruleset.present:
|
|
40
|
+
- name: test
|
|
41
|
+
- ruleset_params:
|
|
42
|
+
target: branch
|
|
43
|
+
enforcement: active
|
|
44
|
+
|
|
45
|
+
name
|
|
46
|
+
Ruleset name to manage.
|
|
47
|
+
|
|
48
|
+
ruleset_params
|
|
49
|
+
Ruleset definition. Must contain at least ``enforcement``
|
|
50
|
+
when the ruleset needs to be created. ``name`` is pulled from
|
|
51
|
+
this state's ``name``.
|
|
52
|
+
|
|
53
|
+
profile
|
|
54
|
+
Profile configuration name to use. Defaults to the resource
|
|
55
|
+
declaration's profile.
|
|
56
|
+
"""
|
|
57
|
+
conn, owner, repo_name = _core_args(profile)
|
|
58
|
+
return sc_rulesets.present(
|
|
59
|
+
conn,
|
|
60
|
+
name,
|
|
61
|
+
repo_name,
|
|
62
|
+
ruleset_params=ruleset_params,
|
|
63
|
+
owner=owner,
|
|
64
|
+
test=__opts__["test"],
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@catch_errors
|
|
69
|
+
def absent(name, profile=None):
|
|
70
|
+
"""
|
|
71
|
+
Ensure a ruleset is absent from the targeted repository.
|
|
72
|
+
|
|
73
|
+
name
|
|
74
|
+
Ruleset name to manage.
|
|
75
|
+
|
|
76
|
+
profile
|
|
77
|
+
Profile configuration name to use. Defaults to the resource
|
|
78
|
+
declaration's profile.
|
|
79
|
+
"""
|
|
80
|
+
conn, owner, repo_name = _core_args(profile)
|
|
81
|
+
return sc_rulesets.absent(conn, name, repo_name, owner=owner, test=__opts__["test"])
|
|
File without changes
|