Skip to content

Commit e78c1eb

Browse files
authored
[PS] migrate KubernetesConfiguration module to autorest v4 (Azure#27700)
1 parent a0ca38a commit e78c1eb

38 files changed

+304
-182
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0 (the ""License"");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an ""AS IS"" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
12+
// is regenerated.
13+
14+
using System;
15+
using System.Reflection;
16+
using System.Runtime.CompilerServices;
17+
using System.Runtime.InteropServices;
18+
19+
[assembly: System.Reflection.AssemblyCompanyAttribute("Microsoft")]
20+
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
21+
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
22+
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - KubernetesConfiguration")]
23+
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.7.3")]
24+
[assembly: System.Reflection.AssemblyVersionAttribute("0.7.3")]
25+
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
26+
[assembly: System.CLSCompliantAttribute(false)]

src/KubernetesConfiguration/KubernetesConfiguration.Autorest/README.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ title: KubernetesConfiguration
5757
module-version: 0.3.0
5858
subject-prefix: ''
5959

60-
identity-correction-for-post: true
61-
resourcegroup-append: true
62-
nested-object-to-string: true
63-
64-
# For new modules, please avoid setting 3.x using the use-extension method and instead, use 4.x as the default option
65-
use-extension:
66-
"@autorest/powershell": "3.x"
67-
6860
directive:
6961
- from: swagger-document
7062
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}"].patch.responses
@@ -193,7 +185,10 @@ directive:
193185
transform: return "string"
194186

195187
- where:
196-
variant: ^Create$|^CreateViaIdentity$|^CreateViaIdentityExpanded$|^Update$|^UpdateViaIdentity$
188+
variant: ^(Create|Update)(?!.*?(Expanded|JsonFilePath|JsonString))
189+
remove: true
190+
- where:
191+
variant: ^CreateViaIdentityExpanded$
197192
remove: true
198193

199194
- where:

src/KubernetesConfiguration/KubernetesConfiguration.Autorest/custom/Get-AzKubernetesConfigFluxOperationStatus.ps1

