-
Notifications
You must be signed in to change notification settings - Fork 4k
Refactor template deployment cmdlets. #10798
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7949a24
Refactor template deployment cmdlets.
Tiano2017 c61d977
Merge remote-tracking branch 'Azure/master' into tiano-deployment-ref…
Tiano2017 c8bd082
Fix test failures.
Tiano2017 bd60d14
Merge remote-tracking branch 'Azure/master' into tiano-deployment-ref…
Tiano2017 79f0952
Merge remote-tracking branch 'Azure/master' into tiano-deployment-ref…
Tiano2017 06ec2f4
help files.
Tiano2017 057e381
more changes.
Tiano2017 d841c38
update help files.
Tiano2017 4d279d2
Merge remote-tracking branch 'Azure/master' into tiano-deployment-ref…
Tiano2017 87da776
add help links.
Tiano2017 fbdfd7e
change "id" parameter to be mandatory.
Tiano2017 5ce0d86
Merge remote-tracking branch 'Azure/master' into tiano-deployment-ref…
Tiano2017 2f6f657
change "id" parameter to be mandatory.
Tiano2017 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,4 @@ | |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ces/ResourceManager/Implementation/Deployments/GetAzureManagementGroupDeploymentCmdlet.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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; | ||
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components; | ||
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels; | ||
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.Deployments; | ||
using Microsoft.Azure.Commands.ResourceManager.Common; | ||
|
||
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation | ||
{ | ||
/// <summary> | ||
/// Get deployments. | ||
/// </summary> | ||
[Cmdlet(VerbsCommon.Get, AzureRMConstants.AzureRMPrefix + "ManagementGroupDeployment", DefaultParameterSetName = GetAzureManagementGroupDeploymentCmdlet.DeploymentNameParameterSet), OutputType(typeof(PSDeployment))] | ||
public class GetAzureManagementGroupDeploymentCmdlet : ResourceManagerCmdletBase | ||
{ | ||
/// <summary> | ||
/// The deployment Id parameter set. | ||
/// </summary> | ||
internal const string DeploymentIdParameterSet = "GetByDeploymentId"; | ||
|
||
/// <summary> | ||
/// The deployment name parameter set. | ||
/// </summary> | ||
internal const string DeploymentNameParameterSet = "GetByDeploymentName"; | ||
|
||
[Parameter(Position = 0, ParameterSetName = GetAzureManagementGroupDeploymentCmdlet.DeploymentNameParameterSet, Mandatory = true, | ||
HelpMessage = "The management group id.")] | ||
[ValidateNotNullOrEmpty] | ||
public string ManagementGroupId { get; set; } | ||
|
||
[Alias("DeploymentName")] | ||
[Parameter(Position = 1, ParameterSetName = GetAzureManagementGroupDeploymentCmdlet.DeploymentNameParameterSet, Mandatory = false, | ||
HelpMessage = "The name of deployment.")] | ||
[ValidateNotNullOrEmpty] | ||
public string Name { get; set; } | ||
|
||
[Alias("DeploymentId", "ResourceId")] | ||
[Parameter(ParameterSetName = GetAzureManagementGroupDeploymentCmdlet.DeploymentIdParameterSet, Mandatory = true, | ||
HelpMessage = "The fully qualified resource Id of the deployment. example: /providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deployments/{deploymentName}")] | ||
[ValidateNotNullOrEmpty] | ||
public string Id { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
FilterDeploymentOptions options = new FilterDeploymentOptions(DeploymentScopeType.ManagementGroup) | ||
{ | ||
ManagementGroupId = this.ManagementGroupId ?? ResourceIdUtility.GetManagementGroupId(this.Id), | ||
DeploymentName = this.Name ?? (string.IsNullOrEmpty(this.Id) ? null : ResourceIdUtility.GetDeploymentName(this.Id)) | ||
}; | ||
|
||
WriteObject(ResourceManagerSdkClient.FilterDeployments(options), true); | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...rceManager/Implementation/Deployments/GetAzureManagementGroupDeploymentOperationCmdlet.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation | ||
{ | ||
using System.Management.Automation; | ||
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels; | ||
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.Deployments; | ||
using Microsoft.Azure.Commands.ResourceManager.Common; | ||
|
||
/// <summary> | ||
/// Gets the deployment operation. | ||
/// </summary> | ||
[Cmdlet(VerbsCommon.Get, AzureRMConstants.AzureRMPrefix + "ManagementGroupDeploymentOperation", | ||
DefaultParameterSetName = GetAzureManagementGroupDeploymentOperationCmdlet.DeploymentNameParameterSet), OutputType(typeof(PSDeploymentOperation))] | ||
public class GetAzureManagementGroupDeploymentOperationCmdlet : ResourceManagerCmdletBase | ||
{ | ||
/// <summary> | ||
/// The deployment name parameter set. | ||
/// </summary> | ||
internal const string DeploymentNameParameterSet = "GetByDeploymentName"; | ||
|
||
/// <summary> | ||
/// The deployment object parameter set. | ||
/// </summary> | ||
internal const string DeploymentObjectParameterSet = "GetByDeploymentObject"; | ||
|
||
/// <summary> | ||
/// Gets or sets the management group id parameter. | ||
/// </summary> | ||
[Parameter(ParameterSetName = GetAzureManagementGroupDeploymentOperationCmdlet.DeploymentNameParameterSet, | ||
Mandatory = true, HelpMessage = "The management group id.")] | ||
[ValidateNotNullOrEmpty] | ||
public string ManagementGroupId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the deployment name parameter. | ||
/// </summary> | ||
[Parameter(ParameterSetName = GetAzureManagementGroupDeploymentOperationCmdlet.DeploymentNameParameterSet, | ||
Mandatory = true, HelpMessage = "The deployment name.")] | ||
[ValidateNotNullOrEmpty] | ||
public string DeploymentName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the deployment operation Id. | ||
/// </summary> | ||
[Parameter(ParameterSetName = GetAzureManagementGroupDeploymentOperationCmdlet.DeploymentNameParameterSet, | ||
Mandatory = false, HelpMessage = "The deployment operation Id.")] | ||
public string OperationId { get; set; } | ||
|
||
[Parameter(ParameterSetName = GetAzureManagementGroupDeploymentOperationCmdlet.DeploymentObjectParameterSet, | ||
Mandatory = true, ValueFromPipeline = true, HelpMessage = "The deployment object.")] | ||
public PSDeployment DeploymentObject { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
var options = new FilterDeploymentOptions(DeploymentScopeType.ManagementGroup) | ||
{ | ||
ManagementGroupId = !string.IsNullOrEmpty(this.ManagementGroupId) ? this.ManagementGroupId : this.DeploymentObject.ManagementGroupId, | ||
DeploymentName = !string.IsNullOrEmpty(this.DeploymentName) ? this.DeploymentName : this.DeploymentObject.DeploymentName | ||
}; | ||
|
||
var deploymentOperations = ResourceManagerSdkClient.ListDeploymentOperationsAtManagementGroup( | ||
options.ManagementGroupId, options.DeploymentName, this.OperationId); | ||
|
||
WriteObject(deploymentOperations, true); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing an optional parameter to mandatory is a breaking change, and it cannot be checked in until next breaking change release which is ~May.
I agree that it should be mandatory, but my suggestion is to add a breaking change attribute and make the change later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also the cause to CI failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be breaking. "Id" is the only parameter in this parameter set. If you don't specify the "id" parameter, you'll land with the default parameter set which is "GetByDeploymentName".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change it back to "mandatory" to false if that's the right thing..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right.. then it's a false positive. Please read Debugging StaticAnalysis Errors to suppress the warning.