Skip to content
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

add ACR repository operations #13946

Merged
merged 15 commits into from
Feb 2, 2021
Merged
4 changes: 2 additions & 2 deletions src/ContainerRegistry/ContainerRegistry.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
# Visual Studio Version 16
VisualStudioVersion = 16.0.30816.121
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContainerRegistry", "ContainerRegistry\ContainerRegistry.csproj", "{FE330703-623A-4C08-9DA7-1C63B4058034}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,16 @@ CmdletsToExport = 'New-AzContainerRegistry', 'Get-AzContainerRegistry',
'Get-AzContainerRegistryWebhookEvent',
'Import-AzContainerRegistryImage', 'Get-AzContainerRegistryUsage',
'Set-AzContainerRegistryNetworkRuleSet',
'New-AzContainerRegistryNetworkRule', 'Connect-AzContainerRegistry'
'New-AzContainerRegistryNetworkRule', 'Connect-AzContainerRegistry',
'Get-AzContainerRegistryRepository',
'Remove-AzContainerRegistryRepository',
'Update-AzContainerRegistryRepository',
'Get-AzContainerRegistryManifest',
'Remove-AzContainerRegistryManifest',
'Update-AzContainerRegistryManifest',
'Get-AzContainerRegistryTag',
'Update-AzContainerRegistryTag',
'Remove-AzContainerRegistryTag'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
10 changes: 10 additions & 0 deletions src/ContainerRegistry/ContainerRegistry/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
- Additional information about change #1
-->
## Upcoming Release
* Added cmdlets to supported repository, manifest, and tag operations:
- `Get-AzContainerRegistryRepository`
- `Update-AzContainerRegistryRepository`
- `Remove-AzContainerRegistryRepository`
- `Get-AzContainerRegistryManifest`
- `Update-AzContainerRegistryManifest`
- `Remove-AzContainerRegistryManifest`
- `Get-AzContainerRegistryTag`
- `Update-AzContainerRegistryTag`
- `Remove-AzContainerRegistryTag`

