Update ConnectorPackageValidator.ps1 (#3629)
Handled some typical internal structure issues in connector/flow/plugin solution zip
This commit is contained in:
Родитель
5c71cc0247
Коммит
2fc295e7c4
|
@ -324,7 +324,14 @@ try {
|
||||||
$secondLevelZipFiles = Get-ChildItem -Path "$tempFolder2/$pkgAssetFoldereName" -Filter "*.zip" | Select-Object -ExpandProperty Name
|
$secondLevelZipFiles = Get-ChildItem -Path "$tempFolder2/$pkgAssetFoldereName" -Filter "*.zip" | Select-Object -ExpandProperty Name
|
||||||
$originalParentFolderPath = $parentFolderPath
|
$originalParentFolderPath = $parentFolderPath
|
||||||
$nodesToCheck = @()
|
$nodesToCheck = @()
|
||||||
|
$isConnectorSolutionPresent= $false
|
||||||
|
$isFlowSolutionPresent = $false
|
||||||
|
$isPluginSolutionPresent = $false
|
||||||
foreach ($secondLevelZipFile in $secondLevelZipFiles) {
|
foreach ($secondLevelZipFile in $secondLevelZipFiles) {
|
||||||
|
$isConnectorFound = $false
|
||||||
|
$isWorkflowsFound = $false
|
||||||
|
$isPluginFound = $false
|
||||||
|
|
||||||
$tempFolder3 = New-Item -ItemType Directory -Path (Join-Path $env:TEMP (New-Guid))
|
$tempFolder3 = New-Item -ItemType Directory -Path (Join-Path $env:TEMP (New-Guid))
|
||||||
# Update the corret currentFolder to the parentFolderPath
|
# Update the corret currentFolder to the parentFolderPath
|
||||||
$parentFolderPath = "$originalParentFolderPath/$secondLevelZipFile"
|
$parentFolderPath = "$originalParentFolderPath/$secondLevelZipFile"
|
||||||
|
@ -354,113 +361,132 @@ try {
|
||||||
# Read the customizations.xml and look for any node "Connector" or "Workflows". If they exist, validate if the folders also exist
|
# Read the customizations.xml and look for any node "Connector" or "Workflows". If they exist, validate if the folders also exist
|
||||||
# Define the path to your XML file and the node name you want to check
|
# Define the path to your XML file and the node name you want to check
|
||||||
$xmlFilePath = "$tempFolder3/customizations.xml"
|
$xmlFilePath = "$tempFolder3/customizations.xml"
|
||||||
$nodeNameToCheck = "Connector"
|
$connectorNodeName = "Connector"
|
||||||
|
|
||||||
# Load the XML file into an XmlDocument object
|
# Load the XML file into an XmlDocument object
|
||||||
[xml]$xmlContent = Get-Content -Path $xmlFilePath
|
[xml]$xmlContent = Get-Content -Path $xmlFilePath
|
||||||
|
|
||||||
# Use XPath to find the node
|
# Use XPath to find the node
|
||||||
$nodeToCheck = $xmlContent.SelectSingleNode("//$nodeNameToCheck")
|
$connectorNode = $xmlContent.SelectSingleNode("//$connectorNodeName")
|
||||||
|
|
||||||
# Check if the node exists and output the result
|
# Check if the connector node exists and set the appropriate flags
|
||||||
if ($nodeToCheck -ne $null) {
|
if ($connectorNode -ne $null) {
|
||||||
if ($nodeToCheck.HasChildNodes -or $nodeToCheck.Attributes.Count -gt 0) {
|
if ($connectorNode.HasChildNodes -or $connectorNode.Attributes.Count -gt 0) {
|
||||||
# check if the folder name is present with the same name
|
$isConnectorFound = $true
|
||||||
$nodeNameFolder = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $nodeNameToCheck}
|
|
||||||
if (-not $nodeNameFolder) {
|
|
||||||
Write-Host "The solution zip file '$secondLevelZipFile' in '$originalParentFolderPath' should contain one folder namely '$nodeNameToCheck'."
|
|
||||||
Write-Host "The folders should match the customization.xml file. They are present by default in an exported solution and should not be modified/removed manually."
|
|
||||||
Write-Host "Please add the required folder to the solution zip or export the correctsolution again."
|
|
||||||
DisplayReferDocumentation
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "Validation failed: Invalid package structure. Check previous messages for details." -ForegroundColor Red
|
|
||||||
Write-Host ""
|
|
||||||
RemoveTempFolder $tempFolder
|
|
||||||
RemoveTempFolder $tempFolder2
|
|
||||||
RemoveTempFolder $tempFolder3
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$nodeNameToCheck = "Workflows"
|
$workflowsNodeName = "Workflows"
|
||||||
# Use XPath to find the node
|
# Use XPath to find the node
|
||||||
$nodeToCheck = $xmlContent.SelectSingleNode("//$nodeNameToCheck")
|
$workflowsNode = $xmlContent.SelectSingleNode("//$workflowsNodeName")
|
||||||
|
|
||||||
# Check if the node exists and output the result
|
# Check if the workflows node exists and set the appropriate flags
|
||||||
if ($nodeToCheck -ne $null) {
|
if ($workflowsNode -ne $null) {
|
||||||
if ($nodeToCheck.HasChildNodes -or $nodeToCheck.Attributes.Count -gt 0) {
|
if ($workflowsNode.HasChildNodes -or $workflowsNode.Attributes.Count -gt 0) {
|
||||||
# check if the folder name is present with the same name
|
$isWorkflowsFound = $true
|
||||||
$nodeNameFolder = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $nodeNameToCheck}
|
}
|
||||||
if (-not $nodeNameFolder) {
|
}
|
||||||
Write-Host "The solution zip file '$secondLevelZipFile' in '$originalParentFolderPath' should contain one folder namely '$nodeNameToCheck'."
|
|
||||||
Write-Host "The folders should match the customization.xml file. They are present by default in an exported solution and should not be modified/removed manually."
|
if ($pluginEnabled) {
|
||||||
Write-Host "Please add the required folder to the solution zip or export the correct solution again."
|
# aiplugin operation
|
||||||
DisplayReferDocumentation
|
$pluginNodeName = "aicopilot_aiplugin"
|
||||||
Write-Host ""
|
# Use XPath to find the node
|
||||||
Write-Host "Validation failed: Invalid package structure. Check previous messages for details." -ForegroundColor Red
|
$pluginNode = $xmlContent.SelectSingleNode("//$pluginNodeName")
|
||||||
Write-Host ""
|
|
||||||
RemoveTempFolder $tempFolder
|
# Check if the aicopilot_aiplugin node exists and set the appropriate flags
|
||||||
RemoveTempFolder $tempFolder2
|
if ($pluginNode -ne $null) {
|
||||||
RemoveTempFolder $tempFolder3
|
if ($pluginNode.HasChildNodes -or $pluginNode.Attributes.Count -gt 0) {
|
||||||
exit
|
$isPluginFound = $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# aiplugin operation
|
|
||||||
$nodeNameToCheck = "aicopilot_aiplugin"
|
# categorize each of the solution zip
|
||||||
# Use XPath to find the node
|
if (($isConnectorFound) -and (-not $isWorkflowsFound) -and (-not $isPluginFound)) {
|
||||||
$nodeToCheck = $xmlContent.SelectSingleNode("//$nodeNameToCheck")
|
$isConnectorSolutionPresent = $true
|
||||||
|
}
|
||||||
# Check if the node exists and output the result
|
if (($isConnectorFound) -and ($isWorkflowsFound) -and (-not $isPluginFound)) {
|
||||||
if ($nodeToCheck -ne $null) {
|
$isFlowSolutionPresent = $true
|
||||||
if ($nodeToCheck.HasChildNodes -or $nodeToCheck.Attributes.Count -gt 0) {
|
}
|
||||||
# check if the folder name is present with the same name
|
if (($isConnectorFound) -and (-not $isWorkflowsFound) -and ($isPluginFound)) {
|
||||||
$folderNameToCheck1 = "aiplugins"
|
$isPluginSolutionPresent = $true
|
||||||
$nodeNameFolder1 = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $folderNameToCheck1}
|
$workFlowsFolderCount++
|
||||||
$folderNameToCheck2 = "aipluginoperations"
|
}
|
||||||
$nodeNameFolder2 = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $folderNameToCheck2}
|
# check if the connector folder name is present with the same name
|
||||||
if ((-not $nodeNameFolder1) -and (-not $nodeNameFolder2)) {
|
if ($isConnectorFound) {
|
||||||
Write-Host "The solution zip file '$secondLevelZipFile' in '$originalParentFolderPath' should contain folders namely '$folderNameToCheck1, $folderNameToCheck2'."
|
$connectorFolder = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $connectorNodeName}
|
||||||
Write-Host "The folders should match the customization.xml file. They are present by default in an exported solution and should not be modified/removed manually."
|
if (-not $connectorFolder) {
|
||||||
Write-Host "Please add the required folders to the solution zip or export the correct solution again."
|
Write-Host "The solution zip file '$secondLevelZipFile' in '$originalParentFolderPath' should contain one folder namely '$connectorNodeName."
|
||||||
DisplayReferDocumentation
|
Write-Host "The folders should match the customization.xml file. They are present by default in an exported solution and should not be modified/removed manually."
|
||||||
Write-Host ""
|
Write-Host "Please add the required folder to the solution zip or export the correctsolution again."
|
||||||
Write-Host "Validation failed: Invalid package structure. Check previous messages for details." -ForegroundColor Red
|
DisplayReferDocumentation
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
RemoveTempFolder $tempFolder
|
Write-Host "Validation failed: Invalid package structure. Check previous messages for details." -ForegroundColor Red
|
||||||
RemoveTempFolder $tempFolder2
|
Write-Host ""
|
||||||
RemoveTempFolder $tempFolder3
|
RemoveTempFolder $tempFolder
|
||||||
exit
|
RemoveTempFolder $tempFolder2
|
||||||
} elseif (-not $nodeNameFolder1) {
|
RemoveTempFolder $tempFolder3
|
||||||
Write-Host "The solution zip file '$secondLevelZipFile' in '$originalParentFolderPath' should contain a folder namely '$folderNameToCheck1'."
|
exit
|
||||||
Write-Host "The folders should match the customization.xml file. They are present by default in an exported solution and should not be modified/removed manually."
|
|
||||||
Write-Host "Please add the required folder to the solution zip or export the correct solution again."
|
|
||||||
DisplayReferDocumentation
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "Validation failed: Invalid package structure. Check previous messages for details." -ForegroundColor Red
|
|
||||||
Write-Host ""
|
|
||||||
RemoveTempFolder $tempFolder
|
|
||||||
RemoveTempFolder $tempFolder2
|
|
||||||
RemoveTempFolder $tempFolder3
|
|
||||||
exit
|
|
||||||
} elseif (-not $nodeNameFolder2) {
|
|
||||||
Write-Host "The solution zip file '$secondLevelZipFile' in '$originalParentFolderPath' should contain a folder namely '$folderNameToCheck2'."
|
|
||||||
Write-Host "The folders should match the customization.xml file. They are present by default in an exported solution and should not be modified/removed manually."
|
|
||||||
Write-Host "Please add the required folder to the solution zip or export the correct solution again."
|
|
||||||
DisplayReferDocumentation
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "Validation failed: Invalid package structure. Check previous messages for details." -ForegroundColor Red
|
|
||||||
Write-Host ""
|
|
||||||
RemoveTempFolder $tempFolder
|
|
||||||
RemoveTempFolder $tempFolder2
|
|
||||||
RemoveTempFolder $tempFolder3
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($isWorkflowsFound) {
|
||||||
|
# check if the folder name is present with the same name
|
||||||
|
$connectorFolder = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $connectorNodeName}
|
||||||
|
$workFlowsFolder = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $workflowsNodeName}
|
||||||
|
if ((-not $workFlowsFolder) -or (-not $connectorFolder)) {
|
||||||
|
$folderNameMissing = if ((-not $workFlowsFolder) -and $connectorFolder) {"folder namely '$workflowsNodeName'"} elseif ((-not $connectorFolder) -and $workFlowsFolder) {"folder namely '$connectorNodeName"} else {"folders namely '$connectorNodeName', '$workflowsNodeName'"}
|
||||||
|
Write-Host "The solution zip file '$secondLevelZipFile' in '$originalParentFolderPath' should contain '$folderNameMissing'."
|
||||||
|
Write-Host "The folders should match the customization.xml file. They are present by default in an exported solution and should not be modified/removed manually."
|
||||||
|
Write-Host "Please add the required folder to the solution zip or export the correct solution again."
|
||||||
|
DisplayReferDocumentation
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Validation failed: Invalid package structure. Check previous messages for details." -ForegroundColor Red
|
||||||
|
Write-Host ""
|
||||||
|
RemoveTempFolder $tempFolder
|
||||||
|
RemoveTempFolder $tempFolder2
|
||||||
|
RemoveTempFolder $tempFolder3
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isPluginFound) {
|
||||||
|
# check if the AI plugin related folder names are present with the same name
|
||||||
|
$connectorFolder = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $connectorNodeName}
|
||||||
|
$folderNameToCheck1 = "aiplugins"
|
||||||
|
$nodeNameFolder1 = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $folderNameToCheck1}
|
||||||
|
$folderNameToCheck2 = "aipluginoperations"
|
||||||
|
$nodeNameFolder2 = Get-ChildItem -Path "$tempFolder3" -Directory | Where-Object {$_.Name -eq $folderNameToCheck2}
|
||||||
|
|
||||||
|
if ((-not $connectorFolder) -or (-not $nodeNameFolder1) -or (-not $nodeNameFolder2)) {
|
||||||
|
$folderNameMissing = if ((-not $nodeNameFolder1) -and $connectorFolder -and $nodeNameFolder2) {"folder namely '$folderNameToCheck1'"} elseif ((-not $connectorFolder) -and $nodeNameFolder1 -and $nodeNameFolder2) {"folder namely '$connectorNodeName"} elseif ((-not $nodeNameFolder2) -and $connectorFolder -and $nodeNameFolder2) {"folder namely '$folderNameToCheck2"} elseif ((-not $nodeNameFolder1) -and (-not $connectorFolder) -and $nodeNameFolder2) {"folders namely '$connectorNodeName', '$folderNameToCheck1'"} elseif ((-not $nodeNameFolder2) -and (-not $connectorFolder) -and $nodeNameFolder1) {"folders namely '$connectorNodeName', '$folderNameToCheck2'"} elseif ((-not $nodeNameFolder1) -and (-not $nodeNameFolder2) -and $connectorFolder) {"folders namely '$folderNameToCheck1', '$folderNameToCheck2'"} else {"folders namely '$connectorNodeName', '$folderNameToCheck1'. '$folderNameToCheck2'"}
|
||||||
|
Write-Host "The solution zip file '$secondLevelZipFile' in '$originalParentFolderPath' should contain '$folderNameMissing"
|
||||||
|
Write-Host "The folders should match the customization.xml file. They are present by default in an exported solution and should not be modified/removed manually."
|
||||||
|
Write-Host "Please add the required folders to the solution zip or export the correct solution again."
|
||||||
|
DisplayReferDocumentation
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Validation failed: Invalid package structure. Check previous messages for details." -ForegroundColor Red
|
||||||
|
Write-Host ""
|
||||||
|
RemoveTempFolder $tempFolder
|
||||||
|
RemoveTempFolder $tempFolder2
|
||||||
|
RemoveTempFolder $tempFolder3
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (-not $isConnectorSolutionPresent) {
|
||||||
|
Write-Host "Connector solution in '$originalParentFolderPath' is invalid. Connector solution should only contain 'Connector' folder."
|
||||||
|
Write-Host "Validate the connector solution has no extra component except 'Connector'. If not so, please remove them from the solution and export again."
|
||||||
|
$resultOfValidation = $false
|
||||||
|
}
|
||||||
|
elseif (-not $isFlowSolutionPresent) {
|
||||||
|
Write-Host "Flow solution in '$originalParentFolderPath' is invalid. Flow solution should contain both 'Connector' and 'Workflows' folders."
|
||||||
|
Write-Host "Validate the flow solution has both 'Connector' and 'Workflows' components. If not so, please recreate the solution and export again."
|
||||||
|
$resultOfValidation = $false
|
||||||
|
}
|
||||||
|
elseif ($pluginEnabled -and (-not $isPluginSolutionPresent)) {
|
||||||
|
Write-Host "Plugin solution in '$originalParentFolderPath' is invalid. Plugin solution should contain 'Connector', 'aiplugins' and 'aipluginoperations' folders."
|
||||||
|
Write-Host "Validate the plugin solution has 'Connector', 'aiplugins' and 'aipluginoperations' components. If not so, please recreate the solution and export again."
|
||||||
|
$resultOfValidation = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($resultOfValidation) {
|
if ($resultOfValidation) {
|
||||||
Write-Host "Validation successful: The package structure is correct." -ForegroundColor Green
|
Write-Host "Validation successful: The package structure is correct." -ForegroundColor Green
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
@ -471,6 +497,7 @@ try {
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
catch {
|
catch {
|
||||||
Write-Host "Validation failed: Internal issue while working with current folder as '$parentFolderPath' - error occurred: $($_.Exception.Message)" -ForegroundColor Yellow
|
Write-Host "Validation failed: Internal issue while working with current folder as '$parentFolderPath' - error occurred: $($_.Exception.Message)" -ForegroundColor Yellow
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
Загрузка…
Ссылка в новой задаче