@@ -5,7 +5,7 @@ $TSP_LOCATION_FILE = "tsp-location.yaml"
55. (Join-Path $PSScriptRoot " .." " .." " common" " scripts" " Helpers" PSModule- Helpers.ps1)
66
77# mgmt: swagger directory name to sdk directory name map
8- $packageNameHash = [ordered ]@ {" vmware" = " avs" ;
8+ $packageNameHash = [ordered ]@ {" vmware" = " avs" ;
99 " azure-kusto" = " kusto" ;
1010 " cosmos-db" = " cosmosdb" ;
1111 " msi" = " managedserviceidentity" ;
@@ -55,7 +55,7 @@ function Get-SwaggerInfo()
5555create or update the autorest config file for sdk (autorest.md)
5656
5757. 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
5959contain only require block, if input-file parameter is provided, autorest.md will contain only require block.
60602. merge the autorestConfig to the autorest.md
6161
@@ -111,9 +111,9 @@ function CreateOrUpdateAutorestConfigFile() {
111111
112112 $inputRegex = " (?:(?:input-file|require)\s*:\s*\r?\n(?:\s*-\s+.*\r?\n)+|(?:input-file|require):\s+.*)"
113113 $fileContent = $fileContent -replace $inputRegex , $configline
114- $fileContent | Set-Content $autorestFilePath
114+ $fileContent | Set-Content $autorestFilePath
115115 }
116-
116+
117117 # update autorest.md with configuration
118118 if ( $autorestConfigYaml ) {
119119 Write-Host " Update autorest.md with configuration."
@@ -153,7 +153,7 @@ function CreateOrUpdateAutorestConfigFile() {
153153 Throw " autorest.md does not exist, and no autorest configuration to create one."
154154 }
155155 }
156- }
156+ }
157157
158158function Update-CIYmlFile () {
159159 param (
@@ -177,6 +177,44 @@ function Update-CIYmlFile() {
177177 }
178178}
179179
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+ }
180218<#
181219. SYNOPSIS
182220Prepare the SDK pacakge for data-plane.
@@ -310,7 +348,7 @@ function New-MgmtPackageFolder() {
310348 [string ]$AUTOREST_CONFIG_FILE = " autorest.md" ,
311349 [string ]$outputJsonFile = " newPacakgeOutput.json"
312350 )
313-
351+
314352 if ($packageName -eq " " ) {
315353 $packageName = $service
316354 }
@@ -334,8 +372,11 @@ function New-MgmtPackageFolder() {
334372 Push-Location $projectFolder
335373 dotnet new azuremgmt -- provider $packageName -- includeCI true -- force
336374 Pop-Location
375+
376+ $packagesPath = Join-Path $sdkPath " sdk"
377+ RegisterMgmtSDKToMgmtCoreClient - packagesPath $packagesPath
337378 }
338-
379+
339380 # update the readme path.
340381 if ($readme ) {
341382 Write-Host " Updating autorest.md file."
@@ -344,19 +385,19 @@ function New-MgmtPackageFolder() {
344385 $file = " $projectFolder /src/$AUTOREST_CONFIG_FILE "
345386 (Get-Content $file ) -replace $rquirefileRex , " $requirefile " | Set-Content $file
346387 }
347-
388+
348389 Push-Location $sdkPath
349390 $relativeFolderPath = Resolve-Path $projectFolder - Relative
350391 Pop-Location
351-
392+
352393 $outputJson = [PSCustomObject ]@ {
353394 service = $service
354395 packageName = $mgmtPackageName
355396 projectFolder = $projectFolder
356397 path = @ ($relativeFolderPath )
357398 }
358399 $outputJson | ConvertTo-Json - depth 100 | Out-File $outputJsonFile
359-
400+
360401 return $projectFolder
361402}
362403
@@ -368,7 +409,7 @@ function CreateOrUpdateTypeSpecConfigFile() {
368409 [string ]$repo = " " ,
369410 [string ]$specRoot = " " ,
370411 [string ]$additionalSubDirectories = " " # additional directories needed, separated by semicolon if more than one
371-
412+
372413 )
373414 if (! (Test-Path - Path $typespecConfigurationFile )) {
374415 New-Item - Path $typespecConfigurationFile
@@ -433,15 +474,15 @@ function New-TypeSpecPackageFolder() {
433474 if (Test-Path - Path $projectFolder / src/ autorest.md) {
434475 Remove-Item - Path $projectFolder / src/ autorest.md
435476 }
436-
477+
437478 CreateOrUpdateTypeSpecConfigFile `
438479 - typespecConfigurationFile $projectFolder / $TSP_LOCATION_FILE `
439480 - directory $relatedTypeSpecProjectFolder `
440481 - commit $commit `
441482 - repo $repo `
442483 - specRoot $specRoot `
443484 - additionalSubDirectories $additionalSubDirectories
444-
485+
445486 Update-CIYmlFile - ciFilePath $ciymlFilePath - artifact $namespace
446487 } else {
447488 Write-Host " Path doesn't exist. create template."
@@ -461,7 +502,7 @@ function New-TypeSpecPackageFolder() {
461502 $clientName = $namespaceArray [-1 ]
462503 $groupName = $namespaceArray [1 .. $endIndex ] -join " ."
463504 $dotnetNewCmd = " dotnet new azsdkdpg --name $namespace --clientName $clientName --groupName $groupName --serviceDirectory $service --force"
464-
505+
465506 if (Test-Path - Path $ciymlFilePath ) {
466507 Write-Host " ci.yml already exists. update it to include the new serviceDirectory."
467508 Update-CIYmlFile - ciFilePath $ciymlFilePath - artifact $namespace
@@ -576,12 +617,12 @@ function Invoke-GenerateAndBuildSDK () {
576617 Write-Host " readmeFile:$readmeFile "
577618 $service , $serviceType = Get-ResourceProviderFromReadme $readmeFile
578619 Write-Host " service:$service , serviceType:$serviceType "
579-
620+
580621 if (! $readmeFile.StartsWith (" http" ) -And ! (Test-Path - Path $readmeFile )) {
581622 Write-Error " readme file '$readmeFile ' does not exist."
582623 exit 1
583624 }
584-
625+
585626 $packagesToGen = @ ()
586627 $newPackageOutput = " newPackageOutput.json"
587628 if ( $serviceType -eq " resource-manager" ) {
@@ -747,7 +788,7 @@ function GeneratePackage()
747788 Remove-Item $logFilePath
748789 }
749790 }
750-
791+
751792 $changelog = [PSCustomObject ]@ {
752793 content = $content
753794 hasBreakingChange = $hasBreakingChange
@@ -778,7 +819,7 @@ function GeneratePackage()
778819 if ( $serviceType -eq " resource-manager" ) {
779820 $ciFilePath = " sdk/$service /ci.mgmt.yml"
780821 }
781- $generatedSDKPackages.Add (@ {packageName = " $packageName " ;
822+ $generatedSDKPackages.Add (@ {packageName = " $packageName " ;
782823 result = $result ;
783824 path = @ (" $path " , " $ciFilePath " );
784825 packageFolder = " $projectFolder " ;
@@ -801,7 +842,7 @@ function UpdateExistingSDKByInputFiles()
801842
802843 $autorestFilesPath = Get-ChildItem - Path " $sdkRootPath /sdk" - Filter autorest.md - Recurse | Resolve-Path - Relative
803844 Write-Host " Updating autorest.md files for all the changed swaggers."
804-
845+
805846 $sdksInfo = @ {}
806847 $regexToFindSha = " https:\/\/[^`" ]*[\/][0-9a-f]{4,40}[\/]"
807848 foreach ($path in $autorestFilesPath ) {
@@ -834,5 +875,5 @@ function UpdateExistingSDKByInputFiles()
834875 $projectFolder = Resolve-Path - Path $projectFolder
835876 GeneratePackage - projectFolder $projectFolder - sdkRootPath $sdkRootPath - path $path - downloadUrlPrefix " $downloadUrlPrefix " - serviceType $serviceType - generatedSDKPackages $generatedSDKPackages
836877 }
837-
878+
838879}
0 commit comments