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

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