Plugin resolution¶
xcore_agent.plugin_resolver — fetches a PluginSource plugin from git
(public or private, HTTPS token or SSH).
xcore_agent.plugin_resolver
¶
Resolves a plugin's source code from wherever PluginSource points, for
plugins a marketplace/registry references by link instead of embedding
inside the .xdeploy artifact (see schema.manifest.PluginSource).
Two origins, marketplace preferred:
- Marketplace (
source.marketplace_slugset) — fetched via the real xcore-team/marketplaceGET /{slug}/installendpoint (agent.marketplace_client.MarketplaceClient), whose response is HMAC-SHA256-signed and verified here againsttrusted_signer_secretbefore anything is extracted to disk. This is the primary path: it's whatxcli plugin installrecords in.xcore-registry.jsonfor anything actually installed from the marketplace (seepacker.builder._read_ registry_source), so most source-based plugins resolve this way without an operator ever writing a raw git URL. - Git (
source.urlset) — a plaingit fetch/checkout, for a plugin never published to the marketplace. This is the fallback: only used when a plugin's origin genuinely isn't the marketplace, not an alternative way to resolve one that is.
Shared between the packer (which may resolve a plugin at build time to pin its hash — not yet implemented, see the packer's docstring) and the agent (which resolves at deploy time, verifying against any pinned hash).
Public vs. private git repos are not distinguished by a flag: they're the
same git operation with different authentication, exactly like using
git directly from a shell —
- SSH URLs (
git@host:org/repo.git) authenticate however the host's SSH agent/config already does; this module does nothing special for them. - HTTPS URLs authenticate via a per-host token from
git_credentials, spliced into the URL ashttps://x-access-token:<token>@host/...— the standard way to handgita token non-interactively. No token configured for that host means the URL is used as-is (fine for a public repo, a clone failure otherwise).
PluginResolutionError
¶
Bases: Exception
Raised when a plugin's source cannot be fetched or is unusable (git failure, marketplace signature mismatch, missing subdirectory, ...).
PluginResolver
dataclass
¶
Source code in xcore_agent/plugin_resolver.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
cache_root: Path
instance-attribute
¶
git_credentials: dict[str, str] | None = None
class-attribute
instance-attribute
¶
marketplace_client: MarketplaceClient | None = None
class-attribute
instance-attribute
¶
trusted_signer_secret: bytes | None = None
class-attribute
instance-attribute
¶
__init__(cache_root: Path, git_credentials: dict[str, str] | None = None, marketplace_client: MarketplaceClient | None = None, trusted_signer_secret: bytes | None = None) -> None
¶
resolve(plugin_id: str, source: PluginSource) -> Path
async
¶
Return a local directory containing plugin_id's code, fetching
it from the marketplace or git (see module docstring) if not
already cached.
Caching is keyed on (plugin_id, version-or-ref): a commit SHA or a
marketplace version is treated as immutable, so this is safe to
reuse indefinitely within cache_root — acceptable since a caller
pins to something immutable whenever integrity matters (see
PluginSource's docstring; a marketplace fetch also gets its own
independent integrity guarantee from the HMAC signature check below,
regardless of caching).
Source code in xcore_agent/plugin_resolver.py
safe_extract_zip(zf: zipfile.ZipFile, dest: Path) -> None
¶
Extract a ZIP archive, rejecting any member that would escape dest
via ../ or an absolute path — same reasoning as agent.pipeline's
_safe_extract for tar archives. Shared with agent.marketplace_
pipeline (the single-plugin deploy-marketplace flow), which fetches
from the same signed marketplace endpoint this module resolves
multi-plugin source: references from.
Source code in xcore_agent/plugin_resolver.py
flatten_single_root(target: Path) -> None
¶
GitHub's zipball API (what the marketplace's /install endpoint
proxies) wraps every archive in a single top-level owner-repo-<sha>/
directory. Strip it so target directly contains the plugin's own
files (plugin.yaml, src/, ...), matching the layout InstallDriver.
install_plugin/this module's own callers expect.