imbi-plugin-github 0.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.
- imbi_plugin_github/__init__.py +13 -0
- imbi_plugin_github/_hosts.py +50 -0
- imbi_plugin_github/deployment.py +999 -0
- imbi_plugin_github/identity.py +436 -0
- imbi_plugin_github-0.1.0.dist-info/METADATA +52 -0
- imbi_plugin_github-0.1.0.dist-info/RECORD +9 -0
- imbi_plugin_github-0.1.0.dist-info/WHEEL +4 -0
- imbi_plugin_github-0.1.0.dist-info/entry_points.txt +7 -0
- imbi_plugin_github-0.1.0.dist-info/licenses/LICENSE +28 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Imbi GitHub identity plugin (github.com / GHEC / GHES)."""
|
|
2
|
+
|
|
3
|
+
from imbi_plugin_github.identity import (
|
|
4
|
+
GitHubEnterpriseCloudPlugin,
|
|
5
|
+
GitHubEnterpriseServerPlugin,
|
|
6
|
+
GitHubPlugin,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
'GitHubEnterpriseCloudPlugin',
|
|
11
|
+
'GitHubEnterpriseServerPlugin',
|
|
12
|
+
'GitHubPlugin',
|
|
13
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Shared host resolution utilities for the GitHub plugins.
|
|
2
|
+
|
|
3
|
+
Identity (``plugin.py``) and deployment (``deployment.py``) plugins both
|
|
4
|
+
accept a ``host`` option and need to normalise it to a bare hostname
|
|
5
|
+
that URLs can be safely composed against. This module is the single
|
|
6
|
+
source of truth for that validation.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import typing
|
|
12
|
+
import urllib.parse
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def normalize_host(raw: typing.Any, label: str) -> str:
|
|
16
|
+
"""Validate and normalize a manifest ``host`` value.
|
|
17
|
+
|
|
18
|
+
Strips whitespace, accepts an optional scheme, and rejects values
|
|
19
|
+
with paths / queries / fragments so callers can compose URLs from
|
|
20
|
+
the result without producing malformed endpoints.
|
|
21
|
+
"""
|
|
22
|
+
host = str(raw or '').strip()
|
|
23
|
+
if not host:
|
|
24
|
+
raise ValueError(f'{label} requires the "host" option')
|
|
25
|
+
parsed = urllib.parse.urlsplit(
|
|
26
|
+
host if '://' in host else f'https://{host}'
|
|
27
|
+
)
|
|
28
|
+
if (
|
|
29
|
+
not parsed.hostname
|
|
30
|
+
or parsed.port is not None
|
|
31
|
+
or parsed.path not in ('', '/')
|
|
32
|
+
or parsed.query
|
|
33
|
+
or parsed.fragment
|
|
34
|
+
):
|
|
35
|
+
raise ValueError(f'{label} got invalid host value: {host!r}')
|
|
36
|
+
return parsed.hostname
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def require_ghec_tenant_host(host: str, label: str) -> str:
|
|
40
|
+
"""Refuse anything that isn't a ``*.ghe.com`` tenant host."""
|
|
41
|
+
if (
|
|
42
|
+
not host.endswith('.ghe.com')
|
|
43
|
+
or host == '.ghe.com'
|
|
44
|
+
or host.startswith('api.')
|
|
45
|
+
):
|
|
46
|
+
raise ValueError(
|
|
47
|
+
f'{label} requires a tenant host like "tenant.ghe.com"; '
|
|
48
|
+
f'got {host!r}'
|
|
49
|
+
)
|
|
50
|
+
return host
|