Skip to content

[ACR] Decouple reliance on Commands.Resources.Rest #5805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ CLRVersion = '4.0'
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '4.5.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.ContainerRegistry.dll',
'.\Microsoft.Azure.Management.ResourceManager.dll',
'.\Microsoft.Azure.Management.Storage.dll',
'.\Microsoft.Azure.Commands.ResourceManager.Cmdlets.dll'
RequiredAssemblies = '.\Microsoft.Azure.Management.ContainerRegistry.dll'

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
Expand All @@ -75,7 +72,8 @@ NestedModules = @('.\Microsoft.Azure.Commands.ContainerRegistry.dll')
FunctionsToExport = @()

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = 'New-AzureRmContainerRegistry', 'Get-AzureRmContainerRegistry',
CmdletsToExport = 'New-AzureRmContainerRegistry',
'Get-AzureRmContainerRegistry',
'Update-AzureRmContainerRegistry',
'Remove-AzureRmContainerRegistry',
'Get-AzureRmContainerRegistryCredential',
Expand Down
1 change: 1 addition & 0 deletions src/ResourceManager/ContainerRegistry/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Current Release
* Decouple reliance on Commands.Resources.Rest and ARM/Storage SDKs.

## Version 1.0.3
* Fix issue with Default Resource Group in CloudShell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.6.0-preview\lib\net452\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.Framework">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.6179.26854-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,26 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.IO;
using System.Linq;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Management.ContainerRegistry;
using Microsoft.Azure.Management.Storage;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using InternalResourceManagementClient = Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient;
using ResourceManagementClient = Microsoft.Azure.Management.ResourceManager.ResourceManagementClient;
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
using TestUtilities = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.ContainerRegistry.Test.ScenarioTests
{
public class TestController
{
private EnvironmentSetupHelper helper;

public ContainerRegistryManagementClient ContainerRegistryClient { get; private set; }

public StorageManagementClient StorageClient { get; private set; }

public ResourceManagementClient ResourceClient { get; private set; }

public TestController()
{
helper = new EnvironmentSetupHelper();
Expand All @@ -53,10 +47,10 @@ public static TestController NewInstance

private void SetupManagementClients(MockContext context)
{
ContainerRegistryClient = GetContainerRegistryManagementClient(context);
StorageClient = GetStorageManagementClient(context);
ResourceClient = GetResourceManagementClient(context);
helper.SetupManagementClients(ContainerRegistryClient, StorageClient, ResourceClient);
helper.SetupManagementClients(
context.GetServiceClient<ContainerRegistryManagementClient>(TestEnvironmentFactory.GetTestEnvironment()),
context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment()),
context.GetServiceClient<InternalResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment()));
}

public void RunPowerShellTest(params string[] scripts)
Expand All @@ -68,7 +62,6 @@ public void RunPowerShellTest(params string[] scripts)
d.Add("Microsoft.Resources", null);
d.Add("Microsoft.Features", null);
d.Add("Microsoft.Authorization", null);
d.Add("Microsoft.Compute", null);
var providersToIgnore = new Dictionary<string, string>();
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
Expand All @@ -94,20 +87,5 @@ public void RunPowerShellTest(params string[] scripts)
}
}
}

private ContainerRegistryManagementClient GetContainerRegistryManagementClient(MockContext context)
{
return context.GetServiceClient<ContainerRegistryManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
}

private StorageManagementClient GetStorageManagementClient(MockContext context)
{
return context.GetServiceClient<StorageManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
}

