Skip to content

Commit f279199

Browse files
authored
Merge pull request #99 from puppetlabs/pdksync_maint-pdk-update
pdksync - (MAINT) PDK Update
2 parents 1816ceb + 4164682 commit f279199

File tree

11 files changed

+790
-198
lines changed

11 files changed

+790
-198
lines changed

.rubocop.yml

Lines changed: 703 additions & 5 deletions
Large diffs are not rendered by default.

.rubocop_todo.yml

Lines changed: 35 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,19 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-11-29 07:54:54 UTC using RuboCop version 1.48.1.
3+
# on 2023-12-21 10:51:41 UTC using RuboCop version 1.48.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 3
10-
# Configuration parameters: AllowedMethods.
11-
# AllowedMethods: enums
12-
Lint/ConstantDefinitionInBlock:
13-
Exclude:
14-
- 'lib/puppet/provider/windows_env/windows_env.rb'
15-
169
# Offense count: 1
17-
# Configuration parameters: AllowComments, AllowEmptyLambdas.
18-
Lint/EmptyBlock:
19-
Exclude:
20-
- 'lib/puppet/provider/windows_env/windows_env.rb'
21-
22-
# Offense count: 5
23-
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
24-
Metrics/AbcSize:
25-
Max: 66
26-
27-
# Offense count: 4
28-
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
29-
# AllowedMethods: refine
30-
Metrics/BlockLength:
31-
Max: 206
10+
# This cop supports safe autocorrection (--autocorrect).
11+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
12+
# URISchemes: http, https
13+
Layout/LineLength:
14+
Max: 301
3215

3316
# Offense count: 2
34-
# Configuration parameters: AllowedMethods, AllowedPatterns.
35-
Metrics/CyclomaticComplexity:
36-
Max: 24
37-
38-
# Offense count: 5
39-
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
40-
Metrics/MethodLength:
41-
Max: 47
42-
43-
# Offense count: 2
44-
# Configuration parameters: AllowedMethods, AllowedPatterns.
45-
Metrics/PerceivedComplexity:
46-
Max: 25
47-
48-
# Offense count: 2
49-
# Configuration parameters: Prefixes, AllowedPatterns.
50-
# Prefixes: when, with, without
51-
RSpec/ContextWording:
52-
Exclude:
53-
- 'spec/acceptance/windows_env_spec.rb'
54-
55-
# Offense count: 2
56-
# Configuration parameters: IgnoredMetadata.
57-
RSpec/DescribeClass:
58-
Exclude:
59-
- '**/spec/features/**/*'
60-
- '**/spec/requests/**/*'
61-
- '**/spec/routing/**/*'
62-
- '**/spec/system/**/*'
63-
- '**/spec/views/**/*'
64-
- 'spec/acceptance/windows_env_spec.rb'
65-
- 'spec/unit/puppet/type/windows_env_type_spec.rb'
66-
67-
# Offense count: 1
6817
# This cop supports unsafe autocorrection (--autocorrect-all).
6918
# Configuration parameters: EnforcedStyle.
7019
# SupportedStyles: nested, compact
@@ -73,20 +22,39 @@ Style/ClassAndModuleChildren:
7322
- 'lib/puppet/provider/windows_env/windows_env.rb'
7423

7524
# Offense count: 2
76-
# Configuration parameters: AllowedConstants.
77-
Style/Documentation:
25+
# This cop supports safe autocorrection (--autocorrect).
26+
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
27+
# SupportedStyles: slashes, percent_r, mixed
28+
Style/RegexpLiteral:
7829
Exclude:
79-
- 'spec/**/*'
80-
- 'test/**/*'
81-
- 'lib/puppet/provider/windows_env/windows_env.rb'
30+
- 'lib/puppet/type/windows_env.rb'
31+
32+
# Offense count: 8
33+
# This cop supports safe autocorrection (--autocorrect).
34+
# Configuration parameters: MinSize.
35+
# SupportedStyles: percent, brackets
36+
Style/SymbolArray:
37+
EnforcedStyle: percent
8238

8339
# Offense count: 1
84-
Style/MixinUsage:
40+
# This cop supports safe autocorrection (--autocorrect).
41+
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
42+
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
43+
Style/TernaryParentheses:
8544
Exclude:
86-
- 'spec/spec_helper.rb'
45+
- 'lib/puppet/provider/windows_env/windows_env.rb'
8746

8847
# Offense count: 1
89-
# This cop supports unsafe autocorrection (--autocorrect-all).
90-
Style/SlicingWithRange:
48+
# This cop supports safe autocorrection (--autocorrect).
49+
# Configuration parameters: EnforcedStyleForMultiline.
50+
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
51+
Style/TrailingCommaInArrayLiteral:
9152
Exclude:
92-
- 'lib/puppet/provider/windows_env/windows_env.rb'
53+
- 'spec/unit/puppet/type/windows_env_type_spec.rb'
54+
55+
# Offense count: 1
56+
# This cop supports safe autocorrection (--autocorrect).
57+
# Configuration parameters: MinSize, WordRegex.
58+
# SupportedStyles: percent, brackets
59+
Style/WordArray:
60+
EnforcedStyle: percent

.sync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml:
1212
spec/acceptance/nodesets/archlinux-2-x64.yml:
1313
delete: true
1414
.rubocop.yml:
15-
unmanaged: true
15+
include_todos: true

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ group :development do
2323
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
2424
gem "facterdb", '~> 1.18', require: false
2525
gem "metadata-json-lint", '~> 3.0', require: false
26+
gem "puppetlabs_spec_helper", '~> 6.0', require: false
2627
gem "rspec-puppet-facts", '~> 2.0', require: false
2728
gem "codecov", '~> 0.2', require: false
2829
gem "dependency_checker", '~> 1.0.0', require: false
@@ -33,6 +34,7 @@ group :development do
3334
gem "rubocop", '= 1.48.1', require: false
3435
gem "rubocop-performance", '= 1.16.0', require: false
3536
gem "rubocop-rspec", '= 2.19.0', require: false
37+
gem "puppet-strings", '~> 4.0', require: false
3638
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
3739
end
3840
group :system_tests do
@@ -41,7 +43,7 @@ group :system_tests do
4143
end
4244
group :release_prep do
4345
gem "puppet-strings", '~> 4.0', require: false
44-
gem "puppetlabs_spec_helper", '~> 7.0', require: false
46+
gem "puppetlabs_spec_helper", '~> 6.0', require: false
4547
end
4648

4749
puppet_version = ENV['PUPPET_GEM_VERSION']

Rakefile

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -4,85 +4,6 @@ require 'bundler'
44
require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus'
55
require 'puppetlabs_spec_helper/rake_tasks'
66
require 'puppet-syntax/tasks/puppet-syntax'
7-
require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator'
87
require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings'
98

