regctl: blobGet func

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-04-17 13:44:44 +02:00
parent 5a20e819d2
commit 4dc0686a1f
2 changed files with 64 additions and 3 deletions

View File

@@ -25,6 +25,11 @@ export interface RegctlOpts {
binPath?: string;
}
export interface RegctlBlobGetOpts {
repository: string;
digest: string;
}
export interface RegctlManifestGetOpts {
image: string;
platform?: string;
@@ -41,6 +46,19 @@ export class Regctl {
this._versionOnce = false;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public async blobGet(opts: RegctlBlobGetOpts): Promise<any> {
return await Exec.getExecOutput(this.binPath, ['blob', 'get', opts.repository, opts.digest], {
ignoreReturnCode: true,
silent: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.trim());
}
return res.stdout;
});
}
public async manifestGet(opts: RegctlManifestGetOpts): Promise<Manifest> {
return await Exec.getExecOutput(this.binPath, ['manifest', 'get', opts.image, `--platform=${opts.platform ?? 'local'}`, `--format={{json .}}`], {
ignoreReturnCode: true,