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

Supported empty directory volume and secret volume for creating container group #17802

Merged
merged 2 commits into from
Apr 18, 2022
Merged
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
13 changes: 12 additions & 1 deletion src/ContainerInstance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This directory contains the PowerShell module for the ContainerInstance service.
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.

## Module Requirements
- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.2.3 or greater
- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.7.5 or greater

## Authentication
AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent.
Expand Down Expand Up @@ -140,4 +140,15 @@ directive:
$["204"] = {
"description": "No content"
}
# Change the type of EmptyDir from IAny() to VolumeEmptyDir
- from: swagger-document
where: $.definitions.Volume.properties.emptyDir
transform: >-
return {
"description": "The empty directory volume.",
"type": "object",
"additionalProperties": true
}
# - model-cmdlet:
# - Volume # Hide to customize AzureFileStorageAccountKey from string to securestring
```
2 changes: 1 addition & 1 deletion src/ContainerInstance/custom/New-AzContainerGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
.Synopsis
Create or update container groups with specified configurations.
.Description
Create or update container groups with specified configurations. For property Volume, we support mounting Azure File share as a volume or specifying git repository as volume directory. The empty directory volume and secret volume are not supported yet.
Create or update container groups with specified configurations.
.Link
https://docs.microsoft.com/powershell/module/az.containerinstance/new-azcontainergroup
#>
Expand Down
70 changes: 46 additions & 24 deletions src/ContainerInstance/custom/New-AzContainerGroupVolumeObject.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@

# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the \"License\");
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an \"AS IS\" BASIS,
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
# is regenerated.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Create a in-memory object for Volume
Create an in-memory object for Volume.
.Description
Create a in-memory object for Volume. Currently, we support mounting Azure File share as a volume or specifying git repository as volume directory. The empty directory volume and secret volume are not supported yet.
Create an in-memory object for Volume.

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.Volume
.Link
https://docs.microsoft.com/powershell/module/az.ContainerInstance/new-AzContainerGroupVolumeObject
#>
Expand All @@ -38,9 +42,9 @@ function New-AzContainerGroupVolumeObject {
[Parameter(HelpMessage="The name of the storage account that contains the Azure File share.")]
[string]
$AzureFileStorageAccountName,
# [Parameter(HelpMessage="The empty directory volume.")]
# [Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IAny]
# $EmptyDir,
[Parameter(HelpMessage="The empty directory volume.")]
[Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.IVolumeEmptyDir]
$EmptyDir,
[Parameter(HelpMessage="Target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name.")]
[string]
$GitRepoDirectoryName,
Expand All @@ -52,28 +56,46 @@ function New-AzContainerGroupVolumeObject {
$GitRepoRevision,
[Parameter(Mandatory, HelpMessage="The name of the volume.")]
[string]
$Name
# ,
# [Parameter(HelpMessage="The secret volume.")]
# [Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.ISecretVolume]
# $Secret
$Name,
[Parameter(HelpMessage="The secret volume.")]
[Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.ISecretVolume]
$Secret
)

process {
$Object = [Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.Volume]::New()

$Object.AzureFileShareName = $AzureFileShareName
if ($PSBoundParameters.ContainsKey('AzureFileReadOnly')) {
$Object.AzureFileReadOnly = $AzureFileReadOnly
}
if ($PSBoundParameters.ContainsKey('AzureFileShareName')) {
$Object.AzureFileShareName = $AzureFileShareName
}
if ($PSBoundParameters.ContainsKey('AzureFileStorageAccountKey')) {
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['AzureFileStorageAccountKey']
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['AzureFileStorageAccountKey']
$Object.AzureFileStorageAccountKey = $psTxt
}
if ($PSBoundParameters.ContainsKey('AzureFileStorageAccountName')) {
$Object.AzureFileStorageAccountName = $AzureFileStorageAccountName
}
if ($PSBoundParameters.ContainsKey('EmptyDir')) {
$Object.EmptyDir = $EmptyDir
}
if ($PSBoundParameters.ContainsKey('GitRepoDirectoryName')) {
$Object.GitRepoDirectory = $GitRepoDirectoryName
}
if ($PSBoundParameters.ContainsKey('GitRepoRepositoryUrl')) {
$Object.GitRepoRepository = $GitRepoRepositoryUrl
}
if ($PSBoundParameters.ContainsKey('GitRepoRevision')) {
$Object.GitRepoRevision = $GitRepoRevision
}
if ($PSBoundParameters.ContainsKey('Name')) {
$Object.Name = $Name
}
if ($PSBoundParameters.ContainsKey('Secret')) {
$Object.Secret = $Secret
}
$Object.AzureFileStorageAccountKey = $psTxt
$Object.AzureFileStorageAccountName = $AzureFileStorageAccountName
# $Object.EmptyDir = $EmptyDir
$Object.GitRepoDirectory = $GitRepoDirectoryName
$Object.GitRepoRepository = $GitRepoRepositoryUrl
$Object.GitRepoRevision = $GitRepoRevision
$Object.Name = $Name
# $Object.Secret = $Secret
return $Object
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,15 @@ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.ContainerInstan
this._gitRepo = null;
}

this._emptyDir = null;

this._secret = null;
}

partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Runtime.Json.JsonObject container)
{
if (this._emptyDir != null && this._emptyDir.Count == 0) {
container.Add("emptyDir", new Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Runtime.Json.JsonObject());
}
}


}
}
2 changes: 1 addition & 1 deletion src/ContainerInstance/docs/Az.ContainerInstance.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Create a in-memory object for ImageRegistryCredential
Create a in-memory object for Port

### [New-AzContainerGroupVolumeObject](New-AzContainerGroupVolumeObject.md)
Create a in-memory object for Volume
Create an in-memory object for Volume.

### [New-AzContainerInstanceEnvironmentVariableObject](New-AzContainerInstanceEnvironmentVariableObject.md)
Create a in-memory object for EnvironmentVariable
Expand Down
5 changes: 3 additions & 2 deletions src/ContainerInstance/docs/New-AzContainerGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ New-AzContainerGroup -Name <String> -ResourceGroupName <String> -Container <ICon
```

