Skip to content

Commit

Permalink
Merge branch 'main' into pdksync_remove_puppet5
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcmaw authored Feb 23, 2021
2 parents 1152b99 + bc971fc commit e846dfe
Show file tree
Hide file tree
Showing 402 changed files with 1,360 additions and 653 deletions.
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ Style/TrailingCommaInArrayLiteral:
Style/SymbolArray:
Description: Using percent style obscures symbolic intent of array's contents.
EnforcedStyle: brackets
inherit_from: ".rubocop_todo.yml"
RSpec/MessageSpies:
EnforcedStyle: receive
Style/Documentation:
Expand Down
30 changes: 23 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-12-17 20:35:36 UTC using RuboCop version 1.6.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 6
# Configuration parameters: AllowComments.
Lint/SuppressedException:
Exclude:
- 'lib/facter/facter_dot_d.rb'
- 'lib/puppet/functions/merge.rb'
- 'lib/puppet/parser/functions/getvar.rb'
- 'lib/puppet/parser/functions/has_interface_with.rb'

# Offense count: 62
# Configuration parameters: IgnoreSharedExamples.
RSpec/NamedSubject:
Enabled: false
Lint/ScriptPermission:
Enabled: false
Style/HashSyntax:

# Offense count: 2
RSpec/SubjectStub:
Exclude:
- spec/spec_helper.rb
EnforcedStyle: hash_rockets
Layout/IndentHeredoc:
Enabled: false
- 'spec/unit/facter/facter_dot_d_spec.rb'
10 changes: 1 addition & 9 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
".gitlab-ci.yml":
delete: true
".rubocop.yml":
default_configs:
inherit_from: ".rubocop_todo.yml"
include_todos: true
".travis.yml":
global_env:
- HONEYCOMB_WRITEKEY="7f3c63a70eecc61d635917de46bea4e6",HONEYCOMB_DATASET="litmus tests"
Expand Down Expand Up @@ -46,16 +45,9 @@ appveyor.yml:
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
simplecov: true
Gemfile:
use_litmus: true
optional:
":development":
- gem: github_changelog_generator
git: https://github.com/skywinder/github-changelog-generator
ref: 20ee04ba1234e9e83eb2ffb5056e23d641c7a018
condition: Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')
Rakefile:
requires:
- puppet-lint/tasks/puppet-lint
spec/spec_helper.rb:
mock_with: ":rspec"
coverage_report: true
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require 'puppet-syntax/tasks/puppet-syntax'
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
require 'puppet-lint/tasks/puppet-lint'

def changelog_user
return unless Rake.application.top_level_tasks.include? "changelog"
Expand Down
6 changes: 4 additions & 2 deletions lib/facter/package_provider.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Fact: package_provider
#
# Purpose: Returns the default provider Puppet will choose to manage packages
Expand All @@ -15,9 +17,9 @@
# Instantiates a dummy package resource and return the provider
setcode do
if defined? Gem && Gem::Version.new(Facter.value(:puppetversion).split(' ')[0]) >= Gem::Version.new('3.6')
Puppet::Type.type(:package).newpackage(:name => 'dummy', :allow_virtual => 'true')[:provider].to_s
Puppet::Type.type(:package).newpackage(name: 'dummy', allow_virtual: 'true')[:provider].to_s
else
Puppet::Type.type(:package).newpackage(:name => 'dummy')[:provider].to_s
Puppet::Type.type(:package).newpackage(name: 'dummy')[:provider].to_s
end
end
end
8 changes: 5 additions & 3 deletions lib/facter/pe_version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Fact: is_pe, pe_version, pe_major_version, pe_minor_version, pe_patch_version
#
# Purpose: Return various facts about the PE state of the system
Expand Down Expand Up @@ -38,7 +40,7 @@

# Fact: pe_major_version
Facter.add('pe_major_version') do
confine :is_pe => true
confine is_pe: true
setcode do
pe_version = Facter.value(:pe_version)
if pe_version
Expand All @@ -49,7 +51,7 @@

# Fact: pe_minor_version
Facter.add('pe_minor_version') do
confine :is_pe => true
confine is_pe: true
setcode do
pe_version = Facter.value(:pe_version)
if pe_version
Expand All @@ -60,7 +62,7 @@

# Fact: pe_patch_version
Facter.add('pe_patch_version') do
confine :is_pe => true
confine is_pe: true
setcode do
pe_version = Facter.value(:pe_version)
if pe_version
Expand Down
2 changes: 2 additions & 0 deletions lib/facter/puppet_settings.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# These facter facts return the value of the Puppet vardir and environment path
# settings for the node running puppet or puppet agent. The intent is to
# enable Puppet modules to automatically have insight into a place where they
Expand Down
26 changes: 14 additions & 12 deletions lib/facter/root_home.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# frozen_string_literal: true

# root_home.rb
module Facter::Util::RootHome
# @summary
# A facter fact to determine the root home directory.
# This varies on PE supported platforms and may be
# reconfigured by the end user.
class << self
# determines the root home directory
def returnt_root_home
root_ent = Facter::Util::Resolution.exec('getent passwd root')
# The home directory is the sixth element in the passwd entry
# If the platform doesn't have getent, root_ent will be nil and we should
# return it straight away.
root_ent && root_ent.split(':')[5]
end
# determines the root home directory
def returnt_root_home
root_ent = Facter::Util::Resolution.exec('getent passwd root')
# The home directory is the sixth element in the passwd entry
# If the platform doesn't have getent, root_ent will be nil and we should
# return it straight away.
root_ent && root_ent.split(':')[5]
end
end
end

