Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``config``
==========

.. automodule:: saltext.github.resources.github.modules.config
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Execution Modules
:toctree:

actions
config
deploy_key
environment
issue
Expand All @@ -16,4 +17,6 @@ Execution Modules
pull
repo
ruleset
saltutil
state
test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``saltutil``
============

.. automodule:: saltext.github.resources.github.modules.saltutil
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``state``
=========

.. automodule:: saltext.github.resources.github.modules.state
:members:
14 changes: 7 additions & 7 deletions docs/topics/repo_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ resource. Compared to the classic
{py:mod}`github_repo <saltext.github.modules.github_repo>` modules,
resources offer:

- direct targeting of repositories (`salt 'github:my-org/my-repo' ...`),
- direct targeting of repositories (`salt 'my-org/my-repo' ...`),
including grain-based targeting across all managed repositories
- per-repository grains (owner, default branch, visibility, ...)
- repository-implicit execution and state modules – SLS files describe
Expand Down Expand Up @@ -67,7 +67,7 @@ with the SRN `github:<owner>/<repo>`.

```bash
# One repository
salt 'github:my-org/my-repo' test.ping
salt 'my-org/my-repo' test.ping

# By resource grain
salt -G 'github:default_branch:master' repo.info
Expand All @@ -83,10 +83,10 @@ Jobs dispatched to a `github` resource use repository-implicit,
entity-scoped execution modules instead of the classic ones:

```bash
salt 'github:my-org/my-repo' repo.update description='Managed by Salt'
salt 'github:my-org/my-repo' actions.set_secret MY_SECRET hunter2
salt 'github:my-org/my-repo' deploy_key.list
salt 'github:my-org/my-repo' environment.get release
salt 'my-org/my-repo' repo.update description='Managed by Salt'
salt 'my-org/my-repo' actions.set_secret MY_SECRET hunter2
salt 'my-org/my-repo' deploy_key.list
salt 'my-org/my-repo' environment.get release
```

See the {doc}`module reference </ref/resources/saltext.github.resources.github>` for the
Expand Down Expand Up @@ -124,7 +124,7 @@ Workflow permissions are restricted:
```

```bash
salt 'github:my-org/my-repo' state.apply repo_setup
salt 'my-org/my-repo' state.apply repo_setup
```

