Skip to content

Add parameters for alternate extensions and encrypt-format #4848

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 12 commits into from
Nov 6, 2017

Conversation

vermashi
Copy link
Contributor

@vermashi vermashi commented Oct 24, 2017

Description


This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

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

@vermashi a few comments that need to be addressed. Also,

  1. Please update the Compute change log to reflect the changes made in this PR

  2. Please add test coverage to verify the changes you are making in this PR are working as intended

ValueFromPipelineByPropertyName = true,
HelpMessage = "The extension type. Specify this parameter to override its default value of \"AzureDiskEncryption\" for Windows VMs and \"AzureDiskEncryptionForLinux\" for Linux VMs.")]
[ValidateNotNullOrEmpty]
public string ExtensionType { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi is there a closed set of values that can be provided to this parameter? If so, please use a ValidateSet to define the possible set of values to allow a user to tab through them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, users are not limited to a closed set of values for this parameter.

ValueFromPipelineByPropertyName = true,
HelpMessage = "The extension publisher name. Specify this parameter only to override the default value of \"Microsoft.Azure.Security\".")]
[ValidateNotNullOrEmpty]
public string ExtensionPublisherName { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi same comment about possibly using a ValidateSet

Copy link
Contributor

Choose a reason for hiding this comment

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

For background, the defaults won't change, and the user can get those if they don't specify this optional parameter.

Position = 18,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Encrypt-Format all data drives that are not already encrypted")]
public SwitchParameter EncryptFormatAll { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi a SwitchParameter should not have a position nor should it accept a value from the pipeline

@@ -76,6 +78,32 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -ExtensionPublisherName
The extension publisher name. Specify this parameter only to override the default value of "Microsoft.Azure.Security".```yaml
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi this is a bug in platyPS - please make sure the ```yaml string is on a line by itself. See the other parameters in this file for guidance.

```

### -ExtensionType
The extension type. Specify this parameter to override its default value of "AzureDiskEncryption" for Windows VMs and "AzureDiskEncryptionForLinux" for Linux VMs.```yaml
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi same comment

@@ -48,6 +50,32 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ExtensionPublisherName
The extension publisher name. Specify this parameter only to override the default value of "Microsoft.Azure.Security".```yaml
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi same comment in this file for the added parameters

@@ -293,6 +296,45 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -EncryptFormatAll
Encrypt-Format all data drives that are not already encrypted```yaml
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi same comment in this file for the added parameters

Copy link
Contributor

@ejarvi ejarvi left a comment

Choose a reason for hiding this comment

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

It looks like the platyPS yaml strings need to be changed as per feedback from @cormacpayne but after that, it looks good to me.

public const string LinuxExtensionDefaultVersion = "0.1";

public const string ExtensionDefaultPublisher = "Microsoft.Azure.Security";
public const string ExtensionDefaultName = "AzureDiskEncryption";
public const string ExtensionDefaultType = "AzureDiskEncryption";
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 ... nice to see this getting disambiguated :)

ValueFromPipelineByPropertyName = true,
HelpMessage = "The extension publisher name. Specify this parameter only to override the default value of \"Microsoft.Azure.Security\".")]
[ValidateNotNullOrEmpty]
public string ExtensionPublisherName { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

For background, the defaults won't change, and the user can get those if they don't specify this optional parameter.

@vermashi
Copy link
Contributor Author

Have addressed most of the comments. Working on the tests.

@vermashi
Copy link
Contributor Author

@cormacpayne

  1. I have been trying to fix the tests but I'm running into an issue that when I try to create KeyVaults while running in Record Mode, I get the exception "TestManagementClientHelper class wasn't initialized with the ResourceManagementClient client". I'm not confident I can fix this issue before the snap date.
  2. Our team has been considering that since the primary purpose of "ExtensionPublisherName" parameter will be to redirect the cmdlet to a private build of the extension, if its ok to pass this information, when required, via an EnvironmentVariable.

TL;DR: 1- The tests might not get fixed by snap date, possible to ship without? Is it ok if we replace some of the newly added parameters in this PR with env-variables?

@maddieclayton
Copy link
Contributor

@vermashi Please fix the merge conflicts and push.

cormacpayne
cormacpayne previously approved these changes Nov 2, 2017
Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

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

@vermashi a few minor comments, otherwise LGTM

@@ -89,6 +89,22 @@ public class DisableAzureDiskEncryptionCommand : VirtualMachineExtensionBaseCmdl
HelpMessage = "Disable auto-upgrade of minor version")]
public SwitchParameter DisableAutoUpgradeMinorVersion { get; set; }

[Parameter(
Mandatory = false,
Position = 6,
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi nit: the number of positional parameters in a single set should be capped at four or five. After this, it can be difficult for the user to remember the order in which they should provide the values, so our recommendation would be to remove the positions from the parameters you added (I would also include the DisableAutoUpgradeMinorVersion parameter above since switch parameters are only named ☺️ )

@@ -58,6 +58,22 @@ public class GetAzureDiskEncryptionStatusCommand : VirtualMachineExtensionBaseCm
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(
Mandatory = false,
Position = 3,
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi nit: you can decide whether or not the positions are needed for the new parameters ☺️

publicSettings.Add(AzureDiskEncryptionExtensionConstants.sequenceVersionKey, SequenceVersion ?? String.Empty);

if (EncryptFormatAll)
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi nit: EncryptFormatAll.IsPresent for consistency with other cmdlets

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Copy link
Member

Choose a reason for hiding this comment

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

@vermashi it looks like the help for these cmdlets needs to be regenerated

@cormacpayne
Copy link
Member

@markcowl markcowl changed the base branch from preview to release-5.0.0 November 2, 2017 23:24
ejarvi
ejarvi previously approved these changes Nov 3, 2017
@cormacpayne
Copy link
Member

@cormacpayne cormacpayne merged commit fca0a14 into Azure:release-5.0.0 Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants