diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 12ed4ff..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM puppet/pdk:latest - -# [Optional] Uncomment this section to install additional packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - diff --git a/.devcontainer/README.md b/.devcontainer/README.md deleted file mode 100644 index cc4675e..0000000 --- a/.devcontainer/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# devcontainer - - -For format details, see https://aka.ms/devcontainer.json. - -For config options, see the README at: -https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet - -``` json -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - }, - - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ] - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pdk --version", -} -``` - - - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index fe7a8b1..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - "settings": { - "terminal.integrated.profiles.linux": { - "bash": { - "path": "bash", - } - } - }, - - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ] -} diff --git a/.fixtures.yml b/.fixtures.yml index ce30541..6692247 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -4,5 +4,3 @@ fixtures: concat: puppetlabs/concat stdlib: puppetlabs/stdlib cron_core: puppetlabs/cron_core - symlinks: - "borgbackup": "#{source_dir}" diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 37a7699..4d9d153 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,3 @@ +--- github: [cirrax] custom: ["https://cirrax.com"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ce287e3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +--- +name: run VoxBox checks + +env: + VOXBOX: 'ghcr.io/voxpupuli/voxbox:8' + +# yamllint disable-line rule:truthy +on: + pull_request: {} + + +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true + +jobs: + build-push: + runs-on: ubuntu-latest + steps: + - name: Setup Podman + run: | + sudo apt update + sudo apt-get -y install podman + podman pull ${VOXBOX} + - name: Checkout Repository + uses: actions/checkout@v4 + - name: run validate + run: | + podman run -it --rm -v $PWD:/repo:Z ${VOXBOX} validate + - name: run check + run: | + podman run -it --rm -v $PWD:/repo:Z ${VOXBOX} check + - name: run lint + run: | + podman run -it --rm -v $PWD:/repo:Z ${VOXBOX} lint + - name: run yamllint + run: | + podman run -it --rm -v $PWD:/repo:Z --entrypoint yamllint ${VOXBOX} . + - name: run rubocop + run: | + podman run -it --rm -v $PWD:/repo:Z ${VOXBOX} rubocop + - name: check syntax + run: | + podman run -it --rm -v $PWD:/repo:Z ${VOXBOX} strings:validate:reference + - name: run spec tests + run: | + podman run -it --rm -v $PWD:/repo:Z ${VOXBOX} fixtures:clean + podman run -it --rm -v $PWD:/repo:Z ${VOXBOX} fixtures:prep + podman run -it --rm -v $PWD:/repo:Z ${VOXBOX} spec diff --git a/.github/workflows/pdk.yml b/.github/workflows/pdk.yml deleted file mode 100644 index 4012fa3..0000000 --- a/.github/workflows/pdk.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: PDK - -on: - - 'push' - - 'pull_request' - -jobs: - validate: - runs-on: ubuntu-latest - container: puppet/pdk:latest - outputs: - puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }} - github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }} - steps: - - name: Install build-essential - run: | - export DEBIAN_FRONTEND=noninteractive; - apt-get --yes update - apt-get --yes install build-essential - - name: Check out repository code - uses: actions/checkout@v3 - - name: run pdk validate - run: pdk validate - - unit-test: - runs-on: ubuntu-latest - container: puppet/pdk:latest - steps: - - name: Install build-essential - run: | - export DEBIAN_FRONTEND=noninteractive; - apt-get --yes update - apt-get --yes install build-essential - - name: Check out repository code - uses: actions/checkout@v3 - - name: run pdk test unit - run: pdk test unit diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 6d5e786..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- -stages: - - syntax - - unit - -default: - cache: - paths: - - vendor/bundle - - before_script: &before_script - - bundle -v - - rm Gemfile.lock || true - - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" - - "# Set `rubygems_version` in the .sync.yml to set a value" - - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" - - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - - gem --version - - bundle -v - - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) - -validate lint check rubocop-Ruby 2.5.7-Puppet ~> 6: - stage: syntax - image: ruby:2.5.7 - script: - - bundle exec rake validate lint check rubocop - variables: - PUPPET_GEM_VERSION: '~> 6' - -parallel_spec-Ruby 2.5.7-Puppet ~> 6: - stage: unit - image: ruby:2.5.7 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 6' - -validate lint check rubocop-Ruby 2.7.2-Puppet ~> 7: - stage: syntax - image: ruby:2.7.2 - script: - - bundle exec rake validate lint check rubocop - variables: - PUPPET_GEM_VERSION: '~> 7' - -parallel_spec-Ruby 2.7.2-Puppet ~> 7: - stage: unit - image: ruby:2.7.2 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 7' - diff --git a/.pdkignore b/.pdkignore deleted file mode 100644 index 84684be..0000000 --- a/.pdkignore +++ /dev/null @@ -1,51 +0,0 @@ -.git/ -.*.sw[op] -.metadata -.yardoc -.yardwarns -*.iml -/.bundle/ -/.idea/ -/.vagrant/ -/coverage/ -/bin/ -/doc/ -/Gemfile.local -/Gemfile.lock -/junit/ -/log/ -/pkg/ -/spec/fixtures/manifests/ -/spec/fixtures/modules/* -/tmp/ -/vendor/ -/.vendor/ -/convert_report.txt -/update_report.txt -.DS_Store -.project -.envrc -/inventory.yaml -/spec/fixtures/litmus_inventory.yaml -.resource_types -.modules -.task_cache.json -.plan_cache.json -.rerun.json -bolt-debug.log -/.fixtures.yml -/Gemfile -/.gitattributes -/.github/ -/.gitignore -/.pdkignore -/.puppet-lint.rc -/Rakefile -/rakelib/ -/.rspec -/..yml -/.yardopts -/spec/ -/.vscode/ -/.sync.yml -/.devcontainer/ diff --git a/.puppet-lint.rc b/.puppet-lint.rc deleted file mode 100644 index 9e15c6e..0000000 --- a/.puppet-lint.rc +++ /dev/null @@ -1,9 +0,0 @@ ---fail-on-warnings ---relative ---no-80chars-check ---no-140chars-check ---no-class_inherits_from_params_class-check ---no-autoloader_layout-check ---no-documentation-check ---no-single_quote_string_with_variables-check ---ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp diff --git a/.rubocop.yml b/.rubocop.yml index 21b82b9..74669e1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,730 +1,7 @@ --- -require: -- rubocop-performance -- rubocop-rspec -AllCops: - NewCops: enable - DisplayCopNames: true - TargetRubyVersion: '2.6' - Include: - - "**/*.rb" - Exclude: - - bin/* - - ".vendor/**/*" - - "**/Gemfile" - - "**/Rakefile" - - pkg/**/* - - spec/fixtures/**/* - - vendor/**/* - - "**/Puppetfile" - - "**/Vagrantfile" - - "**/Guardfile" -Layout/LineLength: - Description: People have wide screens, use them. - Max: 200 -RSpec/BeforeAfterAll: - Description: Beware of using after(:all) as it may cause state to leak between tests. - A necessary evil in acceptance testing. - Exclude: - - spec/acceptance/**/*.rb -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. - EnforcedStyle: braces_for_chaining -Style/ClassAndModuleChildren: - Description: Compact style reduces the required amount of indentation. - EnforcedStyle: compact -Style/EmptyElse: - Description: Enforce against empty else clauses, but allow `nil` for clarity. - EnforcedStyle: empty -Style/FormatString: - Description: Following the main puppet project's style, prefer the % format format. - EnforcedStyle: percent -Style/FormatStringToken: - Description: Following the main puppet project's style, prefer the simpler template - tokens over annotated ones. - EnforcedStyle: template -Style/Lambda: - Description: Prefer the keyword for easier discoverability. - EnforcedStyle: literal -Style/RegexpLiteral: - Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 - EnforcedStyle: percent_r -Style/TernaryParentheses: - Description: Checks for use of parentheses around ternary conditions. Enforce parentheses - on complex expressions for better readability, but seriously consider breaking - it up. - EnforcedStyle: require_parentheses_when_complex -Style/TrailingCommaInArguments: - Description: Prefer always trailing comma on multiline argument lists. This makes - diffs, and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/TrailingCommaInArrayLiteral: - Description: Prefer always trailing comma on multiline literals. This makes diffs, - and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/SymbolArray: - Description: Using percent style obscures symbolic intent of array's contents. - 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: - Enabled: false -Metrics/MethodLength: - Enabled: false -Metrics/ModuleLength: - Enabled: false -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/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 -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 +inherit_gem: + voxpupuli-test: rubocop.yml + +Layout/DotPosition: + # blah: dsfsf + EnforcedStyle: leading diff --git a/.sync.yml b/.sync.yml deleted file mode 100644 index 7d42fda..0000000 --- a/.sync.yml +++ /dev/null @@ -1,8 +0,0 @@ - -.travis.yml: - simplecov: true - -spec/spec_helper.rb: - coverage_report: true - mock_with: ':rspec' - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6630876..0000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- -os: linux -dist: xenial -language: ruby -cache: bundler -before_install: - - bundle -v - - rm -f Gemfile.lock - - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" - - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" - - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" - - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - - gem --version - - bundle -v -script: - - 'SIMPLECOV=yes bundle exec rake $CHECK' -bundler_args: --without system_tests -rvm: - - 2.5.7 -stages: - - static - - spec - - acceptance - - - if: tag =~ ^v\d - name: deploy -jobs: - fast_finish: true - include: - - - env: CHECK="validate lint check rubocop" - stage: static - - - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec - rvm: 2.5.7 - stage: spec - - - env: DEPLOY_TO_FORGE=yes - stage: deploy -branches: - only: - - main - - /^v\d/ -notifications: - email: false diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 6da8d47..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "recommendations": [ - "puppet.puppet-vscode", - "Shopify.ruby-lsp" - ] -} diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..4d35faa --- /dev/null +++ b/.yamllint @@ -0,0 +1,11 @@ +--- +extends: default + +ignore: | + bin/ + spec/fixtures/* + +rules: + # 80 chars should be enough, but don't fail if a line is longer + line-length: + max: 140 diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 29c933b..0000000 --- a/.yardopts +++ /dev/null @@ -1 +0,0 @@ ---markup markdown diff --git a/Gemfile b/Gemfile deleted file mode 100644 index f84ea87..0000000 --- a/Gemfile +++ /dev/null @@ -1,79 +0,0 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' - -def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} - - 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 - [place_or_version, { require: false }] - end -end - -group :development do - 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.2.2', require: false - gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false - gem "facterdb", '~> 2.1', require: false - gem "metadata-json-lint", '~> 4.0', require: false - gem "rspec-puppet-facts", '~> 4.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 "rexml", '>= 3.0.0', '< 3.2.7', require: false -end -group :development, :release_prep do - gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 8.0', require: false - gem "puppet-blacksmith", '~> 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'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] - -gems = {} - -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables - -gems['facter'] = location_for(facter_version) if facter_version -gems['hiera'] = location_for(hiera_version) if hiera_version - -gems.each do |gem_name, gem_params| - gem gem_name, *gem_params -end - -# Evaluate Gemfile.local and ~/.gemfile if they exist -extra_gemfiles = [ - "#{__FILE__}.local", - File.join(Dir.home, '.gemfile'), -] - -extra_gemfiles.each do |gemfile| - if File.file?(gemfile) && File.readable?(gemfile) - eval(File.read(gemfile), binding) - end -end -# vim: syntax=ruby diff --git a/README.md b/README.md index 9ac2d15..ae254ff 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,5 @@ # borg backup puppet module -[![Build Status](https://travis-ci.org/cirrax/puppet-borgbackup.svg?branch=master)](https://travis-ci.org/cirrax/puppet-borgbackup) -[![Puppet Forge](https://img.shields.io/puppetforge/v/cirrax/borgbackup.svg?style=flat-square)](https://forge.puppetlabs.com/cirrax/borgbackup) -[![Puppet Forge](https://img.shields.io/puppetforge/dt/cirrax/borgbackup.svg?style=flat-square)](https://forge.puppet.com/cirrax/borgbackup) -[![Puppet Forge](https://img.shields.io/puppetforge/e/cirrax/borgbackup.svg?style=flat-square)](https://forge.puppet.com/cirrax/borgbackup) -[![Puppet Forge](https://img.shields.io/puppetforge/f/cirrax/borgbackup.svg?style=flat-square)](https://forge.puppet.com/cirrax/borgbackup) #### Table of Contents @@ -71,7 +66,7 @@ The hiera configuration for the node: *Remark:* the initialization of the borg backup repository fails until you configured the ssh key on node-target. -### use a remote git repository +### use a remote git repository To store the generated passphrase and the keyfile in a secure and automated manner, you can use a git repository. Add the following hiera configuration to node-A to fetch and commit to remote gitrepo on node-git: @@ -82,7 +77,7 @@ Add the following hiera configuration to node-A to fetch and commit to remote gi -----BEGIN OPENSSH PRIVATE KEY----- ... -----END OPENSSH PRIVATE KEY----- - + # add pgp public keys of users who should be able to decrypt the passphrase and the keyfile. # to export use: # gpg --export --armor --export-options no-export-attributes,export-minimal ID diff --git a/Rakefile b/Rakefile index 31b5930..6426026 100644 --- a/Rakefile +++ b/Rakefile @@ -1,18 +1,40 @@ -# frozen_string_literal: true +begin + require 'voxpupuli/test/rake' +rescue LoadError + begin + require 'puppetlabs_spec_helper/rake_tasks' + rescue LoadError + end +end -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-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' +require 'puppet_blacksmith/rake_tasks' -PuppetLint.configuration.send('disable_relative') -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.send('disable_140chars') -PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_autoloader_layout') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') -PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.ignore_paths = [".vendor/**/*.pp", ".bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp", "tests/**/*.pp", "types/**/*.pp", "vendor/**/*.pp"] +desc 'run autocorrection tasks' +task :fix do + puts "--------\nrunning: rake lint_fix" + Rake::Task["lint_fix"].invoke + puts "--------\nrunning: rake rubocop:autocorrect" + Rake::Task["rubocop:autocorrect"].invoke +end +Rake::Task["test"].clear +desc 'run several tests in one run' +task :test do + puts "--------\nrunning: rake validate" + Rake::Task["validate"].invoke + puts "--------\nrunning: rake check" + Rake::Task["check"].invoke + puts "--------\nrunning: rake lint" + Rake::Task["lint"].invoke + puts "--------\nrunning: yamllint" + fail unless system('yamllint .') + puts "--------\nrunning: rake rubocop" + Rake::Task["rubocop"].invoke + puts "--------\nrunning: rake strings:validate:reference" + Rake::Task["strings:validate:reference"].invoke +end + +# flag out some things we never use +Rake::Task["strings:gh_pages:update"].clear + +# vim: syntax=ruby diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a70c01e..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -version: 1.1.x.{build} -skip_branch_with_pr: true -branches: - only: - - main - - release -skip_commits: - message: /^\(?doc\)?.*/ -clone_depth: 10 -init: - - SET - - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' -environment: - matrix: - - - RUBY_VERSION: 25-x64 - CHECK: validate lint check rubocop - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25-x64 - CHECK: parallel_spec -matrix: - fast_finish: true -install: - - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% - - bundle install --jobs 4 --retry 2 --without system_tests - - type Gemfile.lock -build: off -test_script: - - bundle exec puppet -V - - ruby -v - - gem -v - - bundle -v - - bundle exec rake %CHECK% -notifications: - - provider: Email - to: - - nobody@nowhere.com - on_build_success: false - on_build_failure: false - on_build_status_changed: false diff --git a/hiera.yaml b/hiera.yaml index 17363f7..829949e 100644 --- a/hiera.yaml +++ b/hiera.yaml @@ -8,4 +8,3 @@ defaults: hierarchy: - name: "commons for borgbackup module" path: "common.yaml" - diff --git a/lib/puppet/functions/borgbackup/noop_connection.rb b/lib/puppet/functions/borgbackup/noop_connection.rb index ca4e17f..8d29fe8 100644 --- a/lib/puppet/functions/borgbackup/noop_connection.rb +++ b/lib/puppet/functions/borgbackup/noop_connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'socket' # @@ -37,7 +39,7 @@ def scope.lookupdefaults(type) noop = Puppet::Parser::Resource::Param.new( name: :noop, value: noop_value, - source: source, + source: source ) # Adding this default fixes a corner case with resource collectors diff --git a/manifests/server.pp b/manifests/server.pp index 9e4d0e7..a2c2115 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -43,6 +43,8 @@ Hash $authorized_keys = {}, Hash $authorized_keys_defaults = {}, ) { + include borgbackup::install + if $user_ensure { user { $borguser: ensure => present, diff --git a/metadata.json b/metadata.json index 5219c6e..f8b0d1c 100644 --- a/metadata.json +++ b/metadata.json @@ -29,7 +29,8 @@ "9", "10", "11", - "12" + "12", + "13" ] }, { @@ -38,7 +39,7 @@ ], "requirements": [ { - "name": "puppet", + "name": "openvox", "version_requirement": ">=4.0.0 < 9.0.0" } ], @@ -47,8 +48,5 @@ "backup", "borgbackup", "restore" - ], - "pdk-version": "3.4.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "tags/3.4.0-0-gd3cc13f" + ] } diff --git a/pdk.yaml b/pdk.yaml deleted file mode 100644 index 4bef4bd..0000000 --- a/pdk.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -ignore: [] diff --git a/spec/classes/borgbackup_spec.rb b/spec/classes/borgbackup_spec.rb index f6d9656..cf2d27d 100644 --- a/spec/classes/borgbackup_spec.rb +++ b/spec/classes/borgbackup_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'spec_helper' @@ -35,7 +36,7 @@ it_behaves_like 'borgbackup class' it { - is_expected.to contain_file(params[:configdir] + '/.ssh') + is_expected.to contain_file("#{params[:configdir]}/.ssh") .with_ensure('directory') .with_owner('root') .with_group('root') @@ -47,7 +48,7 @@ let :params do default_params.merge( repos: { 'default' => { 'passphrase' => 'secret' } }, - default_target: 'irgendwo', + default_target: 'irgendwo' ) end @@ -64,14 +65,14 @@ describe 'with non default configuration directory' do let :params do default_params.merge( - configdir: '/tmp/backupdir', + configdir: '/tmp/backupdir' ) end it_behaves_like 'borgbackup class' it { - is_expected.to contain_file(params[:configdir] + '/.ssh') + is_expected.to contain_file("#{params[:configdir]}/.ssh") .with_ensure('directory') .with_owner('root') .with_group('root') @@ -82,20 +83,20 @@ describe 'with create .ssh directory in default location' do let :params do default_params.merge( - ensure_ssh_directory: false, + ensure_ssh_directory: false ) end it_behaves_like 'borgbackup class' - it { is_expected.not_to contain_file(params[:configdir] + '/.ssh') } + it { is_expected.not_to contain_file("#{params[:configdir]}/.ssh") } end describe 'with create ssh key resource' do let :params do default_params.merge( ssh_key_define: 'file', - ssh_key_res: { '/etc/borgbackup/.ssh/uid' => { 'owner' => 'myowner' } }, + ssh_key_res: { '/etc/borgbackup/.ssh/uid' => { 'owner' => 'myowner' } } ) end diff --git a/spec/classes/git_spec.rb b/spec/classes/git_spec.rb index b8c4ca8..e295c14 100644 --- a/spec/classes/git_spec.rb +++ b/spec/classes/git_spec.rb @@ -1,11 +1,11 @@ - +# frozen_string_literal: true require 'spec_helper' describe 'borgbackup::git' do let(:node) { 'myhost.somewhere.com' } let :default_params do - { packages: ['git', 'gnupg'], + { packages: %w[git gnupg], gpg_keys: {}, gpg_home: '/etc/borgbackup/.gnupg', git_home: '/etc/borgbackup/git' } @@ -36,11 +36,12 @@ is_expected.to contain_exec('commit git repo') .with_cwd(params[:git_home]) } + it { is_expected.to contain_package('gnupg') } it { is_expected.to contain_package('git') } it { - is_expected.to contain_file(params[:git_home] + '/myhost.somewhere.com') + is_expected.to contain_file("#{params[:git_home]}/myhost.somewhere.com") .with_ensure('directory') .with_owner('root') .with_group('root') @@ -64,10 +65,11 @@ .with_command(%r{^git init }) } end + context 'with remote git repo' do let :params do default_params.merge( - gitrepo: 'somewhere/gitrepo', + gitrepo: 'somewhere/gitrepo' ) end @@ -89,6 +91,7 @@ is_expected.to contain_exec('pull git repo') .with_cwd(params[:git_home]) } + it { is_expected.to contain_exec('push git repo') .with_cwd(params[:git_home]) diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb index 1693815..cabd159 100644 --- a/spec/classes/install_spec.rb +++ b/spec/classes/install_spec.rb @@ -1,4 +1,4 @@ - +# frozen_string_literal: true require 'spec_helper' @@ -30,11 +30,11 @@ end end - context 'with non defaults' do + context 'with non defaults' do let :params do default_params.merge( packages: ['backup-whatever'], - package_ensure: 'actual', + package_ensure: 'actual' ) end diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index e9255db..68e6332 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -1,4 +1,4 @@ - +# frozen_string_literal: true require 'spec_helper' @@ -18,6 +18,10 @@ shared_examples 'borgbackup::server shared examples' do it { is_expected.to compile.with_all_deps } + it { + is_expected.to contain_class('borgbackup::install') + } + it { is_expected.to contain_file(params[:backuproot]) .with_ensure('directory') @@ -50,7 +54,7 @@ context 'with non default backuproot' do let :params do default_params.merge( - backuproot: '/tmp/backupdir', + backuproot: '/tmp/backupdir' ) end @@ -60,7 +64,7 @@ context 'with not creating user' do let :params do default_params.merge( - user_ensure: false, + user_ensure: false ) end @@ -72,7 +76,7 @@ describe 'with authorized-keys' do let :params do default_params.merge( - authorized_keys: { 'firstkey' => { 'keys' => ['key'] } }, + authorized_keys: { 'firstkey' => { 'keys' => ['key'] } } ) end @@ -83,6 +87,7 @@ .with_backuproot(params[:backuproot]) .with_keys('["key"]') } + it { is_expected.to contain_concat(params[:authorized_keys_target]) .with_owner(params[:borguser]) @@ -95,7 +100,7 @@ let :params do default_params.merge( authorized_keys_define: 'file', - authorized_keys: { '/etc/borgbackup/.ssh/authorized-keys' => { 'owner' => 'myowner', 'group' => 'mygroup' } }, + authorized_keys: { '/etc/borgbackup/.ssh/authorized-keys' => { 'owner' => 'myowner', 'group' => 'mygroup' } } ) end diff --git a/spec/default_facts.yml b/spec/default_facts.yml deleted file mode 100644 index 3346c39..0000000 --- a/spec/default_facts.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Use default_module_facts.yml for module specific facts. -# -# Facts specified here will override the values provided by rspec-puppet-facts. ---- -networking: - ip: "172.16.254.254" - ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" - mac: "AA:AA:AA:AA:AA:AA" -is_pe: false diff --git a/spec/defines/addtogit_spec.rb b/spec/defines/addtogit_spec.rb index 3726f37..4c48a35 100644 --- a/spec/defines/addtogit_spec.rb +++ b/spec/defines/addtogit_spec.rb @@ -1,4 +1,4 @@ - +# frozen_string_literal: true require 'spec_helper' @@ -11,25 +11,25 @@ it { is_expected.to contain_class('borgbackup::git') } it { - is_expected.to contain_exec('create passphrase file ' + title) + is_expected.to contain_exec("create passphrase file #{title}") .with_environment(%r{GNUPGHOME=}) } it { - is_expected.to contain_exec('create key file ' + title) + is_expected.to contain_exec("create key file #{title}") .with_environment(%r{GNUPGHOME=}) .with_notify('Exec[commit git repo]') .with_provider('shell') } it { - is_expected.to contain_exec('reencrypt key file ' + title) + is_expected.to contain_exec("reencrypt key file #{title}") .with_environment(%r{GNUPGHOME=}) .with_notify('Exec[commit git repo]') } it { - is_expected.to contain_exec('reencrypt passphrase file ' + title) + is_expected.to contain_exec("reencrypt passphrase file #{title}") .with_environment(%r{GNUPGHOME=}) .with_notify('Exec[commit git repo]') } diff --git a/spec/defines/archive_spec.rb b/spec/defines/archive_spec.rb index b4b58da..dccd880 100644 --- a/spec/defines/archive_spec.rb +++ b/spec/defines/archive_spec.rb @@ -1,4 +1,4 @@ - +# frozen_string_literal: true require 'spec_helper' @@ -9,11 +9,11 @@ post_commands: [], create_compression: 'lz4', create_filter: 'AME', - create_options: ['verbose', 'list', 'stats', 'show-rc', 'exclude-caches'], + create_options: %w[verbose list stats show-rc exclude-caches], create_excludes: [], create_includes: [], do_prune: true, - prune_options: ['list', 'show-rc'], + prune_options: %w[list show-rc], keep_daily: 7, keep_weekly: 4, keep_monthly: 6, } @@ -25,9 +25,9 @@ it { is_expected.to contain_class('borgbackup') } it { - is_expected.to contain_concat__fragment('borgbackup::archive ' + params[:reponame] + ' create ' + params[:archive_name]) - .with_target('/etc/borgbackup/repo_' + params[:reponame] + '.sh') - .with_order('20-' + title) + is_expected.to contain_concat__fragment("borgbackup::archive #{params[:reponame]} create #{params[:archive_name]}") + .with_target("/etc/borgbackup/repo_#{params[:reponame]}.sh") + .with_order("20-#{title}") } end @@ -40,16 +40,16 @@ let :params do default_params.merge( archive_name: title, - reponame: 'myrepo', + reponame: 'myrepo' ) end it_behaves_like 'borgbackup::archive shared examples' it { - is_expected.to contain_concat__fragment('borgbackup::archive ' + params[:reponame] + ' prune ' + params[:archive_name]) - .with_target('/etc/borgbackup/repo_' + params[:reponame] + '.sh') - .with_order('70-' + title) + is_expected.to contain_concat__fragment("borgbackup::archive #{params[:reponame]} prune #{params[:archive_name]}") + .with_target("/etc/borgbackup/repo_#{params[:reponame]}.sh") + .with_order("70-#{title}") } end @@ -59,13 +59,13 @@ default_params.merge( archive_name: title, reponame: 'anotherrepo', - do_prune: false, + do_prune: false ) end it_behaves_like 'borgbackup::archive shared examples' - it { is_expected.not_to contain_concat__fragment('borgbackup::archive ' + params[:reponame] + ' prune ' + params[:archive_name]) } + it { is_expected.not_to contain_concat__fragment("borgbackup::archive #{params[:reponame]} prune #{params[:archive_name]}") } end end end diff --git a/spec/defines/authorized_key_spec.rb b/spec/defines/authorized_key_spec.rb index 9ee6a13..a31f2d1 100644 --- a/spec/defines/authorized_key_spec.rb +++ b/spec/defines/authorized_key_spec.rb @@ -1,4 +1,4 @@ - +# frozen_string_literal: true require 'spec_helper' @@ -33,7 +33,7 @@ default_params.merge( reponame: title, backuproot: 'mybackuproot', - target: 'mytarget', + target: 'mytarget' ) end @@ -47,7 +47,7 @@ reponame: title, backuproot: 'mybackuproot', target: 'mytarget', - keys: ['rsa mykey'], + keys: ['rsa mykey'] ) end diff --git a/spec/defines/repo_spec.rb b/spec/defines/repo_spec.rb index 8f43dfd..9b58588 100644 --- a/spec/defines/repo_spec.rb +++ b/spec/defines/repo_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'borgbackup::repo' do @@ -20,28 +22,28 @@ it { is_expected.to contain_class('borgbackup') } it { - is_expected.to contain_concat('/etc/borgbackup/repo_' + params[:reponame] + '.sh') + is_expected.to contain_concat("/etc/borgbackup/repo_#{params[:reponame]}.sh") .with_owner('root') .with_group('root') .with_mode('0700') } it { - is_expected.to contain_concat__fragment('borgbackup::repo ' + params[:reponame] + ' header') - .with_target('/etc/borgbackup/repo_' + params[:reponame] + '.sh') + is_expected.to contain_concat__fragment("borgbackup::repo #{params[:reponame]} header") + .with_target("/etc/borgbackup/repo_#{params[:reponame]}.sh") .with_order('00-header') } it { - is_expected.to contain_concat__fragment('borgbackup::repo ' + params[:reponame] + ' footer') - .with_target('/etc/borgbackup/repo_' + params[:reponame] + '.sh') + is_expected.to contain_concat__fragment("borgbackup::repo #{params[:reponame]} footer") + .with_target("/etc/borgbackup/repo_#{params[:reponame]}.sh") .with_order('99-footer') } it { - is_expected.to contain_exec('initialize borg repo ' + params[:reponame]) - .with_command('/etc/borgbackup/repo_' + params[:reponame] + '.sh init') - .with_unless('/etc/borgbackup/repo_' + params[:reponame] + '.sh list') + is_expected.to contain_exec("initialize borg repo #{params[:reponame]}") + .with_command("/etc/borgbackup/repo_#{params[:reponame]}.sh init") + .with_unless("/etc/borgbackup/repo_#{params[:reponame]}.sh list") } end @@ -53,7 +55,7 @@ let(:title) { 'mytitle' } let :params do default_params.merge( - reponame: title, + reponame: title ) end @@ -71,7 +73,7 @@ let :params do default_params.merge( reponame: title, - archives: { 'arch' => {} }, + archives: { 'arch' => {} } ) end @@ -88,7 +90,7 @@ let :params do default_params.merge( reponame: title, - crontab_define: '', + crontab_define: '' ) end @@ -106,12 +108,13 @@ 'user' => 'someuser', 'hour' => 12, 'minute' => 42, - } }, + } } ) end it_behaves_like 'borgbackup::repo shared examples' it { is_expected.not_to contain_cron('borgbackup run my_cron') } + it { is_expected.to contain_cron('mycustomcron') .with_command('/bin/true') diff --git a/spec/functions/borgbackup_noop_connections_spec.rb b/spec/functions/borgbackup_noop_connections_spec.rb index b42ff45..6e053dc 100644 --- a/spec/functions/borgbackup_noop_connections_spec.rb +++ b/spec/functions/borgbackup_noop_connections_spec.rb @@ -1,6 +1,7 @@ +# frozen_string_literal: true require 'spec_helper' describe 'borgbackup::noop_connection' do - it { is_expected.not_to eq(nil) } + it { is_expected.not_to be_nil } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ae7c1f6..dfe83eb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,75 +1,6 @@ # frozen_string_literal: true -RSpec.configure do |c| - c.mock_with :rspec -end +require 'rspec/core' +require 'voxpupuli/test/spec_helper' -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' - -require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) - -include RspecPuppetFacts - -default_facts = { - puppetversion: Puppet.version, - facterversion: Facter.version, -} - -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) - - 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 - -# 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| - c.default_facts = default_facts - c.before :each do - # 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 +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f }