Skip to content

Commit 7069255

Browse files
committed
Update to PDK v1.10.0
1 parent 0192116 commit 7069255

11 files changed

+168
-66
lines changed

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.rb eol=lf
2+
*.erb eol=lf
3+
*.pp eol=lf
4+
*.sh eol=lf
5+
*.epp eol=lf

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@
2222
/convert_report.txt
2323
/update_report.txt
2424
.DS_Store
25+
.project
26+
.envrc
27+
/inventory.yaml

.pdkignore

+18
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,21 @@
2222
/convert_report.txt
2323
/update_report.txt
2424
.DS_Store
25+
.project
26+
.envrc
27+
/inventory.yaml
28+
/appveyor.yml
29+
/.fixtures.yml
30+
/Gemfile
31+
/.gitattributes
32+
/.gitignore
33+
/.gitlab-ci.yml
34+
/.pdkignore
35+
/Rakefile
36+
/rakelib/
37+
/.rspec
38+
/.rubocop.yml
39+
/.travis.yml
40+
/.yardopts
41+
/spec/
42+
/.vscode/

.puppet-lint.rc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--relative

.rubocop.yml

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ AllCops:
1919
Metrics/LineLength:
2020
Description: People have wide screens, use them.
2121
Max: 200
22+
GetText/DecorateString:
23+
Description: We don't want to decorate test output.
24+
Exclude:
25+
- spec/*
2226
RSpec/BeforeAfterAll:
2327
Description: Beware of using after(:all) as it may cause state to leak between tests.
2428
A necessary evil in acceptance testing.
@@ -82,6 +86,8 @@ Style/StringMethods:
8286
Enabled: true
8387
Layout/EndOfLine:
8488
Enabled: false
89+
Layout/IndentHeredoc:
90+
Enabled: false
8591
Metrics/AbcSize:
8692
Enabled: false
8793
Metrics/BlockLength:

.travis.yml

+28-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
11
---
2-
sudo: false
32
dist: trusty
43
language: ruby
54
cache: bundler
6-
before_install: >
7-
set -ex
8-
&& bundle -v
9-
&& rm -f Gemfile.lock
10-
&& gem update --system
11-
&& gem --version
12-
&& bundle -v
5+
before_install:
6+
- bundle -v
7+
- rm -f Gemfile.lock
8+
- gem update --system $RUBYGEMS_VERSION
9+
- gem --version
10+
- bundle -v
1311
script:
1412
- 'bundle exec rake $CHECK'
1513
bundler_args: --without system_tests
1614
rvm:
17-
- 2.5.1
18-
env:
19-
global:
20-
- BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0"
15+
- 2.5.3
16+
stages:
17+
- static
18+
- spec
19+
- acceptance
20+
-
21+
if: tag =~ ^v\d
22+
name: deploy
2123
matrix:
2224
fast_finish: true
2325
include:
24-
- env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop"
25-
- env: CHECK=parallel_spec
26-
- env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
27-
rvm: 2.4.1
26+
-
27+
env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
28+
stage: static
29+
-
30+
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
31+
rvm: 2.4.5
32+
stage: spec
33+
-
34+
env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec
35+
rvm: 2.5.3
36+
stage: spec
37+
-
38+
env: DEPLOY_TO_FORGE=yes
39+
stage: deploy
2840
branches:
2941
only:
3042
- master

Gemfile

+17-31
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,35 @@
11
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
22

33
def location_for(place_or_version, fake_version = nil)
4-
if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)}
5-
[fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact
6-
elsif place_or_version =~ %r{\Afile:\/\/(.*)}
7-
['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }]
8-
else
9-
[place_or_version, { require: false }]
10-
end
11-
end
4+
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
5+
file_url_regex = %r{\Afile:\/\/(?<path>.*)}
126

13-
def gem_type(place_or_version)
14-
if place_or_version =~ %r{\Agit[:@]}
15-
:git
16-
elsif !place_or_version.nil? && place_or_version.start_with?('file:')
17-
:file
7+
if place_or_version && (git_url = place_or_version.match(git_url_regex))
8+
[fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
9+
elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
10+
['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
1811
else
19-
:gem
12+
[place_or_version, { require: false }]
2013
end
2114
end
2215

2316
ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
2417
minor_version = ruby_version_segments[0..1].join('.')
2518

2619
group :development do
27-
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
28-
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
29-
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
30-
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
31-
gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4')
32-
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
33-
gem "puppet-module-posix-dev-r#{minor_version}", '>= 0.3.5', require: false, platforms: [:ruby]
34-
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
35-
gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
20+
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
21+
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
22+
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
23+
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
24+
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
25+
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
26+
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
27+
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
28+
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
29+
gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
3630
end
3731

3832
puppet_version = ENV['PUPPET_GEM_VERSION']
39-
puppet_type = gem_type(puppet_version)
4033
facter_version = ENV['FACTER_GEM_VERSION']
4134
hiera_version = ENV['HIERA_GEM_VERSION']
4235

@@ -60,13 +53,6 @@ if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
6053
gems['win32-service'] = ['0.8.8', require: false]
6154
end
6255

63-
group :system_tests do
64-
gem "puppet-module-posix-system-r#{minor_version}"
65-
# adding nokogiri gem during tests to satisfy dep in cjc test runner
66-
gem 'nokogiri', :require => false
67-
gem 'serverspec', :require => false
68-
end
69-
7056
gems.each do |gem_name, gem_params|
7157
gem gem_name, *gem_params
7258
end

Rakefile

+70
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,76 @@
11
require 'puppetlabs_spec_helper/rake_tasks'
22
require 'puppet-syntax/tasks/puppet-syntax'
33
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
4+
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
5+
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
6+
7+
def changelog_user
8+
return unless Rake.application.top_level_tasks.include? "changelog"
9+
returnVal = nil || JSON.load(File.read('metadata.json'))['author']
10+
raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
11+
puts "GitHubChangelogGenerator user:#{returnVal}"
12+
returnVal
13+
end
14+
15+
def changelog_project
16+
return unless Rake.application.top_level_tasks.include? "changelog"
17+
returnVal = nil || JSON.load(File.read('metadata.json'))['name']
18+
raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil?
19+
puts "GitHubChangelogGenerator project:#{returnVal}"
20+
returnVal
21+
end
22+
23+
def changelog_future_release
24+
return unless Rake.application.top_level_tasks.include? "changelog"
25+
returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version']
26+
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
27+
puts "GitHubChangelogGenerator future_release:#{returnVal}"
28+
returnVal
29+
end
430

531
PuppetLint.configuration.send('disable_relative')
632

33+
if Bundler.rubygems.find_name('github_changelog_generator').any?
34+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
35+
raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
36+
config.user = "#{changelog_user}"
37+
config.project = "#{changelog_project}"
38+
config.future_release = "#{changelog_future_release}"
39+
config.exclude_labels = ['maintenance']
40+
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
41+
config.add_pr_wo_labels = true
42+
config.issues = false
43+
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
44+
config.configure_sections = {
45+
"Changed" => {
46+
"prefix" => "### Changed",
47+
"labels" => ["backwards-incompatible"],
48+
},
49+
"Added" => {
50+
"prefix" => "### Added",
51+
"labels" => ["feature", "enhancement"],
52+
},
53+
"Fixed" => {
54+
"prefix" => "### Fixed",
55+
"labels" => ["bugfix"],
56+
},
57+
}
58+
end
59+
else
60+
desc 'Generate a Changelog from GitHub'
61+
task :changelog do
62+
raise <<EOM
63+
The changelog tasks depends on unreleased features of the github_changelog_generator gem.
64+
Please manually add it to your .sync.yml for now, and run `pdk update`:
65+
---
66+
Gemfile:
67+
optional:
68+
':development':
69+
- gem: 'github_changelog_generator'
70+
git: 'https://github.com/skywinder/github-changelog-generator'
71+
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
72+
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
73+
EOM
74+
end
75+
end
76+

metadata.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
}
8484
],
8585
"description": "Module for installing/configuring PuppetDB",
86-
"pdk-version": "1.6.0",
87-
"template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
88-
"template-ref": "1.6.0-0-gf5564c0"
86+
"pdk-version": "1.10.0",
87+
"template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git#1.10.0",
88+
"template-ref": "1.10.0-0-gbba9ac3"
8989
}

spec/default_facts.yml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# Facts specified here will override the values provided by rspec-puppet-facts.
44
---
5-
concat_basedir: "/tmp"
65
ipaddress: "172.16.254.254"
76
is_pe: false
87
macaddress: "AA:AA:AA:AA:AA:AA"

spec/spec_helper.rb

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
21
require 'puppetlabs_spec_helper/module_spec_helper'
32
require 'rspec-puppet-facts'
43

5-
begin
6-
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
7-
rescue LoadError => loaderror
8-
warn "Could not require spec_helper_local: #{loaderror.message}"
9-
end
4+
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
105

116
include RspecPuppetFacts
127

@@ -15,15 +10,19 @@
1510
facterversion: Facter.version,
1611
}
1712

18-
default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml'))
19-
default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml'))
13+
default_fact_files = [
14+
File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
15+
File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
16+
]
2017

21-
if File.exist?(default_facts_path) && File.readable?(default_facts_path)
22-
default_facts.merge!(YAML.safe_load(File.read(default_facts_path)))
23-
end
18+
default_fact_files.each do |f|
19+
next unless File.exist?(f) && File.readable?(f) && File.size?(f)
2420

25-
if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path)
26-
default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path)))
21+
begin
22+
default_facts.merge!(YAML.safe_load(File.read(f), [], [], true))
23+
rescue => e
24+
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
25+
end
2726
end
2827

2928
RSpec.configure do |c|
@@ -33,12 +32,15 @@
3332
# by default Puppet runs at warning level
3433
Puppet.settings[:strict] = :warning
3534
end
35+
c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
36+
c.after(:suite) do
37+
end
3638
end
3739

3840
def ensure_module_defined(module_name)
3941
module_name.split('::').reduce(Object) do |last_module, next_module|
40-
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module)
41-
last_module.const_get(next_module)
42+
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
43+
last_module.const_get(next_module, false)
4244
end
4345
end
4446

0 commit comments

Comments
 (0)