Skip to content

Commit de2e66c

Browse files
authored
add ACR repository operations (#13946)
* add ACR repository operations * add shouldprocess * implement iazuresessioncomponentlistener * add comments and exception * fix cache impl * resolve comments * getlastlisted * remove unused class * remove unneeded changes * fix null reference in PSAcrManifest and remove unused suppression * Update ChangeLog.md * fix Acr to ACR in help markdown * fix output type for Get-AzContainerRegistryRepository
1 parent 6c87ccf commit de2e66c

File tree

53 files changed

+3742
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3742
-36
lines changed

src/ContainerRegistry/ContainerRegistry.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio 15
3-
VisualStudioVersion = 15.0.27703.2042
2+
# Visual Studio Version 16
3+
VisualStudioVersion = 16.0.30816.121
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContainerRegistry", "ContainerRegistry\ContainerRegistry.csproj", "{FE330703-623A-4C08-9DA7-1C63B4058034}"
66
EndProject

src/ContainerRegistry/ContainerRegistry/Az.ContainerRegistry.psd1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,16 @@ CmdletsToExport = 'New-AzContainerRegistry', 'Get-AzContainerRegistry',
9090
'Get-AzContainerRegistryWebhookEvent',
9191
'Import-AzContainerRegistryImage', 'Get-AzContainerRegistryUsage',
9292
'Set-AzContainerRegistryNetworkRuleSet',
93-
'New-AzContainerRegistryNetworkRule', 'Connect-AzContainerRegistry'
93+
'New-AzContainerRegistryNetworkRule', 'Connect-AzContainerRegistry',
94+
'Get-AzContainerRegistryRepository',
95+
'Remove-AzContainerRegistryRepository',
96+
'Update-AzContainerRegistryRepository',
97+
'Get-AzContainerRegistryManifest',
98+
'Remove-AzContainerRegistryManifest',
99+
'Update-AzContainerRegistryManifest',
100+
'Get-AzContainerRegistryTag',
101+
'Update-AzContainerRegistryTag',
102+
'Remove-AzContainerRegistryTag'
94103

95104
# Variables to export from this module
96105
# VariablesToExport = @()

src/ContainerRegistry/ContainerRegistry/ChangeLog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added cmdlets to supported repository, manifest, and tag operations:
22+
- `Get-AzContainerRegistryRepository`
23+
- `Update-AzContainerRegistryRepository`
24+
- `Remove-AzContainerRegistryRepository`
25+
- `Get-AzContainerRegistryManifest`
26+
- `Update-AzContainerRegistryManifest`
27+
- `Remove-AzContainerRegistryManifest`
28+
- `Get-AzContainerRegistryTag`
29+
- `Update-AzContainerRegistryTag`
30+
- `Remove-AzContainerRegistryTag`
2131

2232
## Version 2.1.0
2333
* Supported parameter `Name` for and value from pipeline input for `Get-AzContainerRegistryUsage` [#13605]

src/ContainerRegistry/ContainerRegistry/Commands/ConnectAzureContainerRegistry.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
16-
using Microsoft.WindowsAzure.Commands.Common;
1715
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1816
using System;
19-
using System.Collections.Generic;
20-
using System.Linq;
2117
using System.Management.Automation;
2218
using System.Text.RegularExpressions;
2319

@@ -27,8 +23,12 @@ namespace Microsoft.Azure.Commands.ContainerRegistry
2723
[OutputType(typeof(bool))]
2824
public class ConnectAzureContainerRegistry : ContainerRegistryCmdletBase
2925
{
26+
protected const string WithoutNameAndPasswordParameterSet = "WithoutNameAndPasswordParameterSet";
27+
protected const string WithNameAndPasswordParameterSet = "WithNameAndPasswordParameterSet";
28+
3029
[Parameter(Mandatory = true, HelpMessage = "Azure Container Registry Name.", ParameterSetName = WithoutNameAndPasswordParameterSet)]
3130
[Parameter(Mandatory = true, HelpMessage = "Azure Container Registry Name.", ParameterSetName = WithNameAndPasswordParameterSet)]
31+
[Alias("RegistryName")]
3232
[ValidateNotNullOrEmpty]
3333
public string Name { get; set; }
3434

@@ -40,8 +40,6 @@ public class ConnectAzureContainerRegistry : ContainerRegistryCmdletBase
4040
[ValidateNotNullOrEmpty]
4141
public string Password { get; set; }
4242

43-
private RecordingTracingInterceptor _httpTracingInterceptor { get; set; }
44-
4543
protected override void InitDebuggingFilter()
4644
{
4745
AddDebuggingFilter(new Regex("(\\s*access_token\\s*=\\s*)[^\"]+"));
@@ -57,7 +55,7 @@ public override void ExecuteCmdlet() {
5755
if (ParameterSetName.Equals(WithoutNameAndPasswordParameterSet))
5856
{
5957
this.UserName = new Guid().ToString();
60-
this.Password = this.RegistryDataPlaneClient.GetRefreshToken();
58+
this.Password = this.RegistryDataPlaneClient.Authenticate();
6159
}
6260

6361
string LoginScript = string.Format("'{2}' | docker login {0} -u {1} --password-stdin", this.RegistryDataPlaneClient.GetEndPoint(), this.UserName, this.Password);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.ContainerRegistry.Models;
16+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
17+
using System.Management.Automation;
18+
19+
namespace Microsoft.Azure.Commands.ContainerRegistry
20+
{
21+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryRepository", DefaultParameterSetName = ListParameterSet)]
22+
[OutputType(typeof(string), typeof(PSRepositoryAttribute))]
23+
public class GetAzureContainerRegistryRepository : ContainerRegistryDataPlaneCmdletBase
24+
{
25+
[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
26+
[ValidateNotNullOrEmpty]
27+
public string Name { get; set; }
28+
29+
[Parameter(ParameterSetName = ListParameterSet, Mandatory = false, HelpMessage = "First n results.")]
30+
[ValidateNotNullOrEmpty]
31+
public int? First { get; set; } = null;
32+
33+
public override void ExecuteChildCmdlet()
34+
{
35+
if (this.IsParameterBound(c => c.Name))
36+
{
37+
WriteObject(this.RegistryDataPlaneClient.GetRepository(Name));
38+
}
39+
else
40+
{
41+
WriteObject(this.RegistryDataPlaneClient.ListRepository(First), true);
42+
}
43+
}
44+
}
45+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.ContainerRegistry.Models;
16+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
17+
using System.Management.Automation;
18+
19+
namespace Microsoft.Azure.Commands.ContainerRegistry
20+
{
21+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryTag", DefaultParameterSetName = ListParameterSet)]
22+
[OutputType(typeof(PSTagAttribute), typeof(PSTagList))]
23+
public class GetAzureContainerRegistryTag : ContainerRegistryDataPlaneCmdletBase
24+
{
25+
[Parameter(ParameterSetName = ListParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
26+
[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
27+
[ValidateNotNullOrEmpty]
28+
public string RepositoryName { get; set; }
29+
30+
[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Tag.")]
31+
[ValidateNotNullOrEmpty]
32+
public string Name { get; set; }
33+
34+
public override void ExecuteChildCmdlet()
35+
{
36+
if (this.IsParameterBound(c => c.Name))
37+
{
38+
WriteObject(this.RegistryDataPlaneClient.GetTag(RepositoryName, Name));
39+
}
40+
else
41+
{
42+
WriteObject(this.RegistryDataPlaneClient.ListTag(RepositoryName), true);
43+
}
44+
}
45+
}
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.ContainerRegistry.Models;
16+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
17+
using System.Management.Automation;
18+
19+
namespace Microsoft.Azure.Commands.ContainerRegistry
20+
{
21+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryManifest", DefaultParameterSetName = ListParameterSet)]
22+
[OutputType(typeof(PSManifestAttribute), typeof(PSAcrManifest))]
23+
public class GetAzureContainerRegistryManifest : ContainerRegistryDataPlaneCmdletBase
24+
{
25+
[Parameter(ParameterSetName = ListParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
26+
[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
27+
[ValidateNotNullOrEmpty]
28+
public string RepositoryName { get; set; }
29+
30+
[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Manifest reference.")]
31+
[ValidateNotNullOrEmpty]
32+
public string Name { get; set; }
33+
34+
public override void ExecuteChildCmdlet()
35+
{
36+
if (this.IsParameterBound(c => c.Name))
37+
{
38+
WriteObject(this.RegistryDataPlaneClient.GetManifest(RepositoryName, Name));
39+
}
40+
else
41+
{
42+
WriteObject(this.RegistryDataPlaneClient.ListManifest(RepositoryName), true);
43+
}
44+
}
45+
}
46+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Management.Automation;
16+
17+
namespace Microsoft.Azure.Commands.ContainerRegistry.Commands
18+
{
19+
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryManifest", DefaultParameterSetName = ByManifestParameterSet, SupportsShouldProcess = true)]
20+
[OutputType(typeof(bool))]
21+
public class RemoveAzureContainerRegistryManifest : ContainerRegistryDataPlaneCmdletBase
22+
{
23+
[Parameter(Mandatory = true, ParameterSetName = ByManifestParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
24+
[Parameter(Mandatory = true, ParameterSetName = ByTagParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
25+
[ValidateNotNullOrEmpty]
26+
public string RepositoryName { get; set; }
27+
28+
[Parameter(Mandatory = true, ParameterSetName = ByManifestParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Manifest reference.")]
29+
[ValidateNotNullOrEmpty]
30+
public string Manifest { get; set; }
31+
32+
[Parameter(Mandatory = true, ParameterSetName = ByTagParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Tag.")]
33+
[ValidateNotNullOrEmpty]
34+
public string Tag { get; set; }
35+
36+
public override void ExecuteChildCmdlet()
37+
{
38+
if (ParameterSetName.Equals(ByManifestParameterSet))
39+
{
40+
if (this.ShouldProcess(string.Format("Delete manitest {0}@{1} under {2}", this.RepositoryName, this.Manifest, this.RegistryName)))
41+
{
42+
WriteObject(this.RegistryDataPlaneClient.RemoveManifest(this.RepositoryName, this.Manifest));
43+
}
44+
}
45+
else if (ParameterSetName.Equals(ByTagParameterSet))
46+
{
47+
if (this.ShouldProcess(string.Format("Delete manitest for {0}:{1} under {2}", this.RepositoryName, this.Tag, this.RegistryName)))
48+
{
49+
WriteObject(this.RegistryDataPlaneClient.RemoveManifestByTag(this.RepositoryName, this.Tag));
50+
}
51+
}
52+
else
53+
{
54+
throw new PSArgumentException("Invalid parameter set");
55+
}
56+
}
57+
}
58+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.ContainerRegistry.Models;
16+
using System.Management.Automation;
17+
18+
namespace Microsoft.Azure.Commands.ContainerRegistry.Commands
19+
{
20+
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryRepository", SupportsShouldProcess = true)]
21+
[OutputType(typeof(PSDeletedRepository))]
22+
public class RemoveAzureContainerRegistryRepository : ContainerRegistryDataPlaneCmdletBase
23+
{
24+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
25+
[ValidateNotNullOrEmpty]
26+
public string Name { get; set; }
27+
28+
public override void ExecuteChildCmdlet()
29+
{
30+
if (this.ShouldProcess(string.Format("Delete {0} under {1}", this.Name, this.RegistryName)))
31+
{
32+
WriteObject(this.RegistryDataPlaneClient.RemoveRepository(this.Name));
33+
}
34+
}
35+
}
36+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Management.Automation;
16+
17+
namespace Microsoft.Azure.Commands.ContainerRegistry.Commands
18+
{
19+
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryTag", SupportsShouldProcess = true)]
20+
[OutputType(typeof(bool))]
21+
public class RemoveAzureContainerRegistryTag : ContainerRegistryDataPlaneCmdletBase
22+
{
23+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
24+
[ValidateNotNullOrEmpty]
25+
public string RepositoryName { get; set; }
26+
27+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Tag.")]
28+
[ValidateNotNullOrEmpty]
29+
public string Name { get; set; }
30+
31+
public override void ExecuteChildCmdlet()
32+
{
33+
if (this.ShouldProcess(string.Format("Untag {0}:{1} under {2}", this.RepositoryName, this.Name, this.RegistryName)))
34+
{
35+
WriteObject(this.RegistryDataPlaneClient.RemoveTag(this.RepositoryName, this.Name));
36+
}
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)