10-
def changelog_user
11-
return unless Rake.application.top_level_tasks.include? "changelog"
12-
returnVal = nil || JSON.load(File.read('metadata.json'))['author']
13-
raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
14-
puts "GitHubChangelogGenerator user:#{returnVal}"
15-
returnVal
16-
end
17-
18-
def changelog_project
19-
return unless Rake.application.top_level_tasks.include? "changelog"
20-
21-
returnVal = nil
22-
returnVal ||= begin
23-
metadata_source = JSON.load(File.read('metadata.json'))['source']
24-
metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z})
25-
26-
metadata_source_match && metadata_source_match[1]
27-
end
28-
29-
raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil?
30-
31-
puts "GitHubChangelogGenerator project:#{returnVal}"
32-
returnVal
33-
end
34-
35-
def changelog_future_release
36-
return unless Rake.application.top_level_tasks.include? "changelog"
37-
returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version']
38-
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
39-
puts "GitHubChangelogGenerator future_release:#{returnVal}"
40-
returnVal
41-
end
42-
439
PuppetLint.configuration.send('disable_relative')
44-
45-
46-
if Gem.loaded_specs.key? 'github_changelog_generator'
47-
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
48-
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?
49-
config.user = "#{changelog_user}"
50-
config.project = "#{changelog_project}"
51-
config.future_release = "#{changelog_future_release}"
52-
config.exclude_labels = ['maintenance']
53-
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)."
54-
config.add_pr_wo_labels = true
55-
config.issues = false
56-
config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB"
57-
config.configure_sections = {
58-
"Changed" => {
59-
"prefix" => "### Changed",
60-
"labels" => ["backwards-incompatible"],
61-
},
62-
"Added" => {
63-
"prefix" => "### Added",
64-
"labels" => ["enhancement", "feature"],
65-
},
66-
"Fixed" => {
67-
"prefix" => "### Fixed",
68-
"labels" => ["bug", "documentation", "bugfix"],
69-
},
70-
}
71-
end
72-
else
73-
desc 'Generate a Changelog from GitHub'
74-
task :changelog do
75-
raise <<EOM
76-
The changelog tasks depends on recent features of the github_changelog_generator gem.
77-
Please manually add it to your .sync.yml for now, and run `pdk update`:
78-
---
79-
Gemfile:
80-
optional:
81-
':development':
82-
- gem: 'github_changelog_generator'
83-
version: '~> 1.15'
84-
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')"
85-
EOM
86-
end
87-
end
88-

lib/facter/windows_env.rb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66
require 'puppet/util/windows/process'
77

