Skip to content

Marketplace ordering Add Get/Set-AzureRmMarketplaceTerms Cmdlets #4694

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 13 commits into from
Oct 11, 2017

Conversation

prbansa
Copy link
Contributor

@prbansa prbansa commented Oct 1, 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.

@azuresdkci
Copy link

Can one of the admins verify this patch?

@cormacpayne
Copy link
Member

@azuresdkci 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.

@prbansa a few initial comments.

Also, it looks like you will need to regenerate the wxi file as there are a lot of unnecessary changes made to that file.

@cormacpayne - Need some help to fix the wxi file, not sure what needs to be done, this was autogenerated

thanks @cormacpayne , updated the wxi file.

# 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.

@prbansa please set this to version 0.1.0, which is the initial version we set for all modules.

-->
## Current Release

## Version 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.

@prbansa please remove this header and put all information under the Current Release header. We have a script that runs during the release that will place all of this information under the correct header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.1")]
[assembly: AssemblyFileVersion("0.0.1")]
Copy link
Member

Choose a reason for hiding this comment

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

@prbansa both of these versions should match the module version, 0.1.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.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.

@prbansa same comment about these versions matching the module version, 0.1.0

```

### -InputObject
Terms object returned in Get-AzureRmMarketplaceTerms cmdlet. This is a mandatory parameter if Accepted paramter is true.```yaml
Copy link
Member

Choose a reason for hiding this comment

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

@prbansa the ```yaml string at the end should be moved to a line by itself; this is a bug with platyPS. Please see other parameters in this file for an example of how this should look.


namespace Microsoft.Azure.Commands.MarketplaceOrdering.Cmdlets.Agreements
{
[Cmdlet(VerbsCommon.Get, "AzureRmMarketplaceTerms", DefaultParameterSetName = Constants.ParameterSetNames.AgreementParameterSet), OutputType(typeof(PSAgreementTerms))]
Copy link
Member

Choose a reason for hiding this comment

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

@prbansa I missed the design review for these cmdlets, so this may have been answered: is this a resource that can be created for a specific subscription, or even a resource group? Most Get-* cmdlets support providing no parameters (returns all resources in the subscription) or providing a resource group (returns all resources in the resource group).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cormacpayne - Get-AzureRmMarketplaceTerms returns "Terms" object which user can accept and fully automate 3rd party VM deployment experience.
This is not a resource so Get-* is not supported in this case.

[Parameter(Mandatory = false, ValueFromPipeline = true, HelpMessage = "Terms object returned in Get-AzureRmMarketplaceTerms cmdlet. This is a mandatory parameter if Accepted paramter is true.", ParameterSetName = Constants.ParameterSetNames.AgreementParameterSet)]
[ValidateNotNullOrEmpty]
[Alias("Terms")]
public PSAgreementTerms InputObject { 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.

@prbansa InputObject should be in a separate parameter set from Publisher, Product and Name since it will already have the values for these parameters (they should be properties of the object returned from the Get-* cmdlet).

Also, this parameter should accept its value from the pipeline, which will allow a user to pipe the result from the Get-* cmdlet into this parameter. Please take a look at this guide.


[Parameter(Mandatory = true, HelpMessage = "Boolean which would indicate the status of acceptance of the terms, it should be true if any version of the terms have been accepted.", ParameterSetName = Constants.ParameterSetNames.AgreementParameterSet)]
[ValidateNotNullOrEmpty]
public SwitchParameter Accepted { 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.

@prbansa take another look at this parameter after moving the InputObject parameter into a separate parameter set. Right now it is a mandatory SwitchParameter, meaning it should always be provided in the single parameter set that exists today, which provides no value to the cmdlet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cormacpayne Let's discuss this, I changed this from bool based on comment I got on this PR
https://github.com/Azure/azure-powershell-pr/pull/331
Look for comments on this file -MarketplaceOrdering/Cmdlets/Agreements/SetAzureRmMarketplaceTerms.cs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to bool as discussed

@prbansa
Copy link
Contributor Author

prbansa commented Oct 4, 2017

@cormacpayne - updated after review, please look at my changes. Let's work together to fix wxi file

```

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.```yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

The ```yaml text needs to be on a line by itself; this is a bug in the platyPS module. Please see the below parameters for how this should look.

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.

