Unverified Commit 865f69c6 authored by Prathamesh Zarkar's avatar Prathamesh Zarkar Committed by GitHub

#963 specific powershell module version install (#993)

* #963 specific powershell module version install

* review comments addressed

* added test for the version specific module installation and addressed review comments

* Update src/powershell/install.sh

* Update src/powershell/install.sh

* Update src/powershell/install.sh

---------
Co-authored-by: 's avatarSamruddhi Khandale <samruddhikhandale@github.com>
parent 6a9dd077
{
"id": "powershell",
"version": "1.3.5",
"version": "1.4.0",
"name": "PowerShell",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/powershell",
"description": "Installs PowerShell along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.",
......@@ -18,7 +18,7 @@
"modules": {
"type": "string",
"default": "",
"description": "Optional comma separated list of PowerShell modules to install."
"description": "Optional comma separated list of PowerShell modules to install. If you need to install a specific version of a module, use '==' to specify the version (e.g. 'az.resources==2.5.0')"
},
"powershellProfileURL": {
"type": "string",
......
......@@ -242,14 +242,24 @@ if [ "${use_github}" = "true" ]; then
install_using_github
fi
# If PowerShell modules are requested, loop through and install
# If PowerShell modules are requested, loop through and install
if [ ${#POWERSHELL_MODULES[@]} -gt 0 ]; then
echo "Installing PowerShell Modules: ${POWERSHELL_MODULES}"
modules=(`echo ${POWERSHELL_MODULES} | tr ',' ' '`)
for i in "${modules[@]}"
do
echo "Installing ${i}"
pwsh -Command "Install-Module -Name ${i} -AllowClobber -Force -Scope AllUsers" || continue
module_parts=(`echo ${i} | tr '==' ' '`)
module_name="${module_parts[0]}"
args="-Name ${module_name} -AllowClobber -Force -Scope AllUsers"
if [ "${#module_parts[@]}" -eq 2 ]; then
module_version="${module_parts[1]}"
echo "Installing ${module_name} v${module_version}"
args+=" -RequiredVersion ${module_version}"
else
echo "Installing latest version for ${i} module"
fi
pwsh -Command "Install-Module $args" || continue
done
fi
......
#!/bin/bash
set -e
# Import test library for `check` command
source dev-container-features-test-lib
# Extension-specific tests
check "az.resources" pwsh -Command "(Get-Module -ListAvailable -Name Az.Resources).Version.ToString()" | grep 2.5.0
check "az.storage" pwsh -Command "(Get-Module -ListAvailable -Name Az.Storage).Version.ToString()" | grep 4.3.0
# Report result
reportResults
......@@ -16,5 +16,13 @@
"powershellProfileURL": "https://raw.githubusercontent.com/codspace/powershell-profile/main/Test-Profile.ps1"
}
}
},
"install_modules_version": {
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"powershell": {
"modules": "az.resources==2.5.0, az.storage==4.3.0"
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment