Files
runner-images/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1
T

308 lines
10 KiB
PowerShell
Raw Normal View History

function Get-AnsibleVersion {
$ansibleVersion = (ansible --version)[0] -replace "[^\d.]"
return "Ansible $ansibleVersion"
}
function Get-AptFastVersion {
$versionFileContent = Get-Content (which apt-fast) -Raw
$match = [Regex]::Match($versionFileContent, '# apt-fast v(.+)\n')
$aptFastVersion = $match.Groups[1].Value
return "apt-fast $aptFastVersion"
}
2021-02-24 18:21:51 +03:00
function Get-AzCopyVersion {
$azcopyVersion = azcopy --version | Take-OutputPart -Part 2
return "AzCopy $azcopyVersion (available by ``azcopy`` and ``azcopy10`` aliases)"
}
function Get-BazelVersion {
2020-10-05 11:19:24 +03:00
$bazelVersion = bazel --version | Select-String "bazel" | Take-OutputPart -Part 1
return "Bazel $bazelVersion"
}
function Get-BazeliskVersion {
2020-10-07 18:26:40 +03:00
$result = Get-CommandResult "bazelisk version" -Multiline
$bazeliskVersion = $result.Output | Select-String "Bazelisk version:" | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "v"
return "Bazelisk $bazeliskVersion"
}
2021-06-24 03:13:00 -05:00
function Get-BicepVersion {
(bicep --version | Out-String) -match "bicep cli version (?<version>\d+\.\d+\.\d+)" | Out-Null
$bicepVersion = $Matches.Version
return "Bicep $bicepVersion"
}
function Get-CodeQLBundleVersion {
2020-10-01 12:53:28 +03:00
$CodeQLVersionsWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionsWildcard | Select-Object -First 1 -Expand FullName
$CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql"
2020-09-21 08:43:39 +01:00
$CodeQLVersion = & $CodeQLPath version --quiet
return "CodeQL Action Bundle $CodeQLVersion"
}
function Get-PodManVersion {
2020-09-14 10:09:05 +03:00
$podmanVersion = podman --version | Take-OutputPart -Part 2
if ((Test-IsUbuntu18) -or (Test-IsUbuntu20)) {
$aptSourceRepo = Get-AptSourceRepository -PackageName "containers"
return "Podman $podmanVersion (apt source repository: $aptSourceRepo)"
}
return "Podman $podmanVersion"
}
function Get-BuildahVersion {
2020-09-14 10:09:05 +03:00
$buildahVersion = buildah --version | Take-OutputPart -Part 2
if ((Test-IsUbuntu18) -or (Test-IsUbuntu20)) {
$aptSourceRepo = Get-AptSourceRepository -PackageName "containers"
return "Buildah $buildahVersion (apt source repository: $aptSourceRepo)"
}
return "Buildah $buildahVersion"
}
function Get-SkopeoVersion {
2020-09-14 10:09:05 +03:00
$skopeoVersion = skopeo --version | Take-OutputPart -Part 2
if ((Test-IsUbuntu18) -or (Test-IsUbuntu20)) {
$aptSourceRepo = Get-AptSourceRepository -PackageName "containers"
return "Skopeo $skopeoVersion (apt source repository: $aptSourceRepo)"
}
return "Skopeo $skopeoVersion"
}
function Get-CMakeVersion {
2020-09-14 10:09:05 +03:00
$cmakeVersion = cmake --version | Select-Object -First 1 | Take-OutputPart -Part 2
return "CMake $cmakeVersion"
}
2021-10-01 12:33:34 +03:00
function Get-DockerComposeV1Version {
2020-09-14 10:09:05 +03:00
$composeVersion = docker-compose -v | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter ","
2021-10-01 12:33:34 +03:00
return "Docker Compose v1 $composeVersion"
}
function Get-DockerComposeV2Version {
$composeVersion = docker compose version | Take-OutputPart -Part 3
return "Docker Compose v2 $composeVersion"
}
2021-02-09 22:50:11 +03:00
function Get-DockerMobyClientVersion {
$dockerClientVersion = sudo docker version --format '{{.Client.Version}}'
return "Docker-Moby Client $dockerClientVersion"
}
function Get-DockerMobyServerVersion {
$dockerServerVersion = sudo docker version --format '{{.Server.Version}}'
return "Docker-Moby Server $dockerServerVersion"
}
function Get-DockerBuildxVersion {
2020-09-14 10:09:05 +03:00
$buildxVersion = docker buildx version | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "+"
return "Docker-Buildx $buildxVersion"
}
2022-05-16 17:49:51 +02:00
function Get-DockerAmazonECRCredHelperVersion {
$ecrVersion = docker-credential-ecr-login -v | Select-String "Version:" | Take-OutputPart -Part 1
return "Docker Amazon ECR Credential Helper $ecrVersion"
}
function Get-GitVersion {
$gitVersion = git --version | Take-OutputPart -Part -1
$aptSourceRepo = Get-AptSourceRepository -PackageName "git-core"
return "Git $gitVersion (apt source repository: $aptSourceRepo)"
}
function Get-GitLFSVersion {
2020-10-07 18:26:40 +03:00
$result = Get-CommandResult "git-lfs --version"
$gitlfsversion = $result.Output | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/"
$aptSourceRepo = Get-AptSourceRepository -PackageName "git-lfs"
return "Git LFS $gitlfsversion (apt source repository: $aptSourceRepo)"
}
function Get-GitFTPVersion {
2020-09-14 10:09:05 +03:00
$gitftpVersion = git-ftp --version | Take-OutputPart -Part 2
return "Git-ftp $gitftpVersion"
}
function Get-GoogleCloudSDKVersion {
$aptSourceRepo = Get-AptSourceRepository -PackageName "google-cloud-sdk"
return "$(gcloud --version | Select-Object -First 1) (apt source repository: $aptSourceRepo)"
}
function Get-HavegedVersion {
2020-09-14 10:09:05 +03:00
$havegedVersion = dpkg-query --showformat='${Version}' --show haveged | Take-OutputPart -Part 0 -Delimiter "-"
return "Haveged $havegedVersion"
}
function Get-HerokuVersion {
2020-10-05 11:19:24 +03:00
$herokuVersion = heroku version | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/"
return "Heroku $herokuVersion"
}
function Get-HHVMVersion {
2020-09-14 10:09:05 +03:00
$hhvmVersion = hhvm --version | Select-Object -First 1 | Take-OutputPart -Part 2
return "HHVM (HipHop VM) $hhvmVersion"
}
function Get-SVNVersion {
2020-09-14 10:09:05 +03:00
$svnVersion = svn --version | Select-Object -First 1 | Take-OutputPart -Part 2
return "SVN $svnVersion"
}
function Get-KustomizeVersion {
2020-09-14 10:09:05 +03:00
$kustomizeVersion = kustomize version --short | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "v"
return "Kustomize $kustomizeVersion"
}
function Get-KindVersion {
2020-09-14 10:09:05 +03:00
$kindVersion = kind version | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "v"
return "Kind $kindVersion"
}
function Get-KubectlVersion {
2022-05-04 17:09:51 +02:00
$kubectlVersion = (kubectl version --client --output=json | ConvertFrom-Json).clientVersion.gitVersion.Replace('v','')
return "Kubectl $kubectlVersion"
}
function Get-MinikubeVersion {
2021-05-11 10:15:27 +03:00
$minikubeVersion = minikube version --short | Take-OutputPart -Part 0 -Delimiter "v"
return "Minikube $minikubeVersion"
}
function Get-HGVersion {
2020-09-14 10:09:05 +03:00
$hgVersion = hg --version | Select-Object -First 1 | Take-OutputPart -Part -1 | Take-OutputPart -Part 0 -Delimiter ")"
return "Mercurial $hgVersion"
}
function Get-LeiningenVersion {
2020-09-14 10:09:05 +03:00
return "$(lein -v | Take-OutputPart -Part 0,1)"
}
2020-12-03 16:34:14 +01:00
function Get-MediainfoVersion {
$mediainfoVersion = (mediainfo --version | Select-Object -Index 1 | Take-OutputPart -Part 2).Replace('v', '')
return "MediaInfo $mediainfoVersion"
}
function Get-NewmanVersion {
return "Newman $(newman --version)"
}
function Get-NVersion {
$nVersion = (n --version).Replace('v', '')
return "n $nVersion"
}
function Get-NvmVersion {
2020-09-14 21:47:31 +03:00
$nvmVersion = bash -c "source /etc/skel/.nvm/nvm.sh && nvm --version"
return "nvm $nvmVersion"
}
function Get-PackerVersion {
# Packer 1.7.1 has a bug and outputs version to stderr instead of stdout https://github.com/hashicorp/packer/issues/10855
$result = (Get-CommandResult "packer --version").Output
$packerVersion = [regex]::matches($result, "(\d+.){2}\d+").Value
return "Packer $packerVersion"
}
function Get-PhantomJSVersion {
return "PhantomJS $(phantomjs --version)"
}
function Get-TerraformVersion {
return (terraform version | Select-String "^Terraform").Line.Replace('v','')
}
function Get-JqVersion {
2020-09-14 10:09:05 +03:00
$jqVersion = jq --version | Take-OutputPart -Part 1 -Delimiter "-"
return "jq $jqVersion"
}
function Get-AzureCliVersion {
$azcliVersion = (az version | ConvertFrom-Json).'azure-cli'
$aptSourceRepo = Get-AptSourceRepository -PackageName "azure-cli"
return "Azure CLI (azure-cli) $azcliVersion (installation method: $aptSourceRepo)"
}
function Get-AzureDevopsVersion {
$azdevopsVersion = (az version | ConvertFrom-Json).extensions.'azure-devops'
return "Azure CLI (azure-devops) $azdevopsVersion"
}
function Get-AlibabaCloudCliVersion {
return "Alibaba Cloud CLI $(aliyun version)"
}
function Get-AWSCliVersion {
2020-10-07 18:26:40 +03:00
$result = Get-CommandResult "aws --version"
$awsVersion = $result.Output | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/"
return "AWS CLI $awsVersion"
}
function Get-AWSCliSessionManagerPluginVersion {
2020-10-07 18:26:40 +03:00
$result = (Get-CommandResult "session-manager-plugin --version").Output
return "AWS CLI Session manager plugin $result"
}
function Get-AWSSAMVersion {
2020-09-14 10:09:05 +03:00
return "AWS SAM CLI $(sam --version | Take-OutputPart -Part -1)"
}
2021-02-19 18:33:28 +03:00
function Get-FastlaneVersion {
$fastlaneVersion = fastlane --version | Select-String "^fastlane [0-9]" | Take-OutputPart -Part 1
return "Fastlane $fastlaneVersion"
}
function Get-HubCliVersion {
2020-09-14 10:09:05 +03:00
$hubVersion = hub --version | Select-String "hub version" | Take-OutputPart -Part 2
return "Hub CLI $hubVersion"
}
function Get-GitHubCliVersion {
2020-09-14 10:09:05 +03:00
$ghVersion = gh --version | Select-String "gh version" | Take-OutputPart -Part 2
return "GitHub CLI $ghVersion"
}
function Get-NetlifyCliVersion {
2020-10-05 11:19:24 +03:00
$netlifyVersion = netlify --version | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/"
return "Netlify CLI $netlifyVersion"
}
function Get-OCCliVersion {
2020-09-14 10:09:05 +03:00
$ocVersion = oc version | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "-"
return "OpenShift CLI $ocVersion"
}
function Get-ORASCliVersion {
2020-09-14 10:09:05 +03:00
$orasVersion = oras version | Select-String "^Version:" | Take-OutputPart -Part 1
return "ORAS CLI $orasVersion"
}
function Get-VerselCliversion {
2020-10-07 18:26:40 +03:00
$result = Get-CommandResult "vercel --version" -Multiline
return $result.Output | Select-Object -First 1
}
2020-09-24 15:07:30 +03:00
function Get-PulumiVersion {
$pulumiVersion = pulumi version | Take-OutputPart -Part 0 -Delimiter "v"
return "Pulumi $pulumiVersion"
}
function Get-RVersion {
2020-09-24 23:39:14 +03:00
$rVersion = (Get-CommandResult "R --version | grep 'R version'").Output | Take-OutputPart -Part 2
2020-09-24 15:07:30 +03:00
return "R $rVersion"
}
2020-09-24 16:50:28 +03:00
function Get-SphinxVersion {
2020-09-24 23:39:14 +03:00
$sphinxVersion = searchd -h | Select-Object -First 1 | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "-"
return "Sphinx Open Source Search Server $sphinxVersion"
2020-10-02 11:23:02 +03:00
}
function Get-YamllintVersion {
2020-10-04 14:51:46 +03:00
return "$(yamllint --version)"
}
2021-04-14 19:34:49 +03:00
function Get-ZstdVersion {
$zstdVersion = zstd --version | Take-OutputPart -Part 1 -Delimiter "v" | Take-OutputPart -Part 0 -Delimiter ","
return "zstd $zstdVersion (homebrew)"
}
2021-07-15 11:21:48 +02:00
function Get-YqVersion {
$yqVersion = ($(yq -V) -Split " ")[-1]
return "yq $yqVersion"
}