Skip to content

Commit 85ffc83

Browse files
authored
remove scaffolding for sdks from swagger (Azure#47688)
* remove scaffolding for sdks from swagger * add more detail message
1 parent 77a28ed commit 85ffc83

File tree

1 file changed

+62
-101
lines changed

1 file changed

+62
-101
lines changed

eng/scripts/automation/GenerateAndBuildLib.ps1

Lines changed: 62 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ function RegisterMgmtSDKToMgmtCoreClient () {
220220
<#
221221
.SYNOPSIS
222222
Prepare the SDK pacakge for data-plane.
223-
If it does not exist, create SDK package via dotnet template, or update the autorest.md if it already exists.
223+
Update the autorest.md.
224224
225225
#>
226-
function New-DataPlanePackageFolder() {
226+
function Update-DataPlanePackageFolder() {
227227
param(
228228
[string]$service,
229229
[string]$namespace,
@@ -263,61 +263,9 @@ function New-DataPlanePackageFolder() {
263263
CreateOrUpdateAutorestConfigFile -autorestFilePath $file -namespace $namespace -inputfile "$inputfile" -readme "$readme" -autorestConfigYaml "$autorestConfigYaml"
264264
Update-CIYmlFile -ciFilePath $ciymlFilePath -artifact $namespace
265265
} else {
266-
Write-Host "Path doesn't exist. create template."
267-
if ($inputfile -eq "" -And $readme -eq "") {
268-
Throw "[ERROR] Input file should not be empty. Please provide a valid input file or readme file."
269-
}
270-
dotnet new -i $sdkPath/sdk/template
271-
Write-Host "Create project folder $projectFolder"
272-
if (Test-Path -Path $projectFolder) {
273-
Remove-Item -Path $projectFolder -ItemType Directory
274-
}
275-
276-
Push-Location $serviceFolder
277-
$namespaceArray = $namespace.Split(".")
278-
if ( $namespaceArray.Count -lt 3) {
279-
Throw "[ERROR] Invalid namespace name provided: $namespace. Please provide valid namespace."
280-
}
281-
282-
$endIndex = $namespaceArray.Count - 2
283-
$clientName = $namespaceArray[-1]
284-
$groupName = $namespaceArray[1..$endIndex] -join "."
285-
$dotnetNewCmd = "dotnet new azsdkdpg --name $namespace --clientName $clientName --groupName $groupName --serviceDirectory $service --force"
286-
if ($inputfile -ne "") {
287-
$dotnetNewCmd = $dotnetNewCmd + " --swagger '$inputfile'"
288-
}
289-
if ($securityScope -ne "") {
290-
$dotnetNewCmd = $dotnetNewCmd + " --securityScopes $securityScope";
291-
}
292-
293-
if ($securityHeaderName -ne "") {
294-
$dotnetNewCmd = $dotnetNewCmd + " --securityHeaderName $securityHeaderName";
295-
}
296-
297-
if (Test-Path -Path $ciymlFilePath) {
298-
Write-Host "ci.yml already exists. update it to include the new serviceDirectory."
299-
Update-CIYmlFile -ciFilePath $ciymlFilePath -artifact $namespace
300-
301-
$dotnetNewCmd = $dotnetNewCmd + " --includeCI false"
302-
}
303-
# dotnet new azsdkdpg --name $namespace --clientName $clientName --groupName $groupName --serviceDirectory $service --swagger $inputfile --securityScopes $securityScope --securityHeaderName $securityHeaderName --includeCI true --force
304-
Write-Host "Invoke dotnet new command: $dotnetNewCmd"
305-
Invoke-Expression $dotnetNewCmd
306-
307-
$file = (Join-Path $projectFolder "src" $AUTOREST_CONFIG_FILE)
308-
Write-Host "Updating configuration file: $file"
309-
CreateOrUpdateAutorestConfigFile -autorestFilePath $file -namespace $namespace -readme "$readme" -autorestConfigYaml "$autorestConfigYaml"
310-
Pop-Location
311-
312-
$projFile = (Join-Path $projectFolder "src" "$namespace.csproj")
313-
(Get-Content $projFile) -replace "<Version>*.*.*-*.*</Version>", "<Version>1.0.0-beta.1</Version>" | Set-Content $projFile
314-
# dotnet sln
315-
Push-Location $projectFolder
316-
dotnet sln remove src/$namespace.csproj
317-
dotnet sln add src/$namespace.csproj
318-
dotnet sln remove tests/$namespace.Tests.csproj
319-
dotnet sln add tests/$namespace.Tests.csproj
320-
Pop-Location
266+
Write-Error "Project directory doesn't exist. It is a new .NET SDK."
267+
Write-Error "We will not support onboard a new SDK from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
268+
exit 1
321269
}
322270

323271
Push-Location $sdkPath
@@ -338,10 +286,10 @@ function New-DataPlanePackageFolder() {
338286
<#
339287
.SYNOPSIS
340288
Prepare the SDK pacakge for mangement-plane.
341-
If it does not exist, create SDK package via dotnet template, or update the autorest.md if it already exists.
289+
Update the autorest.md.
342290
343291
#>
344-
function New-MgmtPackageFolder() {
292+
function Update-MgmtPackageFolder() {
345293
param(
346294
[string]$service = "",
347295
[string]$packageName = "",
@@ -364,19 +312,9 @@ function New-MgmtPackageFolder() {
364312
$mgmtPackageName = $folderinfo.Name
365313
$projectFolder = "$sdkPath/sdk/$packageName/$mgmtPackageName"
366314
} else {
367-
Write-Host "Path doesn't exist. create template."
368-
dotnet new -i $sdkPath/eng/templates/Azure.ResourceManager.Template
369-
$CaptizedPackageName = [System.Globalization.CultureInfo]::InvariantCulture.TextInfo.ToTitleCase($packageName)
370-
$mgmtPackageName = "Azure.ResourceManager.$CaptizedPackageName"
371-
$projectFolder="$sdkPath/sdk/$packageName/Azure.ResourceManager.$CaptizedPackageName"
372-
Write-Host "Create project folder $projectFolder"
373-
New-Item -Path $projectFolder -ItemType Directory
374-
Push-Location $projectFolder
375-
dotnet new azuremgmt --provider $packageName --includeCI true --force
376-
Pop-Location
377-
378-
$packagesPath = Join-Path $sdkPath "sdk"
379-
RegisterMgmtSDKToMgmtCoreClient -packagesPath $packagesPath
315+
Write-Error "Project directory doesn't exist. It is a new .NET SDK."
316+
Write-Error "We will not support onboard a new service SDK from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
317+
exit 1
380318
}
381319

382320
# update the readme path.
@@ -635,17 +573,24 @@ function Invoke-GenerateAndBuildSDK () {
635573
if ($packageNameHash[$service] -ne "") {
636574
$package = $packageNameHash[$service]
637575
}
638-
New-MgmtPackageFolder -service $service -packageName $package -sdkPath $sdkRootPath -commitid $commitid -readme $readmeFile -outputJsonFile $newpackageoutput
639-
if ( !$?) {
640-
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,package:$package,"
641-
Write-Host "[ERROR] sdkPath:$sdkRootPath,readme:$readmeFile.exit code: $?."
642-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
643-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
576+
$projectFolder = (Join-Path $sdkRootPath "sdk" $package "Azure.ResourceManager.*")
577+
if (Test-Path -Path $projectFolder) {
578+
Update-MgmtPackageFolder -service $service -packageName $package -sdkPath $sdkRootPath -commitid $commitid -readme $readmeFile -outputJsonFile $newpackageoutput
579+
if ( !$?) {
580+
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,package:$package,"
581+
Write-Host "[ERROR] sdkPath:$sdkRootPath,readme:$readmeFile.exit code: $?."
582+
Write-Host "[ERROR] Please review the detail errors for potential fixes."
583+
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
584+
exit 1
585+
}
586+
$newPackageOutputJson = Get-Content $newPackageOutput | Out-String | ConvertFrom-Json
587+
$packagesToGen = $packagesToGen + @($newPackageOutputJson)
588+
Remove-Item $newPackageOutput
589+
} else {
590+
Write-Host "Path doesn't exist. create template."
591+
Write-Error "[ERROR] The service $service is not onboarded yet. We will not support onboard a new service from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
644592
exit 1
645593
}
646-
$newPackageOutputJson = Get-Content $newPackageOutput | Out-String | ConvertFrom-Json
647-
$packagesToGen = $packagesToGen + @($newPackageOutputJson)
648-
Remove-Item $newPackageOutput
649594
} else {
650595
Write-Host "Generate data-plane SDK client library."
651596
$namespace = ""
@@ -668,17 +613,25 @@ function Invoke-GenerateAndBuildSDK () {
668613
$namespace = $directories[-1];
669614
}
670615

671-
New-DataPlanePackageFolder -service $service -namespace $namespace -sdkPath $sdkRootPath -readme $readmeFile -autorestConfigYaml "$autorestConfigYaml" -outputJsonFile $newpackageoutput
672-
if ( !$? ) {
673-
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,namespace:$namespace,"
674-
Write-Host "[ERROR] sdkPath:$sdkRootPath,readme:$readmeFile,autorestConfigYaml:$autorestConfigYaml.exit code: $?."
675-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
676-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
616+
$projectFolder=(Join-Path $sdkRootPath "sdk" $service $namespace)
617+
if (Test-Path -Path $projectFolder) {
618+
Write-Host "Path exists!"
619+
Update-DataPlanePackageFolder -service $service -namespace $namespace -sdkPath $sdkRootPath -readme $readmeFile -autorestConfigYaml "$autorestConfigYaml" -outputJsonFile $newpackageoutput
620+
if ( !$? ) {
621+
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,namespace:$namespace,"
622+
Write-Host "[ERROR] sdkPath:$sdkRootPath,readme:$readmeFile,autorestConfigYaml:$autorestConfigYaml.exit code: $?."
623+
Write-Host "[ERROR] Please review the detail errors for potential fixes."
624+
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
625+
exit 1
626+
}
627+
$newPackageOutputJson = Get-Content $newPackageOutput | Out-String | ConvertFrom-Json
628+
$packagesToGen = $packagesToGen + @($newPackageOutputJson)
629+
Remove-Item $newPackageOutput
630+
} else {
631+
Write-Host "SDK project folder doesn't exist."
632+
Write-Error "[ERROR] The service $service is not onboarded yet. We will not support onboard a new service from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
677633
exit 1
678634
}
679-
$newPackageOutputJson = Get-Content $newPackageOutput | Out-String | ConvertFrom-Json
680-
$packagesToGen = $packagesToGen + @($newPackageOutputJson)
681-
Remove-Item $newPackageOutput
682635
} else {
683636
# handle scenaro: multiple SDK packages one md file.
684637
# npx autorest --version=3.8.4 --csharp $readmeFile --csharp-sdks-folder=$sdkRootPath --skip-csproj --clear-output-folder=true
@@ -697,17 +650,25 @@ function Invoke-GenerateAndBuildSDK () {
697650
if (Test-Path -Path $autorestFilePath) {
698651
$fileContent = Get-Content $autorestFilePath -Raw
699652
if ($fileContent -match $regexForMatch) {
700-
New-DataPlanePackageFolder -service $service -namespace $folder -sdkPath $sdkRootPath -readme $readmeFile -outputJsonFile $newpackageoutput
701-
if ( !$? ) {
702-
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,namespace:$folder,"
703-
Write-Host "[ERROR] sdkPath:$sdkRootPath,readme:$readmeFile. exit code: $?."
704-
Write-Host "[ERROR] Please review the detail errors for potential fixes."
705-
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
653+
$projectFolder=(Join-Path $sdkRootPath "sdk" $service $folder)
654+
if (Test-Path -Path $projectFolder) {
655+
Write-Host "Path exists!"
656+
New-DataPlanePackageFolder -service $service -namespace $folder -sdkPath $sdkRootPath -readme $readmeFile -outputJsonFile $newpackageoutput
657+
if ( !$? ) {
658+
Write-Host "[ERROR] Failed to create sdk project folder.service:$service,namespace:$folder,"
659+
Write-Host "[ERROR] sdkPath:$sdkRootPath,readme:$readmeFile. exit code: $?."
660+
Write-Host "[ERROR] Please review the detail errors for potential fixes."
661+
Write-Host "[ERROR] If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
662+
exit 1
663+
}
664+
$newPackageOutputJson = Get-Content $newPackageOutput | Out-String | ConvertFrom-Json
665+
$packagesToGen = $packagesToGen + @($newPackageOutputJson)
666+
Remove-Item $newPackageOutput
667+
} else {
668+
Write-Host "SDK project folder doesn't exist."
669+
Write-Error "[ERROR] The service $service is not onboarded yet. We will not support onboard a new service from swagger. Please contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."
706670
exit 1
707671
}
708-
$newPackageOutputJson = Get-Content $newPackageOutput | Out-String | ConvertFrom-Json
709-
$packagesToGen = $packagesToGen + @($newPackageOutputJson)
710-
Remove-Item $newPackageOutput
711672
}
712673
}
713674
}
@@ -912,10 +873,10 @@ function GeneratePackage()
912873
language=".Net";
913874
changelog=$changelog;
914875
}
915-
876+
916877
if ($null -ne $installInstructions) {
917878
$packageDetails['installInstructions'] = $installInstructions
918-
}
879+
}
919880
$generatedSDKPackages.Add($packageDetails)
920881
}
921882
function UpdateExistingSDKByInputFiles()

0 commit comments

Comments
 (0)