## DESCRIPTION
Create or update container groups with specified configurations. For property Volume, we support mounting Azure File share as a volume or specifying git repository as volume directory. The empty directory volume and secret volume are not supported yet.
Create or update container groups with specified configurations.
isra-fel marked this conversation as resolved.
Show resolved Hide resolved

## EXAMPLES

Expand Down Expand Up @@ -790,7 +790,8 @@ VOLUME <IVolume[]>: The list of volumes that can be mounted by containers in thi
- `[AzureFileShareName <String>]`: The name of the Azure File share to be mounted as a volume.
- `[AzureFileStorageAccountKey <String>]`: The storage account access key used to access the Azure File share.
- `[AzureFileStorageAccountName <String>]`: The name of the storage account that contains the Azure File share.
- `[EmptyDir <IAny>]`: The empty directory volume.
- `[EmptyDir <IVolumeEmptyDir>]`: The empty directory volume.
- `[(Any) <Object>]`: This indicates any property can be added to this object.
- `[GitRepoDirectory <String>]`: Target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name.
- `[GitRepoRepository <String>]`: Repository URL
- `[GitRepoRevision <String>]`: Commit hash for the specified revision.
Expand Down
75 changes: 69 additions & 6 deletions src/ContainerInstance/docs/New-AzContainerGroupVolumeObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ schema: 2.0.0
# New-AzContainerGroupVolumeObject

## SYNOPSIS
Create a in-memory object for Volume. Currently, we support mounting Azure File share as a volume or specifying git repository as volume directory. The empty directory volume and secret volume are not supported yet.
Create an in-memory object for Volume.
isra-fel marked this conversation as resolved.
Show resolved Hide resolved

## SYNTAX

```
New-AzContainerGroupVolumeObject -Name <String> [-AzureFileReadOnly] [-AzureFileShareName <String>]
[-AzureFileStorageAccountKey <SecureString>] [-AzureFileStorageAccountName <String>]
[-GitRepoDirectoryName <String>] [-GitRepoRepositoryUrl <String>] [-GitRepoRevision <String>]
[<CommonParameters>]
[-EmptyDir <IVolumeEmptyDir>] [-GitRepoDirectoryName <String>] [-GitRepoRepositoryUrl <String>]
[-GitRepoRevision <String>] [-Secret <ISecretVolume>] [<CommonParameters>]
```

