@@ -5,7 +5,7 @@ $TSP_LOCATION_FILE = "tsp-location.yaml"
5
5
. (Join-Path $PSScriptRoot " .." " .." " common" " scripts" " Helpers" PSModule- Helpers.ps1)
6
6
7
7
# mgmt: swagger directory name to sdk directory name map
8
- $packageNameHash = [ordered ]@ {" vmware" = " avs" ;
8
+ $packageNameHash = [ordered ]@ {" vmware" = " avs" ;
9
9
" azure-kusto" = " kusto" ;
10
10
" cosmos-db" = " cosmosdb" ;
11
11
" msi" = " managedserviceidentity" ;
@@ -55,7 +55,7 @@ function Get-SwaggerInfo()
55
55
create or update the autorest config file for sdk (autorest.md)
56
56
57
57
. DESCRIPTION
58
- 1. update input-file or require block according to the input parameter. If readme parameter is provided, autorest.md will
58
+ 1. update input-file or require block according to the input parameter. If readme parameter is provided, autorest.md will
59
59
contain only require block, if input-file parameter is provided, autorest.md will contain only require block.
60
60
2. merge the autorestConfig to the autorest.md
61
61
@@ -111,9 +111,9 @@ function CreateOrUpdateAutorestConfigFile() {
111
111
112
112
$inputRegex = " (?:(?:input-file|require)\s*:\s*\r?\n(?:\s*-\s+.*\r?\n)+|(?:input-file|require):\s+.*)"
113
113
$fileContent = $fileContent -replace $inputRegex , $configline
114
- $fileContent | Set-Content $autorestFilePath
114
+ $fileContent | Set-Content $autorestFilePath
115
115
}
116
-
116
+
117
117
# update autorest.md with configuration
118
118
if ( $autorestConfigYaml ) {
119
119
Write-Host " Update autorest.md with configuration."
@@ -153,7 +153,7 @@ function CreateOrUpdateAutorestConfigFile() {
153
153
Throw " autorest.md does not exist, and no autorest configuration to create one."
154
154
}
155
155
}
156
- }
156
+ }
157
157
158
158
function Update-CIYmlFile () {
159
159
param (
@@ -177,6 +177,44 @@ function Update-CIYmlFile() {
177
177
}
178
178
}
179
179
180
+ function RegisterMgmtSDKToMgmtCoreClient () {
181
+ param (
182
+ [string ]$packagesPath
183
+ )
184
+ $track2MgmtDirs = Get-ChildItem - Path " $packagesPath " - Directory - Recurse - Depth 1 | Where-Object { $_.Name -match " (Azure.ResourceManager.)" -and $ (Test-Path (" $ ( $_.FullName ) /src" )) }
185
+ Write-Host " Updating mgmt core client ci.mgmt.yml"
186
+ # add path for each mgmt library into Azure.ResourceManager
187
+ $armCiFile = " $packagesPath /resourcemanager/ci.mgmt.yml"
188
+ $armLines = Get-Content $armCiFile
189
+ $newLines = [System.Collections.ArrayList ]::new()
190
+ $startIndex = $track2MgmtDirs [0 ].FullName.Replace(' \' , ' /' ).IndexOf((" /sdk/" )) + 1
191
+ $shouldRemove = $false
192
+ foreach ($line in $armLines ) {
193
+ if ($line.StartsWith (" paths:" )) {
194
+ $newLines.Add ($line ) | Out-Null
195
+ $newLines.Add (" include:" ) | Out-Null
196
+ $newLines.Add (" - sdk/resourcemanager" ) | Out-Null
197
+ $newLines.Add (" - common/ManagementTestShared" ) | Out-Null
198
+ $newLines.Add (" - common/ManagementCoreShared" ) | Out-Null
199
+ foreach ($dir in $track2MgmtDirs ) {
200
+ $newLine = " - $ ( $dir.FullName.Replace (' \' , ' /' ).Substring($startIndex , $dir.FullName.Length - $startIndex )) "
201
+ $newLines.Add ($newLine ) | Out-Null
202
+ }
203
+ $shouldRemove = $true
204
+ Continue
205
+ }
206
+
207
+ if ($shouldRemove ) {
208
+ if ($line.StartsWith (" " )) {
209
+ Continue
210
+ }
211
+ $shouldRemove = $false
212
+ }
213
+
214
+ $newLines.Add ($line ) | Out-Null
215
+ }
216
+ Set-Content - Path $armCiFile $newLines
217
+ }
180
218
<#
181
219
. SYNOPSIS
182
220
Prepare the SDK pacakge for data-plane.
@@ -310,7 +348,7 @@ function New-MgmtPackageFolder() {
310
348
[string ]$AUTOREST_CONFIG_FILE = " autorest.md" ,
311
349
[string ]$outputJsonFile = " newPacakgeOutput.json"
312
350
)
313
-
351
+
314
352
if ($packageName -eq " " ) {
315
353
$packageName = $service
316
354
}
@@ -334,8 +372,11 @@ function New-MgmtPackageFolder() {
334
372
Push-Location $projectFolder
335
373
dotnet new azuremgmt -- provider $packageName -- includeCI true -- force
336
374
Pop-Location
375
+
376
+ $packagesPath = Join-Path $sdkPath " sdk"
377
+ RegisterMgmtSDKToMgmtCoreClient - packagesPath $packagesPath
337
378
}
338
-
379
+
339
380
# update the readme path.
340
381
if ($readme ) {
341
382
Write-Host " Updating autorest.md file."
@@ -344,19 +385,19 @@ function New-MgmtPackageFolder() {
344
385
$file = " $projectFolder /src/$AUTOREST_CONFIG_FILE "
345
386
(Get-Content $file ) -replace $rquirefileRex , " $requirefile " | Set-Content $file
346
387
}
347
-
388
+
348
389
Push-Location $sdkPath
349
390
$relativeFolderPath = Resolve-Path $projectFolder - Relative
350
391
Pop-Location
351
-
392
+
352
393
$outputJson = [PSCustomObject ]@ {
353
394
service = $service
354
395
packageName = $mgmtPackageName
355
396
projectFolder = $projectFolder
356
397
path = @ ($relativeFolderPath )
357
398
}
358
399
$outputJson | ConvertTo-Json - depth 100 | Out-File $outputJsonFile
359
-
400
+
360
401
return $projectFolder
361
402
}
362
403
@@ -368,7 +409,7 @@ function CreateOrUpdateTypeSpecConfigFile() {
368
409
[string ]$repo = " " ,
369
410
[string ]$specRoot = " " ,
370
411
[string ]$additionalSubDirectories = " " # additional directories needed, separated by semicolon if more than one
371
-
412
+
372
413
)
373
414
if (! (Test-Path - Path $typespecConfigurationFile )) {
374
415
New-Item - Path $typespecConfigurationFile
@@ -433,15 +474,15 @@ function New-TypeSpecPackageFolder() {
433
474
if (Test-Path - Path $projectFolder / src/ autorest.md) {
434
475
Remove-Item - Path $projectFolder / src/ autorest.md
435
476
}
436
-
477
+
437
478
CreateOrUpdateTypeSpecConfigFile `
438
479
- typespecConfigurationFile $projectFolder / $TSP_LOCATION_FILE `
439
480
- directory $relatedTypeSpecProjectFolder `
440
481
- commit $commit `
441
482
- repo $repo `
442
483
- specRoot $specRoot `
443
484
- additionalSubDirectories $additionalSubDirectories
444
-
485
+
445
486
Update-CIYmlFile - ciFilePath $ciymlFilePath - artifact $namespace
446
487
} else {
447
488
Write-Host " Path doesn't exist. create template."
@@ -461,7 +502,7 @@ function New-TypeSpecPackageFolder() {
461
502
$clientName = $namespaceArray [-1 ]
462
503
$groupName = $namespaceArray [1 .. $endIndex ] -join " ."
463
504
$dotnetNewCmd = " dotnet new azsdkdpg --name $namespace --clientName $clientName --groupName $groupName --serviceDirectory $service --force"
464
-
505
+
465
506
if (Test-Path - Path $ciymlFilePath ) {
466
507
Write-Host " ci.yml already exists. update it to include the new serviceDirectory."
467
508
Update-CIYmlFile - ciFilePath $ciymlFilePath - artifact $namespace
@@ -576,12 +617,12 @@ function Invoke-GenerateAndBuildSDK () {
576
617
Write-Host " readmeFile:$readmeFile "
577
618
$service , $serviceType = Get-ResourceProviderFromReadme $readmeFile
578
619
Write-Host " service:$service , serviceType:$serviceType "
579
-
620
+
580
621
if (! $readmeFile.StartsWith (" http" ) -And ! (Test-Path - Path $readmeFile )) {
581
622
Write-Error " readme file '$readmeFile ' does not exist."
582
623
exit 1
583
624
}
584
-
625
+
585
626
$packagesToGen = @ ()
586
627
$newPackageOutput = " newPackageOutput.json"
587
628
if ( $serviceType -eq " resource-manager" ) {
@@ -747,7 +788,7 @@ function GeneratePackage()
747
788
Remove-Item $logFilePath
748
789
}
749
790
}
750
-
791
+
751
792
$changelog = [PSCustomObject ]@ {
752
793
content = $content
753
794
hasBreakingChange = $hasBreakingChange
@@ -778,7 +819,7 @@ function GeneratePackage()
778
819
if ( $serviceType -eq " resource-manager" ) {
779
820
$ciFilePath = " sdk/$service /ci.mgmt.yml"
780
821
}
781
- $generatedSDKPackages.Add (@ {packageName = " $packageName " ;
822
+ $generatedSDKPackages.Add (@ {packageName = " $packageName " ;
782
823
result = $result ;
783
824
path = @ (" $path " , " $ciFilePath " );
784
825
packageFolder = " $projectFolder " ;
@@ -801,7 +842,7 @@ function UpdateExistingSDKByInputFiles()
801
842
802
843
$autorestFilesPath = Get-ChildItem - Path " $sdkRootPath /sdk" - Filter autorest.md - Recurse | Resolve-Path - Relative
803
844
Write-Host " Updating autorest.md files for all the changed swaggers."
804
-
845
+
805
846
$sdksInfo = @ {}
806
847
$regexToFindSha = " https:\/\/[^`" ]*[\/][0-9a-f]{4,40}[\/]"
807
848
foreach ($path in $autorestFilesPath ) {
@@ -834,5 +875,5 @@ function UpdateExistingSDKByInputFiles()
834
875
$projectFolder = Resolve-Path - Path $projectFolder
835
876
GeneratePackage - projectFolder $projectFolder - sdkRootPath $sdkRootPath - path $path - downloadUrlPrefix " $downloadUrlPrefix " - serviceType $serviceType - generatedSDKPackages $generatedSDKPackages
836
877
}
837
-
878
+
838
879
}
0 commit comments