## Version 2.1.0
* Supported parameter `Name` for and value from pipeline input for `Get-AzContainerRegistryUsage` [#13605]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text.RegularExpressions;

Expand All @@ -27,8 +23,12 @@ namespace Microsoft.Azure.Commands.ContainerRegistry
[OutputType(typeof(bool))]
public class ConnectAzureContainerRegistry : ContainerRegistryCmdletBase
{
protected const string WithoutNameAndPasswordParameterSet = "WithoutNameAndPasswordParameterSet";
protected const string WithNameAndPasswordParameterSet = "WithNameAndPasswordParameterSet";

[Parameter(Mandatory = true, HelpMessage = "Azure Container Registry Name.", ParameterSetName = WithoutNameAndPasswordParameterSet)]
[Parameter(Mandatory = true, HelpMessage = "Azure Container Registry Name.", ParameterSetName = WithNameAndPasswordParameterSet)]
[Alias("RegistryName")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

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

private RecordingTracingInterceptor _httpTracingInterceptor { get; set; }

protected override void InitDebuggingFilter()
{
AddDebuggingFilter(new Regex("(\\s*access_token\\s*=\\s*)[^\"]+"));
Expand All @@ -57,7 +55,7 @@ public override void ExecuteCmdlet() {
if (ParameterSetName.Equals(WithoutNameAndPasswordParameterSet))
{
this.UserName = new Guid().ToString();
this.Password = this.RegistryDataPlaneClient.GetRefreshToken();
this.Password = this.RegistryDataPlaneClient.Authenticate();
}

string LoginScript = string.Format("'{2}' | docker login {0} -u {1} --password-stdin", this.RegistryDataPlaneClient.GetEndPoint(), this.UserName, this.Password);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ContainerRegistry.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.ContainerRegistry
{
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryRepository", DefaultParameterSetName = ListParameterSet)]
[OutputType(typeof(string), typeof(PSRepositoryAttribute))]
public class GetAzureContainerRegistryRepository : ContainerRegistryDataPlaneCmdletBase
{
[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(ParameterSetName = ListParameterSet, Mandatory = false, HelpMessage = "First n results.")]
[ValidateNotNullOrEmpty]
public int? First { get; set; } = null;

public override void ExecuteChildCmdlet()
{
if (this.IsParameterBound(c => c.Name))
{
WriteObject(this.RegistryDataPlaneClient.GetRepository(Name));
}
else
{
WriteObject(this.RegistryDataPlaneClient.ListRepository(First), true);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ContainerRegistry.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.ContainerRegistry
{
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryTag", DefaultParameterSetName = ListParameterSet)]
[OutputType(typeof(PSTagAttribute), typeof(PSTagList))]
public class GetAzureContainerRegistryTag : ContainerRegistryDataPlaneCmdletBase
{
[Parameter(ParameterSetName = ListParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
[ValidateNotNullOrEmpty]
public string RepositoryName { get; set; }

[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Tag.")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

public override void ExecuteChildCmdlet()
{
if (this.IsParameterBound(c => c.Name))
{
WriteObject(this.RegistryDataPlaneClient.GetTag(RepositoryName, Name));
}
else
{
WriteObject(this.RegistryDataPlaneClient.ListTag(RepositoryName), true);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ContainerRegistry.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.ContainerRegistry
{
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryManifest", DefaultParameterSetName = ListParameterSet)]
[OutputType(typeof(PSManifestAttribute), typeof(PSAcrManifest))]
public class GetAzureContainerRegistryManifest : ContainerRegistryDataPlaneCmdletBase
{
[Parameter(ParameterSetName = ListParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
[ValidateNotNullOrEmpty]
public string RepositoryName { get; set; }

[Parameter(ParameterSetName = GetParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Manifest reference.")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

public override void ExecuteChildCmdlet()
{
if (this.IsParameterBound(c => c.Name))
{
WriteObject(this.RegistryDataPlaneClient.GetManifest(RepositoryName, Name));
}
else
{
WriteObject(this.RegistryDataPlaneClient.ListManifest(RepositoryName), true);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Management.Automation;

namespace Microsoft.Azure.Commands.ContainerRegistry.Commands
{
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryManifest", DefaultParameterSetName = ByManifestParameterSet, SupportsShouldProcess = true)]
[OutputType(typeof(bool))]
public class RemoveAzureContainerRegistryManifest : ContainerRegistryDataPlaneCmdletBase
{
[Parameter(Mandatory = true, ParameterSetName = ByManifestParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
[Parameter(Mandatory = true, ParameterSetName = ByTagParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
[ValidateNotNullOrEmpty]
public string RepositoryName { get; set; }

[Parameter(Mandatory = true, ParameterSetName = ByManifestParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Manifest reference.")]
[ValidateNotNullOrEmpty]
public string Manifest { get; set; }

[Parameter(Mandatory = true, ParameterSetName = ByTagParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Tag.")]
[ValidateNotNullOrEmpty]
public string Tag { get; set; }

public override void ExecuteChildCmdlet()
{
if (ParameterSetName.Equals(ByManifestParameterSet))
{
if (this.ShouldProcess(string.Format("Delete manitest {0}@{1} under {2}", this.RepositoryName, this.Manifest, this.RegistryName)))
{
WriteObject(this.RegistryDataPlaneClient.RemoveManifest(this.RepositoryName, this.Manifest));
}
}
else if (ParameterSetName.Equals(ByTagParameterSet))
{
if (this.ShouldProcess(string.Format("Delete manitest for {0}:{1} under {2}", this.RepositoryName, this.Tag, this.RegistryName)))
{
WriteObject(this.RegistryDataPlaneClient.RemoveManifestByTag(this.RepositoryName, this.Tag));
}
}
else
{
throw new PSArgumentException("Invalid parameter set");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ContainerRegistry.Models;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.ContainerRegistry.Commands
{
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryRepository", SupportsShouldProcess = true)]
[OutputType(typeof(PSDeletedRepository))]
public class RemoveAzureContainerRegistryRepository : ContainerRegistryDataPlaneCmdletBase
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

public override void ExecuteChildCmdlet()
{
if (this.ShouldProcess(string.Format("Delete {0} under {1}", this.Name, this.RegistryName)))
{
WriteObject(this.RegistryDataPlaneClient.RemoveRepository(this.Name));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Management.Automation;

namespace Microsoft.Azure.Commands.ContainerRegistry.Commands
{
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ContainerRegistryTag", SupportsShouldProcess = true)]
[OutputType(typeof(bool))]
public class RemoveAzureContainerRegistryTag : ContainerRegistryDataPlaneCmdletBase
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Repository Name.")]
[ValidateNotNullOrEmpty]
public string RepositoryName { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Tag.")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

public override void ExecuteChildCmdlet()
{
if (this.ShouldProcess(string.Format("Untag {0}:{1} under {2}", this.RepositoryName, this.Name, this.RegistryName)))
{
WriteObject(this.RegistryDataPlaneClient.RemoveTag(this.RepositoryName, this.Name));
}
}
}
}
Loading