@prbansa a couple minor things I forgot to mention:

(1) You will need to add your module to the AzureRM.psd1 roll-up module. This will ensure that your cmdlets are installed when a user runs Install-Module AzureRM.

(2) In order for your tests to be run, you will need to make sure they get picked up by our Smart Tester (which scans the files in a PR and runs tests associated with the files changed). To do so, you will need to update the following things:

@prbansa
Copy link
Contributor Author

prbansa commented Oct 5, 2017

@cormacpayne Updated the code as discussed, I like to understand how to skip the tests as you suggested.

@prbansa
Copy link
Contributor Author

prbansa commented Oct 5, 2017

@cormacpayne this build failed because of unit tests as you predicted, let me know how can I skip the tests and if any other feedback you have on my latest commit.

<None Include="ScenarioTests\AgreementsTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.MarketplaceOrdering.Test.ScenarioTests.AgreementsTests\TestGetAgreement.json" />
Copy link
Contributor

@maddieclayton maddieclayton Oct 5, 2017

Choose a reason for hiding this comment

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

Session records should all be copied to output directory (similar to ScenarioTest\AgreementTests.ps1 above) - this should solve your issue.

<None Include="SessionRecords\Microsoft.Azure.Commands.MarketplaceOrdering.Test.ScenarioTests.AgreementsTests\TestGetAgreement.json" > <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure will update this

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.

@prbansa two minor comments, otherwise LGTM

```

### -Reject
Pass this to reject the legal terms.```yaml
Copy link
Member

Choose a reason for hiding this comment

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

@prbansa looks like the ```yaml string got added to the wrong line in the last commit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, fixed.

}
catch (ErrorResponseException e)
{
WriteWarning(e.Body.Error.Message);
Copy link
Member

Choose a reason for hiding this comment

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

@prbansa I think we should do some null-checking around this, I would hate for the actual cmdlet error to not get bubbled up because some part of this chain is null

@cormacpayne
Copy link
Member

@cormacpayne
Copy link
Member

@prbansa you will need to resolve the merge conflicts; I sent you a message offline about how to do so.

Also, the on-demand job is failing StaticAnalysis because the noun used for a couple of cmdlets/parameters is plural, which goes against PowerShell guidance. However, in this case, it is allowed, so you will need to suppress these errors. To do so, you will need to open on-demand job and open the SignatureIssues.csv file in a text editor. Copy the severity 1 issues (there should be three) and append them to the end of tools/StaticAnalysis/Exceptions/SignatureIssues.csv (also open in a text editor). Please let me know if you have any questions.

@prbansa prbansa force-pushed the MarketplaceOrdering_CmdLets branch from 3865fa3 to 9278752 Compare October 7, 2017 06:34
@prbansa
Copy link
Contributor Author

prbansa commented Oct 7, 2017

@cormacpayne , @markcowl I have made the necessary changes to merge the conflicts in wxi, it gave some trouble.
Do you think it will be better if I submit a new PR.

@markcowl markcowl changed the base branch from preview to release-4.4.1 October 7, 2017 23:56
@cormacpayne
Copy link
Member

# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '3.4.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 version will need to be updated for the preview branch

…hell into MarketplaceOrdering_CmdLets

# Conflicts:
#	tools/AzureRM/AzureRM.psd1
@cormacpayne
Copy link
Member

@prbansa
Copy link
Contributor Author

prbansa commented Oct 11, 2017

@cormacpayne - I tested the installer from - http://azuresdkci.cloudapp.net/job/posh-pack/37/artifact/setup/build/Debug/
Looks good.

@markcowl
Copy link
Member

@markcowl markcowl merged commit 221015a into Azure:release-4.4.1 Oct 11, 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.

5 participants