Skip to content

Commit af5f2d3

Browse files
florindragosdavejrt
authored andcommitted
Puppet 6 support (#375)
* in puppet 6 undef values are now nil - fixes #334 these changes are puppet 5 & 6 compatible. * Fix tests for puppet 6
1 parent 5283e6c commit af5f2d3

15 files changed

+53
-38
lines changed

.fixtures.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ fixtures:
55
translate: 'puppetlabs-translate'
66
powershell: 'puppetlabs-powershell'
77
reboot: 'puppetlabs-reboot'
8+
repositories:
9+
yumrepo_core:
10+
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
11+
puppet_version: ">= 6.0.0"
812
symlinks:
913
docker: "#{source_dir}"

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ script:
1313
env:
1414
- PUPPET_GEM_VERSION="~> 4.0"
1515
- PUPPET_GEM_VERSION="~> 5.0"
16+
- PUPPET_GEM_VERSION="~> 6.0"
1617
matrix:
1718
fast_finish: true
19+
exclude:
20+
- rvm: 2.2.5
21+
env: PUPPET_GEM_VERSION="~> 6.0"

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ group :test do
77
elsif puppet_git_url = ENV['PUPPET_GIT_URL']
88
gem "puppet", :git => puppet_git_url
99
else
10-
gem "puppet", "5.5.6"
10+
gem "puppet", "6.0.3"
1111
end
1212
gem "puppet-lint", "2.3.3"
1313
gem "puppet-lint-unquoted_string-check", "0.3.0"

lib/puppet/parser/functions/docker_plugin_enable_flags.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Puppet::Parser::Functions
88
opts = args[0] || {}
99
flags = []
1010
flags << '--force' if opts['force_remove'] == true
11-
flags << "'#{opts['plugin_name']}'" if opts['plugin_name'].to_s != 'undef'
11+
flags << "'#{opts['plugin_name']}'" if opts['plugin_name'] && opts['plugin_name'].to_s != 'undef'
1212
flags.flatten.join(' ')
1313
end
1414
end

lib/puppet/parser/functions/docker_plugin_install_flags.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ module Puppet::Parser::Functions
77
newfunction(:docker_plugin_install_flags, :type => :rvalue) do |args|
88
opts = args[0] || {}
99
flags = []
10-
flags << "--alias #{opts['plugin_alias']}" if opts['plugin_alias'].to_s != 'undef'
10+
flags << "--alias #{opts['plugin_alias']}" if opts['plugin_alias'] && opts['plugin_alias'].to_s != 'undef'
1111
flags << '--disable' if opts['disable_on_install'] == true
1212
flags << '--disable-content-trust' if opts['disable_content_trust'] == true
1313
flags << '--grant-all-permissions' if opts['grant_all_permissions'] == true
14-
flags << "'#{opts['plugin_name']}'" if opts['plugin_name'].to_s != 'undef'
14+
flags << "'#{opts['plugin_name']}'" if opts['plugin_name'] && opts['plugin_name'].to_s != 'undef'
1515
if opts['settings'].is_a? Array
1616
opts['settings'].each do |setting|
1717
flags << setting.to_s

lib/puppet/parser/functions/docker_plugin_remove_flags.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Puppet::Parser::Functions
88
opts = args[0] || {}
99
flags = []
1010
flags << '--force' if opts['force_remove'] == true
11-
flags << "'#{opts['plugin_name']}'" if opts['plugin_name'].to_s != 'undef'
11+
flags << "'#{opts['plugin_name']}'" if opts['plugin_name'] && opts['plugin_name'].to_s != 'undef'
1212
flags.flatten.join(' ')
1313
end
1414
end

lib/puppet/parser/functions/docker_run_flags.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ module Puppet::Parser::Functions
4646
flags << '--detach=true'
4747
end
4848

49-
if opts['health_check_cmd'].to_s != 'undef'
49+
if opts['health_check_cmd'] && opts['health_check_cmd'].to_s != 'undef'
5050
flags << "--health-cmd='#{opts['health_check_cmd']}'"
5151
end
5252

53-
if opts['health_check_interval'].to_s != 'undef'
53+
if opts['health_check_interval'] && opts['health_check_interval'].to_s != 'undef'
5454
flags << "--health-interval=#{opts['health_check_interval']}s"
5555
end
5656

@@ -62,7 +62,7 @@ module Puppet::Parser::Functions
6262
flags << '--read-only=true'
6363
end
6464

65-
params_join_char = if opts['osfamily'].to_s != 'undef'
65+
params_join_char = if opts['osfamily'] && opts['osfamily'].to_s != 'undef'
6666
opts['osfamily'].casecmp('windows').zero? ? " `\n" : " \\\n"
6767
else
6868
" \\\n"

lib/puppet/parser/functions/docker_secrets_flags.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ module Puppet::Parser::Functions
1212
flags << 'create'
1313
end
1414

15-
if opts['secret_name'].to_s != 'undef'
15+
if opts['secret_name'] && opts['secret_name'].to_s != 'undef'
1616
flags << "'#{opts['secret_name']}'"
1717
end
1818

19-
if opts['secret_path'].to_s != 'undef'
19+
if opts['secret_path'] && opts['secret_path'].to_s != 'undef'
2020
flags << "'#{opts['secret_path']}'"
2121
end
2222

lib/puppet/parser/functions/docker_service_flags.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Puppet::Parser::Functions
1212
flags << '--detach'
1313
end
1414

15-
if opts['service_name'].to_s != 'undef'
15+
if opts['service_name'] && opts['service_name'].to_s != 'undef'
1616
flags << "'#{opts['service_name']}'"
1717
end
1818

@@ -28,23 +28,23 @@ module Puppet::Parser::Functions
2828
end
2929
end
3030

31-
if opts['publish'].to_s != 'undef'
31+
if opts['publish'] && opts['publish'].to_s != 'undef'
3232
flags << "--publish '#{opts['publish']}'"
3333
end
3434

35-
if opts['replicas'].to_s != 'undef'
35+
if opts['replicas'] && opts['replicas'].to_s != 'undef'
3636
flags << "--replicas '#{opts['replicas']}'"
3737
end
3838

3939
if opts['tty'].to_s != 'false'
4040
flags << '--tty'
4141
end
4242

43-
if opts['user'].to_s != 'undef'
43+
if opts['user'] && opts['user'].to_s != 'undef'
4444
flags << "--user '#{opts['publish']}'"
4545
end
4646

47-
if opts['workdir'].to_s != 'undef'
47+
if opts['workdir'] && opts['workdir'].to_s != 'undef'
4848
flags << "--workdir '#{opts['workdir']}'"
4949
end
5050

@@ -54,19 +54,19 @@ module Puppet::Parser::Functions
5454
end
5555
end
5656

57-
if opts['host_socket'].to_s != 'undef'
57+
if opts['host_socket'] && opts['host_socket'].to_s != 'undef'
5858
flags << "-H '#{opts['host_socket']}'"
5959
end
6060

61-
if opts['registry_mirror'].to_s != 'undef'
61+
if opts['registry_mirror'] && opts['registry_mirror'].to_s != 'undef'
6262
flags << "--registry-mirror='#{opts['registry_mirror']}'"
6363
end
6464

65-
if opts['image'].to_s != 'undef'
65+
if opts['image'] && opts['image'].to_s != 'undef'
6666
flags << "'#{opts['image']}'"
6767
end
6868

69-
if opts['command'].to_s != 'undef'
69+
if opts['command'] && opts['command'].to_s != 'undef'
7070
flags << opts['command'].to_s
7171
end
7272

lib/puppet/parser/functions/docker_stack_flags.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ module Puppet::Parser::Functions
88
opts = args[0] || {}
99
flags = []
1010

11-
if opts['bundle_file'].to_s != 'undef'
11+
if opts['bundle_file'] && opts['bundle_file'].to_s != 'undef'
1212
flags << "--bundle-file '#{opts['bundle_file']}'"
1313
end
1414

15-
if opts['compose_files'].to_s != 'undef'
15+
if opts['compose_files'] && opts['compose_files'].to_s != 'undef'
1616
opts['compose_files'].each do |file|
1717
flags << "--compose-file '#{file}'"
1818
end
1919
end
2020

21-
if opts['resolve_image'].to_s != 'undef'
21+
if opts['resolve_image'] && opts['resolve_image'].to_s != 'undef'
2222
flags << "--resolve-image '#{opts['resolve_image']}'"
2323
end
2424

25-
if opts['prune'].to_s != 'undef'
25+
if opts['prune'] && opts['prune'].to_s != 'undef'
2626
flags << "--prune '#{opts['prune']}'"
2727
end
2828

29-
if opts['with_registry_auth']
29+
if opts['with_registry_auth'] && opts['with_registry_auth'].to_s != 'undef'
3030
flags << '--with-registry-auth'
3131
end
3232

lib/puppet/parser/functions/docker_swarm_init_flags.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,39 @@ module Puppet::Parser::Functions
1212
flags << 'init'
1313
end
1414

15-
if opts['advertise_addr'].to_s != 'undef'
15+
if opts['advertise_addr'] && opts['advertise_addr'].to_s != 'undef'
1616
flags << "--advertise-addr '#{opts['advertise_addr']}'"
1717
end
1818

1919
if opts['autolock'].to_s != 'false'
2020
flags << '--autolock'
2121
end
2222

23-
if opts['cert_expiry'].to_s != 'undef'
23+
if opts['cert_expiry'] && opts['cert_expiry'].to_s != 'undef'
2424
flags << "--cert-expiry '#{opts['cert_expiry']}'"
2525
end
2626

27-
if opts['dispatcher_heartbeat'].to_s != 'undef'
27+
if opts['dispatcher_heartbeat'] && opts['dispatcher_heartbeat'].to_s != 'undef'
2828
flags << "--dispatcher-heartbeat '#{opts['dispatcher_heartbeat']}'"
2929
end
3030

31-
if opts['external_ca'].to_s != 'undef'
31+
if opts['external_ca'] && opts['external_ca'].to_s != 'undef'
3232
flags << "--external-ca '#{opts['external_ca']}'"
3333
end
3434

3535
if opts['force_new_cluster'].to_s != 'false'
3636
flags << '--force-new-cluster'
3737
end
3838

39-
if opts['listen_addr'].to_s != 'undef'
39+
if opts['listen_addr'] && opts['listen_addr'].to_s != 'undef'
4040
flags << "--listen-addr '#{opts['listen_addr']}'"
4141
end
4242

43-
if opts['max_snapshots'].to_s != 'undef'
43+
if opts['max_snapshots'] && opts['max_snapshots'].to_s != 'undef'
4444
flags << "--max-snapshots '#{opts['max_snapshots']}'"
4545
end
4646

47-
if opts['snapshot_interval'].to_s != 'undef'
47+
if opts['snapshot_interval'] && opts['snapshot_interval'].to_s != 'undef'
4848
flags << "--snapshot-interval '#{opts['snapshot_interval']}'"
4949
end
5050

lib/puppet/parser/functions/docker_swarm_join_flags.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ module Puppet::Parser::Functions
1212
flags << 'join'
1313
end
1414

15-
if opts['advertise_addr'].to_s != 'undef'
15+
if opts['advertise_addr'] && opts['advertise_addr'].to_s != 'undef'
1616
flags << "--advertise-addr '#{opts['advertise_addr']}'"
1717
end
1818

19-
if opts['listen_addr'].to_s != 'undef'
19+
if opts['listen_addr'] && opts['listen_addr'].to_s != 'undef'
2020
flags << "--listen-addr \"#{opts['listen_addr']}\""
2121
end
2222

23-
if opts['token'].to_s != 'undef'
23+
if opts['token'] && opts['token'].to_s != 'undef'
2424
flags << "--token '#{opts['token']}'"
2525
end
2626

spec/acceptance/compose_v3_spec.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
tmp_path = 'C:/cygwin64/tmp'
88
test_container = 'nanoserver-sac2016'
99
else
10+
if fact('osfamily') == 'RedHat'
11+
docker_args = "repo_opt => '--enablerepo=localmirror-extras'"
12+
else
13+
docker_args = ''
14+
end
1015
install_dir = '/usr/local/bin'
1116
file_extension = ''
12-
docker_args = ''
1317
tmp_path = '/tmp'
1418
test_container = 'debian'
1519
end

spec/acceptance/stack_spec.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ class { 'docker': #{docker_args} }
8080
end
8181

8282
it 'should not find a docker stack' do
83+
sleep 5
8384
shell('docker stack ls') do |r|
8485
expect(r.stdout).to_not match(/web/)
8586
end
8687
end
8788
end
8889

8990
context 'creating stack with multi compose files' do
90-
91+
9192
before(:all) do
9293
@install_code = <<-code
9394
docker::stack { 'web':
@@ -127,7 +128,7 @@ class { 'docker': #{docker_args} }
127128
code
128129

129130
apply_manifest(@destroy_code, :catch_failures=>true)
130-
sleep 5 # wait for containers to stop
131+
sleep 10 # wait for containers to stop
131132
end
132133

133134
it 'should be idempotent' do

spec/spec_helper_acceptance.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, e
144144

145145
if fact_on(host, 'osfamily') == 'windows'
146146
win_host = only_host_with_role(hosts, 'default')
147-
@windows_ip = win_host.ip
147+
retry_on_error_matching(60, 5, /connection failure running/) do
148+
@windows_ip = win_host.ip
149+
end
148150
apply_manifest_on(host, "class { 'docker': docker_ee => true, extra_parameters => '\"insecure-registries\": [ \"#{@windows_ip}:5000\" ]' }")
149151
docker_path = "/cygdrive/c/Program Files/Docker"
150152
host.add_env_var('PATH', docker_path)

0 commit comments

Comments
 (0)