private ResourceManagementClient GetResourceManagementClient(MockContext context)
{
return context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
}
}
}
155,472 changes: 1,170 additions & 154,302 deletions ...ntainerRegistry.Test.ScenarioTests.ContainerRegistryTests/TestAzureContainerRegistry.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"Entries": [
{
"RequestUri": "/subscriptions/474240ee-c2a4-4373-bc0d-bd2e3dba4714/providers/Microsoft.ContainerRegistry/checkNameAvailability?api-version=2017-10-01",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNDc0MjQwZWUtYzJhNC00MzczLWJjMGQtYmQyZTNkYmE0NzE0L3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVyUmVnaXN0cnkvY2hlY2tOYW1lQXZhaWxhYmlsaXR5P2FwaS12ZXJzaW9uPTIwMTctMTAtMDE=",
"RequestUri": "/subscriptions/84c559c6-30a0-417c-ba06-8a2253b388c3/providers/Microsoft.ContainerRegistry/checkNameAvailability?api-version=2017-10-01",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODRjNTU5YzYtMzBhMC00MTdjLWJhMDYtOGEyMjUzYjM4OGMzL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVyUmVnaXN0cnkvY2hlY2tOYW1lQXZhaWxhYmlsaXR5P2FwaS12ZXJzaW9uPTIwMTctMTAtMDE=",
"RequestMethod": "POST",
"RequestBody": "{\r\n \"name\": \"regps3697\",\r\n \"type\": \"Microsoft.ContainerRegistry/registries\"\r\n}",
"RequestBody": "{\r\n \"name\": \"regps3538\",\r\n \"type\": \"Microsoft.ContainerRegistry/registries\"\r\n}",
"RequestHeaders": {
"Content-Type": [
"application/json; charset=utf-8"
Expand All @@ -13,15 +13,15 @@
"80"
],
"x-ms-client-request-id": [
"9f170182-bc94-48d0-a0fc-ee2ecc6ae9e2"
"5f388704-861d-4277-af82-ae3d3243ff02"
],
"accept-language": [
"en-US"
],
"User-Agent": [
"FxVersion/4.7.2117.0",
"OSName/WindowsServer2016Datacenter",
"OSVersion/6.3.14393",
"FxVersion/4.7.2633.0",
"OSName/Windows10Enterprise",
"OSVersion/6.3.16299",
"Microsoft.Azure.Management.ContainerRegistry.ContainerRegistryManagementClient/2.0.0.0"
]
},
Expand All @@ -43,22 +43,25 @@
"max-age=31536000; includeSubDomains"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"14998"
"14969"
],
"x-ms-request-id": [
"d2d34a49-83d8-434c-bddb-cd0d3412fae8"
"31caa2ad-5c45-406d-bea4-36e4cd898149"
],
"x-ms-correlation-request-id": [
"d2d34a49-83d8-434c-bddb-cd0d3412fae8"
"31caa2ad-5c45-406d-bea4-36e4cd898149"
],
"x-ms-routing-request-id": [
"WESTUS2:20171120T191819Z:d2d34a49-83d8-434c-bddb-cd0d3412fae8"
"WESTUS2:20180326T235648Z:31caa2ad-5c45-406d-bea4-36e4cd898149"
],
"X-Content-Type-Options": [
"nosniff"
],
"Cache-Control": [
"no-cache"
],
"Date": [
"Mon, 20 Nov 2017 19:18:19 GMT"
"Mon, 26 Mar 2018 23:56:47 GMT"
],
"Server": [
"Microsoft-HTTPAPI/2.0"
Expand All @@ -67,8 +70,8 @@
"StatusCode": 200
},
{
"RequestUri": "/subscriptions/474240ee-c2a4-4373-bc0d-bd2e3dba4714/providers/Microsoft.ContainerRegistry/checkNameAvailability?api-version=2017-10-01",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNDc0MjQwZWUtYzJhNC00MzczLWJjMGQtYmQyZTNkYmE0NzE0L3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVyUmVnaXN0cnkvY2hlY2tOYW1lQXZhaWxhYmlsaXR5P2FwaS12ZXJzaW9uPTIwMTctMTAtMDE=",
"RequestUri": "/subscriptions/84c559c6-30a0-417c-ba06-8a2253b388c3/providers/Microsoft.ContainerRegistry/checkNameAvailability?api-version=2017-10-01",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODRjNTU5YzYtMzBhMC00MTdjLWJhMDYtOGEyMjUzYjM4OGMzL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVyUmVnaXN0cnkvY2hlY2tOYW1lQXZhaWxhYmlsaXR5P2FwaS12ZXJzaW9uPTIwMTctMTAtMDE=",
"RequestMethod": "POST",
"RequestBody": "{\r\n \"name\": \"Microsoft\",\r\n \"type\": \"Microsoft.ContainerRegistry/registries\"\r\n}",
"RequestHeaders": {
Expand All @@ -79,15 +82,15 @@
"80"
],
"x-ms-client-request-id": [
"187d33e7-7bf5-4044-ad13-d97c5b9879f0"
"62d7703b-35b5-4557-9d8f-ae7a6656dfe9"
],
"accept-language": [
"en-US"
],
"User-Agent": [
"FxVersion/4.7.2117.0",
"OSName/WindowsServer2016Datacenter",
"OSVersion/6.3.14393",
"FxVersion/4.7.2633.0",
"OSName/Windows10Enterprise",
"OSVersion/6.3.16299",
"Microsoft.Azure.Management.ContainerRegistry.ContainerRegistryManagementClient/2.0.0.0"
]
},
Expand All @@ -109,22 +112,25 @@
"max-age=31536000; includeSubDomains"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"14997"
"14968"
],
"x-ms-request-id": [
"87de9584-8d5e-4d50-9720-b9847755c8b4"
"6ff77e99-bf2e-4d84-82d9-566cb990b01a"
],
"x-ms-correlation-request-id": [
"87de9584-8d5e-4d50-9720-b9847755c8b4"
"6ff77e99-bf2e-4d84-82d9-566cb990b01a"
],
"x-ms-routing-request-id": [
"WESTUS2:20171120T191819Z:87de9584-8d5e-4d50-9720-b9847755c8b4"
"WESTUS2:20180326T235648Z:6ff77e99-bf2e-4d84-82d9-566cb990b01a"
],
"X-Content-Type-Options": [
"nosniff"
],
"Cache-Control": [
"no-cache"
],
"Date": [
"Mon, 20 Nov 2017 19:18:19 GMT"
"Mon, 26 Mar 2018 23:56:47 GMT"
],
"Server": [
"Microsoft-HTTPAPI/2.0"
Expand All @@ -135,10 +141,10 @@
],
"Names": {
"Test-AzureContainerRegistryNameAvailability": [
"ps3697"
"ps3538"
]
},
"Variables": {
"SubscriptionId": "474240ee-c2a4-4373-bc0d-bd2e3dba4714"
"SubscriptionId": "84c559c6-30a0-417c-ba06-8a2253b388c3"
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ContainerRegistry" version="2.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="6.5.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@
<Reference Include="Microsoft.Azure.Management.ContainerRegistry, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerRegistry.2.0.0\lib\net452\Microsoft.Azure.Management.ContainerRegistry.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.6.0-preview\lib\net452\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -118,10 +111,6 @@
<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
<Name>Commands.ResourceManager.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\Resources\Commands.ResourceManager\Cmdlets\Commands.Resources.Rest.csproj">
<Project>{8058d403-06e3-4bed-8924-d166ce303961}</Project>
<Name>Commands.Resources.Rest</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\..\..\tools\Common.Dependencies.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using System.Collections.Generic;
using System.Management.Automation;

Expand All @@ -23,6 +24,7 @@ public class GetAzureContainerRegistry : ContainerRegistryCmdletBase
{
[Parameter(Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ListRegistriesParameterSet, HelpMessage = "Resource Group Name.")]
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = RegistryNameParameterSet, HelpMessage = "Resource Group Name.")]
[ResourceGroupCompleter()]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

