From b780e8a41fb0acc91143694f165b732fb3fd5366 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Mon, 30 Aug 2021 13:44:45 -0700 Subject: [PATCH 1/5] trial migration to ACR SDK --- Bicep.sln | 7 + .../packages.lock.json | 45 ++-- src/Bicep.Cli.UnitTests/packages.lock.json | 45 ++-- src/Bicep.Cli/packages.lock.json | 45 ++-- .../packages.lock.json | 45 ++-- .../BicepRegistryBlobClient.cs | 204 +++++++++--------- src/Bicep.Core.Samples/packages.lock.json | 45 ++-- src/Bicep.Core.UnitTests/packages.lock.json | 45 ++-- src/Bicep.Core/Bicep.Core.csproj | 2 +- .../Registry/AzureContainerRegistryManager.cs | 61 +----- .../ContainerRegistryClientFactory.cs | 5 +- .../IContainerRegistryClientFactory.cs | 4 +- src/Bicep.Core/Registry/Oci/OciManifest.cs | 26 +-- src/Bicep.Core/Registry/OciModuleRegistry.cs | 2 +- src/Bicep.Core/packages.lock.json | 35 ++- .../packages.lock.json | 45 ++-- .../packages.lock.json | 45 ++-- src/Bicep.Decompiler/packages.lock.json | 45 ++-- .../packages.lock.json | 45 ++-- .../packages.lock.json | 45 ++-- src/Bicep.LangServer/packages.lock.json | 45 ++-- src/Bicep.Wasm/packages.lock.json | 45 ++-- 22 files changed, 443 insertions(+), 488 deletions(-) diff --git a/Bicep.sln b/Bicep.sln index f97d853094a..885c206fae7 100644 --- a/Bicep.sln +++ b/Bicep.sln @@ -72,6 +72,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bicep.MSBuild", "src\Bicep. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bicep.Core.RegistryClient", "src\Bicep.Core.RegistryClient\Bicep.Core.RegistryClient.csproj", "{AA51BD66-BD30-432C-82B6-C783F232D989}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Containers.ContainerRegistry", "..\azure-sdk-for-net\sdk\containerregistry\Azure.Containers.ContainerRegistry\src\Azure.Containers.ContainerRegistry.csproj", "{3F04EBA8-F6BB-4A24-8AAE-9FE629F50ABE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -142,6 +144,10 @@ Global {AA51BD66-BD30-432C-82B6-C783F232D989}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA51BD66-BD30-432C-82B6-C783F232D989}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA51BD66-BD30-432C-82B6-C783F232D989}.Release|Any CPU.Build.0 = Release|Any CPU + {3F04EBA8-F6BB-4A24-8AAE-9FE629F50ABE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F04EBA8-F6BB-4A24-8AAE-9FE629F50ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F04EBA8-F6BB-4A24-8AAE-9FE629F50ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F04EBA8-F6BB-4A24-8AAE-9FE629F50ABE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -163,6 +169,7 @@ Global {F3AF01F6-24E8-4129-80B6-84AC070B5C7D} = {61643BA1-BE82-4430-A3D3-CB7A16E747E3} {61026689-70A0-403E-B616-DFAEEF259444} = {38A0A11F-72BD-4512-A4A9-AC953936C09F} {AA51BD66-BD30-432C-82B6-C783F232D989} = {FE323E78-E865-46E2-859A-E4F6FB312C0F} + {3F04EBA8-F6BB-4A24-8AAE-9FE629F50ABE} = {FE323E78-E865-46E2-859A-E4F6FB312C0F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {21F77282-91E7-4304-B1EF-FADFA4F39E37} diff --git a/src/Bicep.Cli.IntegrationTests/packages.lock.json b/src/Bicep.Cli.IntegrationTests/packages.lock.json index 6ed3e2e5b50..c5348a1e124 100644 --- a/src/Bicep.Cli.IntegrationTests/packages.lock.json +++ b/src/Bicep.Cli.IntegrationTests/packages.lock.json @@ -75,22 +75,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2208,6 +2192,27 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep": { "type": "Project", "dependencies": { @@ -2232,11 +2237,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2244,12 +2249,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.core.samples": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Cli.UnitTests/packages.lock.json b/src/Bicep.Cli.UnitTests/packages.lock.json index d5551b889af..ad7776c63fb 100644 --- a/src/Bicep.Cli.UnitTests/packages.lock.json +++ b/src/Bicep.Cli.UnitTests/packages.lock.json @@ -75,22 +75,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -1253,6 +1237,27 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep": { "type": "Project", "dependencies": { @@ -1267,11 +1272,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -1279,12 +1284,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.decompiler": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Cli/packages.lock.json b/src/Bicep.Cli/packages.lock.json index 9ccfcd89ae8..2a77f3c87a8 100644 --- a/src/Bicep.Cli/packages.lock.json +++ b/src/Bicep.Cli/packages.lock.json @@ -48,22 +48,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -287,16 +271,37 @@ "resolved": "4.5.2", "contentHash": "BG/TNxDFv0svAzx8OiMXDlsHfGw623BZ8tCXw4YLhDFDvDhNUEV58jKYMGRnkbJNm7c3JNNJDiN7JBMzxRBR2w==" }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -304,12 +309,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.decompiler": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Core.IntegrationTests/packages.lock.json b/src/Bicep.Core.IntegrationTests/packages.lock.json index 47209b0aff4..72b06098e7e 100644 --- a/src/Bicep.Core.IntegrationTests/packages.lock.json +++ b/src/Bicep.Core.IntegrationTests/packages.lock.json @@ -86,22 +86,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2209,6 +2193,27 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep": { "type": "Project", "dependencies": { @@ -2223,11 +2228,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2235,12 +2240,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.core.samples": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Core.RegistryClient/BicepRegistryBlobClient.cs b/src/Bicep.Core.RegistryClient/BicepRegistryBlobClient.cs index 39f8df0e3b9..bf0a8ffd031 100644 --- a/src/Bicep.Core.RegistryClient/BicepRegistryBlobClient.cs +++ b/src/Bicep.Core.RegistryClient/BicepRegistryBlobClient.cs @@ -1,105 +1,105 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using System; -using System.IO; -using System.Threading.Tasks; -using System.Threading; -using Bicep.Core.Registry.Oci; -using Bicep.Core.RegistryClient.Models; - -namespace Bicep.Core.RegistryClient -{ - public class BicepRegistryBlobClient - { - private readonly Uri _endpoint; - private readonly string _registryName; - private readonly HttpPipeline _pipeline; - private readonly HttpPipeline _acrAuthPipeline; - private readonly ClientDiagnostics _clientDiagnostics; - private readonly ContainerRegistryRestClient _restClient; - private readonly AuthenticationRestClient _acrAuthClient; - private readonly ContainerRegistryBlobRestClient _blobRestClient; - private readonly string _repositoryName; - - public BicepRegistryBlobClient(Uri endpoint, TokenCredential credential, string repositoryName) : this(endpoint, credential, repositoryName, new ContainerRegistryClientOptions()) - { - } - - public BicepRegistryBlobClient(Uri endpoint, TokenCredential credential, string repositoryName, ContainerRegistryClientOptions options) - { - Argument.AssertNotNull(endpoint, nameof(endpoint)); - Argument.AssertNotNull(credential, nameof(credential)); - Argument.AssertNotNull(options, nameof(options)); - - _endpoint = endpoint; - _registryName = endpoint.Host.Split('.')[0]; - _repositoryName = repositoryName; - _clientDiagnostics = new ClientDiagnostics(options); - - _acrAuthPipeline = HttpPipelineBuilder.Build(options); - _acrAuthClient = new AuthenticationRestClient(_clientDiagnostics, _acrAuthPipeline, endpoint.AbsoluteUri); - - _pipeline = HttpPipelineBuilder.Build(options, new ContainerRegistryChallengeAuthenticationPolicy(credential, options.AuthenticationScope, _acrAuthClient)); - _restClient = new ContainerRegistryRestClient(_clientDiagnostics, _pipeline, _endpoint.AbsoluteUri); - _blobRestClient = new ContainerRegistryBlobRestClient(_clientDiagnostics, _pipeline, _endpoint.AbsoluteUri); - } - - // allows mocking - protected BicepRegistryBlobClient() - { - } - - public virtual async Task> UploadBlobAsync(Stream stream, CancellationToken cancellationToken = default) - { - string digest = DigestHelper.ComputeDigest(DigestHelper.AlgorithmIdentifierSha256, stream); - - ResponseWithHeaders startUploadResult = - await _blobRestClient.StartUploadAsync(_repositoryName, cancellationToken).ConfigureAwait(false); - - stream.Position = 0; - ResponseWithHeaders uploadChunkResult = - await _blobRestClient.UploadChunkAsync(startUploadResult.Headers.Location, stream, cancellationToken).ConfigureAwait(false); - - ResponseWithHeaders completeUploadResult = - await _blobRestClient.CompleteUploadAsync(digest, uploadChunkResult.Headers.Location, null, cancellationToken).ConfigureAwait(false); - - return Response.FromValue(new UploadBlobResult(), completeUploadResult.GetRawResponse()); - } - - public virtual async Task> UploadManifestAsync(Stream stream, UploadManifestOptions options = default, CancellationToken cancellationToken = default) - { - options ??= new UploadManifestOptions(); - - string reference = options.Tag ?? DigestHelper.ComputeDigest(DigestHelper.AlgorithmIdentifierSha256, stream); - stream.Position = 0; - ResponseWithHeaders response = await _restClient.CreateManifestAsync(_repositoryName, reference, options.MediaType, stream, cancellationToken).ConfigureAwait(false); - - return Response.FromValue(new UploadManifestResult(), response.GetRawResponse()); - } - - public virtual async Task> DownloadManifestAsync(string reference, DownloadManifestOptions options = default, CancellationToken cancellationToken = default) - { - options ??= new DownloadManifestOptions(); - - Response manifestWrapper = await _restClient.GetManifestAsync(_repositoryName, reference, options.MediaType.ToSerialString(), cancellationToken).ConfigureAwait(false); - - manifestWrapper.GetRawResponse().Headers.TryGetValue("Docker-Content-Digest", out var digest); - - Stream stream = manifestWrapper.GetRawResponse().ContentStream; - stream.Position = 0; - - return Response.FromValue(new DownloadManifestResult(digest, stream), manifestWrapper.GetRawResponse()); - } - - public virtual async Task> DownloadBlobAsync(string digest, DownloadBlobOptions options = default, CancellationToken cancellationToken = default) - { - options ??= new DownloadBlobOptions(); - ResponseWithHeaders blobResult = await _blobRestClient.GetBlobAsync(_repositoryName, digest, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DownloadBlobResult(digest, blobResult.Value), blobResult.GetRawResponse()); - } - } -} +//using Azure; +//using Azure.Core; +//using Azure.Core.Pipeline; +//using System; +//using System.IO; +//using System.Threading.Tasks; +//using System.Threading; +//using Bicep.Core.Registry.Oci; +//using Bicep.Core.RegistryClient.Models; + +//namespace Bicep.Core.RegistryClient +//{ +// public class BicepRegistryBlobClient +// { +// private readonly Uri _endpoint; +// private readonly string _registryName; +// private readonly HttpPipeline _pipeline; +// private readonly HttpPipeline _acrAuthPipeline; +// private readonly ClientDiagnostics _clientDiagnostics; +// private readonly ContainerRegistryRestClient _restClient; +// private readonly AuthenticationRestClient _acrAuthClient; +// private readonly ContainerRegistryBlobRestClient _blobRestClient; +// private readonly string _repositoryName; + +// public BicepRegistryBlobClient(Uri endpoint, TokenCredential credential, string repositoryName) : this(endpoint, credential, repositoryName, new ContainerRegistryClientOptions()) +// { +// } + +// public BicepRegistryBlobClient(Uri endpoint, TokenCredential credential, string repositoryName, ContainerRegistryClientOptions options) +// { +// Argument.AssertNotNull(endpoint, nameof(endpoint)); +// Argument.AssertNotNull(credential, nameof(credential)); +// Argument.AssertNotNull(options, nameof(options)); + +// _endpoint = endpoint; +// _registryName = endpoint.Host.Split('.')[0]; +// _repositoryName = repositoryName; +// _clientDiagnostics = new ClientDiagnostics(options); + +// _acrAuthPipeline = HttpPipelineBuilder.Build(options); +// _acrAuthClient = new AuthenticationRestClient(_clientDiagnostics, _acrAuthPipeline, endpoint.AbsoluteUri); + +// _pipeline = HttpPipelineBuilder.Build(options, new ContainerRegistryChallengeAuthenticationPolicy(credential, options.AuthenticationScope, _acrAuthClient)); +// _restClient = new ContainerRegistryRestClient(_clientDiagnostics, _pipeline, _endpoint.AbsoluteUri); +// _blobRestClient = new ContainerRegistryBlobRestClient(_clientDiagnostics, _pipeline, _endpoint.AbsoluteUri); +// } + +// // allows mocking +// protected BicepRegistryBlobClient() +// { +// } + +// public virtual async Task> UploadBlobAsync(Stream stream, CancellationToken cancellationToken = default) +// { +// string digest = DigestHelper.ComputeDigest(DigestHelper.AlgorithmIdentifierSha256, stream); + +// ResponseWithHeaders startUploadResult = +// await _blobRestClient.StartUploadAsync(_repositoryName, cancellationToken).ConfigureAwait(false); + +// stream.Position = 0; +// ResponseWithHeaders uploadChunkResult = +// await _blobRestClient.UploadChunkAsync(startUploadResult.Headers.Location, stream, cancellationToken).ConfigureAwait(false); + +// ResponseWithHeaders completeUploadResult = +// await _blobRestClient.CompleteUploadAsync(digest, uploadChunkResult.Headers.Location, null, cancellationToken).ConfigureAwait(false); + +// return Response.FromValue(new UploadBlobResult(), completeUploadResult.GetRawResponse()); +// } + +// public virtual async Task> UploadManifestAsync(Stream stream, UploadManifestOptions options = default, CancellationToken cancellationToken = default) +// { +// options ??= new UploadManifestOptions(); + +// string reference = options.Tag ?? DigestHelper.ComputeDigest(DigestHelper.AlgorithmIdentifierSha256, stream); +// stream.Position = 0; +// ResponseWithHeaders response = await _restClient.CreateManifestAsync(_repositoryName, reference, options.MediaType, stream, cancellationToken).ConfigureAwait(false); + +// return Response.FromValue(new UploadManifestResult(), response.GetRawResponse()); +// } + +// public virtual async Task> DownloadManifestAsync(string reference, DownloadManifestOptions options = default, CancellationToken cancellationToken = default) +// { +// options ??= new DownloadManifestOptions(); + +// Response manifestWrapper = await _restClient.GetManifestAsync(_repositoryName, reference, options.MediaType.ToSerialString(), cancellationToken).ConfigureAwait(false); + +// manifestWrapper.GetRawResponse().Headers.TryGetValue("Docker-Content-Digest", out var digest); + +// Stream stream = manifestWrapper.GetRawResponse().ContentStream; +// stream.Position = 0; + +// return Response.FromValue(new DownloadManifestResult(digest, stream), manifestWrapper.GetRawResponse()); +// } + +// public virtual async Task> DownloadBlobAsync(string digest, DownloadBlobOptions options = default, CancellationToken cancellationToken = default) +// { +// options ??= new DownloadBlobOptions(); +// ResponseWithHeaders blobResult = await _blobRestClient.GetBlobAsync(_repositoryName, digest, cancellationToken).ConfigureAwait(false); +// return Response.FromValue(new DownloadBlobResult(digest, blobResult.Value), blobResult.GetRawResponse()); +// } +// } +//} diff --git a/src/Bicep.Core.Samples/packages.lock.json b/src/Bicep.Core.Samples/packages.lock.json index f050655cd2f..cdab0221f49 100644 --- a/src/Bicep.Core.Samples/packages.lock.json +++ b/src/Bicep.Core.Samples/packages.lock.json @@ -75,22 +75,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2208,6 +2192,27 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep": { "type": "Project", "dependencies": { @@ -2222,11 +2227,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2234,12 +2239,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.core.unittests": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Core.UnitTests/packages.lock.json b/src/Bicep.Core.UnitTests/packages.lock.json index e851951cd9b..29bdc42cba1 100644 --- a/src/Bicep.Core.UnitTests/packages.lock.json +++ b/src/Bicep.Core.UnitTests/packages.lock.json @@ -157,22 +157,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2213,16 +2197,37 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2230,12 +2235,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.langserver": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Core/Bicep.Core.csproj b/src/Bicep.Core/Bicep.Core.csproj index c3435e43b01..5e03e3b3d9e 100644 --- a/src/Bicep.Core/Bicep.Core.csproj +++ b/src/Bicep.Core/Bicep.Core.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs index 7bea5c536cd..3f73c910826 100644 --- a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs +++ b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs @@ -5,14 +5,15 @@ using Azure.Core; using Bicep.Core.Modules; using Bicep.Core.Registry.Oci; -using Bicep.Core.RegistryClient; -using Bicep.Core.RegistryClient.Models; +using Azure.Containers.ContainerRegistry.Specialized; +//using Bicep.Core.RegistryClient; +//using Bicep.Core.RegistryClient.Models; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; -using UploadManifestOptions = Bicep.Core.RegistryClient.UploadManifestOptions; +//using UploadManifestOptions = Bicep.Core.RegistryClient.UploadManifestOptions; namespace Bicep.Core.Registry { @@ -20,7 +21,6 @@ public class AzureContainerRegistryManager { // media types are case-insensitive (they are lowercase by convention only) private const StringComparison MediaTypeComparison = StringComparison.OrdinalIgnoreCase; - private const StringComparison DigestComparison = StringComparison.Ordinal; private readonly string artifactCachePath; private readonly TokenCredential tokenCredential; @@ -33,7 +33,7 @@ public AzureContainerRegistryManager(string artifactCachePath, TokenCredential t this.clientFactory = clientFactory; } - public async Task PullArtifactsync(OciArtifactModuleReference moduleReference) + public async Task PullArtifactAsync(OciArtifactModuleReference moduleReference) { try { @@ -84,7 +84,7 @@ public async Task PushArtifactAsync(OciArtifactModuleReference moduleReference, manifestStream.Position = 0; // BUG: the client closes the stream :( - var manifestUploadResult = await blobClient.UploadManifestAsync(manifestStream, new UploadManifestOptions(ContentType.ApplicationVndOciImageManifestV1Json, moduleReference.Tag)); + var manifestUploadResult = await blobClient.UploadManifestAsync(manifestStream, new UploadManifestOptions(ManifestMediaType.OciManifest, moduleReference.Tag)); } public string GetLocalPackageDirectory(OciArtifactModuleReference reference) @@ -108,7 +108,7 @@ public string GetLocalPackageDirectory(OciArtifactModuleReference reference) private static Uri GetRegistryUri(OciArtifactModuleReference moduleReference) => new Uri($"https://{moduleReference.Registry}"); - private BicepRegistryBlobClient CreateBlobClient(OciArtifactModuleReference moduleReference) => this.clientFactory.CreateBlobClient(GetRegistryUri(moduleReference), moduleReference.Repository, this.tokenCredential); + private ContainerRegistryBlobClient CreateBlobClient(OciArtifactModuleReference moduleReference) => this.clientFactory.CreateBlobClient(GetRegistryUri(moduleReference), moduleReference.Repository, this.tokenCredential); private static void CreateModuleDirectory(string modulePath) { @@ -135,12 +135,12 @@ private async Task PullArtifactInternalAsync(OciArtifactModuleReference moduleRe await ProcessManifest(client, manifest, modulePath); } - private static async Task DownloadManifestAsync(OciArtifactModuleReference moduleReference, BicepRegistryBlobClient client) + private static async Task DownloadManifestAsync(OciArtifactModuleReference moduleReference, ContainerRegistryBlobClient client) { Response manifestResponse; try { - manifestResponse = await client.DownloadManifestAsync(moduleReference.Tag, new DownloadManifestOptions(ContentType.ApplicationVndOciImageManifestV1Json)); + manifestResponse = await client.DownloadManifestAsync(moduleReference.Tag, new DownloadManifestOptions()); } catch(RequestFailedException exception) when (exception.Status == 404) { @@ -148,8 +148,6 @@ private static async Task DownloadManifestAsync(OciArtifactModuleRe throw new AcrManagerException("The module does not exist in the registry.", exception); } - ValidateManifestResponse(manifestResponse); - // the SDK doesn't expose all the manifest properties we need // so we need to deserialize the manifest ourselves to get everything var stream = manifestResponse.Value.Content; @@ -157,23 +155,7 @@ private static async Task DownloadManifestAsync(OciArtifactModuleRe return DeserializeManifest(stream); } - private static void ValidateManifestResponse(Response manifestResponse) - { - var digestFromRegistry = manifestResponse.Value.Digest; - - var stream = manifestResponse.Value.Content; - stream.Position = 0; - - // TODO: The registry may use a different digest algorithm - we need to handle that - string digestFromContent = DigestHelper.ComputeDigest(DigestHelper.AlgorithmIdentifierSha256, stream); - - if (!string.Equals(digestFromRegistry, digestFromContent, DigestComparison)) - { - throw new AcrManagerException($"There is a mismatch in the manifest digests. Received content digest = {digestFromContent}, Digest in registry response = {digestFromRegistry}"); - } - } - - private static async Task ProcessManifest(BicepRegistryBlobClient client, OciManifest manifest, string modulePath) + private static async Task ProcessManifest(ContainerRegistryBlobClient client, OciManifest manifest, string modulePath) { ProcessConfig(manifest.Config); if (manifest.Layers.Length != 1) @@ -186,26 +168,7 @@ private static async Task ProcessManifest(BicepRegistryBlobClient client, OciMan await ProcessLayer(client, layer, modulePath); } - private static void ValidateBlobResponse(Response blobResponse, OciDescriptor descriptor) - { - var stream = blobResponse.Value.Content; - - if(descriptor.Size != stream.Length) - { - throw new InvalidModuleException($"Expected blob size of {descriptor.Size} bytes but received {stream.Length} bytes from the registry."); - } - - stream.Position = 0; - string digestFromContents = DigestHelper.ComputeDigest(DigestHelper.AlgorithmIdentifierSha256, stream); - stream.Position = 0; - - if(!string.Equals(descriptor.Digest, digestFromContents, DigestComparison)) - { - throw new InvalidModuleException($"There is a mismatch in the layer digests. Received content digest = {digestFromContents}, Requested digest = {descriptor.Digest}"); - } - } - - private static async Task ProcessLayer(BicepRegistryBlobClient client, OciDescriptor layer, string modulePath) + private static async Task ProcessLayer(ContainerRegistryBlobClient client, OciDescriptor layer, string modulePath) { if(!string.Equals(layer.MediaType, BicepMediaTypes.BicepModuleLayerV1Json, MediaTypeComparison)) { @@ -222,8 +185,6 @@ private static async Task ProcessLayer(BicepRegistryBlobClient client, OciDescri throw new InvalidModuleException($"Module manifest refers to a non-existent blob with digest \"{layer.Digest}\".", exception); } - ValidateBlobResponse(blobResult, layer); - var layerPath = Path.Combine(modulePath, "main.json"); using var fileStream = new FileStream(layerPath, FileMode.Create); diff --git a/src/Bicep.Core/Registry/ContainerRegistryClientFactory.cs b/src/Bicep.Core/Registry/ContainerRegistryClientFactory.cs index 333b3c789e5..91be3b2de81 100644 --- a/src/Bicep.Core/Registry/ContainerRegistryClientFactory.cs +++ b/src/Bicep.Core/Registry/ContainerRegistryClientFactory.cs @@ -1,15 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using Azure.Containers.ContainerRegistry; +using Azure.Containers.ContainerRegistry.Specialized; using Azure.Core; -using Bicep.Core.RegistryClient; using System; namespace Bicep.Core.Registry { public class ContainerRegistryClientFactory : IContainerRegistryClientFactory { - public BicepRegistryBlobClient CreateBlobClient(Uri registryUri, string repository, TokenCredential credential) + public ContainerRegistryBlobClient CreateBlobClient(Uri registryUri, string repository, TokenCredential credential) { var options = new ContainerRegistryClientOptions(); diff --git a/src/Bicep.Core/Registry/IContainerRegistryClientFactory.cs b/src/Bicep.Core/Registry/IContainerRegistryClientFactory.cs index 2127f715c5a..c84538d14c9 100644 --- a/src/Bicep.Core/Registry/IContainerRegistryClientFactory.cs +++ b/src/Bicep.Core/Registry/IContainerRegistryClientFactory.cs @@ -2,7 +2,7 @@ // Licensed under the MIT License. using Azure.Core; -using Bicep.Core.RegistryClient; +using Azure.Containers.ContainerRegistry.Specialized; using System; namespace Bicep.Core.Registry @@ -13,6 +13,6 @@ namespace Bicep.Core.Registry /// This exists because we need to inject mock clients in integration tests and because the real client constructor requires parameters. public interface IContainerRegistryClientFactory { - BicepRegistryBlobClient CreateBlobClient(Uri registryUri, string repository, TokenCredential credential); + ContainerRegistryBlobClient CreateBlobClient(Uri registryUri, string repository, TokenCredential credential); } } diff --git a/src/Bicep.Core/Registry/Oci/OciManifest.cs b/src/Bicep.Core/Registry/Oci/OciManifest.cs index bf39f246468..0b737b78d62 100644 --- a/src/Bicep.Core/Registry/Oci/OciManifest.cs +++ b/src/Bicep.Core/Registry/Oci/OciManifest.cs @@ -6,20 +6,20 @@ namespace Bicep.Core.Registry.Oci { - public class OciManifest - { - // TODO: Add top-level annotations - public OciManifest(int schemaVersion, OciDescriptor config, IEnumerable layers) - { - this.SchemaVersion = schemaVersion; - this.Config = config; - this.Layers = layers.ToImmutableArray(); - } + //public class OciManifest + //{ + // // TODO: Add top-level annotations + // public OciManifest(int schemaVersion, OciDescriptor config, IEnumerable layers) + // { + // this.SchemaVersion = schemaVersion; + // this.Config = config; + // this.Layers = layers.ToImmutableArray(); + // } - public int SchemaVersion { get; } + // public int SchemaVersion { get; } - public OciDescriptor Config { get; } + // public OciDescriptor Config { get; } - public ImmutableArray Layers { get; } - } + // public ImmutableArray Layers { get; } + //} } diff --git a/src/Bicep.Core/Registry/OciModuleRegistry.cs b/src/Bicep.Core/Registry/OciModuleRegistry.cs index f5cc983394b..44da70c8114 100644 --- a/src/Bicep.Core/Registry/OciModuleRegistry.cs +++ b/src/Bicep.Core/Registry/OciModuleRegistry.cs @@ -57,7 +57,7 @@ public bool IsModuleRestoreRequired(ModuleReference reference) { using (var timer = new ExecutionTimer($"Restore module {reference.FullyQualifiedReference}")) { - var result = await this.client.PullArtifactsync(reference); + var result = await this.client.PullArtifactAsync(reference); if (!result.Success) { diff --git a/src/Bicep.Core/packages.lock.json b/src/Bicep.Core/packages.lock.json index bee51f8bc05..eb43f30425d 100644 --- a/src/Bicep.Core/packages.lock.json +++ b/src/Bicep.Core/packages.lock.json @@ -131,22 +131,6 @@ "System.Memory": "4.5.4" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Microsoft.Bcl.AsyncInterfaces": { "type": "Transitive", "resolved": "5.0.0", @@ -1455,10 +1439,25 @@ "System.Xml.XmlDocument": "4.3.0" } }, - "bicep.core.registryclient": { + "azure.containers.containerregistry": { "type": "Project", "dependencies": { - "Azure.Core": "1.14.0" + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" } } }, diff --git a/src/Bicep.Decompiler.IntegrationTests/packages.lock.json b/src/Bicep.Decompiler.IntegrationTests/packages.lock.json index 9a6f0d5735b..5b0a709647e 100644 --- a/src/Bicep.Decompiler.IntegrationTests/packages.lock.json +++ b/src/Bicep.Decompiler.IntegrationTests/packages.lock.json @@ -75,22 +75,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2207,16 +2191,37 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2224,12 +2229,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.core.unittests": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Decompiler.UnitTests/packages.lock.json b/src/Bicep.Decompiler.UnitTests/packages.lock.json index 9a6f0d5735b..5b0a709647e 100644 --- a/src/Bicep.Decompiler.UnitTests/packages.lock.json +++ b/src/Bicep.Decompiler.UnitTests/packages.lock.json @@ -75,22 +75,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2207,16 +2191,37 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2224,12 +2229,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.core.unittests": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Decompiler/packages.lock.json b/src/Bicep.Decompiler/packages.lock.json index 4ab8991b2f5..01348ad59d4 100644 --- a/src/Bicep.Decompiler/packages.lock.json +++ b/src/Bicep.Decompiler/packages.lock.json @@ -55,22 +55,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -1441,28 +1425,43 @@ "System.Xml.XmlDocument": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", "Newtonsoft.Json": "13.0.1", "System.Collections.Immutable": "5.0.0" } - }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } } }, ".NETStandard,Version=v2.1/linux-musl-x64": { diff --git a/src/Bicep.LangServer.IntegrationTests/packages.lock.json b/src/Bicep.LangServer.IntegrationTests/packages.lock.json index 19d245f2694..9ae3ded0a05 100644 --- a/src/Bicep.LangServer.IntegrationTests/packages.lock.json +++ b/src/Bicep.LangServer.IntegrationTests/packages.lock.json @@ -97,22 +97,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2221,6 +2205,27 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep": { "type": "Project", "dependencies": { @@ -2235,11 +2240,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2247,12 +2252,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.core.samples": { "type": "Project", "dependencies": { diff --git a/src/Bicep.LangServer.UnitTests/packages.lock.json b/src/Bicep.LangServer.UnitTests/packages.lock.json index 19d245f2694..9ae3ded0a05 100644 --- a/src/Bicep.LangServer.UnitTests/packages.lock.json +++ b/src/Bicep.LangServer.UnitTests/packages.lock.json @@ -97,22 +97,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2221,6 +2205,27 @@ "System.Xml.ReaderWriter": "4.3.0" } }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep": { "type": "Project", "dependencies": { @@ -2235,11 +2240,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2247,12 +2252,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.core.samples": { "type": "Project", "dependencies": { diff --git a/src/Bicep.LangServer/packages.lock.json b/src/Bicep.LangServer/packages.lock.json index 3d325c3bbf1..c18a44ed4d4 100644 --- a/src/Bicep.LangServer/packages.lock.json +++ b/src/Bicep.LangServer/packages.lock.json @@ -42,22 +42,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -548,28 +532,43 @@ "resolved": "4.5.3", "contentHash": "+MvhNtcvIbqmhANyKu91jQnvIRVSTiaOiFNfKWwXGHG48YAb4I/TyH8spsySiPYla7gKal5ZnF3teJqZAximyQ==" }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", "Newtonsoft.Json": "13.0.1", "System.Collections.Immutable": "5.0.0" } - }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } } }, ".NETCoreApp,Version=v5.0/linux-musl-x64": { diff --git a/src/Bicep.Wasm/packages.lock.json b/src/Bicep.Wasm/packages.lock.json index 245a300f337..1d0c410d30f 100644 --- a/src/Bicep.Wasm/packages.lock.json +++ b/src/Bicep.Wasm/packages.lock.json @@ -49,22 +49,6 @@ "Azure.Bicep.Types": "0.1.245" } }, - "Azure.Core": { - "type": "Transitive", - "resolved": "1.14.0", - "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -371,16 +355,37 @@ "resolved": "4.5.2", "contentHash": "BG/TNxDFv0svAzx8OiMXDlsHfGw623BZ8tCXw4YLhDFDvDhNUEV58jKYMGRnkbJNm7c3JNNJDiN7JBMzxRBR2w==" }, + "azure.containers.containerregistry": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.19.0-alpha.20210827.1", + "System.Text.Json": "4.6.0" + } + }, + "azure.core": { + "type": "Project", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", + "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", - "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -388,12 +393,6 @@ "System.Collections.Immutable": "5.0.0" } }, - "bicep.core.registryclient": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.14.0" - } - }, "bicep.decompiler": { "type": "Project", "dependencies": { From 0bbe7ab5fa0b0d1f96bb8d265875a9bdbc496b82 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Tue, 31 Aug 2021 14:12:59 -0700 Subject: [PATCH 2/5] api updates --- .../Registry/AzureContainerRegistryManager.cs | 2 +- src/Bicep.Core/Registry/Oci/OciManifest.cs | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs index 3f73c910826..e8f4a131376 100644 --- a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs +++ b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs @@ -84,7 +84,7 @@ public async Task PushArtifactAsync(OciArtifactModuleReference moduleReference, manifestStream.Position = 0; // BUG: the client closes the stream :( - var manifestUploadResult = await blobClient.UploadManifestAsync(manifestStream, new UploadManifestOptions(ManifestMediaType.OciManifest, moduleReference.Tag)); + var manifestUploadResult = await blobClient.UploadManifestAsync(manifestStream, new UploadManifestOptions() { Tag = moduleReference.Tag }); } public string GetLocalPackageDirectory(OciArtifactModuleReference reference) diff --git a/src/Bicep.Core/Registry/Oci/OciManifest.cs b/src/Bicep.Core/Registry/Oci/OciManifest.cs index 0b737b78d62..bf39f246468 100644 --- a/src/Bicep.Core/Registry/Oci/OciManifest.cs +++ b/src/Bicep.Core/Registry/Oci/OciManifest.cs @@ -6,20 +6,20 @@ namespace Bicep.Core.Registry.Oci { - //public class OciManifest - //{ - // // TODO: Add top-level annotations - // public OciManifest(int schemaVersion, OciDescriptor config, IEnumerable layers) - // { - // this.SchemaVersion = schemaVersion; - // this.Config = config; - // this.Layers = layers.ToImmutableArray(); - // } + public class OciManifest + { + // TODO: Add top-level annotations + public OciManifest(int schemaVersion, OciDescriptor config, IEnumerable layers) + { + this.SchemaVersion = schemaVersion; + this.Config = config; + this.Layers = layers.ToImmutableArray(); + } - // public int SchemaVersion { get; } + public int SchemaVersion { get; } - // public OciDescriptor Config { get; } + public OciDescriptor Config { get; } - // public ImmutableArray Layers { get; } - //} + public ImmutableArray Layers { get; } + } } From 9d8a6689dfd44a129d12ccc9aa029122df54007f Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Tue, 31 Aug 2021 15:41:59 -0700 Subject: [PATCH 3/5] testing removal of locally-defined OciDescriptor --- .../packages.lock.json | 45 +++++++++--------- src/Bicep.Cli.UnitTests/packages.lock.json | 45 +++++++++--------- src/Bicep.Cli/packages.lock.json | 45 +++++++++--------- .../packages.lock.json | 45 +++++++++--------- src/Bicep.Core.Samples/packages.lock.json | 45 +++++++++--------- src/Bicep.Core.UnitTests/packages.lock.json | 45 +++++++++--------- .../Registry/AzureContainerRegistryManager.cs | 43 +++++++++-------- .../Registry/Oci/DescriptorFactory.cs | 7 +-- src/Bicep.Core/Registry/Oci/OciDescriptor.cs | 28 ----------- src/Bicep.Core/Registry/Oci/OciManifest.cs | 25 ---------- .../Registry/Oci/OciManifestSerialization.cs | 46 ------------------- .../Registry/Oci/StreamDescriptor.cs | 5 +- src/Bicep.Core/packages.lock.json | 35 +++++++------- .../packages.lock.json | 45 +++++++++--------- .../packages.lock.json | 45 +++++++++--------- src/Bicep.Decompiler/packages.lock.json | 45 +++++++++--------- .../packages.lock.json | 45 +++++++++--------- .../packages.lock.json | 45 +++++++++--------- src/Bicep.LangServer/packages.lock.json | 45 +++++++++--------- src/Bicep.Wasm/packages.lock.json | 45 +++++++++--------- 20 files changed, 345 insertions(+), 429 deletions(-) delete mode 100644 src/Bicep.Core/Registry/Oci/OciDescriptor.cs delete mode 100644 src/Bicep.Core/Registry/Oci/OciManifest.cs delete mode 100644 src/Bicep.Core/Registry/Oci/OciManifestSerialization.cs diff --git a/src/Bicep.Cli.IntegrationTests/packages.lock.json b/src/Bicep.Cli.IntegrationTests/packages.lock.json index c5348a1e124..6ed3e2e5b50 100644 --- a/src/Bicep.Cli.IntegrationTests/packages.lock.json +++ b/src/Bicep.Cli.IntegrationTests/packages.lock.json @@ -75,6 +75,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2192,27 +2208,6 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep": { "type": "Project", "dependencies": { @@ -2237,11 +2232,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2249,6 +2244,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.core.samples": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Cli.UnitTests/packages.lock.json b/src/Bicep.Cli.UnitTests/packages.lock.json index ad7776c63fb..d5551b889af 100644 --- a/src/Bicep.Cli.UnitTests/packages.lock.json +++ b/src/Bicep.Cli.UnitTests/packages.lock.json @@ -75,6 +75,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -1237,27 +1253,6 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep": { "type": "Project", "dependencies": { @@ -1272,11 +1267,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -1284,6 +1279,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.decompiler": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Cli/packages.lock.json b/src/Bicep.Cli/packages.lock.json index 2a77f3c87a8..9ccfcd89ae8 100644 --- a/src/Bicep.Cli/packages.lock.json +++ b/src/Bicep.Cli/packages.lock.json @@ -48,6 +48,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -271,37 +287,16 @@ "resolved": "4.5.2", "contentHash": "BG/TNxDFv0svAzx8OiMXDlsHfGw623BZ8tCXw4YLhDFDvDhNUEV58jKYMGRnkbJNm7c3JNNJDiN7JBMzxRBR2w==" }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -309,6 +304,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.decompiler": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Core.IntegrationTests/packages.lock.json b/src/Bicep.Core.IntegrationTests/packages.lock.json index 72b06098e7e..47209b0aff4 100644 --- a/src/Bicep.Core.IntegrationTests/packages.lock.json +++ b/src/Bicep.Core.IntegrationTests/packages.lock.json @@ -86,6 +86,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2193,27 +2209,6 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep": { "type": "Project", "dependencies": { @@ -2228,11 +2223,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2240,6 +2235,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.core.samples": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Core.Samples/packages.lock.json b/src/Bicep.Core.Samples/packages.lock.json index cdab0221f49..f050655cd2f 100644 --- a/src/Bicep.Core.Samples/packages.lock.json +++ b/src/Bicep.Core.Samples/packages.lock.json @@ -75,6 +75,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2192,27 +2208,6 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep": { "type": "Project", "dependencies": { @@ -2227,11 +2222,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2239,6 +2234,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.core.unittests": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Core.UnitTests/packages.lock.json b/src/Bicep.Core.UnitTests/packages.lock.json index 29bdc42cba1..e851951cd9b 100644 --- a/src/Bicep.Core.UnitTests/packages.lock.json +++ b/src/Bicep.Core.UnitTests/packages.lock.json @@ -157,6 +157,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2197,37 +2213,16 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2235,6 +2230,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.langserver": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs index e8f4a131376..f4f6ddaa094 100644 --- a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs +++ b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs @@ -67,7 +67,7 @@ public async Task PushArtifactAsync(OciArtifactModuleReference moduleReference, config.ResetStream(); var configUploadResult = await blobClient.UploadBlobAsync(config.Stream); - var layerDescriptors = new List(layers.Length); + var layerDescriptors = new List(layers.Length); foreach (var layer in layers) { layer.ResetStream(); @@ -78,9 +78,11 @@ public async Task PushArtifactAsync(OciArtifactModuleReference moduleReference, var layerUploadResult = await blobClient.UploadBlobAsync(layer.Stream); } - var manifest = new OciManifest(2, configDescriptor, layerDescriptors); + var manifest = new OciManifest(configDescriptor, layerDescriptors); using var manifestStream = new MemoryStream(); - OciManifestSerialization.SerializeManifest(manifestStream, manifest); + + // TODO: do this serialization in an overload on blobClient + //OciManifestSerialization.SerializeManifest(manifestStream, manifest); manifestStream.Position = 0; // BUG: the client closes the stream :( @@ -151,14 +153,15 @@ private static async Task DownloadManifestAsync(OciArtifactModuleRe // the SDK doesn't expose all the manifest properties we need // so we need to deserialize the manifest ourselves to get everything var stream = manifestResponse.Value.Content; - stream.Position = 0; - return DeserializeManifest(stream); + // TODO: Get this from the DownloadManifest overload + //stream.Position = 0; + //return DeserializeManifest(stream); } private static async Task ProcessManifest(ContainerRegistryBlobClient client, OciManifest manifest, string modulePath) { ProcessConfig(manifest.Config); - if (manifest.Layers.Length != 1) + if (manifest.Layers.Count != 1) { throw new InvalidModuleException("Expected a single layer in the OCI artifact."); } @@ -168,7 +171,7 @@ private static async Task ProcessManifest(ContainerRegistryBlobClient client, Oc await ProcessLayer(client, layer, modulePath); } - private static async Task ProcessLayer(ContainerRegistryBlobClient client, OciDescriptor layer, string modulePath) + private static async Task ProcessLayer(ContainerRegistryBlobClient client, ArtifactBlobDescriptor layer, string modulePath) { if(!string.Equals(layer.MediaType, BicepMediaTypes.BicepModuleLayerV1Json, MediaTypeComparison)) { @@ -191,7 +194,7 @@ private static async Task ProcessLayer(ContainerRegistryBlobClient client, OciDe await blobResult.Value.Content.CopyToAsync(fileStream); } - private static void ProcessConfig(OciDescriptor config) + private static void ProcessConfig(ArtifactBlobDescriptor config) { // media types are case insensitive if(!string.Equals(config.MediaType, BicepMediaTypes.BicepModuleConfigV1, MediaTypeComparison)) @@ -205,18 +208,18 @@ private static void ProcessConfig(OciDescriptor config) } } - private static OciManifest DeserializeManifest(Stream stream) - { - try - { - - return OciManifestSerialization.DeserializeManifest(stream); - } - catch(Exception exception) - { - throw new InvalidModuleException("Unable to deserialize the module manifest.", exception); - } - } + //private static OciManifest DeserializeManifest(Stream stream) + //{ + // try + // { + + // return OciManifestSerialization.DeserializeManifest(stream); + // } + // catch(Exception exception) + // { + // throw new InvalidModuleException("Unable to deserialize the module manifest.", exception); + // } + //} private class AcrManagerException : Exception { diff --git a/src/Bicep.Core/Registry/Oci/DescriptorFactory.cs b/src/Bicep.Core/Registry/Oci/DescriptorFactory.cs index 6036f162b84..1824bc265e3 100644 --- a/src/Bicep.Core/Registry/Oci/DescriptorFactory.cs +++ b/src/Bicep.Core/Registry/Oci/DescriptorFactory.cs @@ -5,6 +5,7 @@ using System.Security.Cryptography; using System; using System.Text; +using Azure.Containers.ContainerRegistry.Specialized; namespace Bicep.Core.Registry.Oci { @@ -13,14 +14,14 @@ public static class DescriptorFactory public const string AlgorithmIdentifierSha256 = "sha256"; public const string AlgorithmIdentifierSha512 = "sha512"; - public static OciDescriptor CreateDescriptor(string algorithmIdentifier, StreamDescriptor streamDescriptor) + public static ArtifactBlobDescriptor CreateDescriptor(string algorithmIdentifier, StreamDescriptor streamDescriptor) { var digest = ComputeDigest(algorithmIdentifier, streamDescriptor.Stream); - return new OciDescriptor(streamDescriptor.MediaType, digest, streamDescriptor.Stream.Length, streamDescriptor.Annotations); + return new ArtifactBlobDescriptor(streamDescriptor.MediaType, digest, streamDescriptor.Stream.Length); } - public static string ComputeDigest(string algorithmIdentifier, Stream stream) + private static string ComputeDigest(string algorithmIdentifier, Stream stream) { using var algorithm = CreateHashAlgorithm(algorithmIdentifier); var hashValue = algorithm.ComputeHash(stream); diff --git a/src/Bicep.Core/Registry/Oci/OciDescriptor.cs b/src/Bicep.Core/Registry/Oci/OciDescriptor.cs deleted file mode 100644 index 7a061443476..00000000000 --- a/src/Bicep.Core/Registry/Oci/OciDescriptor.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -using System.Collections.Generic; -using System.Collections.Immutable; - -namespace Bicep.Core.Registry.Oci -{ - public class OciDescriptor - { - public OciDescriptor(string mediaType, string digest, long size, IDictionary? annotations) - { - this.MediaType = mediaType; - this.Digest = digest; - this.Size = size; - this.Annotations = annotations?.ToImmutableDictionary() ?? ImmutableDictionary.Empty; - } - - public string MediaType { get; } - - public string Digest { get; } - - public long Size { get; } - - // TODO: Skip serialization for empty annotations - public ImmutableDictionary Annotations { get; } - } -} diff --git a/src/Bicep.Core/Registry/Oci/OciManifest.cs b/src/Bicep.Core/Registry/Oci/OciManifest.cs deleted file mode 100644 index bf39f246468..00000000000 --- a/src/Bicep.Core/Registry/Oci/OciManifest.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -using System.Collections.Generic; -using System.Collections.Immutable; - -namespace Bicep.Core.Registry.Oci -{ - public class OciManifest - { - // TODO: Add top-level annotations - public OciManifest(int schemaVersion, OciDescriptor config, IEnumerable layers) - { - this.SchemaVersion = schemaVersion; - this.Config = config; - this.Layers = layers.ToImmutableArray(); - } - - public int SchemaVersion { get; } - - public OciDescriptor Config { get; } - - public ImmutableArray Layers { get; } - } -} diff --git a/src/Bicep.Core/Registry/Oci/OciManifestSerialization.cs b/src/Bicep.Core/Registry/Oci/OciManifestSerialization.cs deleted file mode 100644 index 73f377185d9..00000000000 --- a/src/Bicep.Core/Registry/Oci/OciManifestSerialization.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -using Newtonsoft.Json.Serialization; -using Newtonsoft.Json; -using System; -using System.IO; -using System.Text; - -namespace Bicep.Core.Registry.Oci -{ - public class OciManifestSerialization - { - private static readonly Encoding ManifestEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false); - - public static OciManifest DeserializeManifest(Stream stream) - { - using var streamReader = new StreamReader(stream, ManifestEncoding, detectEncodingFromByteOrderMarks: true, bufferSize: -1, leaveOpen: true); - using var reader = new JsonTextReader(streamReader); - - var serializer = CreateSerializer(); - var manifest = serializer.Deserialize(reader); - - return manifest ?? throw new InvalidOperationException("Manifest is null"); - } - - public static void SerializeManifest(Stream stream, OciManifest manifest) - { - using var streamWriter = new StreamWriter(stream, ManifestEncoding, bufferSize: -1, leaveOpen: true); - using var writer = new JsonTextWriter(streamWriter); - - var serializer = CreateSerializer(); - serializer.Serialize(writer, manifest); - } - - private static JsonSerializer CreateSerializer() - { - return JsonSerializer.Create(new JsonSerializerSettings - { - ContractResolver = new CamelCasePropertyNamesContractResolver(), - NullValueHandling = NullValueHandling.Ignore, - TypeNameHandling = TypeNameHandling.None - }); - } - } -} diff --git a/src/Bicep.Core/Registry/Oci/StreamDescriptor.cs b/src/Bicep.Core/Registry/Oci/StreamDescriptor.cs index d490ccc4983..23fa9536a31 100644 --- a/src/Bicep.Core/Registry/Oci/StreamDescriptor.cs +++ b/src/Bicep.Core/Registry/Oci/StreamDescriptor.cs @@ -9,19 +9,16 @@ namespace Bicep.Core.Registry.Oci { public class StreamDescriptor { - public StreamDescriptor(Stream stream, string mediaType, IDictionary? annotations = null) + public StreamDescriptor(Stream stream, string mediaType) { Stream = stream; MediaType = mediaType; - Annotations = annotations?.ToImmutableDictionary() ?? ImmutableDictionary.Empty; } public Stream Stream { get; } public string MediaType { get; } - public ImmutableDictionary Annotations { get; } - public void ResetStream() => this.Stream.Position = 0; } } diff --git a/src/Bicep.Core/packages.lock.json b/src/Bicep.Core/packages.lock.json index eb43f30425d..bee51f8bc05 100644 --- a/src/Bicep.Core/packages.lock.json +++ b/src/Bicep.Core/packages.lock.json @@ -131,6 +131,22 @@ "System.Memory": "4.5.4" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Microsoft.Bcl.AsyncInterfaces": { "type": "Transitive", "resolved": "5.0.0", @@ -1439,25 +1455,10 @@ "System.Xml.XmlDocument": "4.3.0" } }, - "azure.containers.containerregistry": { + "bicep.core.registryclient": { "type": "Project", "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" + "Azure.Core": "1.14.0" } } }, diff --git a/src/Bicep.Decompiler.IntegrationTests/packages.lock.json b/src/Bicep.Decompiler.IntegrationTests/packages.lock.json index 5b0a709647e..9a6f0d5735b 100644 --- a/src/Bicep.Decompiler.IntegrationTests/packages.lock.json +++ b/src/Bicep.Decompiler.IntegrationTests/packages.lock.json @@ -75,6 +75,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2191,37 +2207,16 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2229,6 +2224,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.core.unittests": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Decompiler.UnitTests/packages.lock.json b/src/Bicep.Decompiler.UnitTests/packages.lock.json index 5b0a709647e..9a6f0d5735b 100644 --- a/src/Bicep.Decompiler.UnitTests/packages.lock.json +++ b/src/Bicep.Decompiler.UnitTests/packages.lock.json @@ -75,6 +75,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2191,37 +2207,16 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2229,6 +2224,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.core.unittests": { "type": "Project", "dependencies": { diff --git a/src/Bicep.Decompiler/packages.lock.json b/src/Bicep.Decompiler/packages.lock.json index 01348ad59d4..4ab8991b2f5 100644 --- a/src/Bicep.Decompiler/packages.lock.json +++ b/src/Bicep.Decompiler/packages.lock.json @@ -55,6 +55,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -1425,43 +1441,28 @@ "System.Xml.XmlDocument": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", "Newtonsoft.Json": "13.0.1", "System.Collections.Immutable": "5.0.0" } + }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } } }, ".NETStandard,Version=v2.1/linux-musl-x64": { diff --git a/src/Bicep.LangServer.IntegrationTests/packages.lock.json b/src/Bicep.LangServer.IntegrationTests/packages.lock.json index 9ae3ded0a05..19d245f2694 100644 --- a/src/Bicep.LangServer.IntegrationTests/packages.lock.json +++ b/src/Bicep.LangServer.IntegrationTests/packages.lock.json @@ -97,6 +97,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2205,27 +2221,6 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep": { "type": "Project", "dependencies": { @@ -2240,11 +2235,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2252,6 +2247,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.core.samples": { "type": "Project", "dependencies": { diff --git a/src/Bicep.LangServer.UnitTests/packages.lock.json b/src/Bicep.LangServer.UnitTests/packages.lock.json index 9ae3ded0a05..19d245f2694 100644 --- a/src/Bicep.LangServer.UnitTests/packages.lock.json +++ b/src/Bicep.LangServer.UnitTests/packages.lock.json @@ -97,6 +97,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -2205,27 +2221,6 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep": { "type": "Project", "dependencies": { @@ -2240,11 +2235,11 @@ "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -2252,6 +2247,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.core.samples": { "type": "Project", "dependencies": { diff --git a/src/Bicep.LangServer/packages.lock.json b/src/Bicep.LangServer/packages.lock.json index c18a44ed4d4..3d325c3bbf1 100644 --- a/src/Bicep.LangServer/packages.lock.json +++ b/src/Bicep.LangServer/packages.lock.json @@ -42,6 +42,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -532,43 +548,28 @@ "resolved": "4.5.3", "contentHash": "+MvhNtcvIbqmhANyKu91jQnvIRVSTiaOiFNfKWwXGHG48YAb4I/TyH8spsySiPYla7gKal5ZnF3teJqZAximyQ==" }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", "Newtonsoft.Json": "13.0.1", "System.Collections.Immutable": "5.0.0" } + }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } } }, ".NETCoreApp,Version=v5.0/linux-musl-x64": { diff --git a/src/Bicep.Wasm/packages.lock.json b/src/Bicep.Wasm/packages.lock.json index 1d0c410d30f..245a300f337 100644 --- a/src/Bicep.Wasm/packages.lock.json +++ b/src/Bicep.Wasm/packages.lock.json @@ -49,6 +49,22 @@ "Azure.Bicep.Types": "0.1.245" } }, + "Azure.Core": { + "type": "Transitive", + "resolved": "1.14.0", + "contentHash": "kUMUOZX4FcmfHmy7OjyP5LovO5FMXco9uUYB76l77mtqMVbZ0cLobv+XCy/j6LpStc8cZo2sI1+dMXhk0YROEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "1.0.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.6.0", + "System.Memory": "4.5.4", + "System.Memory.Data": "1.0.2", + "System.Numerics.Vectors": "4.5.0", + "System.Text.Encodings.Web": "4.7.2", + "System.Text.Json": "4.6.0", + "System.Threading.Tasks.Extensions": "4.5.2" + } + }, "Azure.Deployments.Core": { "type": "Transitive", "resolved": "1.0.207", @@ -355,37 +371,16 @@ "resolved": "4.5.2", "contentHash": "BG/TNxDFv0svAzx8OiMXDlsHfGw623BZ8tCXw4YLhDFDvDhNUEV58jKYMGRnkbJNm7c3JNNJDiN7JBMzxRBR2w==" }, - "azure.containers.containerregistry": { - "type": "Project", - "dependencies": { - "Azure.Core": "1.19.0-alpha.20210827.1", - "System.Text.Json": "4.6.0" - } - }, - "azure.core": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "1.0.0", - "System.Buffers": "4.5.1", - "System.Diagnostics.DiagnosticSource": "4.6.0", - "System.Memory": "4.5.4", - "System.Memory.Data": "1.0.2", - "System.Numerics.Vectors": "4.5.0", - "System.Text.Encodings.Web": "4.7.2", - "System.Text.Json": "4.6.0", - "System.Threading.Tasks.Extensions": "4.5.2" - } - }, "bicep.core": { "type": "Project", "dependencies": { "Azure.Bicep.Types": "0.1.245", "Azure.Bicep.Types.Az": "0.1.245", - "Azure.Containers.ContainerRegistry": "1.0.0-alpha.20210830.1", "Azure.Deployments.Core": "1.0.207", "Azure.Deployments.Expression": "1.0.207", "Azure.Deployments.Templates": "1.0.207", "Azure.Identity": "1.4.0", + "Bicep.Core.RegistryClient": "1.0.0", "Microsoft.Extensions.Configuration": "5.0.0", "Microsoft.Extensions.Configuration.Binder": "5.0.0", "Microsoft.Extensions.Configuration.Json": "5.0.0", @@ -393,6 +388,12 @@ "System.Collections.Immutable": "5.0.0" } }, + "bicep.core.registryclient": { + "type": "Project", + "dependencies": { + "Azure.Core": "1.14.0" + } + }, "bicep.decompiler": { "type": "Project", "dependencies": { From 387bad51f9eb24cf67b592878eb43459954dd8d7 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Thu, 2 Sep 2021 17:01:08 -0700 Subject: [PATCH 4/5] updates for 1.1.0-beta.1 API --- .../Registry/AzureContainerRegistryManager.cs | 32 ++++++------------- .../Registry/Oci/DescriptorFactory.cs | 9 ++++-- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs index f4f6ddaa094..e8e7da4835c 100644 --- a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs +++ b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs @@ -6,14 +6,11 @@ using Bicep.Core.Modules; using Bicep.Core.Registry.Oci; using Azure.Containers.ContainerRegistry.Specialized; -//using Bicep.Core.RegistryClient; -//using Bicep.Core.RegistryClient.Models; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; -//using UploadManifestOptions = Bicep.Core.RegistryClient.UploadManifestOptions; namespace Bicep.Core.Registry { @@ -61,32 +58,28 @@ public async Task PushArtifactAsync(OciArtifactModuleReference moduleReference, var blobClient = this.CreateBlobClient(moduleReference); + var manifest = new OciManifest(); config.ResetStream(); var configDescriptor = DescriptorFactory.CreateDescriptor(algorithmIdentifier, config); config.ResetStream(); var configUploadResult = await blobClient.UploadBlobAsync(config.Stream); + manifest.Config = configDescriptor; - var layerDescriptors = new List(layers.Length); + var layerDescriptors = new List(layers.Length); foreach (var layer in layers) { layer.ResetStream(); var layerDescriptor = DescriptorFactory.CreateDescriptor(algorithmIdentifier, layer); - layerDescriptors.Add(layerDescriptor); layer.ResetStream(); var layerUploadResult = await blobClient.UploadBlobAsync(layer.Stream); - } - - var manifest = new OciManifest(configDescriptor, layerDescriptors); - using var manifestStream = new MemoryStream(); - // TODO: do this serialization in an overload on blobClient - //OciManifestSerialization.SerializeManifest(manifestStream, manifest); + manifest.Layers.Add(layerDescriptor); + } - manifestStream.Position = 0; // BUG: the client closes the stream :( - var manifestUploadResult = await blobClient.UploadManifestAsync(manifestStream, new UploadManifestOptions() { Tag = moduleReference.Tag }); + var manifestUploadResult = await blobClient.UploadManifestAsync(manifest, new UploadManifestOptions() { Tag = moduleReference.Tag }); } public string GetLocalPackageDirectory(OciArtifactModuleReference reference) @@ -142,7 +135,7 @@ private static async Task DownloadManifestAsync(OciArtifactModuleRe Response manifestResponse; try { - manifestResponse = await client.DownloadManifestAsync(moduleReference.Tag, new DownloadManifestOptions()); + manifestResponse = await client.DownloadManifestAsync(moduleReference.Tag); } catch(RequestFailedException exception) when (exception.Status == 404) { @@ -150,12 +143,7 @@ private static async Task DownloadManifestAsync(OciArtifactModuleRe throw new AcrManagerException("The module does not exist in the registry.", exception); } - // the SDK doesn't expose all the manifest properties we need - // so we need to deserialize the manifest ourselves to get everything - var stream = manifestResponse.Value.Content; - // TODO: Get this from the DownloadManifest overload - //stream.Position = 0; - //return DeserializeManifest(stream); + return manifestResponse.Value.Manifest; } private static async Task ProcessManifest(ContainerRegistryBlobClient client, OciManifest manifest, string modulePath) @@ -171,7 +159,7 @@ private static async Task ProcessManifest(ContainerRegistryBlobClient client, Oc await ProcessLayer(client, layer, modulePath); } - private static async Task ProcessLayer(ContainerRegistryBlobClient client, ArtifactBlobDescriptor layer, string modulePath) + private static async Task ProcessLayer(ContainerRegistryBlobClient client, OciBlobDescriptor layer, string modulePath) { if(!string.Equals(layer.MediaType, BicepMediaTypes.BicepModuleLayerV1Json, MediaTypeComparison)) { @@ -194,7 +182,7 @@ private static async Task ProcessLayer(ContainerRegistryBlobClient client, Artif await blobResult.Value.Content.CopyToAsync(fileStream); } - private static void ProcessConfig(ArtifactBlobDescriptor config) + private static void ProcessConfig(OciBlobDescriptor config) { // media types are case insensitive if(!string.Equals(config.MediaType, BicepMediaTypes.BicepModuleConfigV1, MediaTypeComparison)) diff --git a/src/Bicep.Core/Registry/Oci/DescriptorFactory.cs b/src/Bicep.Core/Registry/Oci/DescriptorFactory.cs index 1824bc265e3..6c69caabcf4 100644 --- a/src/Bicep.Core/Registry/Oci/DescriptorFactory.cs +++ b/src/Bicep.Core/Registry/Oci/DescriptorFactory.cs @@ -14,11 +14,16 @@ public static class DescriptorFactory public const string AlgorithmIdentifierSha256 = "sha256"; public const string AlgorithmIdentifierSha512 = "sha512"; - public static ArtifactBlobDescriptor CreateDescriptor(string algorithmIdentifier, StreamDescriptor streamDescriptor) + public static OciBlobDescriptor CreateDescriptor(string algorithmIdentifier, StreamDescriptor streamDescriptor) { var digest = ComputeDigest(algorithmIdentifier, streamDescriptor.Stream); - return new ArtifactBlobDescriptor(streamDescriptor.MediaType, digest, streamDescriptor.Stream.Length); + return new OciBlobDescriptor() + { + MediaType = streamDescriptor.MediaType, + Digest = digest, + Size = streamDescriptor.Stream.Length + }; } private static string ComputeDigest(string algorithmIdentifier, Stream stream) From 8b62687c6db2c334904ffea9adc9b19a3b7100f4 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Tue, 7 Sep 2021 11:31:18 -0700 Subject: [PATCH 5/5] download manifest by tag --- src/Bicep.Core/Registry/AzureContainerRegistryManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs index e8e7da4835c..579b4a92436 100644 --- a/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs +++ b/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs @@ -11,6 +11,8 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using Azure.Containers.ContainerRegistry; +using Azure.Identity; namespace Bicep.Core.Registry { @@ -135,7 +137,9 @@ private static async Task DownloadManifestAsync(OciArtifactModuleRe Response manifestResponse; try { - manifestResponse = await client.DownloadManifestAsync(moduleReference.Tag); + ContainerRegistryClient registryClient = new ContainerRegistryClient(new Uri("example.azurecr.io"), new DefaultAzureCredential()); + var tagProperties = registryClient.GetArtifact(moduleReference.Repository, moduleReference.Tag).GetTagProperties(moduleReference.Tag); + manifestResponse = await client.DownloadManifestAsync(tagProperties.Value.Digest); } catch(RequestFailedException exception) when (exception.Status == 404) {