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

[Compute] Autogen PR Issue 6 #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

-->
## Upcoming Release
* Updated `Set-AzDiskSecurityProfile` cmdlet.
- Added new business logic for the existing parameter `SecurityType`. The default value is now set to `ConfidentialVM` unless the user specifies a value. The `SecurityType` value is temporarily changed to all lower case for verification and then changed back to all upper case after assignment.
* Fixed `New-AzVmss` to correctly work when using `-EdgeZone` by creating the Load Balancer in the correct edge zone.
* Removed references to image aliases in `New-AzVM` and `New-AzVmss` to images that were removed.
* Fixed `New-AzVmss` to correctly work when using `-EdgeZone` by creating the Load Balancer in the correct edge zone.
* Removed references to image aliases in `New-AzVM` and `New-AzVmss` to images that were removed.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -41,12 +41,12 @@ public class SetAzDiskSecurityProfile : Microsoft.Azure.Commands.ResourceManager
public PSDisk Disk { get; set; }

[Parameter(
Mandatory = true,
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Gets or sets the SecurityType property. Possible values include: TrustedLaunch, ConfidentialVM_DiskEncryptedWithCustomerKey, ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey, ConfidentialVM_DiskEncryptedWithPlatformKey")]
[PSArgumentCompleter("Standard", "TrustedLaunch", "ConfidentialVM_DiskEncryptedWithCustomerKey", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey",
"ConfidentialVM_DiskEncryptedWithPlatformKey")]
public string SecurityType { get; set; }
public string SecurityType { get; set; } = "ConfidentialVM";

[Parameter(
Mandatory = false,
Expand All @@ -64,9 +64,14 @@ protected override void ProcessRecord()

private void Run()
{
// At this time, it is impossible to set SecurityType to Standard ("") as it is a mandatory property on the backend.
// If Standard is used, then there should be no securityProfile at all for now.
if (SecurityType.ToLower() != ConstantValues.StandardSecurityType)
SecurityType = SecurityType.ToLower();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before accessing a parameter, if it's bound needs to be checked first.

if (SecurityType != "standard" && SecurityType != "confidentialvm" && SecurityType != "trustedlaunch")
{
throw new ArgumentException($"Invalid SecurityType value: {SecurityType}");
}
SecurityType = SecurityType.ToUpper();

if (SecurityType != ConstantValues.StandardSecurityType)
{
if(this.Disk.SecurityProfile == null)
{
Expand All @@ -75,8 +80,7 @@ private void Run()
this.Disk.SecurityProfile.SecurityType = SecurityType;
}

// Allow the Standard scenario, which will be nulled out just before the .Net SDK create call for disks.
if (SecurityType.ToLower() == ConstantValues.StandardSecurityType)
if (SecurityType == ConstantValues.StandardSecurityType)
{
if (this.Disk.SecurityProfile == null)
{
Expand All @@ -98,4 +102,5 @@ private void Run()
}
}

}
}

2 changes: 1 addition & 1 deletion src/Compute/Compute/Generated/Models/PSDisk.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down