From 6d1219b9e0e79821304c9d655853aed3afa2ff00 Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Thu, 5 Sep 2024 15:17:58 -0500 Subject: [PATCH] [puppetsync] Clean up for linters Clean up files distributed by puppetsync for various linters. Also fix a quoting issue in create-github-release action. --- .github/workflows/pr_tests.yml | 4 +- .github/workflows/validate_tokens.yml | 17 ------- CHANGELOG | 3 ++ metadata.json | 4 +- spec/spec_helper.rb | 69 ++++++++++++++++----------- 5 files changed, 47 insertions(+), 50 deletions(-) diff --git a/.github/workflows/pr_tests.yml b/.github/workflows/pr_tests.yml index 1780c4a..21ca28c 100644 --- a/.github/workflows/pr_tests.yml +++ b/.github/workflows/pr_tests.yml @@ -115,8 +115,8 @@ jobs: experimental: false - label: 'Puppet 8.x' puppet_version: '~> 8.0' - ruby_version: 3.1 - experimental: true + ruby_version: '3.2' + experimental: false fail-fast: false env: PUPPET_VERSION: ${{matrix.puppet.puppet_version}} diff --git a/.github/workflows/validate_tokens.yml b/.github/workflows/validate_tokens.yml index 0650ac5..11dd5f3 100644 --- a/.github/workflows/validate_tokens.yml +++ b/.github/workflows/validate_tokens.yml @@ -14,9 +14,7 @@ # GitHub Secret variable Type Notes # ------------------------ -------- ---------------------------------------- # PUPPETFORGE_API_TOKEN Required -# GITLAB_API_PRIVATE_TOKEN Required GitLab token (should have `api` scope) # NO_SCOPE_GITHUB_TOKEN Required GitHub token (should have no scopes) -# GITLAB_SERVER_URL Optional Specify a GL server other than gitlab.com # The secure vars will be filtered in GitHub Actions log output, and aren't # provided to untrusted builds (i.e, triggered by PR from another repository) # @@ -40,21 +38,6 @@ jobs: --header "Authorization: Bearer ${PUPPETFORGE_API_TOKEN:-default_content_to_cause_401_response}" \ https://forgeapi.puppet.com/v3/users > /dev/null - gitlab: - name: 'GitLab token has scope for developer' - runs-on: ubuntu-latest - env: - GITLAB_API_PRIVATE_TOKEN: ${{ secrets.GITLAB_API_PRIVATE_TOKEN }} - GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }} - GITLAB_ORG: ${{ github.event.organization.login }} - steps: - - run: | - GITLAB_API_URL="${GITLAB_API_URL:-https://gitlab.com/api/v4}" - curl -I --http1.1 --fail --silent --show-error \ - --header 'Content-Type: application/json' \ - --header "Authorization: Bearer $GITLAB_API_PRIVATE_TOKEN" \ - "${CURL_CMD[@]}" "${GITLAB_API_URL}/groups/$GITLAB_ORG/audit_events" - github-no-scope: name: 'No-scope GitHub token has NO scopes' runs-on: ubuntu-latest diff --git a/CHANGELOG b/CHANGELOG index 392d29a..2fb8793 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +* Thu Sep 05 2024 Steven Pritchard - 0.15.0 +- [puppetsync] Add EL9 support + * Mon Oct 23 2023 Steven Pritchard - 0.14.0 - [puppetsync] Add EL9 support diff --git a/metadata.json b/metadata.json index b4309a1..51df718 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "simp-haveged", - "version": "0.14.0", + "version": "0.15.0", "author": "SIMP Team", "summary": "Install and manage the HAVEGE daemon.", "license": "BSD-2-Clause", @@ -16,7 +16,7 @@ "dependencies": [ { "name": "puppet/systemd", - "version_requirement": ">= 4.0.2 < 7.0.0" + "version_requirement": ">= 4.0.2 < 8.0.0" }, { "name": "simp/simplib", diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 04592ca..223b5ac 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,11 @@ # frozen_string_literal: true +# +# ------------------------------------------------------------------------------ +# NOTICE: **This file is maintained with puppetsync** +# +# This file is automatically updated as part of a puppet module baseline. +# The next baseline sync will overwrite any local changes made to this file. +# ------------------------------------------------------------------------------ require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet' @@ -11,29 +18,25 @@ fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) module_name = File.basename(File.expand_path(File.join(__FILE__, '../..'))) -# Add fixture lib dirs to LOAD_PATH. Work-around for PUP-3336 -if Puppet.version < '4.0.0' - Dir["#{fixture_path}/modules/*/lib"].entries.each do |lib_dir| - $LOAD_PATH << lib_dir - end -end - -unless ENV.key?('TRUSTED_NODE_DATA') - warn '== WARNING: TRUSTED_NODE_DATA is unset, using TRUSTED_NODE_DATA=yes' - ENV['TRUSTED_NODE_DATA'] = 'yes' +if ENV['PUPPET_DEBUG'] + Puppet::Util::Log.level = :debug + Puppet::Util::Log.newdestination(:console) end -default_hiera_config = <<-DEFAULT_HIERA_CONFIG +default_hiera_config = <<~HIERA_CONFIG --- -:backends: - - "yaml" -:yaml: - :datadir: "stub" -:hierarchy: - - "%{custom_hiera}" - - "%{module_name}" - - "default" -DEFAULT_HIERA_CONFIG +version: 5 +hierarchy: + - name: Custom Test Hiera + path: "%{custom_hiera}.yaml" + - name: "%{module_name}" + path: "%{module_name}.yaml" + - name: Common + path: default.yaml +defaults: + data_hash: yaml_data + datadir: "stub" +HIERA_CONFIG # This can be used from inside your spec tests to set the testable environment. # You can use this to stub out an ENC. @@ -82,9 +85,10 @@ def set_hieradata(hieradata) RSpec.configure do |c| # If nothing else... c.default_facts = { - :production => { - :path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin', - :concat_basedir => '/tmp' + production: { + #:fqdn => 'production.rspec.test.localdomain', + path: '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin', + concat_basedir: '/tmp' } } @@ -110,10 +114,16 @@ def set_hieradata(hieradata) # rubocop:disable RSpec/BeforeAfterAll c.before(:all) do - # rubocop:disable Security/YAMLLoad - data = YAML.load(default_hiera_config) - # rubocop:enable Security/YAMLLoad - data[:yaml][:datadir] = File.join(fixture_path, 'hieradata') + data = YAML.safe_load(default_hiera_config) + data.each_key do |key| + next unless data[key].is_a?(Hash) + + if data[key][:datadir] == 'stub' + data[key][:datadir] = File.join(fixture_path, 'hieradata') + elsif data[key]['datadir'] == 'stub' + data[key]['datadir'] = File.join(fixture_path, 'hieradata') + end + end File.open(c.hiera_config, 'w') do |f| f.write data.to_yaml @@ -130,6 +140,7 @@ def set_hieradata(hieradata) end # ensure the user running these tests has an accessible environmentpath + Puppet[:digest_algorithm] = 'sha256' Puppet[:environmentpath] = @spec_global_env_temp Puppet[:user] = Etc.getpwuid(Process.uid).name Puppet[:group] = Etc.getgrgid(Process.gid).name @@ -152,7 +163,7 @@ def set_hieradata(hieradata) Dir.glob("#{RSpec.configuration.module_path}/*").each do |dir| begin Pathname.new(dir).realpath - rescue StandardError => e - raise "ERROR: The module '#{dir}' is not installed (#{e.message}). Tests cannot continue." + rescue StandardError + raise "ERROR: The module '#{dir}' is not installed. Tests cannot continue." end end