Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
92 changes: 92 additions & 0 deletions src/Azs.ContainerService.Admin/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<!-- region Generated -->
# Azs.ContainerService.Admin
This directory contains the PowerShell module for the ContainerServiceAdmin service.

---
## Status
[![Azs.ContainerService.Admin](https://img.shields.io/powershellgallery/v/Azs.ContainerService.Admin.svg?style=flat-square&label=Azs.ContainerService.Admin "Azs.ContainerService.Admin")](https://www.powershellgallery.com/packages/Azs.ContainerService.Admin/)

## Info
- Modifiable: yes
- Generated: all
- Committed: yes
- Packaged: yes

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

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

## Development
For information on how to develop for `Azs.ContainerService.Admin`, see [how-to.md](how-to.md).
<!-- endregion -->

## Generation Requirements
Use of the beta version of `autorest.powershell` generator requires the following:
- [NodeJS LTS](https://nodejs.org) (10.15.x LTS preferred)
- **Note**: It *will not work* with Node < 10.x. Using 11.x builds may cause issues as they may introduce instability or breaking changes.
> If you want an easy way to install and update Node, [NVS - Node Version Switcher](../nodejs/installing-via-nvs.md) or [NVM - Node Version Manager](../nodejs/installing-via-nvm.md) is recommended.
- [AutoRest](https://aka.ms/autorest) v3 beta <br>`npm install -g autorest@beta`<br>&nbsp;
- PowerShell 6.0 or greater
- If you don't have it installed, you can use the cross-platform npm package <br>`npm install -g pwsh`<br>&nbsp;
- .NET Core SDK 2.0 or greater
- If you don't have it installed, you can use the cross-platform npm package <br>`npm install -g dotnet-sdk-2.2`<br>&nbsp;

## Run Generation
In this directory, run AutoRest:
> `autorest`

---
### AutoRest Configuration
> see https://aka.ms/autorest

``` yaml
require:
- $(this-folder)/../readme.azurestack.md
- $(repo)/specification/azsadmin/resource-manager/containerservice/readme.azsautogen.md

metadata:
description: 'Microsoft AzureStack PowerShell: ContainerService Admin cmdlets'

### PSD1 metadata changes
subject-prefix: ''
module-version: 0.1.0
service-name: ContainerServiceAdmin

### File Renames
### IMPORTANT - Note that the following settings are case sensitive ###
module-name: Azs.ContainerService.Admin
csproj: Azs.ContainerService.Admin.csproj
psd1: Azs.ContainerService.Admin.psd1
psm1: Azs.ContainerService.Admin.psm1
```

### Parameter default values
``` yaml
directive:

# Add release notes
- from: Azs.ContainerService.Admin.nuspec
where: $
transform: $ = $.replace('<releaseNotes></releaseNotes>', '<releaseNotes>AzureStack Hub Admin module generated with https://github.com/Azure/autorest.powershell.</releaseNotes>');

# Add Az.Accounts/Az.Resources as dependencies
- from: Azs.ContainerService.Admin.nuspec
where: $
transform: $ = $.replace('<dependency id=\"Az.Accounts\" version=\"1.6.0\" />', '<dependency id="Az.Accounts" version="2.2.8" />\n <dependency id="Az.Resources" version="[0.11.0]" />');

# PSD1 changes for RequiredModules
- from: source-file-csharp
where: $
transform: $ = $.replace('sb.AppendLine\(\$@\"\{Indent\}RequiredAssemblies = \'\{\"./bin/Azs.ContainerService.Admin.private.dll\"\}\'\"\);', 'sb.AppendLine\(\$@\"\{Indent\}RequiredAssemblies = \'\{\"./bin/Azs.ContainerService.Admin.private.dll\"\}\'\"\);\n sb.AppendLine\(\$@\"\{Indent\}RequiredModules = @\(@\{\{ModuleName = \'Az.Accounts\'; ModuleVersion = \'2.2.8\'; \}\}, @\{\{ModuleName = \'Az.Resources\'; RequiredVersion = \'0.11.0\'; \}\}\)\"\);');

# PSD1 changes for ReleaseNotes
- from: source-file-csharp
where: $
transform: $ = $.replace('sb.AppendLine\(\$@\"\{Indent\}\{Indent\}\{Indent\}ReleaseNotes = \'\'\"\);', 'sb.AppendLine\(\$@\"\{Indent\}\{Indent\}\{Indent\}ReleaseNotes = \'AzureStack Hub Admin module generated with https://github.com/Azure/autorest.powershell\'\"\);' );
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"Get-AzsContainerService+[NoContext]+TestGetContainerService+$GET+https://management.azure.com/subscriptions/40a8de27-eef0-47f4-b4e1-4168820581b8/providers/Microsoft.ContainerService.Admin/locations/redmond/managedClusters?api-version=2019-11-01+1": {
"Request": {
"Method": "GET",
"RequestUri": "https://adminmanagement.redmond.ext-n31r1201.masd.stbtest.microsoft.com/subscriptions/40a8de27-eef0-47f4-b4e1-4168820581b8/providers/Microsoft.ContainerService.Admin/locations/redmond/managedClusters?api-version=2019-11-01",
"Content": null,
"isContentBase64": false,
"Headers": {
"x-ms-unique-id": [ "1" ],
"x-ms-client-request-id": [ "68b5e6e1-3d73-404d-8677-7a5bc94d2197" ],
"CommandName": [ "Get-AzsContainerService" ],
"FullCommandName": [ "Get-AzsContainerService_List" ],
"ParameterSetName": [ "__AllParameterSets" ],
"User-Agent": [ "AzurePowershell/Az4.0.0-preview" ],
"Authorization": [ "[Filtered]" ]
},
"ContentHeaders": {
}
},
"Response": {
"StatusCode": 200,
"Headers": {
"Cache-Control": [ "no-cache" ],
"Pragma": [ "no-cache" ],
"x-ms-request-id": [ "2b39b838-c46d-4ae4-9518-91903936a705" ],
"Server": [ "Microsoft-HTTPAPI/2.0" ],
"x-ms-ratelimit-remaining-subscription-reads": [ "14990" ],
"x-ms-correlation-request-id": [ "50c0dbbe-bd7c-4ecb-9dfc-3ea57077d1d7" ],
"x-ms-routing-request-id": [ "REDMOND:20210816T232443Z:50c0dbbe-bd7c-4ecb-9dfc-3ea57077d1d7" ],
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
"X-Content-Type-Options": [ "nosniff" ],
"Date": [ "Mon, 16 Aug 2021 23:24:43 GMT" ]
},
"ContentHeaders": {
"Content-Length": [ "2491" ],
"Content-Type": [ "application/json; charset=utf-8" ],
"Expires": [ "-1" ]
},
"Content": "{\"value\":[{\"id\":\"/subscriptions/40a8de27-eef0-47f4-b4e1-4168820581b8/providers/Microsoft.ContainerService.Admin/locations/redmond/managedclusters/demok8s\",\"name\":\"redmond/demok8s\",\"type\":\"Microsoft.ContainerService.Admin/locations/managedclusters\",\"properties\":{\"id\":\"/subscriptions/650c424d-9945-4897-98ff-d33c9222be8b/resourcegroups/demok8s/providers/Microsoft.ContainerService/managedClusters/demok8s\",\"name\":\"demok8s\",\"location\":\"redmond\",\"creationDate\":\"2021-08-05T20:49:51+00:00\",\"subscriptionId\":\"650c424d-9945-4897-98ff-d33c9222be8b\",\"orchestratorVersion\":\"1.20.7\",\"provisioningState\":\"Succeeded\"}},{\"id\":\"/subscriptions/40a8de27-eef0-47f4-b4e1-4168820581b8/providers/Microsoft.ContainerService.Admin/locations/redmond/managedclusters/moassafakscni\",\"name\":\"redmond/moassafakscni\",\"type\":\"Microsoft.ContainerService.Admin/locations/managedclusters\",\"properties\":{\"id\":\"/subscriptions/650c424d-9945-4897-98ff-d33c9222be8b/resourcegroups/moassafRG/providers/Microsoft.ContainerService/managedClusters/moassafakscni\",\"name\":\"moassafakscni\",\"location\":\"redmond\",\"creationDate\":\"2021-08-11T18:21:30+00:00\",\"subscriptionId\":\"650c424d-9945-4897-98ff-d33c9222be8b\",\"orchestratorVersion\":\"1.20.7\",\"provisioningState\":\"Failed\"}},{\"id\":\"/subscriptions/40a8de27-eef0-47f4-b4e1-4168820581b8/providers/Microsoft.ContainerService.Admin/locations/redmond/managedclusters/moassafclustercni\",\"name\":\"redmond/moassafclustercni\",\"type\":\"Microsoft.ContainerService.Admin/locations/managedclusters\",\"properties\":{\"id\":\"/subscriptions/650c424d-9945-4897-98ff-d33c9222be8b/resourcegroups/moassafRG/providers/Microsoft.ContainerService/managedClusters/moassafclustercni\",\"name\":\"moassafclustercni\",\"location\":\"redmond\",\"creationDate\":\"2021-08-03T17:39:40+00:00\",\"subscriptionId\":\"650c424d-9945-4897-98ff-d33c9222be8b\",\"orchestratorVersion\":\"1.20.7\",\"provisioningState\":\"Failed\"}},{\"id\":\"/subscriptions/40a8de27-eef0-47f4-b4e1-4168820581b8/providers/Microsoft.ContainerService.Admin/locations/redmond/managedclusters/testdnscluster\",\"name\":\"redmond/testdnscluster\",\"type\":\"Microsoft.ContainerService.Admin/locations/managedclusters\",\"properties\":{\"id\":\"/subscriptions/650c424d-9945-4897-98ff-d33c9222be8b/resourcegroups/testdnsrg/providers/Microsoft.ContainerService/managedClusters/testdnscluster\",\"name\":\"testdnscluster\",\"location\":\"redmond\",\"creationDate\":\"2021-08-03T21:31:41+00:00\",\"subscriptionId\":\"650c424d-9945-4897-98ff-d33c9222be8b\",\"orchestratorVersion\":\"1.20.7\",\"provisioningState\":\"Succeeded\"}}]}",
"isContentBase64": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
if (-Not (Test-Path -Path $loadEnvPath)) {
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
}
. ($loadEnvPath)
$TestRecordingFile = Join-Path $PSScriptRoot 'Get-AzsContainerService.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 'Get-AzsContainerService' {
BeforeEach {
function ValidateContainerService {
param(
[Parameter(Mandatory = $true)]
$ManagedClusters
)
$managedClusters | Should Not Be $null
$managedClusters.orchestratorVersion | Should Not Be $null
$managedClusters.provisioningState | Should Not Be $null
}
}

AfterEach {
$global:Client = $null
}

It "TestGetContainerService" -Skip:$('TestGetContainerService' -in $global:SkippedTests) {
$global:TestName = 'TestGetContainerService'

$result = Get-AzsContainerService
$result | Should Not Be $null
ValidateContainerService -ManagedClusters $result
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"Get-AzsContainerServiceQuota+[NoContext]+TestGetContainerServiceQuota+$GET+https://management.azure.com/subscriptions/40a8de27-eef0-47f4-b4e1-4168820581b8/providers/Microsoft.ContainerService.Admin/locations/redmond/quotas?api-version=2019-11-01+1": {
"Request": {
"Method": "GET",
"RequestUri": "https://adminmanagement.redmond.ext-n31r1201.masd.stbtest.microsoft.com/subscriptions/40a8de27-eef0-47f4-b4e1-4168820581b8/providers/Microsoft.ContainerService.Admin/locations/redmond/quotas?api-version=2019-11-01",
"Content": null,
"isContentBase64": false,
"Headers": {
"x-ms-unique-id": [ "2" ],
"x-ms-client-request-id": [ "9e7a786d-e8f4-479d-97d6-e859e405c608" ],
"CommandName": [ "Get-AzsContainerServiceQuota" ],
"FullCommandName": [ "Get-AzsContainerServiceQuota_List" ],
"ParameterSetName": [ "__AllParameterSets" ],
"User-Agent": [ "AzurePowershell/Az4.0.0-preview" ],
"Authorization": [ "[Filtered]" ]
},
"ContentHeaders": {
}
},
"Response": {
"StatusCode": 200,
"Headers": {
"Cache-Control": [ "no-cache" ],
"Pragma": [ "no-cache" ],
"x-ms-request-id": [ "a2a8094b-52bc-4bab-9460-792473abbc0d" ],
"Server": [ "Microsoft-HTTPAPI/2.0" ],
"x-ms-ratelimit-remaining-subscription-reads": [ "14988" ],
"x-ms-correlation-request-id": [ "f95c8f63-d22c-463b-b899-b24811dd70aa" ],
"x-ms-routing-request-id": [ "REDMOND:20210816T232445Z:f95c8f63-d22c-463b-b899-b24811dd70aa" ],
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
"X-Content-Type-Options": [ "nosniff" ],
"Date": [ "Mon, 16 Aug 2021 23:24:45 GMT" ]
},
"ContentHeaders": {
"Content-Length": [ "270" ],
"Content-Type": [ "application/json; charset=utf-8" ],
"Expires": [ "-1" ]
},
"Content": "{\"value\":[{\"id\":\"/subscriptions/40a8de27-eef0-47f4-b4e1-4168820581b8/providers/Microsoft.ContainerService.Admin/locations/redmond/quotas/Unlimited\",\"name\":\"redmond/Unlimited\",\"type\":\"Microsoft.ContainerService.Admin/locations/quotas\",\"properties\":{\"name\":\"Unlimited\"}}]}",
"isContentBase64": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
if (-Not (Test-Path -Path $loadEnvPath)) {
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
}
. ($loadEnvPath)
$TestRecordingFile = Join-Path $PSScriptRoot 'Get-AzsContainerServiceQuota.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 'Get-AzsContainerServiceQuota' {
BeforeEach {
function ValidateContainerServiceQuota {
param(
[Parameter(Mandatory = $true)]
$ManagedClustersQuota
)
$managedClustersQuota | Should Not Be $null
$managedClustersQuota.name | Should Not Be $null
}
}

AfterEach {
$global:Client = $null
}

It "TestGetContainerServiceQuota" -Skip:$('TestGetContainerServiceQuota' -in $global:SkippedTests) {
$global:TestName = 'TestGetContainerServiceQuota'

$result = Get-AzsContainerServiceQuota
$result | Should Not Be $null
ValidateContainerServiceQuota -ManagedClustersQuota $result
}
}
4 changes: 4 additions & 0 deletions src/Azs.ContainerService.Admin/test/env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SubscriptionId": "40a8de27-eef0-47f4-b4e1-4168820581b8",
"Location": "redmond"
}
28 changes: 28 additions & 0 deletions src/Azs.ContainerService.Admin/test/loadEnv.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# 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,
# 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.
# ----------------------------------------------------------------------------------
$envFile = 'env.json'
if ($TestMode -eq 'live') {
$envFile = 'localEnv.json'
}

if (Test-Path -Path (Join-Path $PSScriptRoot $envFile)) {
$envFilePath = Join-Path $PSScriptRoot $envFile
} else {
$envFilePath = Join-Path $PSScriptRoot '..\$envFile'
}
$env = @{}
if (Test-Path -Path $envFilePath) {
$env = Get-Content (Join-Path $PSScriptRoot $envFile) | ConvertFrom-Json
$PSDefaultParameterValues=@{"*:SubscriptionId"=$env.SubscriptionId; "*:Location"=$env.Location}
}