88
# This list must be in uppercase
9-
whitelist = %w[
10-
ALLUSERSPROFILE
11-
APPDATA
12-
COMMONPROGRAMFILES
13-
COMMONPROGRAMFILES(X86)
14-
HOME
15-
HOMEDRIVE
16-
HOMEPATH
17-
LOCALAPPDATA
18-
PATHEXT
19-
PROCESSOR_IDENTIFIER
20-
PROCESSOR_LEVEL
21-
PROCESSOR_REVISION
22-
PROGRAMDATA
23-
PROGRAMFILES
24-
PROGRAMFILES(X86)
25-
PSMODULEPATH
26-
PUBLIC
27-
SYSTEMDRIVE
28-
SYSTEMROOT
29-
TEMP
30-
TMP
31-
USERPROFILE
32-
WINDIR
9+
whitelist = [
10+
'ALLUSERSPROFILE',
11+
'APPDATA',
12+
'COMMONPROGRAMFILES',
13+
'COMMONPROGRAMFILES(X86)',
14+
'HOME',
15+
'HOMEDRIVE',
16+
'HOMEPATH',
17+
'LOCALAPPDATA',
18+
'PATHEXT',
19+
'PROCESSOR_IDENTIFIER',
20+
'PROCESSOR_LEVEL',
21+
'PROCESSOR_REVISION',
22+
'PROGRAMDATA',
23+
'PROGRAMFILES',
24+
'PROGRAMFILES(X86)',
25+
'PSMODULEPATH',
26+
'PUBLIC',
27+
'SYSTEMDRIVE',
28+
'SYSTEMROOT',
29+
'TEMP',
30+
'TMP',
31+
'USERPROFILE',
32+
'WINDIR',
3333
]
3434

3535
result = {}

lib/puppet/provider/windows_env/windows_env.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ module self::WinAPI
6363
ffi_convention :stdcall
6464

6565
ffi_lib :User32
66-
attach_function :SendMessageTimeout, :SendMessageTimeoutA, %i[uintptr_t uint pointer pointer uint uint pointer], :pointer
66+
attach_function :SendMessageTimeout, :SendMessageTimeoutA, [:uintptr_t, :uint, :pointer, :pointer, :uint, :uint, :pointer], :pointer
6767

6868
ffi_lib :Advapi32
69-
attach_function :RegLoadKey, :RegLoadKeyA, %i[uintptr_t pointer pointer], :long
70-
attach_function :RegUnLoadKey, :RegUnLoadKeyA, %i[uintptr_t pointer], :long
69+
attach_function :RegLoadKey, :RegLoadKeyA, [:uintptr_t, :pointer, :pointer], :long
70+
attach_function :RegUnLoadKey, :RegUnLoadKeyA, [:uintptr_t, :pointer], :long
7171

7272
# Ruby < 1.9 doesn't know about encoding.
7373
if defined?(::Encoding)
7474
# Workaround for https://bugs.ruby-lang.org/issues/10820 .
75-
attach_function :RegDeleteValue, :RegDeleteValueW, %i[uintptr_t buffer_in], :long
75+
attach_function :RegDeleteValue, :RegDeleteValueW, [:uintptr_t, :buffer_in], :long
7676

7777
# Borrowed from Puppet core. Duplicated for old version compatibilty.
7878
def self.from_string_to_wide_string(str)
@@ -163,7 +163,7 @@ def exists?
163163
# when removing in 'prepend' and 'append' modes. Otherwise, if the value
164164
# were in the variable but not at the beginning (prepend) or end (append),
165165
# it would not be removed.
166-
@resource[:mergemode] = :insert if @resource[:ensure] == :absent && %i[append prepend].include?(@resource[:mergemode])
166+
@resource[:mergemode] = :insert if @resource[:ensure] == :absent && [:append, :prepend].include?(@resource[:mergemode])
167167

168168
case @resource[:mergemode]
169169
when :clobber

lib/puppet/type/windows_env.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def self.check_collisions(resource)
1414
# Cannot have two resources in clobber mode on the same var
1515
@mergemode[user] ||= {}
1616
last = @mergemode[user][var]
17-
raise "Multiple resources are managing the same environment variable but at least one is in clobber mergemode. (Offending resources: #{resource}, #{last})" if (!last.nil? && last.catalog == resource.catalog) && ((resource[:mergemode] == :clobber && last) || (last && last[:mergemode] == :clobber))
17+
raise "Multiple resources are managing the same environment variable but at least one is in clobber mergemode. (Offending resources: #{resource}, #{last})" \
18+
if (!last.nil? && last.catalog == resource.catalog) && \
19+
((resource[:mergemode] == :clobber && last) || \
20+
(last && last[:mergemode] == :clobber))
1821

1922
@mergemode[user][var] = resource
2023

@@ -97,7 +100,7 @@ def self.title_patterns
97100
validate do
98101
raise "'value' parameter must be provided when 'ensure => present'" if self[:ensure] == :present && [nil, :undef].include?(self[:value])
99102
if self[:ensure] == :absent && [nil, :undef].include?(self[:value]) &&
100-
%i[prepend append insert].include?(self[:mergemode])
103+
[:prepend, :append, :insert].include?(self[:mergemode])
101104
raise "'value' parameter must be provided when 'ensure => absent' and 'mergemode => #{self[:mergemode]}'"
102105
end
103106

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
],
3232
"pdk-version": "3.0.0",
3333
"template-url": "https://github.com/puppetlabs/pdk-templates.git#main",
34-
"template-ref": "heads/main-0-g01c6a19"
34+
"template-ref": "heads/main-0-g79a2f93"
3535
}

spec/spec_helper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
default_facts = {
1515
puppetversion: Puppet.version,
16-
facterversion: Facter.version
16+
facterversion: Facter.version,
1717
}
1818

1919
default_fact_files = [
2020
File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
21-
File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml'))
21+
File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
2222
]
2323

2424
default_fact_files.each do |f|
@@ -38,7 +38,7 @@
3838

3939
RSpec.configure do |c|
4040
c.default_facts = default_facts
41-
c.before do
41+
c.before :each do
4242
# set to strictest setting for testing
4343
# by default Puppet runs at warning level
4444
Puppet.settings[:strict] = :warning
@@ -51,8 +51,8 @@
5151

5252
# Filter backtrace noise
5353
backtrace_exclusion_patterns = [
54-
/spec_helper/,
55-
/gems/
54+
%r{spec_helper},
55+
%r{gems},
5656
]
5757

5858
if c.respond_to?(:backtrace_exclusion_patterns)

0 commit comments

Comments
 (0)