Add --override-arguments option to win_chocolatey module (#65101)

* Add --override-arguments option to win_chocolatey module

* Fix version and argument type

* Added changelog fragment and tests
This commit is contained in:
Rostyslav 2019-11-25 00:51:13 +01:00 committed by Jordan Borean
parent 63b94fca7e
commit a8fa432096
5 changed files with 42 additions and 11 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- win_chocolatey - Add ``override_args`` option to allow overriding builtin install arguments for a Chocolatey package

View file

@ -19,11 +19,12 @@ $spec = @{
allow_multiple = @{ type = "bool"; default = $false } allow_multiple = @{ type = "bool"; default = $false }
allow_prerelease = @{ type = "bool"; default = $false } allow_prerelease = @{ type = "bool"; default = $false }
architecture = @{ type = "str"; default = "default"; choices = "default", "x86" } architecture = @{ type = "str"; default = "default"; choices = "default", "x86" }
install_args = @{ type = "str" } force = @{ type = "bool"; default = $false }
ignore_checksums = @{ type = "bool"; default = $false } ignore_checksums = @{ type = "bool"; default = $false }
ignore_dependencies = @{ type = "bool"; default = $false } ignore_dependencies = @{ type = "bool"; default = $false }
force = @{ type = "bool"; default = $false } install_args = @{ type = "str" }
name = @{ type = "list"; elements = "str"; required = $true } name = @{ type = "list"; elements = "str"; required = $true }
override_args = @{ type = "bool"; default = $false }
package_params = @{ type = "str"; aliases = @("params") } package_params = @{ type = "str"; aliases = @("params") }
pinned = @{ type = "bool" } pinned = @{ type = "bool" }
proxy_url = @{ type = "str" } proxy_url = @{ type = "str" }
@ -46,11 +47,12 @@ $allow_empty_checksums = $module.Params.allow_empty_checksums
$allow_multiple = $module.Params.allow_multiple $allow_multiple = $module.Params.allow_multiple
$allow_prerelease = $module.Params.allow_prerelease $allow_prerelease = $module.Params.allow_prerelease
$architecture = $module.Params.architecture $architecture = $module.Params.architecture
$install_args = $module.Params.install_args $force = $module.Params.force
$ignore_checksums = $module.Params.ignore_checksums $ignore_checksums = $module.Params.ignore_checksums
$ignore_dependencies = $module.Params.ignore_dependencies $ignore_dependencies = $module.Params.ignore_dependencies
$force = $module.Params.force $install_args = $module.Params.install_args
$name = $module.Params.name $name = $module.Params.name
$override_args = $module.Params.override_args
$package_params = $module.Params.package_params $package_params = $module.Params.package_params
$pinned = $module.Params.pinned $pinned = $module.Params.pinned
$proxy_url = $module.Params.proxy_url $proxy_url = $module.Params.proxy_url
@ -101,6 +103,7 @@ Function Get-InstallChocolateyArguments {
[bool]$force, [bool]$force,
[bool]$ignore_dependencies, [bool]$ignore_dependencies,
[String]$install_args, [String]$install_args,
[bool]$override_args,
[String]$package_params, [String]$package_params,
[String]$proxy_url, [String]$proxy_url,
[String]$proxy_username, [String]$proxy_username,
@ -146,6 +149,9 @@ Function Get-InstallChocolateyArguments {
$arguments.Add("--install-arguments") > $null $arguments.Add("--install-arguments") > $null
$arguments.add($install_args) > $null $arguments.add($install_args) > $null
} }
if ($override_args) {
$arguments.Add("--override-arguments") > $null
}
if ($package_params) { if ($package_params) {
$arguments.Add("--package-parameters") > $null $arguments.Add("--package-parameters") > $null
$arguments.Add($package_params) > $null $arguments.Add($package_params) > $null
@ -469,6 +475,7 @@ Function Update-ChocolateyPackage {
[bool]$ignore_checksums, [bool]$ignore_checksums,
[bool]$ignore_dependencies, [bool]$ignore_dependencies,
[String]$install_args, [String]$install_args,
[bool]$override_args,
[String]$package_params, [String]$package_params,
[String]$proxy_url, [String]$proxy_url,
[String]$proxy_username, [String]$proxy_username,
@ -494,6 +501,7 @@ Function Update-ChocolateyPackage {
ignore_checksums = $ignore_checksums ignore_checksums = $ignore_checksums
ignore_dependencies = $ignore_dependencies ignore_dependencies = $ignore_dependencies
install_args = $install_args install_args = $install_args
override_args = $override_args
package_params = $package_params package_params = $package_params
proxy_url = $proxy_url proxy_url = $proxy_url
proxy_username = $proxy_username proxy_username = $proxy_username
@ -544,6 +552,7 @@ Function Install-ChocolateyPackage {
[bool]$ignore_checksums, [bool]$ignore_checksums,
[bool]$ignore_dependencies, [bool]$ignore_dependencies,
[String]$install_args, [String]$install_args,
[bool]$override_args,
[String]$package_params, [String]$package_params,
[String]$proxy_url, [String]$proxy_url,
[String]$proxy_username, [String]$proxy_username,
@ -568,6 +577,7 @@ Function Install-ChocolateyPackage {
ignore_checksums = $ignore_checksums ignore_checksums = $ignore_checksums
ignore_dependencies = $ignore_dependencies ignore_dependencies = $ignore_dependencies
install_args = $install_args install_args = $install_args
override_args = $override_args
package_params = $package_params package_params = $package_params
proxy_url = $proxy_url proxy_url = $proxy_url
proxy_username = $proxy_username proxy_username = $proxy_username
@ -736,6 +746,7 @@ if ($state -in @("downgrade", "latest", "present", "reinstalled")) {
ignore_checksums = $ignore_checksums ignore_checksums = $ignore_checksums
ignore_dependencies = $ignore_dependencies ignore_dependencies = $ignore_dependencies
install_args = $install_args install_args = $install_args
override_args = $override_args
package_params = $package_params package_params = $package_params
proxy_url = $proxy_url proxy_url = $proxy_url
proxy_username = $proxy_username proxy_username = $proxy_username

View file

@ -65,13 +65,6 @@ options:
made. made.
type: bool type: bool
default: no default: no
install_args:
description:
- Arguments to pass to the native installer.
- These are arguments that are passed directly to the installer the
Chocolatey package runs, this is generally an advanced option.
type: str
version_added: '2.1'
ignore_checksums: ignore_checksums:
description: description:
- Ignore the checksums provided by the package. - Ignore the checksums provided by the package.
@ -86,12 +79,26 @@ options:
type: bool type: bool
default: no default: no
version_added: '2.1' version_added: '2.1'
install_args:
description:
- Arguments to pass to the native installer.
- These are arguments that are passed directly to the installer the
Chocolatey package runs, this is generally an advanced option.
type: str
version_added: '2.1'
name: name:
description: description:
- Name of the package(s) to be installed. - Name of the package(s) to be installed.
- Set to C(all) to run the action on all the installed packages. - Set to C(all) to run the action on all the installed packages.
type: list type: list
required: yes required: yes
override_args:
description:
- Override arguments of native installer with arguments provided by user.
- Should install arguments be used exclusively without appending
to current package passed arguments.
type: bool
version_added: '2.10'
package_params: package_params:
description: description:
- Parameters to pass to the package. - Parameters to pass to the package.

View file

@ -25,6 +25,11 @@ if ($env:ChocolateyForceX86) {
} else { } else {
$force_x86 = $false $force_x86 = $false
} }
if ($env:ChocolateyInstallOverride) {
$override_args = $true
} else {
$override_args = $false
}
#$process_env = Get-EnvironmentVariableNames -Scope Process #$process_env = Get-EnvironmentVariableNames -Scope Process
#$env_vars = @{} #$env_vars = @{}
#foreach ($name in $process_env) { #foreach ($name in $process_env) {
@ -39,6 +44,7 @@ $package_info = @{
force_x86 = $force_x86 force_x86 = $force_x86
ignore_checksums = $ignore_checksums ignore_checksums = $ignore_checksums
install_args = $env:ChocolateyInstallArguments install_args = $env:ChocolateyInstallArguments
override_args = $override_args
package_params = Get-PackageParameters package_params = Get-PackageParameters
proxy_url = $env:ChocolateyProxyLocation proxy_url = $env:ChocolateyProxyLocation
source = $source source = $source

View file

@ -55,6 +55,7 @@
- (install_actual_info.stdout|from_json).force_x86 == False - (install_actual_info.stdout|from_json).force_x86 == False
- (install_actual_info.stdout|from_json).ignore_checksums == False - (install_actual_info.stdout|from_json).ignore_checksums == False
- (install_actual_info.stdout|from_json).install_args == None - (install_actual_info.stdout|from_json).install_args == None
- (install_actual_info.stdout|from_json).override_args == False
- (install_actual_info.stdout|from_json).package_params == {} - (install_actual_info.stdout|from_json).package_params == {}
- (install_actual_info.stdout|from_json).proxy_url == None - (install_actual_info.stdout|from_json).proxy_url == None
- (install_actual_info.stdout|from_json).source == "normal" - (install_actual_info.stdout|from_json).source == "normal"
@ -151,6 +152,7 @@
- (install_multiple_package1.stdout|from_json).force_x86 == False - (install_multiple_package1.stdout|from_json).force_x86 == False
- (install_multiple_package1.stdout|from_json).ignore_checksums == False - (install_multiple_package1.stdout|from_json).ignore_checksums == False
- (install_multiple_package1.stdout|from_json).install_args == None - (install_multiple_package1.stdout|from_json).install_args == None
- (install_multiple_package1.stdout|from_json).override_args == False
- (install_multiple_package1.stdout|from_json).package_params == {} - (install_multiple_package1.stdout|from_json).package_params == {}
- (install_multiple_package1.stdout|from_json).proxy_url == None - (install_multiple_package1.stdout|from_json).proxy_url == None
- (install_multiple_package1.stdout|from_json).source == "normal" - (install_multiple_package1.stdout|from_json).source == "normal"
@ -160,6 +162,7 @@
- (install_multiple_package2.stdout|from_json).force_x86 == False - (install_multiple_package2.stdout|from_json).force_x86 == False
- (install_multiple_package2.stdout|from_json).ignore_checksums == False - (install_multiple_package2.stdout|from_json).ignore_checksums == False
- (install_multiple_package2.stdout|from_json).install_args == None - (install_multiple_package2.stdout|from_json).install_args == None
- (install_multiple_package2.stdout|from_json).override_args == False
- (install_multiple_package2.stdout|from_json).package_params == {} - (install_multiple_package2.stdout|from_json).package_params == {}
- (install_multiple_package2.stdout|from_json).proxy_url == None - (install_multiple_package2.stdout|from_json).proxy_url == None
- (install_multiple_package2.stdout|from_json).source == "normal" - (install_multiple_package2.stdout|from_json).source == "normal"
@ -221,6 +224,7 @@
name: '{{ test_choco_package1 }}' name: '{{ test_choco_package1 }}'
state: present state: present
install_args: /install_arg 1 /install_arg 2 install_args: /install_arg 1 /install_arg 2
override_args: yes
package_params: /param1 /param2:value package_params: /param1 /param2:value
allow_empty_checksums: yes allow_empty_checksums: yes
architecture: x86 architecture: x86
@ -248,6 +252,7 @@
- (install_params_info.stdout|from_json).force_x86 == True - (install_params_info.stdout|from_json).force_x86 == True
- (install_params_info.stdout|from_json).ignore_checksums == True - (install_params_info.stdout|from_json).ignore_checksums == True
- (install_params_info.stdout|from_json).install_args == "/install_arg 1 /install_arg 2" - (install_params_info.stdout|from_json).install_args == "/install_arg 1 /install_arg 2"
- (install_params_info.stdout|from_json).override_args == True
- (install_params_info.stdout|from_json).package_params.keys()|count == 2 - (install_params_info.stdout|from_json).package_params.keys()|count == 2
- (install_params_info.stdout|from_json).package_params.param1 == True - (install_params_info.stdout|from_json).package_params.param1 == True
- (install_params_info.stdout|from_json).package_params.param2 == "value" - (install_params_info.stdout|from_json).package_params.param2 == "value"