saltext.github.utils.gh.environments¶
Operations on GitHub repository (deployment) environments.
- saltext.github.utils.gh.environments.branch_policy_from_patterns(deployment_branches)[source]¶
Map a
deployment_branchesspecification (all,protectedor a list of branch name patterns) onto the API’sdeployment_branch_policysetting.- deployment_branches
Which branches can deploy. Either
all,protected(branches with branch protection rules) or a list of branch name patterns.
- saltext.github.utils.gh.environments.normalize(env)[source]¶
Extract the managed settings from an environment API payload into a flat mapping with
wait_timer,prevent_self_review,reviewersanddeployment_branch_policy. The API scatters them overprotection_rulesentries.- env
Environment payload to normalize.
- saltext.github.utils.gh.environments.list_all(conn, repo_name, *, owner=None)[source]¶
Return all environments of a repository.
- conn
GitHubConnectionto use.- repo_name
Repository name.
- owner
Owner of the repository. Defaults to the connection’s owner.
- saltext.github.utils.gh.environments.get(conn, repo_name, name, *, owner=None)[source]¶
Return the data of a single environment.
- conn
GitHubConnectionto use.- repo_name
Repository name.
- name
Environment name.
- owner
Owner of the repository. Defaults to the connection’s owner.
Raises
GitHubNotFoundErrorif the environment does not exist.
- saltext.github.utils.gh.environments.set_(conn, repo_name, name, *, wait_timer=None, prevent_self_review=None, reviewers=None, deployment_branch_policy=None, owner=None)[source]¶
Create or update an environment, replacing its whole configuration. Unspecified settings are reset to their defaults. Returns the data of the environment.
- conn
GitHubConnectionto use.- repo_name
Repository name.
- name
Environment name.
- wait_timer
Amount of time to delay a job after it is initially triggered, in minutes.
- prevent_self_review
Prevent a user who created a job from approving it.
- reviewers
People or teams that may review jobs that reference the environment, as a list of mappings with
type(UserorTeam) andid.- deployment_branch_policy
Type of deployment branch policy for this environment, either
None(default) to allow all branches or a mapping withprotected_branchesandcustom_branch_policiesbooleans. Branch name patterns for custom policies are managed separately, seecreate_branch_policy().- owner
Owner of the repository. Defaults to the connection’s owner.
- saltext.github.utils.gh.environments.delete(conn, repo_name, name, *, owner=None)[source]¶
Delete an environment from a repository.
- conn
GitHubConnectionto use.- repo_name
Repository name.
- name
Environment name.
- owner
Owner of the repository. Defaults to the connection’s owner.
- saltext.github.utils.gh.environments.list_branch_policies(conn, repo_name, environment, *, owner=None)[source]¶
Return all deployment branch policies of an environment.
- conn
GitHubConnectionto use.- repo_name
Repository name.
- environment
Environment name.
- owner
Owner of the repository. Defaults to the connection’s owner.
- saltext.github.utils.gh.environments.create_branch_policy(conn, repo_name, environment, name, *, typ='branch', owner=None)[source]¶
Add a deployment branch (or tag) policy to an environment. Returns the data of the created policy.
The environment’s
deployment_branch_policymust havecustom_branch_policiesenabled.- conn
GitHubConnectionto use.- repo_name
Repository name.
- environment
Environment name.
- name
Name pattern that branches (or tags) must match in order to deploy to the environment.
- typ
Target of this rule, either
branchortag. Defaults tobranch.- owner
Owner of the repository. Defaults to the connection’s owner.
- saltext.github.utils.gh.environments.delete_branch_policy(conn, repo_name, environment, policy_id, *, owner=None)[source]¶
Remove a deployment branch policy from an environment.
- conn
GitHubConnectionto use.- repo_name
Repository name.
- environment
Environment name.
- policy_id
Branch policy ID.
- owner
Owner of the repository. Defaults to the connection’s owner.