File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
lib/puppet/parser/functions Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ module Puppet::Parser::Functions
10
10
opts = args [ 0 ] || { }
11
11
flags = [ ]
12
12
flags << '--force' if opts [ 'force_remove' ] == true
13
- flags << "'#{ opts [ 'plugin_name' ] } '" if opts [ 'plugin_name' ] && opts [ 'plugin_name' ] . to_s != 'undef'
13
+ if opts [ 'plugin_alias' ] && opts [ 'plugin_alias' ] . to_s != 'undef'
14
+ flags << "'#{ opts [ 'plugin_alias' ] } '"
15
+ elsif opts [ 'plugin_name' ] && opts [ 'plugin_name' ] . to_s != 'undef'
16
+ flags << "'#{ opts [ 'plugin_name' ] } '"
17
+ end
14
18
flags . flatten . join ( ' ' )
15
19
end
16
20
end
Original file line number Diff line number Diff line change 79
79
})
80
80
81
81
$exec_install = " ${docker_command} install ${docker_plugin_install_flags} "
82
- $unless_install = " ${docker_command} ls | grep -w ${plugin_name} "
82
+ $unless_install = " ${docker_command} ls --format='{{.PluginReference}}' | grep -w ${plugin_name} "
83
83
84
84
exec { "plugin install ${plugin_name}" :
85
85
command => $exec_install ,
95
95
})
96
96
97
97
$exec_rm = " ${docker_command} rm ${docker_plugin_remove_flags} "
98
- $onlyif_rm = " ${docker_command} ls | grep -w ${plugin_name} "
98
+ $onlyif_rm = " ${docker_command} ls --format='{{.PluginReference}}' | grep -w ${plugin_name} "
99
99
100
100
exec { "plugin remove ${plugin_name}" :
101
101
command => $exec_rm ,
109
109
if $enabled {
110
110
$docker_plugin_enable_flags = docker_plugin_enable_flags({
111
111
plugin_name => $plugin_name ,
112
+ plugin_alias => $plugin_alias ,
112
113
timeout => $timeout ,
113
114
})
114
115
115
116
$exec_enable = " ${docker_command} enable ${docker_plugin_enable_flags} "
116
- $onlyif_enable = " ${docker_command} ls -f enabled=false | grep -w ${plugin_name} "
117
+ $onlyif_enable = " ${docker_command} ls -f enabled=false --format='{{.PluginReference}}' | grep -w ${plugin_name} "
117
118
118
119
exec { "plugin enable ${plugin_name}" :
119
120
command => $exec_enable ,
129
130
environment => ' HOME=/root' ,
130
131
path => [' /bin' , ' /usr/bin' ],
131
132
timeout => 0,
132
- unless => " ${docker_command} ls -f enabled=false | grep -w ${plugin_name} " ,
133
+ unless => " ${docker_command} ls -f enabled=false --format='{{.PluginReference}}' | grep -w ${plugin_name} " ,
133
134
}
134
135
}
135
136
}
Original file line number Diff line number Diff line change 16
16
context 'with defaults for all parameters' do
17
17
it { is_expected . to compile . with_all_deps }
18
18
it { is_expected . to contain_exec ( 'plugin install foo/plugin:latest' ) . with_command ( %r{docker plugin install} ) }
19
+ it { is_expected . to contain_exec ( 'plugin install foo/plugin:latest' ) . with_unless ( %r{docker ls --format='{{.PluginReference}}' | grep -w foo/plugin:latest} ) }
19
20
end
20
21
21
22
context 'with enabled => false' do
22
23
let ( :params ) { { 'enabled' => false } }
23
24
24
25
it { is_expected . to compile . with_all_deps }
25
26
it { is_expected . to contain_exec ( 'disable foo/plugin:latest' ) . with_command ( %r{docker plugin disable} ) }
27
+ it { is_expected . to contain_exec ( 'disable foo/plugin:latest' ) . with_unless ( %r{docker ls --format='{{.PluginReference}}' | grep -w foo/plugin:latest} ) }
26
28
end
27
29
28
30
context 'with ensure => absent' do
29
31
let ( :params ) { { 'ensure' => 'absent' } }
30
32
31
33
it { is_expected . to compile . with_all_deps }
32
34
it { is_expected . to contain_exec ( 'plugin remove foo/plugin:latest' ) . with_command ( %r{docker plugin rm} ) }
35
+ it { is_expected . to contain_exec ( 'plugin remove foo/plugin:latest' ) . with_onlyif ( %r{docker ls --format='{{.PluginReference}}' | grep -w foo/plugin:latest} ) }
36
+ end
37
+
38
+ context 'with alias => foo-plugin' do
39
+ let ( :params ) { { 'plugin_alias' => 'foo-plugin' } }
40
+
41
+ it { is_expected . to contain_exec ( 'plugin install foo/plugin:latest' ) . with_command ( %r{docker plugin install} ) }
42
+ it { is_expected . to contain_exec ( 'plugin install foo/plugin:latest' ) . with_unless ( %r{docker ls --format='{{.PluginReference}}' | grep -w foo/plugin:latest} ) }
33
43
end
34
44
end
You can’t perform that action at this time.
0 commit comments