Skip to content

Service Fabric RP PowerShell #3783

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 75 commits into from
May 1, 2017
Merged

Service Fabric RP PowerShell #3783

merged 75 commits into from
May 1, 2017

Conversation

chingchenmsft
Copy link

@chingchenmsft chingchenmsft commented Apr 17, 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.

@msftclas
Copy link

@chingchenmsft,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@azuresdkci
Copy link

Can one of the admins verify this patch?

@cormacpayne
Copy link
Member

@azuresdki add to whitelist

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.

@chingchenmsft a few initial comments before reviewing the cmdlets.

Also, in order for your tests to run, you will need to add a reference to your test dll to the following file

@@ -52,6 +52,9 @@
<Reference Include="Microsoft.Azure.Management.ResourceManager">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.2.0-preview\lib\net45\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.ServiceFabric">
Copy link
Member

@cormacpayne cormacpayne Apr 17, 2017

Choose a reason for hiding this comment

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

@chingchenmsft why was this reference added? #Resolved

Copy link
Author

Choose a reason for hiding this comment

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

removed.


In reply to: 111838002 [](ancestors = 111838002)

# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '2.5.0'; })
Copy link
Member

Choose a reason for hiding this comment

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

@chingchenmsft this will need to be version 2.8.0

Copy link
Author

Choose a reason for hiding this comment

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

done.

Copy link
Author

Choose a reason for hiding this comment

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

fixed.

Copy link
Author

Choose a reason for hiding this comment

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

sorry will fix it.

Copy link
Author

Choose a reason for hiding this comment

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

fixed.

<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
<Name>Commands.ResourceManager.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\Profile\Commands.Profile\Commands.Profile.csproj">
Copy link
Member

Choose a reason for hiding this comment

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

@chingchenmsft why are you adding references to the Profile, Resources, and Tags projects?

Copy link
Author

Choose a reason for hiding this comment

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

i used a method in resource, and the resource need the other two to compile


In reply to: 111838392 [](ancestors = 111838392)

Copy link
Member

Choose a reason for hiding this comment

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

Adding references to other cmdlet projects is not allowed. There is a PR in the current stack that removes all of these for existing projects (#3734). Please ensure that you are using one of the common code libraries for accessing common features - this might mean moving some additional items into common code.

Copy link
Author

Choose a reason for hiding this comment

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

i checked, Key Vault also referenced the method, can you help to abstract it to common ?

<None Include="ScenarioTests\TestServiceFabric.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ServiceFabric.Test.ScenarioTests.TestServiceFabric\TestAddAzureRmServiceFabricClientCertificate.json" />
Copy link
Member

Choose a reason for hiding this comment

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

@chingchenmsft all of session record json files will need to have the <CopyToOutputDirectory>Always</CopyToOutputDirectory> tag so that they can be copied and found during the build

Copy link
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

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

Some general comments:

(1) Please regenerate the wxi file following the instructions here:

(2) Please add your test project to azure.powershell.test.targets in the repo root

(3) Please add in the documentation folder and changelog for your module directory, and please fill out the changelog entiry introducing your new cmdlets
(4) As discussed in review, generally you should allow piping between cmdlets by using a parameter set that takes ValueFromPipeline using your own types, rather than using ValueFromPipelineByPropertyName over all the properties. Normally, only ResourceGroupName and Name should be set up for ValueFromPipelineByPropertyName

(5) You need to implement ShouldProcess for all cmdlets that make changes. You can find a discussion of appropriate ShouldProcess implementation here: https://gist.github.com/markcowl/338e16fe5c8bbf195aff9f8af0db585d

# RootModule = ''

# Version number of this module.
ModuleVersion = '1.0.0'
Copy link
Member

Choose a reason for hiding this comment

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

This should probably start with '0.x.0', as I imagine your cmdlet surface area will be changing

Copy link
Author

Choose a reason for hiding this comment

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

changed to 0.1.0 , is this fine for our first version ?

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = SingleUpdateWithCommonNameSet,
HelpMessage = "Client authentication type")]
[ValidateNotNullOrEmpty()]
public virtual bool IsAdmin { 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.

You should not use boolean parameters. This should be a switch parameter

Copy link
Author

Choose a reason for hiding this comment

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

fixed.

HelpMessage = "Specify client certificate thumbprint and authentication type")]
[ValidateNotNullOrEmpty()]
[Alias("ThumbprintsAndAuthenticationTypes")]
public Hashtable ThumbprintsAndTypes { 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.

This is a hashtable of thumbbprints and booleans? How about havein a parameter for admincertificatethumbprint that takes an array of certs and a parameter that takes non-admin certificate thumbprints? This hashtable strikes me as difficult to fire out.

Copy link
Author

Choose a reason for hiding this comment

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

changed.


[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "The sku name")]
[ValidateNotNullOrEmpty()]
Copy link
Member