Expand Down Expand Up @@ -50,7 +52,7 @@ public override void ExecuteCmdlet()
if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId))
{
string resourceGroup, registryName, childResourceName;
if(!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName))
if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName))
{
WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage);
return;
Expand Down Expand Up @@ -81,7 +83,7 @@ private void ListRegistry()

if (IncludeDetail)
{
foreach(var psr in psRegistries)
foreach (var psr in psRegistries)
{
SetRegistryDetials(psr);
}
Expand All @@ -91,7 +93,7 @@ private void ListRegistry()

private void SetRegistryDetials(PSContainerRegistry registry)
{
if(!string.IsNullOrEmpty(registry.ResourceGroupName) && !string.IsNullOrEmpty(registry.Name))
if (!string.IsNullOrEmpty(registry.ResourceGroupName) && !string.IsNullOrEmpty(registry.Name))
{
registry.Usages = RegistryClient.ListRegistryUsage(registry.ResourceGroupName, registry.Name)?.Value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace Microsoft.Azure.Commands.ContainerRegistry
public class GetAzureContainerRegistryCredential : ContainerRegistryCmdletBase
{
[Parameter(Position = 0, Mandatory = true, ParameterSetName = NameResourceGroupParameterSet, HelpMessage = "Resource Group Name.")]
[ResourceGroupCompleter()]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

Expand Down Expand Up @@ -49,7 +50,7 @@ public override void ExecuteCmdlet()
else if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId))
{
string resourceGroup, registryName, childResourceName;
if(!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName))
if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName))
{
WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage);
return;
Expand Down
Loading