Skip to content

Commit 998e819

Browse files
committed
Changes as requested by @hbuckle
1. Parameterised the install_options method to make testing easier. 2. Added an example in the documentation of how to pass a hash and a switch to the install_options argument
1 parent d097248 commit 998e819

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ file{"C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Micr
188188

189189
`puppet-powershellmodule` implements a [package type](http://docs.puppet.com/references/latest/type.html#package) with a resource provider, which is built into Puppet.
190190

191+
The implementation supports the [install_options](https://puppet.com/docs/puppet/6.2/type.html#package-attribute-install_options) attribute which can be used to pass additional options to the PowerShell Install-Modules command, e.g.:
192+
193+
```
194+
package { 'xPSDesiredStateConfiguration':
195+
ensure => latest,
196+
provider => 'windowspowershell',
197+
source => 'PSGallery',
198+
install_options => [ '-AllowClobber',
199+
{ '-proxy' => 'http://proxy.local.domain' } ]
200+
}
201+
202+
```
203+
191204
### pspackageprovider
192205

193206
#### Properties/Parameters

lib/puppet/provider/package/powershellcore.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def update
5555
# @param options [Array]
5656
# @return Concatenated list of options
5757
# @api private
58-
def install_options
59-
return unless @resource[:install_options]
58+
def install_options(options)
59+
return unless options
6060

61-
@resource[:install_options].collect do |val|
61+
options.collect do |val|
6262
case val
6363
when Hash
6464
val.keys.sort.collect do |k|
@@ -88,7 +88,7 @@ def install_command
8888
command = "Install-Module #{@resource[:name]} -Scope AllUsers -Force"
8989
command << " -RequiredVersion #{@resource[:ensure]}" unless [:present, :latest].include? @resource[:ensure]
9090
command << " -Repository #{@resource[:source]}" if @resource[:source]
91-
command << " #{install_options}" if @resource[:install_options]
91+
command << " #{install_options(@resource[:install_options])}" if @resource[:install_options]
9292
command
9393
end
9494

@@ -103,7 +103,7 @@ def latest_command
103103
def update_command
104104
command = "Install-Module #{@resource[:name]} -Scope AllUsers -Force"
105105
command << " -Repository #{@resource[:source]}" if @resource[:source]
106-
command << " #{install_options}" if @resource[:install_options]
106+
command << " #{install_options(@resource[:install_options])}" if @resource[:install_options]
107107
command
108108
end
109109
end

0 commit comments

Comments
 (0)