Files
runner-images-sangeeth/images/ubuntu/scripts/docs-gen/SoftwareReport.Helpers.psm1
Shamil Mubarakshin 1bd9214f41 [ubuntu] Rename build scripts (#8866)
* [ubuntu] Rename build scripts

* [ubuntu] Change reboot to inline shell

* [ubuntu] Move disk space validation to pester tests

* [ubuntu] Rename helper and tests files

* [ubuntu] Changes to cleanup, post-deployment and r scripts
2023-11-22 21:49:23 +01:00

42 lines
1019 B
PowerShell

function Take-OutputPart {
param (
[Parameter(ValueFromPipeline)]
[string] $toolOutput,
[string] $Delimiter = " ",
[int[]] $Part
)
$parts = $toolOutput.Split($Delimiter, [System.StringSplitOptions]::RemoveEmptyEntries)
$selectedParts = $parts[$Part]
return [string]::Join($Delimiter, $selectedParts)
}
function Restore-UserOwner {
sudo chown -R ${env:USER}: $env:HOME
}
function Get-LinkTarget {
param (
[string] $inputPath
)
$link = Get-Item $inputPath | Select-Object -ExpandProperty Target
if ($link) {
return " -> $link"
}
return ""
}
function Get-PathWithLink {
param (
[string] $inputPath
)
$link = Get-LinkTarget($inputPath)
return "${inputPath}${link}"
}
function Get-AptSourceRepository {
param([String] $PackageName)
$sourceUrl = Get-Content "$PSScriptRoot/../helpers/apt-sources.txt" | Select-String -Pattern $PackageName | Take-OutputPart -Part (1..3)
return $sourceUrl
}