Skip to content

Apply azure container instance SDK 2017-10-01 #5020

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 8 commits into from
Dec 2, 2017
Merged

Apply azure container instance SDK 2017-10-01 #5020

merged 8 commits into from
Dec 2, 2017

Conversation

yolocs
Copy link
Contributor

@yolocs yolocs commented Nov 22, 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.

@cormacpayne
Copy link
Member

@azuresdkci test this please

@cormacpayne
Copy link
Member

@yolo3301 would you mind resolving the merge conflicts?

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.

@yolo3301 a few minor comments. We should have a quick cmdlet design review via email discussing the cmdlet changes that you are making in this PR. The cmdlet review template can be found here.

@@ -12,7 +12,7 @@
# RootModule = ''

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

Choose a reason for hiding this comment

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

@yolo3301 you can revert any change made to versions in this PR. We will handle the versioning before publishing the module

@@ -19,6 +19,12 @@
-->
## Current Release

## Version 0.1.1
Copy link
Member

Choose a reason for hiding this comment

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

@yolo3301 please remove the ## Version 0.1.1 header and move the below content to be under ## Current Release

@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0")]
[assembly: AssemblyFileVersion("0.1.0")]
[assembly: AssemblyVersion("0.1.1")]
Copy link
Member

Choose a reason for hiding this comment

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

@yolo3301 please revert the changes made in this file

[ValidateNotNullOrEmpty]
public int? Port { get; set; }
public int[] Ports { 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.

@yolo3301 why was this change made?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We support multiple ports. In Azure CLI we have already made a similar change.

Copy link
Member

Choose a reason for hiding this comment

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

@yolo3301 from PowerShell's Strongly Encouraged Development Guidelines (the snippet can be found here), parameter names should be singular unless there is validation for the parameter preventing the user from passing only one object. If a user can pass just one port, then this parameter should be public int[] Port

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know. Updated.

@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0")]
Copy link
Member

Choose a reason for hiding this comment

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

@yolo3301 please revert the changes made in this file

## PARAMETERS

### -AzureFileVolumeAccountKey
The storage account key of the Azure File share to mount.```yaml
Copy link
Member

Choose a reason for hiding this comment

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

@yolo3301 please make sure that the trailing ```yaml string is moved to a line by itself. This applies to all markdown files that have been edited in this file. This is caused from a bug in the platyPS module.

@@ -65,7 +65,7 @@ RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; RequiredVersion = '4.0.0';
@{ModuleName = 'AzureRM.CognitiveServices'; RequiredVersion = '0.9.0'; },
@{ModuleName = 'AzureRM.Compute'; RequiredVersion = '4.0.1'; },
@{ModuleName = 'AzureRM.Consumption'; RequiredVersion = '0.3.0'; },
@{ModuleName = 'AzureRM.ContainerInstance'; RequiredVersion = '0.1.0'; },
@{ModuleName = 'AzureRM.ContainerInstance'; RequiredVersion = '0.1.1'; },
Copy link
Member

Choose a reason for hiding this comment

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

@yolo3301 please revert the change made in this file

@yolocs
Copy link
Contributor Author

yolocs commented Nov 27, 2017

@cormacpayne Created a simple review page

@maddieclayton
Copy link
Contributor

@cormacpayne
Copy link
Member

@azuresdkci test this please

Copy link
Contributor

@maddieclayton maddieclayton left a comment

Choose a reason for hiding this comment

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

Some initial comments

@@ -23,17 +23,22 @@ function Test-AzureRmContainerGroup
$location = Get-ProviderLocation "Microsoft.ContainerInstance/ContainerGroups"
$image = "nginx"
$osType = "Linux"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a test for the new parameter set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will the session recording expose storage account key used for volume?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes - Can you create a test storage account and delete it at the end of the test? This should prevent any security issues caused by exposing the account key.

@@ -46,6 +47,12 @@ public class NewAzureContainerGroupCommand : ContainerInstanceCmdletBase
ParameterSetName = CreateContainerGroupWithRegistryParamSet,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The resource group name.")]
[Parameter(
Copy link
Contributor

Choose a reason for hiding this comment

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

If a parameter is in all sets, and Mandatory and in the same position, you don't need to have a separate attribute for each parameter set. Please erase all parameter attributes and put in:

[Parameter(
Mandatory = true,
Position = 0,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The resource group name.")]

Apply this all other parameters also. Especially if you plan to add more parameter sets in the future, there is no need to create a new attribute each time.

@@ -149,6 +177,34 @@ public class NewAzureContainerGroupCommand : ContainerInstanceCmdletBase
[ValidateNotNullOrEmpty]
public PSCredential RegistryCredential { get; set; }

[Parameter(
Copy link
Contributor

Choose a reason for hiding this comment

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

Quick recommendation: move these parameters above all of the non-mandatory parameters so that the users will see them more quickly when scanning help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But these are only mandatory for this parameter set. Should I still do the same?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, they are not in the other parameter sets, so it won't affect those other parameter sets.

ParameterSetName = CreateContainerGroupWithAzureFileVolumeParamSet,
HelpMessage = "The storage account key of the Azure File share to mount.")]
[ValidateNotNullOrEmpty]
public PSCredential AzureFileVolumeAccountKey { 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.

Is account key the correct name for this parameter? I wouldn't usually consider a PSCredential to be a "key". Please correct me if I am wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's what I would consider a PSCredential to be - it requires both a username and password, so "key" seems like the wrong name.

@@ -62,7 +62,12 @@ public class PSContainer
/// <summary>
/// Gets or sets the events.
/// </summary>
public IList<PSContainerEvent> Events { 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.

Is the change from PSContainerEvent to PSEvent an unrelated change? Just want to make sure I understand the scope of the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously an event belongs to a container. Now an event can also belong to the container group. Simply keep up with sdk.

/// <summary>
/// Gets or sets the state of the container group.
/// </summary>
public string State { 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.

Same here. Is this just to keep up to date with the current SDK?

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.

```

This commands creates a container group using a custom image from a custom container image registry.

### Example 6: Creates a container group that mounts Azure File volume
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome examples! Thanks for this.

Copy link
Contributor

@maddieclayton maddieclayton left a comment

Choose a reason for hiding this comment

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

Two more small things.

<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\TestContainerInstanceLog.json">
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\*">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add these tests separately? We generally like to stay away from using *

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. Just curious why?

Position = 2,
HelpMessage = "The container image.")]
[ValidateNotNullOrEmpty]
public string Image { 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.

Image previously was not a named parameter - was this addition intentional? If so, that is okay, I just want to ensure that the change was intended.

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.

@maddieclayton
Copy link
Contributor

@azuresdkci test this please

@maddieclayton
Copy link
Contributor

maddieclayton commented Dec 2, 2017

@maddieclayton maddieclayton merged commit 21dc0cc into Azure:preview Dec 2, 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