export type CreateApiImagesNamePushArgs = {name: string, tag?: string | undefined, platform?: string | undefined, 'X-Registry-Auth': string}; export type CreateApiImagesNamePushOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Push an image * * POST /images/{name}/push */ export const createApiImagesNamePush = async (args: CreateApiImagesNamePushArgs, options: CreateApiImagesNamePushOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.tag != null) query.append("tag", String(args.tag)) if (args.platform != null) query.append("platform", String(args.platform)) if (args['X-Registry-Auth'] != null) headers.set("X-Registry-Auth", String(args['X-Registry-Auth'])) const url = `${baseUrl.replace(/\/+$/, '')}/images/${encodeURIComponent(String(args.name))}/push${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };