pkgcore.bugzilla.apikey module¶
Locating a bugs.gentoo.org api key, and wiring it into an argparser.
find_api_key() consults four sources in order, stopping at the first one
holding a non-empty value:
an explicit key, normally from
--api-key. Convenient, but visible to anyone able to readps.the
BUGZ_API_KEYenvironment variable. The only source usable from CI without writing a secret to disk.~/.bugzrc, an INI file whose name and layout come from pybugz. The sectionsdefault,gentooandGentooare tried in that order:[default] key = AbCdEf0123456789AbCdEf0123456789AbCdEf01
Only the
keyoption is read, so an existing pybugz config works as is.~/.bugz_token, holding nothing but the key:AbCdEf0123456789AbCdEf0123456789AbCdEf01
Either file being group or world readable is warned about, but still used.
Finding no key at all is not an error. The client then runs anonymously, which
is read only, and which Bugzilla further degrades by truncating every email
address it returns at the @.
- class pkgcore.bugzilla.apikey.BugzillaApiKey[source]¶
Bases:
objectAdds
--api-key, defaulting throughfind_api_key()
- class pkgcore.bugzilla.apikey.BugzillaClientArgs[source]¶
Bases:
BugzillaApiKeyAs
BugzillaApiKey, plus--bugzilla-urland a ready client.The client lands on
namespace.bugzilla; its delayed default runs after the key’s, so the key is resolved by the time it is built.
- pkgcore.bugzilla.apikey.find_api_key(explicit: str | None = None, *, allow_env: bool = True, home: Path | None = None) str | None[source]¶
Locate an api key, per the precedence documented for this module.
- Parameters:
explicit – a key supplied directly, normally from
--api-key; blank or whitespace-only is treated as absentallow_env – whether
$BUGZ_API_KEYmay be consultedhome – directory to look the dotfiles up in, defaulting to the user’s home
- Returns:
the key, or None to run anonymously
- Raises:
BugzillaUsageError – if
~/.bugzrcexists but can’t be parsed