Skip to content

Commit 06def4a

Browse files
committed
Format
1 parent 0808938 commit 06def4a

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/init.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ pub struct InitArgs {
4747
workspace_folder: Option<PathBuf>,
4848
}
4949

50-
async fn get_feature(index: &registry::DevcontainerIndex, feature_ref: &OciReference) -> anyhow::Result<registry::Feature> {
50+
async fn get_feature(
51+
index: &registry::DevcontainerIndex,
52+
feature_ref: &OciReference,
53+
) -> anyhow::Result<registry::Feature> {
5154
log::debug!("get_feature");
5255

5356
match index.get_feature(&feature_ref.id()) {

src/registry.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::ops::Not;
66
use std::path::Path;
77

88
use anyhow::{Context, Result};
9-
use oci_client::Client;
109
use oci_client::secrets::RegistryAuth;
11-
use serde_json::Value as JsonValue;
10+
use oci_client::Client;
1211
use serde::{Deserialize, Serialize};
12+
use serde_json::Value as JsonValue;
1313

1414
use crate::oci_ref::OciReference;
1515

@@ -416,7 +416,9 @@ pub async fn pull_devcontainer_index<P: AsRef<Path>>(filename: P) -> Result<()>
416416

417417
let image: OciReference = "ghcr.io/devcontainers/index:latest".parse()?;
418418
let accepted_media_types = vec!["application/vnd.devcontainers.index.layer.v1+json"];
419-
let blob = get_layer_bytes(&image, accepted_media_types).await.context("Failed to pull devcontainer index")?;
419+
let blob = get_layer_bytes(&image, accepted_media_types)
420+
.await
421+
.context("Failed to pull devcontainer index")?;
420422
let mut file = File::create(filename)?;
421423

422424
file.write_all(&blob[..])?;
@@ -431,7 +433,9 @@ pub async fn pull_archive_bytes(image: &OciReference) -> Result<Vec<u8>> {
431433
log::debug!("pull_archive_bytes");
432434

433435
let accepted_media_types = vec!["application/vnd.devcontainers.layer.v1+tar"];
434-
let blob = get_layer_bytes(image, accepted_media_types).await.context("Failed to pull archive bytes")?;
436+
let blob = get_layer_bytes(image, accepted_media_types)
437+
.await
438+
.context("Failed to pull archive bytes")?;
435439

436440
log::debug!("pull_archive_bytes: Pulled {} bytes for {}", blob.len(), &image.0);
437441

@@ -441,7 +445,10 @@ pub async fn pull_archive_bytes(image: &OciReference) -> Result<Vec<u8>> {
441445
async fn get_layer_bytes(OciReference(image): &OciReference, accepted_media_types: Vec<&str>) -> Result<Vec<u8>> {
442446
let auth = RegistryAuth::Anonymous;
443447
let client = Client::new(Default::default());
444-
let image_data = client.pull(image, &auth, accepted_media_types).await.context("Failed to pull image data")?;
448+
let image_data = client
449+
.pull(image, &auth, accepted_media_types)
450+
.await
451+
.context("Failed to pull image data")?;
445452
let blob = image_data
446453
.layers
447454
.into_iter()

0 commit comments

Comments
 (0)