Unlike the classic {py:func}`github_repo.present <saltext.github.states.github_repo.present>` state,
Expand Down
12 changes: 6 additions & 6 deletions src/saltext/github/resources/github/modules/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def list_secrets(*, fields=None, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' actions.list_secrets
salt 'my-org/my-repo' actions.list_secrets

fields
Only include these fields in the output. A single field name
Expand All @@ -57,7 +57,7 @@ def get_secret(name, *, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' actions.get_secret MY_SECRET
salt 'my-org/my-repo' actions.get_secret MY_SECRET

name
Name of the secret.
Expand All @@ -80,7 +80,7 @@ def set_secret(name, value, *, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' actions.set_secret MY_SECRET hunter2
salt 'my-org/my-repo' actions.set_secret MY_SECRET hunter2

name
Name of the secret.
Expand All @@ -105,7 +105,7 @@ def remove_secret(name, *, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' actions.remove_secret MY_SECRET
salt 'my-org/my-repo' actions.remove_secret MY_SECRET

name
Name of the secret.
Expand All @@ -129,7 +129,7 @@ def get_workflow_permissions(*, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' actions.get_workflow_permissions
salt 'my-org/my-repo' actions.get_workflow_permissions

profile
Profile configuration name to use. Defaults to the resource
Expand All @@ -150,7 +150,7 @@ def set_workflow_permissions(

.. code-block:: bash

salt 'github:my-org/my-repo' actions.set_workflow_permissions \\
salt 'my-org/my-repo' actions.set_workflow_permissions \\
default_workflow_permissions=read can_approve_pull_request_reviews=true

default_workflow_permissions
Expand Down
69 changes: 69 additions & 0 deletions src/saltext/github/resources/github/modules/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""
Look up configuration values from the managing minion.

.. versionadded:: 1.1.0

Repositories have no minion configuration of their own — GitHub
profiles and related settings live on the managing minion. The stock
:py:mod:`state <salt.modules.state>` execution module (re-exported for
this resource type) relies on ``config.get``/``config.option``, so this
override provides them: it delegates to the managing minion's loader
when the ``__minion__`` escape hatch is packed (state-engine context)
and falls back to the managing minion's opts otherwise (the minion's
dispatch-context per-type loaders do not pack ``__minion__``).
"""

import logging

import salt.utils.data

log = logging.getLogger(__name__)


def _minion():
try:
return __minion__
except NameError:
return None


def get(key, default="", delimiter=":", omit_opts=False, **kwargs):
"""
Look up a config value on the managing minion. See
:py:func:`config.get <salt.modules.config.get>` for details.

CLI Example:

.. code-block:: bash

salt 'my-org/my-repo' config.get state_verbose
"""
minion = _minion()
if minion is not None:
return minion["config.get"](
key, default=default, delimiter=delimiter, omit_opts=omit_opts, **kwargs
)
if omit_opts:
return default
return salt.utils.data.traverse_dict_and_list(__opts__, key, default, delimiter)


def option(value, default="", omit_opts=False, omit_all=False, **kwargs):
"""
Return the value of a specific config option on the managing minion.
See :py:func:`config.option <salt.modules.config.option>` for details.

CLI Example:

.. code-block:: bash

salt 'my-org/my-repo' config.option state_queue
"""
minion = _minion()
if minion is not None:
return minion["config.option"](
value, default=default, omit_opts=omit_opts, omit_all=omit_all, **kwargs
)
if not (omit_opts or omit_all) and value in __opts__:
return __opts__[value]
return default
8 changes: 4 additions & 4 deletions src/saltext/github/resources/github/modules/deploy_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def list_(*, fields=None, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' deploy_key.list
salt 'my-org/my-repo' deploy_key.list

fields
Only include these fields in the output. A single field name
Expand All @@ -54,7 +54,7 @@ def get(key_id, *, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' deploy_key.get 12345
salt 'my-org/my-repo' deploy_key.get 12345

key_id
ID of the deploy key.
Expand All @@ -79,7 +79,7 @@ def add(title, key, *, read_only=False, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' deploy_key.add autorelease 'ssh-ed25519 AAAA...' read_only=false
salt 'my-org/my-repo' deploy_key.add autorelease 'ssh-ed25519 AAAA...' read_only=false

title
Display title of the deploy key.
Expand Down Expand Up @@ -108,7 +108,7 @@ def remove(key_id, *, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' deploy_key.remove 12345
salt 'my-org/my-repo' deploy_key.remove 12345

key_id
ID of the deploy key.
Expand Down
6 changes: 3 additions & 3 deletions src/saltext/github/resources/github/modules/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def list_(

.. code-block:: bash

salt 'github:my-org/my-repo' issue.list
salt 'my-org/my-repo' issue.list

milestone
Number of a GitHub milestone, or a string of either ``*`` or ``none``.
Expand Down Expand Up @@ -119,7 +119,7 @@ def get(number, *, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' issue.get 514
salt 'my-org/my-repo' issue.get 514

number
Issue number to retrieve.
Expand All @@ -140,7 +140,7 @@ def get_comments(number, *, since=None, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' issue.get_comments 514
salt 'my-org/my-repo' issue.get_comments 514

number
Issue number for which to retrieve comments.
Expand Down
10 changes: 5 additions & 5 deletions src/saltext/github/resources/github/modules/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def list_(*, fields=None, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' label.list
salt 'my-org/my-repo' label.list

fields
Only include these fields in the output. A single field name
Expand All @@ -56,7 +56,7 @@ def get(name, *, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' label.get bug
salt 'my-org/my-repo' label.get bug

name
Name of the label.
Expand All @@ -78,7 +78,7 @@ def add(name, *, color=None, description=None, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' label.add release color=00ff00
salt 'my-org/my-repo' label.add release color=00ff00

name
Name of the label.
Expand Down Expand Up @@ -109,7 +109,7 @@ def edit(name, *, new_name=None, color=None, description=None, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' label.edit release color=00ff00
salt 'my-org/my-repo' label.edit release color=00ff00

name
Current name of the label.
Expand Down Expand Up @@ -147,7 +147,7 @@ def remove(name, *, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' label.remove release
salt 'my-org/my-repo' label.remove release

name
Name of the label.
Expand Down
6 changes: 3 additions & 3 deletions src/saltext/github/resources/github/modules/milestone.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def list_(

.. code-block:: bash

salt 'github:my-org/my-repo' milestone.list
salt 'my-org/my-repo' milestone.list

state
Filter milestones by their state. Either ``open``, ``closed``, or ``all``.
Expand Down Expand Up @@ -81,8 +81,8 @@ def get(number=None, *, name=None, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' milestone.get 72
salt 'github:my-org/my-repo' milestone.get name=my_milestone
salt 'my-org/my-repo' milestone.get 72
salt 'my-org/my-repo' milestone.get name=my_milestone

number
Milestone number to retrieve. If provided, overrides ``name``.
Expand Down
8 changes: 4 additions & 4 deletions src/saltext/github/resources/github/modules/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get(*, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' pages.get
salt 'my-org/my-repo' pages.get

profile
Profile configuration name to use. Defaults to the resource
Expand All @@ -49,7 +49,7 @@ def setup(*, build_type=None, source_branch=None, source_path=None, profile=None

.. code-block:: bash

salt 'github:my-org/my-repo' pages.setup build_type=workflow
salt 'my-org/my-repo' pages.setup build_type=workflow

build_type
Process by which the site is built, either ``legacy``
Expand Down Expand Up @@ -93,7 +93,7 @@ def update(

.. code-block:: bash

salt 'github:my-org/my-repo' pages.update build_type=workflow
salt 'my-org/my-repo' pages.update build_type=workflow

build_type
Process by which the site is built, either ``legacy``
Expand Down Expand Up @@ -138,7 +138,7 @@ def remove(*, profile=None):

.. code-block:: bash

salt 'github:my-org/my-repo' pages.remove
salt 'my-org/my-repo' pages.remove

profile
Profile configuration name to use. Defaults to the resource
Expand Down
2 changes: 1 addition & 1 deletion src/saltext/github/resources/github/modules/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def list_(

.. code-block:: bash

salt 'github:my-org/my-repo' pull.list
salt 'my-org/my-repo' pull.list

state
Filter returned pull requests by their state. Can be either
Expand Down
Loading
Loading