## DESCRIPTION
Create a in-memory object for Volume
Create an in-memory object for Volume.

## EXAMPLES

Expand All @@ -30,15 +30,35 @@ New-AzContainerGroupVolumeObject -Name "myvolume" -AzureFileShareName "myshare"
```

```output
******

Name
----
myvolume
```

This command creates a Azure File volume.

### Example 2: Create an empty directory volume
```powershell
New-AzContainerGroupVolumeObject -Name "emptyvolume" -EmptyDir @{} | fl
```

```output
AzureFileReadOnly :
AzureFileShareName :
AzureFileStorageAccountKey :
AzureFileStorageAccountName :
EmptyDir : {
}
GitRepoDirectory :
GitRepoRepository :
GitRepoRevision :
Name : emptyvolume
Secret : {
}
```

This command creates an empty directory volume.

## PARAMETERS

### -AzureFileReadOnly
Expand Down Expand Up @@ -101,6 +121,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -EmptyDir
The empty directory volume.
To construct, see NOTES section for EMPTYDIR properties and create a hash table.

```yaml
Type: Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.IVolumeEmptyDir
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -GitRepoDirectoryName
Target directory name.
Must not contain or start with '..'.
Expand Down Expand Up @@ -164,6 +200,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Secret
The secret volume.
To construct, see NOTES section for SECRET properties and create a hash table.

```yaml
Type: Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.ISecretVolume
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

Expand All @@ -177,5 +229,16 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

ALIASES

COMPLEX PARAMETER PROPERTIES

To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.


EMPTYDIR <IVolumeEmptyDir>: The empty directory volume.
- `[(Any) <Object>]`: This indicates any property can be added to this object.

SECRET <ISecretVolume>: The secret volume.
- `[(Any) <String>]`: This indicates any property can be added to this object.

## RELATED LINKS

Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Location Name Zone ResourceGroupName
-------- ---- ---- -----------------
eastus test-cg test-rg
```

Create a container group with a container instance

## PARAMETERS
Expand Down
26 changes: 23 additions & 3 deletions src/ContainerInstance/examples/New-AzContainerGroupVolumeObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,31 @@ New-AzContainerGroupVolumeObject -Name "myvolume" -AzureFileShareName "myshare"
```

```output
******

Name
----
myvolume
```

This command creates a Azure File volume.
This command creates a Azure File volume.

### Example 2: Create an empty directory volume
```powershell
New-AzContainerGroupVolumeObject -Name "emptyvolume" -EmptyDir @{} | fl
```

```output
AzureFileReadOnly :
AzureFileShareName :
AzureFileStorageAccountKey :
AzureFileStorageAccountName :
EmptyDir : {
}
GitRepoDirectory :
GitRepoRepository :
GitRepoRevision :
Name : emptyvolume
Secret : {
}
```

This command creates an empty directory volume.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if(($null -eq $TestName) -or ($TestName -contains 'New-AzContainerInstanceVolumeObject'))
{
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
if (-Not (Test-Path -Path $loadEnvPath)) {
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
}
. ($loadEnvPath)
$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzContainerInstanceVolumeObject.Recording.json'
$currentPath = $PSScriptRoot
while(-not $mockingPath) {
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
$currentPath = Split-Path -Path $currentPath -Parent
}
. ($mockingPath | Select-Object -First 1).FullName
}

Describe 'New-AzContainerInstanceVolumeObject' {
It '__AllParameterSets' -skip {
{ throw [System.NotImplementedException] } | Should -Not -Throw
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
"Az.ContainerInstance","Get-AzContainerGroup","Get-AzContainerGroup","0","3000","The type of property 'EmptyDir' of type 'Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.IVolume' has changed from 'Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IAny' to 'Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IVolumeEmptyDir'.","Change the type of property 'EmptyDir' back to 'Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IAny'."
"Az.ContainerInstance","New-AzContainerGroupVolumeObject","New-AzContainerGroupVolumeObject","0","3000","The type of property 'EmptyDir' of type 'Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.Volume' has changed from 'Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IAny' to 'Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IVolumeEmptyDir'.","Change the type of property 'EmptyDir' back to 'Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IAny'."