mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-10 18:56:53 +00:00
fix(image-updates): normalize docker.io host aliases to the registry API host (#1706)
* fix(image-updates): normalize docker.io host aliases to the registry API host parseImageRef kept a literal `docker.io` or `index.docker.io` host when the user wrote an explicit registry prefix, so every downstream request hit the marketing domain instead of registry-1.docker.io and failed with an unhandled 3xx. Normalize both aliases before the library/ auto-prefix check so explicit and implicit Docker Hub refs resolve identically. * test(image-updates): pin docker.io alias parity and drop redundant coverage Add the index.docker.io namespace-omitted parseImageRef case and a buildRollbackTarget assertion for an explicit docker.io/ ref, and drop the compareLocalToRemoteTag traefik-shape test that only duplicated existing attestation-manifest coverage. Also clarify the canonicalRegistry doc comment now that it and parseImageRef normalize to different forms. * docs(image-updates): correct canonicalRegistry comment's call-path example * test(image-updates): collapse docker.io alias cases into a single it.each
This commit is contained in:
@@ -35,7 +35,12 @@ export function parseImageRef(imageRef: string): ParsedRef | null {
|
||||
if (slashIdx !== -1) {
|
||||
const firstPart = imageRef.slice(0, slashIdx);
|
||||
if (firstPart.includes('.') || firstPart.includes(':') || firstPart === 'localhost') {
|
||||
registry = firstPart;
|
||||
// docker.io / index.docker.io are Docker Hub aliases; normalize them to the
|
||||
// actual registry API host so requests never hit the marketing domain (which
|
||||
// redirects instead of serving /v2/) and the library/ auto-prefix below still applies.
|
||||
registry = (firstPart === 'docker.io' || firstPart === 'index.docker.io')
|
||||
? 'registry-1.docker.io'
|
||||
: firstPart;
|
||||
rest = imageRef.slice(slashIdx + 1);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +219,12 @@ const MANIFEST_ACCEPT = [
|
||||
'application/vnd.oci.image.manifest.v1+json',
|
||||
].join(', ');
|
||||
|
||||
/** docker.io has three hostnames that all address the same registry. */
|
||||
/**
|
||||
* docker.io has three hostnames that all address the same registry. Folds two
|
||||
* already-parsed ParsedRef.registry values down to a shared form for equality/cache-key
|
||||
* comparisons; not the canonical form parseImageRef assigns (which normalizes to
|
||||
* 'registry-1.docker.io').
|
||||
*/
|
||||
function canonicalRegistry(host: string): string {
|
||||
if (host === 'docker.io' || host === 'index.docker.io' || host === 'registry-1.docker.io') {
|
||||
return 'docker.io';
|
||||
|
||||
Reference in New Issue
Block a user