saltext.github.utils.gh.profile

Resolution of Salt profile configuration into GitHub connections, shared between the github, github_org and github_repo execution modules as well as the github resource type.

Profiles are resolved directly from opts, mirroring config.get’s lookup order: minion configuration, then grains, then pillar, then master configuration (which reaches the minion via the master’s pillar_opts setting, rendered under pillar["master"]). SDB URIs in profile values are rendered on access, like config.get renders them. config.get itself cannot serve as the backend since it is unavailable to parts of the resource subsystem (type discovery runs before the minion’s module loader exists).

saltext.github.utils.gh.profile.get_config_value(profile, config_name, *, opts, context=None, utils=None, default=<object object>)[source]

Return a profile’s configuration value based on the supplied configuration name. See the module docstring for the lookup order and SDB handling; the first scope carrying the requested value wins.

profile

Profile name that contains configuration information.

config_name

Configuration item name to look up.

opts

The minion configuration (__opts__).

context

Pass __context__ to cache rendered values, saving repeated SDB lookups.

utils

Pass __utils__ when available to avoid building a fresh utils loader for SDB rendering.

default

Value to return when the profile does not carry the item. Without it, a missing item raises a CommandExecutionError.

saltext.github.utils.gh.profile.get_api_url(profile, *, opts, context=None, utils=None)[source]

Return the configured GitHub API base URL, defaulting to the public one.

profile

Profile name that contains configuration information.

opts

The minion configuration (__opts__).

context

Pass __context__ to cache rendered values.

utils

Pass __utils__ when available (SDB rendering).

saltext.github.utils.gh.profile.get_owner(profile, *, opts, context=None, utils=None)[source]

Return the configured default repository owner: the profile’s owner, falling back to the legacy org_name alias. Returns None when neither is set, making the connection default to the token’s user.

profile

Profile name that contains configuration information.

opts

The minion configuration (__opts__).

context

Pass __context__ to cache rendered values.

utils

Pass __utils__ when available (SDB rendering).

saltext.github.utils.gh.profile.get_conn(profile, *, opts, context, utils=None)[source]

Return a GitHubConnection for a profile, cached in context for performance.

Unless the profile disables it (cache), the connection carries a PersistentCache for slow-changing API data, surviving across processes.

profile

Profile name that contains configuration information.

opts

The minion configuration (__opts__).

context

Pass __context__. Caches the connection and rendered profile values.

utils

Pass __utils__ when available (SDB rendering).

saltext.github.utils.gh.profile.resource_decl(opts)[source]

Return the github resource type’s declaration from the resource pillar subtree ({} when unset or not a mapping).

opts

The minion configuration (__opts__).

saltext.github.utils.gh.profile.resource_profile(opts)[source]

Return the default profile name configured in the github resource declaration, defaulting to github.

opts

The minion configuration (__opts__).

saltext.github.utils.gh.profile.resource_owners(opts)[source]

Return the owners named in the github resource declaration as a list (an empty one when unset). The declaration’s owners may be a plain list of owner names or a mapping of owner name to per-owner settings (profile, repos, exclude, include_archived).

opts

The minion configuration (__opts__).

saltext.github.utils.gh.profile.resource_owner_setting(opts, owner, key, default=None)[source]

Return a declaration setting for one owner: the owner’s own value from the owners mapping when set, otherwise the declaration-level value, otherwise default.

opts

The minion configuration (__opts__).

owner

Owner (organization or user) login.

key

Setting name (profile, repos, exclude, include_archived).

default

Value to return when neither the owner nor the declaration carries the setting.

saltext.github.utils.gh.profile.resource_owner_profile(opts, owner)[source]

Return the profile name to use for one owner’s repositories: the owner’s profile override from the declaration’s owners mapping when present, otherwise the declaration’s default profile. Owner names are matched case-insensitively.

opts

The minion configuration (__opts__).

owner

Owner (organization or user) login.

saltext.github.utils.gh.profile.resource_profiles(opts)[source]

Return all distinct profile names referenced by the github resource declaration: the default one plus any per-owner overrides.

opts

The minion configuration (__opts__).

saltext.github.utils.gh.profile.resource_conn(opts, context, *, profile=None, owner=None, utils=None)[source]

Return the GitHubConnection for a github resource context, resolved from opts.

opts

The minion configuration (__opts__).

context

Cache mapping for the connection (__context__).

profile

Profile name override. When unset, the profile is resolved from the resource declaration: the targeted owner’s override when declared, otherwise the declaration’s default profile (github when unset).

owner

Owner the connection is for, used to resolve per-owner profile overrides. Ignored when profile is passed.

utils

Pass __utils__ when available (SDB rendering).