+5-7
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ Get Async Operation status
2020
.Description
2121
Get Async Operation status
2222
.Example
23-
{{ Add code here }}
24-
.Example
25-
{{ Add code here }}
23+
Get-AzKubernetesConfigFluxOperationStatus -ClusterName azpstest_cluster_arc -ClusterType ConnectedClusters -FluxConfigurationName azpstestflux-k8s -ResourceGroupName azps_test_group -OperationId e9871335-7ba8-4100-8cb4-73b3464eb863
2624
2725
.Inputs
2826
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IKubernetesConfigurationIdentity
2927
.Outputs
30-
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20220301.IOperationStatusResult
28+
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IOperationStatusResult
3129
.Notes
3230
COMPLEX PARAMETER PROPERTIES
3331
@@ -49,7 +47,7 @@ https://learn.microsoft.com/powershell/module/az.kubernetesconfiguration/get-azk
4947
#>
5048
function Get-AzKubernetesConfigFluxOperationStatus {
5149
[Alias('Get-AzK8sConfigFluxOperationStatus')]
52-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20220301.IOperationStatusResult])]
50+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IOperationStatusResult])]
5351
[CmdletBinding(DefaultParameterSetName = 'Get', PositionalBinding = $false)]
5452
param(
5553
[Parameter(ParameterSetName = 'Get', Mandatory)]
@@ -72,7 +70,7 @@ function Get-AzKubernetesConfigFluxOperationStatus {
7270
# Name of the Flux Configuration.
7371
${FluxConfigurationName},
7472

75-
[Parameter(ParameterSetName = 'Get', Mandatory)]
73+
[Parameter(ParameterSetName='Get', Mandatory)]
7674
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Category('Path')]
7775
[System.String]
7876
# operation Id
@@ -151,7 +149,7 @@ function Get-AzKubernetesConfigFluxOperationStatus {
151149
process {
152150
try {
153151
$hasInputObject = $PSBoundParameters.Remove('InputObject')
154-
152+
155153
if ($hasInputObject) {
156154
$null = $PSBoundParameters.Add('InputObject', $InputObject)
157155
}

src/KubernetesConfiguration/KubernetesConfiguration.Autorest/custom/Get-AzKubernetesConfiguration.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ Gets details of the Source Control Configuration.
2020
.Description
2121
Gets details of the Source Control Configuration.
2222
.Example
23-
{{ Add code here }}
23+
Get-AzKubernetesConfiguration -ResourceGroupName azps_test_group -ClusterName azpstest_cluster_arc -ClusterType ConnectedClusters
2424
.Example
25-
{{ Add code here }}
25+
Get-AzKubernetesConfiguration -ResourceGroupName azps_test_group -ClusterName azpstest_cluster_arc -ClusterType ConnectedClusters -Name azpstestk8s
2626
2727
.Inputs
2828
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IKubernetesConfigurationIdentity
2929
.Outputs
30-
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.ISourceControlConfiguration
30+
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.ISourceControlConfiguration
3131
.Notes
3232
COMPLEX PARAMETER PROPERTIES
3333
@@ -49,7 +49,7 @@ https://learn.microsoft.com/powershell/module/az.kubernetesconfiguration/get-azk
4949
#>
5050
function Get-AzKubernetesConfiguration {
5151
[Alias('Get-AzK8sConfiguration')]
52-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.ISourceControlConfiguration])]
52+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.ISourceControlConfiguration])]
5353
[CmdletBinding(DefaultParameterSetName = 'List', PositionalBinding = $false)]
5454
param(
5555
[Parameter(ParameterSetName = 'Get', Mandatory)]

src/KubernetesConfiguration/KubernetesConfiguration.Autorest/custom/Get-AzKubernetesConfigurationFlux.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ Gets details of the Flux Configuration.
2020
.Description
2121
Gets details of the Flux Configuration.
2222
.Example
23-
{{ Add code here }}
23+
Get-AzKubernetesConfigurationFlux -ClusterName azpstest_cluster_arc -ClusterType ConnectedClusters -ResourceGroupName azps_test_group
2424
.Example
25-
{{ Add code here }}
25+
Get-AzKubernetesConfigurationFlux -ClusterName azpstest_cluster_arc -ClusterType ConnectedClusters -Name azpstestflux-k8s -ResourceGroupName azps_test_group
2626
2727
.Inputs
2828
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IKubernetesConfigurationIdentity
2929
.Outputs
30-
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.IFluxConfiguration
30+
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IFluxConfiguration
3131
.Notes
3232
COMPLEX PARAMETER PROPERTIES
3333
@@ -49,7 +49,7 @@ https://learn.microsoft.com/powershell/module/az.kubernetesconfiguration/get-azk
4949
#>
5050
function Get-AzKubernetesConfigurationFlux {
5151
[Alias('Get-AzK8sConfigurationFlux')]
52-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.IFluxConfiguration])]
52+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IFluxConfiguration])]
5353
[CmdletBinding(DefaultParameterSetName = 'List', PositionalBinding = $false)]
5454
param(
5555
[Parameter(ParameterSetName = 'Get', Mandatory)]

src/KubernetesConfiguration/KubernetesConfiguration.Autorest/custom/Get-AzKubernetesExtension.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ Gets Kubernetes Cluster Extension.
2020
.Description
2121
Gets Kubernetes Cluster Extension.
2222
.Example
23-
{{ Add code here }}
23+
Get-AzKubernetesExtension -ClusterName azpstest_cluster_arc -ClusterType ConnectedClusters -Name azpstest-extension -ResourceGroupName azps_test_group
2424
.Example
25-
{{ Add code here }}
25+
Get-AzKubernetesExtension -ClusterName azpstest_cluster_arc -ClusterType ConnectedClusters -ResourceGroupName azps_test_group
2626
2727
.Inputs
2828
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IKubernetesConfigurationIdentity
2929
.Outputs
30-
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.IExtension
30+
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IExtension
3131
.Notes
3232
COMPLEX PARAMETER PROPERTIES
3333
@@ -49,7 +49,7 @@ https://learn.microsoft.com/powershell/module/az.kubernetesconfiguration/get-azk
4949
#>
5050
function Get-AzKubernetesExtension {
5151
[Alias('Get-AzK8sExtension')]
52-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.IExtension])]
52+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IExtension])]
5353
[CmdletBinding(DefaultParameterSetName = 'List', PositionalBinding = $false)]
5454
param(
5555
[Parameter(ParameterSetName = 'Get', Mandatory)]

src/KubernetesConfiguration/KubernetesConfiguration.Autorest/custom/New-AzKubernetesConfiguration.ps1

+14-13
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ Create a new Kubernetes Source Control Configuration.
2020
.Description
2121
Create a new Kubernetes Source Control Configuration.
2222
.Example
23-
{{ Add code here }}
23+
New-AzConnectedKubernetes -ClusterName azpstest_cluster_arc -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01
24+
New-AzKubernetesConfiguration -ResourceGroupName azps_test_group -ClusterName azpstest_cluster_arc -Name azpstestk8s -RepositoryUrl http://github.com/xxxx -ClusterType ConnectedClusters
2425
.Example
25-
{{ Add code here }}
26+
New-AzConnectedKubernetes -ClusterName azpstest_cluster_arc -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01
27+
New-AzKubernetesConfiguration -ResourceGroupName azps_test_group -ClusterName azpstest_cluster_arc -Name azpstestk8s-operator -RepositoryUrl http://github.com/xxxx -OperatorScope 'cluster' -ClusterType ConnectedClusters
2628
2729
.Outputs
28-
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.ISourceControlConfiguration
30+
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.ISourceControlConfiguration
2931
.Link
3032
https://learn.microsoft.com/powershell/module/az.kubernetesconfiguration/new-azkubernetesconfiguration
3133
#>
3234
function New-AzKubernetesConfiguration {
3335
[Alias('New-AzK8sConfiguration')]
34-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.ISourceControlConfiguration])]
36+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.ISourceControlConfiguration])]
3537
[CmdletBinding(DefaultParameterSetName = 'CreateExpanded', PositionalBinding = $false, SupportsShouldProcess, ConfirmImpact = 'Medium')]
3638
param(
3739
[Parameter(Mandatory)]
@@ -71,15 +73,14 @@ function New-AzKubernetesConfiguration {
7173

7274
[Parameter()]
7375
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Category('Body')]
74-
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Runtime.Info(PossibleTypes = ([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.IConfigurationProtectedSettings]))]
76+
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Runtime.Info(PossibleTypes = ([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IConfigurationProtectedSettings]))]
7577
[System.Collections.Hashtable]
7678
# Name-value pairs of protected configuration settings for the configuration
7779
${ConfigurationProtectedSetting},
7880

