Skip to content

Commit

Permalink
Merge branch 'main' into feature/pushManifestWithSubject
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Pan <[email protected]>
  • Loading branch information
Patrick Pan committed Dec 3, 2024
2 parents 2b24e07 + a9103d2 commit 7df36ca
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ dotnet_naming_symbols.public_members.applicable_kinds = property, field, method
dotnet_naming_symbols.public_members.applicable_accessibilities = public
dotnet_naming_symbols.public_members.required_modifiers =

dotnet_naming_style.public_uppercase_style.capitalization = pascal_case
dotnet_naming_style.public_uppercase_style.capitalization = pascal_case

# CA2007: Consider calling ConfigureAwait on the awaited task
dotnet_diagnostic.CA2007.severity = warning
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./tests/OrasProject.Oras.Tests/coverage.opencover.xml
files: ./tests/OrasProject.Oras.Tests/coverage.opencover.xml
18 changes: 9 additions & 9 deletions src/OrasProject.Oras/Packer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public static async Task<Descriptor> PackManifestAsync(
switch (version)
{
case ManifestVersion.Version1_0:
return await PackManifestV1_0Async(pusher, artifactType, options, cancellationToken);
return await PackManifestV1_0Async(pusher, artifactType, options, cancellationToken).ConfigureAwait(false);
case ManifestVersion.Version1_1:
return await PackManifestV1_1Async(pusher, artifactType, options, cancellationToken);
return await PackManifestV1_1Async(pusher, artifactType, options, cancellationToken).ConfigureAwait(false);
default:
throw new NotSupportedException($"ManifestVersion({version}) is not supported");
}
Expand Down Expand Up @@ -146,7 +146,7 @@ private static async Task<Descriptor> PackManifestV1_0Async(IPushable pusher, st
artifactType = MediaTypeUnknownConfig;
}
ValidateMediaType(artifactType);
configDescriptor = await PushCustomEmptyConfigAsync(pusher, artifactType, options.ConfigAnnotations, cancellationToken);
configDescriptor = await PushCustomEmptyConfigAsync(pusher, artifactType, options.ConfigAnnotations, cancellationToken).ConfigureAwait(false);
}

var annotations = EnsureAnnotationCreated(options.ManifestAnnotations, "org.opencontainers.image.created");
Expand All @@ -159,7 +159,7 @@ private static async Task<Descriptor> PackManifestV1_0Async(IPushable pusher, st
Annotations = annotations
};

return await PushManifestAsync(pusher, manifest, manifest.MediaType, manifest.Config.MediaType, manifest.Annotations, cancellationToken);
return await PushManifestAsync(pusher, manifest, manifest.MediaType, manifest.Config.MediaType, manifest.Annotations, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -192,7 +192,7 @@ private static async Task<Descriptor> PackManifestV1_1Async(IPushable pusher, st
configDescriptor = Descriptor.Empty;
options.Config = configDescriptor;
var configBytes = new byte[] { 0x7B, 0x7D };
await PushIfNotExistAsync(pusher, configDescriptor, configBytes, cancellationToken);
await PushIfNotExistAsync(pusher, configDescriptor, configBytes, cancellationToken).ConfigureAwait(false);
}

if (options.Layers == null || options.Layers.Count == 0)
Expand All @@ -215,7 +215,7 @@ private static async Task<Descriptor> PackManifestV1_1Async(IPushable pusher, st
Annotations = annotations
};

return await PushManifestAsync(pusher, manifest, manifest.MediaType, manifest.ArtifactType, manifest.Annotations, cancellationToken);
return await PushManifestAsync(pusher, manifest, manifest.MediaType, manifest.ArtifactType, manifest.Annotations, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -235,7 +235,7 @@ private static async Task<Descriptor> PushManifestAsync(IPushable pusher, object
manifestDesc.ArtifactType = artifactType;
manifestDesc.Annotations = annotations;

await pusher.PushAsync(manifestDesc, new MemoryStream(manifestJson), cancellationToken);
await pusher.PushAsync(manifestDesc, new MemoryStream(manifestJson), cancellationToken).ConfigureAwait(false);
return manifestDesc;
}

Expand Down Expand Up @@ -266,7 +266,7 @@ private static async Task<Descriptor> PushCustomEmptyConfigAsync(IPushable pushe
var configDescriptor = Descriptor.Create(configBytes, mediaType);
configDescriptor.Annotations = annotations;

await PushIfNotExistAsync(pusher, configDescriptor, configBytes, cancellationToken);
await PushIfNotExistAsync(pusher, configDescriptor, configBytes, cancellationToken).ConfigureAwait(false);
return configDescriptor;
}

Expand All @@ -280,7 +280,7 @@ private static async Task<Descriptor> PushCustomEmptyConfigAsync(IPushable pushe
/// <returns></returns>
private static async Task PushIfNotExistAsync(IPushable pusher, Descriptor descriptor, byte[] data, CancellationToken cancellationToken = default)
{
await pusher.PushAsync(descriptor, new MemoryStream(data), cancellationToken);
await pusher.PushAsync(descriptor, new MemoryStream(data), cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions src/OrasProject.Oras/Registry/Remote/BlobStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public async Task PushAsync(Descriptor expected, Stream content, CancellationTok
url = location.IsAbsoluteUri ? location : new Uri(url, location);
}

await CompletePushAsync(url, expected, content, cancellationToken);
await CompletePushAsync(url, expected, content, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -255,7 +255,8 @@ async Task<Stream> GetContentStream()
return stream;
}

await using (var contents = await GetContentStream())
var contents = await GetContentStream().ConfigureAwait(false);
await using (contents.ConfigureAwait(false))
{
await CompletePushAsync(url, descriptor, contents, cancellationToken).ConfigureAwait(false);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/OrasProject.Oras.Tests/OrasProject.Oras.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>

<!-- Disable requiring ConfigureAwait(false) for awaited tasks -->
<NoWarn>CA2007</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 7df36ca

Please sign in to comment.