regctl: manifestGet
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -19,10 +19,17 @@ import * as semver from 'semver';
|
||||
|
||||
import {Exec} from '../exec';
|
||||
|
||||
import {Manifest} from '../types/oci/manifest';
|
||||
|
||||
export interface RegctlOpts {
|
||||
binPath?: string;
|
||||
}
|
||||
|
||||
export interface RegctlManifestGetOpts {
|
||||
image: string;
|
||||
platform?: string;
|
||||
}
|
||||
|
||||
export class Regctl {
|
||||
private readonly binPath: string;
|
||||
private _version: string;
|
||||
@@ -34,6 +41,18 @@ export class Regctl {
|
||||
this._versionOnce = false;
|
||||
}
|
||||
|
||||
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,
|
||||
silent: true
|
||||
}).then(res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
throw new Error(res.stderr.trim());
|
||||
}
|
||||
return <Manifest>JSON.parse(res.stdout.trim());
|
||||
});
|
||||
}
|
||||
|
||||
public async isAvailable(): Promise<boolean> {
|
||||
const ok: boolean = await Exec.getExecOutput(this.binPath, [], {
|
||||
ignoreReturnCode: true,
|
||||
|
||||
Reference in New Issue
Block a user