Expand All @@ -21,7 +23,7 @@ def returnt_root_home
end

Facter.add(:root_home) do
confine :kernel => :darwin
confine kernel: :darwin
setcode do
str = Facter::Util::Resolution.exec('dscacheutil -q user -a name root')
hash = {}
Expand All @@ -34,12 +36,12 @@ def returnt_root_home
end

Facter.add(:root_home) do
confine :kernel => :aix
confine kernel: :aix
root_home = nil
setcode do
str = Facter::Util::Resolution.exec('lsuser -c -a home root')
str && str.split("\n").each do |line|
next if line =~ %r{^#}
str&.split("\n")&.each do |line|
next if %r{^#}.match?(line)
root_home = line.split(%r{:})[1]
end
root_home
Expand Down
4 changes: 3 additions & 1 deletion lib/facter/service_provider.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Fact: service_provider
#
# Purpose: Returns the default provider Puppet will choose to manage services
Expand All @@ -12,6 +14,6 @@

Facter.add(:service_provider) do
setcode do
Puppet::Type.type(:service).newservice(:name => 'dummy')[:provider].to_s
Puppet::Type.type(:service).newservice(name: 'dummy')[:provider].to_s
end
end
2 changes: 2 additions & 0 deletions lib/facter/util/puppet_settings.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# A method to evaluate a Facter code block if puppet is loaded.
module Facter::Util::PuppetSettings
# This method is intended to provide a convenient way to evaluate a
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet/functions/deprecation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Function to print deprecation warnings, Logs a warning once for a given key.
#
# The uniqueness key - can appear once.
Expand Down Expand Up @@ -25,7 +27,7 @@ def deprecation(key, message)
end
# depending on configuration setting of strict
case Puppet.settings[:strict]
when :off # rubocop:disable Lint/EmptyWhen : Is required to prevent false errors
when :off
# do nothing
when :error
raise("deprecation. #{key}. #{message}")
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/fact.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Digs into the facts hash using dot-notation
#
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet/functions/is_a.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Boolean check to determine whether a variable is of a given data type.
# This is equivalent to the `=~` type checks.
Expand Down Expand Up @@ -35,7 +37,7 @@
param 'Type', :type
end

def is_a(value, type) # rubocop:disable Style/PredicateName : Used in to many other places to rename at this time, attempting to refactor caused Rubocop to crash.
def is_a(value, type) # rubocop:disable Naming/PredicateName : Used in to many other places to rename at this time, attempting to refactor caused Rubocop to crash.
# See puppet's lib/puppet/pops/evaluator/evaluator_impl.rb eval_MatchExpression
Puppet::Pops::Types::TypeCalculator.instance?(type, value)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/is_absolute_path.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Wrapper that calls the Puppet 3.x function of the same name.
Puppet::Functions.create_function(:is_absolute_path) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/is_array.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Wrapper that calls the Puppet 3.x function of the same name.
Puppet::Functions.create_function(:is_array) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/is_bool.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Wrapper that calls the Puppet 3.x function of the same name.
Puppet::Functions.create_function(:is_bool) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/is_float.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Wrapper that calls the Puppet 3.x function of the same name.
Puppet::Functions.create_function(:is_float) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/is_ip_address.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Wrapper that calls the Puppet 3.x function of the same name.
Puppet::Functions.create_function(:is_ip_address) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/is_ipv4_address.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Wrapper that calls the Puppet 3.x function of the same name.
Puppet::Functions.create_function(:is_ipv4_address) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/is_ipv6_address.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Wrapper that calls the Puppet 3.x function of the same name.
Puppet::Functions.create_function(:is_ipv6_address) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/is_numeric.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Wrapper that calls the Puppet 3.x function of the same name.
Puppet::Functions.create_function(:is_numeric) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/is_string.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Wrapper that calls the Puppet 3.x function of the same name.
Puppet::Functions.create_function(:is_string) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/length.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# **Deprecated:** A function to eventually replace the old size() function for stdlib
#
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet/functions/merge.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Merges two or more hashes together or hashes resulting from iteration, and returns
# the resulting hash.
Expand Down Expand Up @@ -102,7 +104,7 @@ def merge_iterable3(iterable)
accumulator.merge!(r) if r.is_a?(Hash)
index += 1
end
rescue StopIteration # rubocop:disable Lint/HandleExceptions
rescue StopIteration
end
end
accumulator
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/os_version_gte.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Checks if the OS version is at least a certain version.
# > *Note:*
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/seeded_rand_string.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Generates a consistent random string of specific length based on provided seed.
#
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/sprintf_hash.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Uses sprintf with named references.
#
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/stdlib/end_with.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Returns true if str ends with one of the prefixes given. Each of the prefixes should be a String.
#
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/stdlib/extname.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Returns the Extension (the Portion of Filename in Path starting from the
# last Period).
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/stdlib/ip_in_range.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Returns true if the ipaddress is within the given CIDRs
#
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/stdlib/start_with.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Returns true if str starts with one of the prefixes given. Each of the prefixes should be a String.
#
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/to_json.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'
# @summary
# Convert a data structure and output to JSON
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/to_json_pretty.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'

# @summary
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/to_yaml.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'yaml'
# @summary
# Convert a data structure and output it as YAML
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/type_of.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Returns the type of the passed value.
#
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/validate_absolute_path.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Validate the string represents an absolute path in the filesystem.
Puppet::Functions.create_function(:validate_absolute_path) do
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/functions/validate_array.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# @summary
# Validate the passed value represents an array.
Puppet::Functions.create_function(:validate_array) do
Expand Down
Loading

0 comments on commit e846dfe

Please sign in to comment.