Choose a reason for hiding this comment

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

Is there not a validateset for this?

Copy link
Author

Choose a reason for hiding this comment

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

this can't be set, it depend on region availability

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Tier")]
[ValidateNotNullOrEmpty()]
public string Tier
Copy link
Member

Choose a reason for hiding this comment

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

ValidateSet?

Copy link
Author

Choose a reason for hiding this comment

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

this can't be set, it depend on region availability

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify Sku name of the node type")]
[ValidateNotNullOrEmpty()]
public string SkuName { 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.

Same, why not just Sku?

Copy link
Author

Choose a reason for hiding this comment

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

changed.


namespace Microsoft.Azure.Commands.ServiceFabric.Commands
{
[Cmdlet(VerbsData.Update, CmdletNoun.AzureRmServiceFabricReliability), OutputType(typeof(PSCluster))]
Copy link
Member

Choose a reason for hiding this comment

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

SupportsShouldProcess

Copy link
Author

Choose a reason for hiding this comment

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

fixed.

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "VM instance number")]
[ValidateNotNullOrEmpty()]
public ReliabilityLevel ReliabilityLevel { 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.

ValidateSet

Copy link
Author

Choose a reason for hiding this comment

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

it is Enum, still need ValidateSet?

HelpMessage = "The number of nodes to add")]
[ValidateNotNullOrEmpty()]
[Alias("NumberOfNodesToAdd")]
public virtual int Number { 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.

I think you may want a ValidateRange, not a ValidateNotNullOrEmpty

Copy link
Author

Choose a reason for hiding this comment

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

done.


[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Node type name")]
public string NodeTypeName { 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.

Node Type

Copy link
Author

Choose a reason for hiding this comment

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

done

@markcowl
Copy link
Member

@chingchenmsft There are credscan matches causing the build to fail, you can find these summarized here: http://azuresdkci.cloudapp.net/job/powershell/8321/artifact/src/Package/credscan-filtered.tsv

Copy link
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

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

You need to resolve the credscan issues identified here: http://azuresdkci.cloudapp.net/job/powershell/8321/artifact/src/Package/credscan-filtered.tsv

Also, it looks like you didn't add a changelog.md for your new RP, please add a changelog, and put details on the current release in the 'Current Release' section. The changelog format is as here: https://github.com/Azure/azure-powershell/blob/preview/src/ResourceManager/Cdn/ChangeLog.md, you only need the Current Release section

@chingchenmsft
Copy link
Author

removed the cred, and add changelog.md

markcowl
markcowl previously approved these changes Apr 29, 2017
@markcowl
Copy link
Member

markcowl commented Apr 29, 2017

@markcowl
Copy link
Member

markcowl commented Apr 30, 2017

@markcowl markcowl dismissed cormacpayne’s stale review May 1, 2017 04:06

Talked with Cormac, we agreed the dependencies are acceptabel for now

@markcowl markcowl merged commit 5e079f8 into Azure:preview May 1, 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.

6 participants