diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9032a01 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +*.rb eol=lf +*.erb eol=lf +*.pp eol=lf +*.sh eol=lf +*.epp eol=lf diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..cc96ece --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1 @@ +--relative diff --git a/.rubocop.yml b/.rubocop.yml index 40a58e0..21b82b9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,19 +1,25 @@ --- -require: rubocop-rspec +require: +- rubocop-performance +- rubocop-rspec AllCops: + NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.6' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" - - Gemfile - - Rakefile + - "**/Gemfile" + - "**/Rakefile" - pkg/**/* - spec/fixtures/**/* - vendor/**/* -Metrics/LineLength: + - "**/Puppetfile" + - "**/Vagrantfile" + - "**/Guardfile" +Layout/LineLength: Description: People have wide screens, use them. Max: 200 RSpec/BeforeAfterAll: @@ -24,6 +30,9 @@ RSpec/BeforeAfterAll: RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each +RSpec/DescribeSymbol: + Exclude: + - spec/unit/facter/**/*.rb Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. @@ -56,7 +65,7 @@ Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma @@ -65,18 +74,182 @@ Style/SymbolArray: EnforcedStyle: brackets RSpec/MessageSpies: EnforcedStyle: receive +Style/Documentation: + Exclude: + - lib/puppet/parser/functions/**/* + - spec/**/* +Style/WordArray: + EnforcedStyle: brackets +Performance/AncestorsInclude: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/CaseWhenSplat: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/Sum: + Enabled: true Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true +Bundler/GemFilename: + Enabled: false +Bundler/InsecureProtocolSource: + Enabled: false +Capybara/CurrentPathExpectation: + Enabled: false +Capybara/VisibilityMatcher: + Enabled: false +Gemspec/DuplicatedAssignment: + Enabled: false +Gemspec/OrderedDependencies: + Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false +Gemspec/RubyVersionGlobalsUsage: + Enabled: false +Layout/ArgumentAlignment: + Enabled: false +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: + Enabled: false +Layout/EmptyComment: + Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: false Layout/EndOfLine: Enabled: false +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: + Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false +Metrics/BlockNesting: + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: @@ -89,19 +262,469 @@ Metrics/ParameterLists: Enabled: false Metrics/PerceivedComplexity: Enabled: false +Migration/DepartmentName: + Enabled: false +Naming/AccessorMethodName: + Enabled: false +Naming/BlockParameterName: + Enabled: false +Naming/HeredocDelimiterCase: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false +Naming/MethodParameterName: + Enabled: false +Naming/RescuedExceptionsVariableName: + Enabled: false +Naming/VariableNumber: + Enabled: false +Performance/BindCall: + Enabled: false +Performance/DeletePrefix: + Enabled: false +Performance/DeleteSuffix: + Enabled: false +Performance/InefficientHashSearch: + Enabled: false +Performance/UnfreezeString: + Enabled: false +Performance/UriDefaultParser: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/ContainExactly: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false RSpec/ExampleLength: Enabled: false -RSpec/MessageExpectation: +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MatchArray: + Enabled: false +RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false -Style/AsciiComments: +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: Enabled: false Style/IfUnlessModifier: Enabled: false +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedUnless: + Enabled: false +Style/NumericPredicate: + Enabled: false +Style/OptionalBooleanParameter: + Enabled: false +Style/OrAssignment: + Enabled: false +Style/RandomWithOffset: + Enabled: false +Style/RedundantAssignment: + Enabled: false +Style/RedundantCondition: + Enabled: false +Style/RedundantConditional: + Enabled: false +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: false +Style/RedundantRegexpCharacterClass: + Enabled: false +Style/RedundantRegexpEscape: + Enabled: false +Style/RedundantSelfAssignment: + Enabled: false +Style/RedundantSort: + Enabled: false +Style/RescueStandardError: + Enabled: false +Style/SingleArgumentDig: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: false +Style/StderrPuts: + Enabled: false +Style/StringConcatenation: + Enabled: false +Style/Strip: + Enabled: false Style/SymbolProc: Enabled: false +Style/TrailingBodyOnClass: + Enabled: false +Style/TrailingBodyOnMethodDefinition: + Enabled: false +Style/TrailingBodyOnModule: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +Style/TrailingMethodEndStatement: + Enabled: false +Style/UnpackFirst: + Enabled: false +Capybara/MatchStyle: + Enabled: false +Capybara/NegationMatcher: + Enabled: false +Capybara/SpecificActions: + Enabled: false +Capybara/SpecificFinders: + Enabled: false +Capybara/SpecificMatcher: + Enabled: false +Gemspec/DeprecatedAttributeAssignment: + Enabled: false +Gemspec/DevelopmentDependencies: + Enabled: false +Gemspec/RequireMFA: + Enabled: false +Layout/LineContinuationLeadingSpace: + Enabled: false +Layout/LineContinuationSpacing: + Enabled: false +Layout/LineEndStringConcatenationIndentation: + Enabled: false +Layout/SpaceBeforeBrackets: + Enabled: false +Lint/AmbiguousAssignment: + Enabled: false +Lint/AmbiguousOperatorPrecedence: + Enabled: false +Lint/AmbiguousRange: + Enabled: false +Lint/ConstantOverwrittenInRescue: + Enabled: false +Lint/DeprecatedConstants: + Enabled: false +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateMagicComment: + Enabled: false +Lint/DuplicateMatchPattern: + Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/EmptyInPattern: + Enabled: false +Lint/IncompatibleIoSelectWithFiberScheduler: + Enabled: false +Lint/LambdaWithoutLiteralBlock: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/NonAtomicFileOperation: + Enabled: false +Lint/NumberedParameterAssignment: + Enabled: false +Lint/OrAssignmentToConstant: + Enabled: false +Lint/RedundantDirGlobSort: + Enabled: false +Lint/RefinementImportMethods: + Enabled: false +Lint/RequireRangeParentheses: + Enabled: false +Lint/RequireRelativeSelfPath: + Enabled: false +Lint/SymbolConversion: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/TripleQuotes: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +Lint/UselessRescue: + Enabled: false +Lint/UselessRuby2Keywords: + Enabled: false +Metrics/CollectionLiteralLength: + Enabled: false +Naming/BlockForwarding: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Performance/ConcurrentMonotonicTime: + Enabled: false +Performance/MapCompact: + Enabled: false +Performance/RedundantEqualityComparisonBlock: + Enabled: false +Performance/RedundantSplitRegexpArgument: + Enabled: false +Performance/StringIdentifierArgument: + Enabled: false +RSpec/BeEq: + Enabled: false +RSpec/BeNil: + Enabled: false +RSpec/ChangeByZero: + Enabled: false +RSpec/ClassCheck: + Enabled: false +RSpec/DuplicatedMetadata: + Enabled: false +RSpec/ExcessiveDocstringSpacing: + Enabled: false +RSpec/FactoryBot/ConsistentParenthesesStyle: + Enabled: false +RSpec/FactoryBot/FactoryNameStyle: + Enabled: false +RSpec/FactoryBot/SyntaxMethods: + Enabled: false +RSpec/IdenticalEqualityAssertion: + Enabled: false +RSpec/NoExpectationExample: + Enabled: false +RSpec/PendingWithoutReason: + Enabled: false +RSpec/Rails/AvoidSetupHook: + Enabled: false +RSpec/Rails/HaveHttpStatus: + Enabled: false +RSpec/Rails/InferredSpecType: + Enabled: false +RSpec/Rails/MinitestAssertions: + Enabled: false +RSpec/Rails/TravelAround: + Enabled: false +RSpec/RedundantAround: + Enabled: false +RSpec/SkipBlockInsideExample: + Enabled: false +RSpec/SortMetadata: + Enabled: false +RSpec/SubjectDeclaration: + Enabled: false +RSpec/VerifiedDoubleReference: + Enabled: false +Security/CompoundHash: + Enabled: false +Security/IoMethods: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false +Style/ArrayIntersect: + Enabled: false +Style/CollectionCompact: + Enabled: false +Style/ComparableClamp: + Enabled: false +Style/ConcatArrayLiterals: + Enabled: false +Style/DataInheritance: + Enabled: false +Style/DirEmpty: + Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/EmptyHeredoc: + Enabled: false +Style/EndlessMethod: + Enabled: false +Style/EnvHome: + Enabled: false +Style/FetchEnvVar: + Enabled: false +Style/FileEmpty: + Enabled: false +Style/FileRead: + Enabled: false +Style/FileWrite: + Enabled: false +Style/HashConversion: + Enabled: false +Style/HashExcept: + Enabled: false +Style/IfWithBooleanLiteralBranches: + Enabled: false +Style/InPatternThen: + Enabled: false +Style/MagicCommentFormat: + Enabled: false +Style/MapCompactWithConditionalBlock: + Enabled: false +Style/MapToHash: + Enabled: false +Style/MapToSet: + Enabled: false +Style/MinMaxComparison: + Enabled: false +Style/MultilineInPatternThen: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NestedFileDirname: + Enabled: false +Style/NilLambda: + Enabled: false +Style/NumberedParameters: + Enabled: false +Style/NumberedParametersLimit: + Enabled: false +Style/ObjectThen: + Enabled: false +Style/OpenStructUse: + Enabled: false +Style/OperatorMethodCall: + Enabled: false +Style/QuotedSymbols: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/RedundantConstantBase: + Enabled: false +Style/RedundantDoubleSplatHashBraces: + Enabled: false +Style/RedundantEach: + Enabled: false +Style/RedundantHeredocDelimiterQuotes: + Enabled: false +Style/RedundantInitialize: + Enabled: false +Style/RedundantLineContinuation: + Enabled: false +Style/RedundantSelfAssignmentBranch: + Enabled: false +Style/RedundantStringEscape: + Enabled: false +Style/SelectByRegexp: + Enabled: false +Style/StringChars: + Enabled: false +Style/SwapValues: + Enabled: false diff --git a/.ruby-version b/.ruby-version index 8122ad0..acf9bf0 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.8 \ No newline at end of file +3.2.2 \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..6da8d47 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "puppet.puppet-vscode", + "Shopify.ruby-lsp" + ] +} diff --git a/Gemfile b/Gemfile index b675bb5..d1e95db 100644 --- a/Gemfile +++ b/Gemfile @@ -1,44 +1,52 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' def location_for(place_or_version, fake_version = nil) - if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)} - [fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact - elsif place_or_version =~ %r{\Afile:\/\/(.*)} - ['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }] - else - [place_or_version, { require: false }] - end -end + git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} + file_url_regex = %r{\Afile:\/\/(?.*)} -def gem_type(place_or_version) - if place_or_version =~ %r{\Agit[:@]} - :git - elsif !place_or_version.nil? && place_or_version.start_with?('file:') - :file + if place_or_version && (git_url = place_or_version.match(git_url_regex)) + [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact + elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) + ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] else - :gem + [place_or_version, { require: false }] end end -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = ruby_version_segments[0..1].join('.') - group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4') - gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-blacksmith", '~> 3.4', require: false, platforms: [:ruby] - gem "hiera-eyaml", require: false + 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)) + gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "deep_merge", '~> 1.0', require: false + gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false + gem "facterdb", '~> 1.18', require: false + gem "metadata-json-lint", '~> 4.0', require: false + gem "rspec-puppet-facts", '~> 3.0', require: false + gem "dependency_checker", '~> 1.0.0', require: false + gem "parallel_tests", '= 3.12.1', require: false + gem "pry", '~> 0.10', require: false + gem "simplecov-console", '~> 0.9', require: false + gem "puppet-debugger", '~> 1.0', require: false + gem "rubocop", '~> 1.50.0', require: false + gem "rubocop-performance", '= 1.16.0', require: false + gem "rubocop-rspec", '= 2.19.0', require: false + gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "hiera-eyaml", require: false +end +group :development, :release_prep do + gem "puppet-strings", '~> 4.0', require: false + gem "puppetlabs_spec_helper", '~> 7.0', require: false +end +group :system_tests do + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "serverspec", '~> 2.41', require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] -puppet_type = gem_type(puppet_version) facter_version = ENV['FACTER_GEM_VERSION'] hiera_version = ENV['HIERA_GEM_VERSION'] @@ -52,16 +60,6 @@ gems['puppet'] = location_for(puppet_version) gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version -if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} - # If we're using a Puppet gem on Windows which handles its own win32-xxx gem - # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). - gems['win32-dir'] = ['<= 0.4.9', require: false] - gems['win32-eventlog'] = ['<= 0.6.5', require: false] - gems['win32-process'] = ['<= 0.7.5', require: false] - gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['0.8.8', require: false] -end - gems.each do |gem_name, gem_params| gem gem_name, *gem_params end diff --git a/Gemfile.lock b/Gemfile.lock index 66e3a7e..4f59161 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,184 +1,428 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - ast (2.4.0) - coderay (1.1.2) - diff-lcs (1.3) - docile (1.3.1) - domain_name (0.5.20180417) - unf (>= 0.0.5, < 1.0.0) - facter (2.5.1) - facterdb (0.5.2) - facter + CFPropertyList (3.0.7) + base64 + nkf + rexml + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + ansi (1.5.0) + ast (2.4.2) + awesome_print (1.9.2) + aws-eventstream (1.3.0) + aws-partitions (1.927.0) + aws-sdk-core (3.195.0) + aws-eventstream (~> 1, >= 1.3.0) + aws-partitions (~> 1, >= 1.651.0) + aws-sigv4 (~> 1.8) + jmespath (~> 1, >= 1.6.1) + aws-sdk-ec2 (1.456.0) + aws-sdk-core (~> 3, >= 3.193.0) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.8.0) + aws-eventstream (~> 1, >= 1.0.2) + base64 (0.2.0) + bigdecimal (3.1.8) + bindata (2.5.0) + bolt (3.29.0) + CFPropertyList (>= 2.2) + addressable (~> 2.5) + aws-sdk-ec2 (~> 1) + concurrent-ruby (~> 1.0) + ffi (>= 1.9.25, < 2.0.0) + hiera-eyaml (~> 3) + jwt (~> 2.2) + logging (~> 2.2) + minitar (~> 0.6) + net-scp (>= 1.2, < 5.0) + net-ssh (>= 4.0, < 8.0) + net-ssh-krb (~> 0.5) + orchestrator_client (~> 0.5) + puppet (>= 6.18.0) + puppet-resource_api (>= 1.8.1) + puppet-strings (>= 2.3.0, < 5.0) + puppetfile-resolver (>= 0.6.2, < 1.0) + r10k (~> 3.10) + ruby_smb (~> 1.0) + terminal-table (~> 3.0) + winrm (~> 2.0) + winrm-fs (~> 1.3) + builder (3.2.4) + coderay (1.1.3) + colored2 (3.1.2) + concurrent-ruby (1.2.3) + connection_pool (2.4.1) + cri (2.15.11) + deep_merge (1.2.2) + dependency_checker (1.0.1) + parallel + puppet_forge (>= 2.2, < 6.0) + rake (~> 13.0) + semantic_puppet (~> 1.0) + diff-lcs (1.5.1) + docile (1.4.0) + docker-api (2.2.0) + excon (>= 0.47.0) + multi_json + erubi (1.12.0) + excon (0.110.0) + facter (4.7.0) + hocon (~> 1.3) + thor (>= 1.0.1, < 1.3) + facterdb (1.24.0) + facter (< 5.0.0) jgrep - fast_gettext (1.1.2) - gettext (3.2.9) + faraday (2.9.0) + faraday-net_http (>= 2.0, < 3.2) + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) + faraday-net_http (3.1.0) + net-http + fast_gettext (2.3.0) + ffi (1.16.3) + forwardable (1.3.3) + gettext (3.4.9) + erubi locale (>= 2.0.5) + prime + racc text (>= 1.3.0) - gettext-setup (0.30) - fast_gettext (~> 1.1.0) - gettext (>= 3.0.2) + gettext-setup (1.1.0) + fast_gettext (~> 2.1) + gettext (~> 3.4) locale - hiera (3.4.3) - hiera-eyaml (2.1.0) - highline (~> 1.6.19) - trollop (~> 2.0) - highline (1.6.21) - http-cookie (1.0.3) - domain_name (~> 0.5) - jgrep (1.5.0) - json (2.0.4) - json-schema (2.8.0) - addressable (>= 2.4) - locale (2.1.2) - mcollective-client (2.12.1) - json - stomp - systemu - metaclass (0.0.4) - metadata-json-lint (2.1.0) - json-schema (~> 2.8) + gssapi (1.3.1) + ffi (>= 1.0.1) + gyoku (1.4.0) + builder (>= 2.1.2) + rexml (~> 3.0) + hiera-eyaml (3.4.0) + highline + optimist + highline (3.0.1) + hocon (1.4.0) + httpclient (2.8.3) + jgrep (1.5.4) + jmespath (1.6.2) + json (2.6.3) + json-schema (4.3.0) + addressable (>= 2.8) + jwt (2.2.3) + little-plugger (1.1.4) + locale (2.1.4) + log4r (1.1.10) + logging (2.3.1) + little-plugger (~> 1.1) + multi_json (~> 1.14) + metadata-json-lint (4.0.0) + json-schema (>= 2.8, < 5.0) + semantic_puppet (~> 1.0) spdx-licenses (~> 1.0) - method_source (0.8.2) - mime-types (2.99.3) - mocha (1.1.0) - metaclass (~> 0.0.1) - multi_json (1.13.1) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (4.2.0) - net-telnet (0.1.1) - netrc (0.11.0) - parallel (1.12.1) - parallel_tests (2.14.2) + method_source (1.1.0) + minitar (0.9) + mocha (1.16.1) + molinillo (0.8.0) + multi_json (1.15.0) + net-http (0.4.1) + uri + net-http-persistent (4.0.2) + connection_pool (~> 2.2) + net-scp (4.0.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-ssh (7.2.3) + net-ssh-krb (0.5.1) + gssapi (~> 1.3.0) + net-ssh (>= 2.0) + net-telnet (0.2.0) + nkf (0.2.0) + nori (2.7.0) + bigdecimal + optimist (3.1.0) + orchestrator_client (0.5.3) + faraday + net-http-persistent + parallel (1.24.0) + parallel_tests (3.12.1) parallel - parser (2.5.1.0) - ast (~> 2.4.0) - powerpack (0.1.1) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - public_suffix (3.0.2) - puppet (5.5.1) - facter (> 2.0.1, < 4) - fast_gettext (~> 1.1.2) - hiera (>= 3.2.1, < 4) + parser (3.3.1.0) + ast (~> 2.4.1) + racc + pathspec (1.1.3) + pluginator (1.5.0) + prime (0.1.2) + forwardable + singleton + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (5.0.5) + puppet (8.6.0) + concurrent-ruby (~> 1.0) + deep_merge (~> 1.0) + facter (>= 4.3.0, < 5) + fast_gettext (>= 2.1, < 3) locale (~> 2.1) - multi_json (~> 1.10) - puppet-blacksmith (3.4.0) - puppet (>= 2.7.16) - rest-client (~> 1.8.0) - puppet-lint (2.3.5) - puppet-module-posix-default-r2.4 (0.3.3) - puppet-module-posix-dev-r2.4 (0.3.3) - gettext-setup (~> 0.26) - metadata-json-lint (>= 2.0.2, < 3.0.0) - mocha (>= 1.0.0, < 1.2.0) - parallel_tests (>= 2.14.1, < 2.14.3) - pry (~> 0.10.4) - puppet-blacksmith (>= 3.4.0) - puppet-lint (>= 2.3.0, < 3.0.0) - puppet-syntax (>= 2.4.1, < 3.0.0) - puppet_pot_generator (~> 1.0) - puppetlabs_spec_helper (>= 2.7.0, < 3.0.0) - rainbow (~> 2.0) - rspec-puppet (>= 2.3.2, < 3.0.0) - rspec-puppet-facts (~> 1.8) - rspec_junit_formatter (~> 0.2) - rubocop (~> 0.49.0) - rubocop-i18n (~> 1.2.0) - rubocop-rspec (~> 1.16.0) - simplecov (>= 0.14.1, < 1.0.0) - specinfra (= 2.67.3) - puppet-syntax (2.4.1) - rake - puppet_pot_generator (1.0.1) - puppet - puppetlabs_spec_helper (2.8.0) + multi_json (~> 1.13) + puppet-resource_api (~> 1.5) + scanf (~> 1.0) + semantic_puppet (~> 1.0) + puppet-debugger (1.4.0) + awesome_print (~> 1.7) + bundler + facterdb (>= 0.4.0) + pluginator (~> 1.5.0) + puppet (>= 6) + rb-readline (>= 0.5.5) + table_print (>= 1.0.0) + tty-pager (~> 0.14) + puppet-lint (4.2.4) + puppet-lint-absolute_classname-check (4.0.0) + puppet-lint (>= 3.0, < 5) + puppet-lint-anchor-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-file_ensure-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-leading_zero-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-lookup_in_parameter-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-manifest_whitespace-check (0.3.0) + puppet-lint (>= 1.0, < 5) + puppet-lint-optional_default-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-param-docs (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-param-types (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-params_empty_string-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-resource_reference_syntax (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-strict_indent-check (3.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-topscope-variable-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-trailing_comma-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-unquoted_string-check (3.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-variable_contains_upcase (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-version_comparison-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-modulebuilder (1.0.0) + minitar (~> 0.9) + pathspec (>= 0.2.1, < 2.0.0) + puppet-resource_api (1.9.0) + hocon (>= 1.0) + puppet-strings (4.1.2) + rgen (~> 0.9) + yard (~> 0.9) + puppet-syntax (4.1.1) + puppet (>= 7, < 9) + rake (~> 13.1) + puppet_forge (5.0.3) + faraday (~> 2.0) + faraday-follow_redirects (~> 0.3.0) + minitar + semantic_puppet (~> 1.0) + puppet_litmus (1.4.0) + bolt (~> 3.0) + docker-api (>= 1.34, < 3.0.0) + parallel + puppet-modulebuilder (>= 0.3.0) + retryable (~> 3.0) + rspec + tty-spinner (>= 0.5.0, < 1.0.0) + puppetfile-resolver (0.6.3) + molinillo (~> 0.6) + semantic_puppet (~> 1.0) + puppetlabs_spec_helper (7.2.0) mocha (~> 1.0) - puppet-lint (~> 2.0) - puppet-syntax (~> 2.0) - rspec-puppet (~> 2.0) - rainbow (2.2.2) - rake - rake (12.3.1) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) + pathspec (>= 0.2, < 2.0.0) + puppet-lint (~> 4.0) + puppet-syntax (~> 4.1, >= 4.1.1) + rspec-github (~> 2.0) + rspec-puppet (~> 4.0) + r10k (3.15.3) + colored2 (= 3.1.2) + cri (>= 2.15.10) + fast_gettext (>= 1.1.0, < 3.0.0) + gettext (>= 3.0.2, < 4.0.0) + gettext-setup (>= 0.24, < 2.0.0) + jwt (~> 2.2.3) + log4r (= 1.1.10) + minitar (~> 0.9) + multi_json (~> 1.10) + puppet_forge (>= 2.3.0) + racc (1.7.3) + rainbow (3.1.1) + rake (13.2.1) + rb-readline (0.5.5) + regexp_parser (2.9.1) + retryable (3.0.5) + rexml (3.2.6) + rgen (0.9.1) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) + rspec-support (~> 3.13.0) + rspec-github (2.4.0) + rspec-core (~> 3.0) + rspec-its (1.3.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-puppet (2.6.11) - rspec - rspec-puppet-facts (1.9.0) - facter - facterdb (>= 0.5.0) - json - mcollective-client - puppet - rspec-support (3.7.1) - rspec_junit_formatter (0.4.1) - rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.49.1) + rspec-support (~> 3.13.0) + rspec-puppet (4.0.2) + rspec (~> 3.0) + rspec-puppet-facts (3.0.0) + deep_merge (~> 1.2) + facter (< 5) + facterdb (>= 0.5.0, < 2) + puppet (>= 7, < 9) + rspec-support (3.13.1) + rubocop (1.50.2) + json (~> 2.3) parallel (~> 1.10) - parser (>= 2.3.3.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - rubocop-i18n (1.2.0) - rubocop (~> 0.49.0) - rubocop-rspec (1.16.0) - rubocop (>= 0.49.0) - ruby-progressbar (1.9.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-capybara (2.20.0) + rubocop (~> 1.41) + rubocop-performance (1.16.0) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rspec (2.19.0) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + ruby-progressbar (1.13.0) + ruby_smb (1.1.0) + bindata + rubyntlm + windows_error + rubyntlm (0.6.3) + rubyzip (2.3.2) + scanf (1.0.0) + semantic_puppet (1.1.0) + serverspec (2.42.3) + multi_json + rspec (~> 3.0) + rspec-its + specinfra (~> 2.72) sfl (2.3) - simplecov (0.16.1) + simplecov (0.22.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - slop (3.6.0) - spdx-licenses (1.2.0) - specinfra (2.67.3) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-console (0.9.1) + ansi + simplecov + terminal-table + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + singleton (0.2.0) + spdx-licenses (1.3.0) + specinfra (2.89.0) net-scp - net-ssh (>= 2.7, < 5.0) + net-ssh (>= 2.7) net-telnet sfl - stomp (1.4.4) - systemu (2.6.5) + strings (0.2.1) + strings-ansi (~> 0.2) + unicode-display_width (>= 1.5, < 3.0) + unicode_utils (~> 1.4) + strings-ansi (0.2.0) + table_print (1.5.7) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) text (1.3.1) - trollop (2.1.2) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.5) - unicode-display_width (1.3.3) + thor (1.2.2) + tty-cursor (0.7.1) + tty-pager (0.14.0) + strings (~> 0.2.0) + tty-screen (~> 0.8) + tty-screen (0.8.2) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) + unicode-display_width (2.5.0) + unicode_utils (1.4.0) + uri (0.13.0) + voxpupuli-puppet-lint-plugins (5.0.0) + puppet-lint (~> 4.0) + puppet-lint-absolute_classname-check (~> 4.0) + puppet-lint-anchor-check (~> 2.0) + puppet-lint-file_ensure-check (~> 2.0) + puppet-lint-leading_zero-check (~> 2.0) + puppet-lint-lookup_in_parameter-check (~> 2.0) + puppet-lint-manifest_whitespace-check (~> 0.3, < 1.0.0) + puppet-lint-optional_default-check (~> 2.0) + puppet-lint-param-docs (~> 2.0) + puppet-lint-param-types (~> 2.0) + puppet-lint-params_empty_string-check (~> 2.0) + puppet-lint-resource_reference_syntax (~> 2.0) + puppet-lint-strict_indent-check (~> 3.0) + puppet-lint-topscope-variable-check (~> 2.0) + puppet-lint-trailing_comma-check (~> 2.0) + puppet-lint-unquoted_string-check (~> 3.0) + puppet-lint-variable_contains_upcase (~> 2.0) + puppet-lint-version_comparison-check (~> 2.0) + windows_error (0.1.5) + winrm (2.3.6) + builder (>= 2.1.2) + erubi (~> 1.8) + gssapi (~> 1.2) + gyoku (~> 1.0) + httpclient (~> 2.2, >= 2.2.0.2) + logging (>= 1.6.1, < 3.0) + nori (~> 2.0) + rubyntlm (~> 0.6.0, >= 0.6.3) + winrm-fs (1.3.5) + erubi (~> 1.8) + logging (>= 1.6.1, < 3.0) + rubyzip (~> 2.0) + winrm (~> 2.0) + yard (0.9.36) PLATFORMS - ruby + x86_64-linux DEPENDENCIES - fast_gettext + CFPropertyList (< 3.0.7) + deep_merge (~> 1.0) + dependency_checker (~> 1.0.0) + facterdb (~> 1.18) hiera-eyaml - json (<= 2.0.4) + json (= 2.6.3) + metadata-json-lint (~> 4.0) + parallel_tests (= 3.12.1) + pry (~> 0.10) puppet - puppet-blacksmith (~> 3.4) - puppet-module-posix-default-r2.4 - puppet-module-posix-dev-r2.4 - puppet-module-win-default-r2.4 - puppet-module-win-dev-r2.4 + puppet-debugger (~> 1.0) + puppet-strings (~> 4.0) + puppet_litmus (~> 1.0) + puppetlabs_spec_helper (~> 7.0) + rb-readline (= 0.5.5) + rspec-puppet-facts (~> 3.0) + rubocop (~> 1.50.0) + rubocop-performance (= 1.16.0) + rubocop-rspec (= 2.19.0) + serverspec (~> 2.41) + simplecov-console (~> 0.9) + voxpupuli-puppet-lint-plugins (~> 5.0) BUNDLED WITH - 1.16.1 + 2.4.13 diff --git a/Rakefile b/Rakefile index fb58663..77590fe 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,9 @@ +# frozen_string_literal: true + +require 'bundler' +require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? +require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' -PuppetLint.configuration.send('relative') +PuppetLint.configuration.send('disable_relative') diff --git a/lib/puppet/functions/eyaml_tools/utils.rb b/lib/puppet/functions/eyaml_tools/utils.rb index c528fa8..0117336 100644 --- a/lib/puppet/functions/eyaml_tools/utils.rb +++ b/lib/puppet/functions/eyaml_tools/utils.rb @@ -1,4 +1,3 @@ -require 'hiera' require 'hiera/backend/eyaml/options' module EyamlTools @@ -24,7 +23,7 @@ def ensure_config def hiera_config config_file = hiera_config_file if config_file - Hiera::Config.load(config_file) + YAML.load_file(config_file) end end diff --git a/metadata.json b/metadata.json index ebaeb3e..14acf42 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "universityofwarwick-eyaml_tools", - "version": "2.0.0", + "version": "2.1.0", "author": "University of Warwick", "summary": "Exposes hiera-eyaml's decryption as Puppet functions.", "license": "proprietary", @@ -29,10 +29,10 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.7.0 < 6.0.0" + "version_requirement": ">= 8.0.0 < 9.0.0" } ], - "pdk-version": "1.5.0", - "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", - "template-ref": "1.5.0-0-gd1b3eca" + "pdk-version": "3.2.0", + "template-url": "pdk-default#3.2.0", + "template-ref": "tags/3.2.0-0-gb257ef1" } diff --git a/spec/default_facts.yml b/spec/default_facts.yml index 3248be5..3346c39 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -2,7 +2,8 @@ # # Facts specified here will override the values provided by rspec-puppet-facts. --- -concat_basedir: "/tmp" -ipaddress: "172.16.254.254" +networking: + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2330d4d..cc1a496 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.configure do |c| c.mock_with :mocha end @@ -5,11 +7,7 @@ require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' -begin - require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) -rescue LoadError => loaderror - warn "Could not require spec_helper_local: #{loaderror.message}" -end +require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) include RspecPuppetFacts @@ -18,15 +16,25 @@ facterversion: Facter.version, } -default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')) -default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')) +default_fact_files = [ + File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), + File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), +] + +default_fact_files.each do |f| + next unless File.exist?(f) && File.readable?(f) && File.size?(f) -if File.exist?(default_facts_path) && File.readable?(default_facts_path) - default_facts.merge!(YAML.safe_load(File.read(default_facts_path))) + begin + require 'deep_merge' + default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + rescue StandardError => e + RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" + end end -if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path) - default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path))) +# read default_facts and merge them over what is provided by facterdb +default_facts.each do |fact, value| + add_custom_fact fact, value, merge_facts: true end RSpec.configure do |c| @@ -36,5 +44,33 @@ # set to strictest setting for testing # by default Puppet runs at warning level Puppet.settings[:strict] = :warning + Puppet.settings[:strict_variables] = true + end + c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] + c.after(:suite) do + RSpec::Puppet::Coverage.report!(0) + end + + # Filter backtrace noise + backtrace_exclusion_patterns = [ + %r{spec_helper}, + %r{gems}, + ] + + if c.respond_to?(:backtrace_exclusion_patterns) + c.backtrace_exclusion_patterns = backtrace_exclusion_patterns + elsif c.respond_to?(:backtrace_clean_patterns) + c.backtrace_clean_patterns = backtrace_exclusion_patterns + end +end + +# Ensures that a module is defined +# @param module_name Name of the module +def ensure_module_defined(module_name) + module_name.split('::').reduce(Object) do |last_module, next_module| + last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) + last_module.const_get(next_module, false) end end + +# 'spec_overrides' from sync.yml will appear below this line