A simple, zero-configuration script to quickly boot FreeBSD ISO images using QEMU

Merge pull request #8 from tsirysndr/feat/docker-io-default-registry

feat: add default registry prefix for image repository and improve logging

authored by tsiry-sandratraina.com and committed by

GitHub 116a40db fee4a274

+23 -6
+23 -6
src/oras.ts
··· 149 }), 150 }); 151 152 const pushToRegistry = ( 153 img: { repository: string; tag: string; path: string }, 154 ) => 155 Effect.tryPromise({ 156 try: async () => { 157 - console.log(`Pushing image ${img.repository}...`); 158 const process = new Deno.Command("oras", { 159 args: [ 160 "push", 161 - `${img.repository}:${img.tag}-${getCurrentArch()}`, 162 "--artifact-type", 163 "application/vnd.oci.image.layer.v1.tar", 164 "--annotation", ··· 166 "--annotation", 167 "org.opencontainers.image.os=freebsd", 168 "--annotation", 169 - "org.opencontainers.image.description=QEMU raw disk image", 170 basename(img.path), 171 ], 172 stdout: "inherit", ··· 218 Effect.tryPromise({ 219 try: async () => { 220 console.log(`Pulling image ${image}`); 221 const process = new Deno.Command("oras", { 222 args: [ 223 "pull", 224 - `${image}-${getCurrentArch()}`, 225 ], 226 stdin: "inherit", 227 stdout: "inherit", ··· 244 export const getImageArchivePath = (image: string) => 245 Effect.tryPromise({ 246 try: async () => { 247 const process = new Deno.Command("oras", { 248 args: [ 249 "manifest", 250 "fetch", 251 - `${image}-${getCurrentArch()}`, 252 ], 253 stdout: "piped", 254 stderr: "inherit", ··· 293 const getImageDigest = (image: string) => 294 Effect.tryPromise({ 295 try: async () => { 296 const process = new Deno.Command("oras", { 297 args: [ 298 "manifest", 299 "fetch", 300 - `${image}-${getCurrentArch()}`, 301 ], 302 stdout: "piped", 303 stderr: "inherit",
··· 149 }), 150 }); 151 152 + // add docker.io/ if no registry is specified 153 + const formatRepository = (repository: string) => 154 + repository.match(/^[^\/]+\.[^\/]+\/.*/i) 155 + ? repository 156 + : `docker.io/${repository}`; 157 + 158 const pushToRegistry = ( 159 img: { repository: string; tag: string; path: string }, 160 ) => 161 Effect.tryPromise({ 162 try: async () => { 163 + console.log(`Pushing image ${formatRepository(img.repository)}...`); 164 const process = new Deno.Command("oras", { 165 args: [ 166 "push", 167 + `${formatRepository(img.repository)}:${img.tag}-${getCurrentArch()}`, 168 "--artifact-type", 169 "application/vnd.oci.image.layer.v1.tar", 170 "--annotation", ··· 172 "--annotation", 173 "org.opencontainers.image.os=freebsd", 174 "--annotation", 175 + "org.opencontainers.image.description=QEMU raw disk image of FreeBSD", 176 basename(img.path), 177 ], 178 stdout: "inherit", ··· 224 Effect.tryPromise({ 225 try: async () => { 226 console.log(`Pulling image ${image}`); 227 + const repository = image.split(":")[0]; 228 + const tag = image.split(":")[1] || "latest"; 229 + console.log( 230 + "pull", 231 + `${formatRepository(repository)}:${tag}-${getCurrentArch()}`, 232 + ); 233 + 234 const process = new Deno.Command("oras", { 235 args: [ 236 "pull", 237 + `${formatRepository(repository)}:${tag}-${getCurrentArch()}`, 238 ], 239 stdin: "inherit", 240 stdout: "inherit", ··· 257 export const getImageArchivePath = (image: string) => 258 Effect.tryPromise({ 259 try: async () => { 260 + const repository = image.split(":")[0]; 261 + const tag = image.split(":")[1] || "latest"; 262 const process = new Deno.Command("oras", { 263 args: [ 264 "manifest", 265 "fetch", 266 + `${formatRepository(repository)}:${tag}-${getCurrentArch()}`, 267 ], 268 stdout: "piped", 269 stderr: "inherit", ··· 308 const getImageDigest = (image: string) => 309 Effect.tryPromise({ 310 try: async () => { 311 + const repository = image.split(":")[0]; 312 + const tag = image.split(":")[1] || "latest"; 313 const process = new Deno.Command("oras", { 314 args: [ 315 "manifest", 316 "fetch", 317 + `${formatRepository(repository)}:${tag}-${getCurrentArch()}`, 318 ], 319 stdout: "piped", 320 stderr: "inherit",