7981
[Parameter()]
8082
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Category('Body')]
8183
[System.Management.Automation.SwitchParameter]
82-
[switch]
8384
# Option to enable Helm Operator for this git configuration.
8485
${EnableHelmOperator},
8586

@@ -115,16 +116,16 @@ function New-AzKubernetesConfiguration {
115116
${OperatorParam},
116117

117118
[Parameter()]
118-
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.OperatorScopeType])]
119+
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.PSArgumentCompleterAttribute("cluster", "namespace")]
119120
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Category('Body')]
120-
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.OperatorScopeType]
121+
[System.String]
121122
# Scope at which the operator will be installed.
122123
${OperatorScope},
123124

124125
[Parameter()]
125-
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.OperatorType])]
126+
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.PSArgumentCompleterAttribute("Flux")]
126127
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Category('Body')]
127-
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.OperatorType]
128+
[System.String]
128129
# Type of the operator
129130
${OperatorType},
130131

@@ -196,10 +197,10 @@ function New-AzKubernetesConfiguration {
196197
process {
197198
try {
198199
if ($PSBoundParameters.ContainsKey('ClusterScoped')) {
199-
$PSBoundParameters.OperatorScope = [Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.OperatorScopeType]::Cluster
200+
$PSBoundParameters.OperatorScope = 'Cluster'
200201
}
201202
else {
202-
$PSBoundParameters.OperatorScope = [Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.OperatorScopeType]::Namespace
203+
$PSBoundParameters.OperatorScope = 'Namespace'
203204
}
204205

205206
if ($ClusterType -eq 'ManagedClusters') {
@@ -215,7 +216,7 @@ function New-AzKubernetesConfiguration {
215216
Write-Error "Please select ClusterType from the following three values: 'ManagedClusters', 'ConnectedClusters', 'ProvisionedClusters'"
216217
}
217218

218-
$PSBoundParameters.Add('OperatorType', [Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.OperatorType]::Flux)
219+
$PSBoundParameters.Add('OperatorType', 'Flux')
219220

220221
write-host "Azure Kubernetes Configuration is being created, need to wait a few minutes..."
221222
Az.KubernetesConfiguration.internal\New-AzKubernetesConfiguration @PSBoundParameters

src/KubernetesConfiguration/KubernetesConfiguration.Autorest/custom/New-AzKubernetesConfigurationFlux.ps1

+22-11
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,29 @@ Create a new Kubernetes Flux Configuration.
2020
.Description
2121
Create a new Kubernetes Flux Configuration.
2222
.Example
23-
{{ Add code here }}
24-
.Example
25-
{{ Add code here }}
23+
$kustomizations = @{
24+
infra=@{
25+
Name = "infra"
26+
Path = "./infrastructure"
27+
Prune = "true"
28+
};
29+
apps=@{
30+
Name = "apps"
31+
Path = "./apps/staging"
32+
Prune = "true"
33+
DependsOn = @("infra")
34+
}
35+
}
36+
New-AzKubernetesConfigurationFlux -ClusterName azpstest_cluster_arc -ClusterType ConnectedClusters -Name azpstestflux-k8s -ResourceGroupName azpstest_gp -Namespace namespace-t01 -Scope 'cluster' -GitRepositoryUrl https://github.com/Azure/gitops-flux2-kustomize-helm-mt -RepositoryRefBranch main -SourceKind 'GitRepository' -GitRepositorySyncIntervalInSecond 600 -GitRepositoryTimeoutInSecond 600 -Suspend:$false -Kustomization $kustomizations
2637
2738
.Outputs
28-
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.IFluxConfiguration
39+
Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IFluxConfiguration
2940
.Link
3041
https://learn.microsoft.com/powershell/module/az.kubernetesconfiguration/new-azkubernetesconfigurationflux
3142
#>
3243
function New-AzKubernetesConfigurationFlux {
3344
[Alias('New-AzK8sConfigurationFlux')]
34-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.IFluxConfiguration])]
45+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IFluxConfiguration])]
3546
[CmdletBinding(DefaultParameterSetName = 'CreateExpanded', PositionalBinding = $false, SupportsShouldProcess, ConfirmImpact = 'Medium')]
3647
param(
3748
[Parameter(Mandatory)]
@@ -155,7 +166,7 @@ function New-AzKubernetesConfigurationFlux {
155166

156167
[Parameter()]
157168
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Category('Body')]
158-
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Runtime.Info(PossibleTypes = ([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.IFluxConfigurationPropertiesConfigurationProtectedSettings]))]
169+
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Runtime.Info(PossibleTypes = ([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IFluxConfigurationPropertiesConfigurationProtectedSettings]))]
159170
[System.Collections.Hashtable]
160171
# Key-value pairs of protected configuration settings for the configuration
161172
${ConfigurationProtectedSetting},
@@ -204,7 +215,7 @@ function New-AzKubernetesConfigurationFlux {
204215

205216
[Parameter()]
206217
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Category('Body')]
207-
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Runtime.Info(PossibleTypes = ([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.Api20221101.IFluxConfigurationPropertiesKustomizations]))]
218+
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Runtime.Info(PossibleTypes = ([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Models.IFluxConfigurationPropertiesKustomizations]))]
208219
[System.Collections.Hashtable]
209220
# Array of kustomizations used to reconcile the artifact pulled by the source type on the cluster.
210221
${Kustomization},
@@ -251,9 +262,9 @@ function New-AzKubernetesConfigurationFlux {
251262
${RepositoryRefTag},
252263

253264
[Parameter()]
254-
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.ScopeType])]
265+
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.PSArgumentCompleterAttribute("cluster", "namespace")]
255266
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Category('Body')]
256-
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.ScopeType]
267+
[System.String]
257268
# Scope at which the operator will be installed.
258269
${Scope},
259270

@@ -294,9 +305,9 @@ function New-AzKubernetesConfigurationFlux {
294305
${ServicePrincipalTenantId},
295306

296307
[Parameter()]
297-
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.SourceKindType])]
308+
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.PSArgumentCompleterAttribute("GitRepository", "Bucket", "AzureBlob")]
298309
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Category('Body')]
299-
[Microsoft.Azure.PowerShell.Cmdlets.KubernetesConfiguration.Support.SourceKindType]
310+
[System.String]
300311
# Source Kind to pull the configuration data from.
301312
${SourceKind},
302313

0 commit comments

Comments
 (0)