Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #58 from mhaylock/support_plugins_without_prefix
Browse files Browse the repository at this point in the history
Make prefixing of plugin names optional
  • Loading branch information
jhaals committed Jan 6, 2015
2 parents 533a7c6 + b1a79c7 commit 6728b7b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ vagrant::plugin { 'vagrant-berkshelf':
}
```

By default, the module will prefix any plugin name that is missing the `vagrant-` prefix. e.g:

```puppet
vagrant::plugin { 'berkshelf': } # Resolves to vagrant-berkshelf
```

Some plugins such as [sahara](https://github.com/jedi4ever/sahara) do not use this prefix. You can override the automatic prefix behaviour with the prefix parameter. The usage would look as follows:

```puppet
vagrant::plugin { 'sahara':
prefix => false
}
```

Boxes
--

Expand Down
6 changes: 0 additions & 6 deletions lib/puppet/type/vagrant_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@

newparam :name do
isnamevar

validate do |value|
unless value =~ /\Avagrant-\w+(-\w+)*\z/
raise Puppet::Error, "Invalid value for name: #{value}"
end
end
end

newparam :user do
Expand Down
5 changes: 3 additions & 2 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
$ensure = 'present',
$force = false,
$license = undef,
$version = latest
$version = latest,
$prefix = true
) {
require vagrant

if $name =~ /^vagrant-/ {
if !$prefix or $name =~ /^vagrant-/ {
$plugin_name = $name
} else {
$plugin_name = "vagrant-${name}"
Expand Down
12 changes: 12 additions & 0 deletions spec/defines/vagrant__plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
it do
should contain_vagrant_plugin('vagrant-vmware-fusion')
end

context 'prefix is false' do
let(:params) do
{
:prefix => false
}
end

it do
should contain_vagrant_plugin('vmware-fusion')
end
end
end

context 'version specified' do
Expand Down

0 comments on commit 6728b7b

Please sign in to comment.