Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
{
"name": "VoxBox",
"image": "ghcr.io/voxpupuli/voxbox:latest"
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/create_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

name: Create Git tag

on:
workflow_dispatch:

permissions: {}

jobs:
create_tag:
uses: 'voxpupuli/gha-puppet/.github/workflows/create_tag.yml@v4'
with:
allowed_owner: 'voxpupuli'
git_name: 'pccibot'
git_email: '12855858+pccibot@users.noreply.github.com'
secrets:
# Configure secrets here:
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
ssh_private_key: ${{ secrets.PCCI_SSH_PRIVATE_KEY }}
5 changes: 4 additions & 1 deletion .github/workflows/prepare_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ permissions:

jobs:
release_prep:
uses: 'voxpupuli/gha-puppet/.github/workflows/prepare_release.yml@v3'
uses: 'voxpupuli/gha-puppet/.github/workflows/prepare_release.yml@v4'
with:
version: ${{ github.event.inputs.version }}
allowed_owner: 'voxpupuli'
git_name: 'pccibot'
git_email: '12855858+pccibot@users.noreply.github.com'
secrets:
# Configure secrets here:
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
github_pat: '${{ secrets.PCCI_PAT_RELEASE_PREP }}'
ssh_private_key: '${{ secrets.PCCI_SSH_PRIVATE_KEY }}'
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ name: Release
on:
push:
tags:
- '*'
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#onpushbranchestagsbranches-ignoretags-ignore
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#filter-pattern-cheat-sheet
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
contents: write

jobs:
release:
name: Release
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v3
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v4
with:
allowed_owner: 'voxpupuli'
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '10.5.0'
modulesync_config_version: '10.7.0'
45 changes: 25 additions & 20 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-08-17 21:30:48 UTC using RuboCop version 1.50.2.
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
# using RuboCop version 1.85.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -29,17 +29,6 @@ Lint/ShadowingOuterLocalVariable:
- 'lib/puppet/face/catalog/pull.rb'
- 'lib/puppet/face/catalog/seed.rb'

# Offense count: 2
Lint/UriEscapeUnescape:
Exclude:
- 'lib/puppet/catalog-diff/searchfacts.rb'

# Offense count: 1
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'lib/puppet/face/catalog/seed.rb'

# Offense count: 5
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
Expand All @@ -48,7 +37,7 @@ Naming/MethodParameterName:
- 'lib/puppet/catalog-diff/formater.rb'

# Offense count: 4
# Configuration parameters: Max.
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
RSpec/IndexedLet:
Exclude:
- 'spec/unit/puppet/catalog_diff/comparer_spec.rb'
Expand Down Expand Up @@ -79,12 +68,13 @@ Style/FormatString:
- 'lib/puppet/catalog-diff/differ.rb'
- 'lib/puppet/catalog-diff/formater.rb'

# Offense count: 12
# Offense count: 11
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- '**/*.arb'
- 'lib/puppet/catalog-diff/comparer.rb'
- 'lib/puppet/catalog-diff/compilecatalog.rb'
- 'lib/puppet/catalog-diff/differ.rb'
Expand All @@ -95,19 +85,34 @@ Style/FrozenStringLiteralComment:
- 'lib/puppet/face/catalog/diff.rb'
- 'lib/puppet/face/catalog/pull.rb'
- 'lib/puppet/face/catalog/seed.rb'
- 'spec/spec_helper_local.rb'
- 'spec/unit/puppet/catalog_diff/comparer_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapToHash:
# Configuration parameters: AllowedReceivers.
# AllowedReceivers: Thread.current
Style/HashEachMethods:
Exclude:
- 'lib/puppet/catalog-diff/searchfacts.rb'
- 'lib/puppet/catalog-diff/compilecatalog.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapIntoArray:
Exclude:
- 'lib/puppet/catalog-diff/comparer.rb'
- 'lib/puppet/catalog-diff/preprocessor.rb'

# Offense count: 1
Style/MixinUsage:
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapJoin:
Exclude:
- 'spec/spec_helper_local.rb'
- 'lib/puppet/catalog-diff/formater.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapToHash:
Exclude:
- 'lib/puppet/catalog-diff/searchfacts.rb'

# Offense count: 1
Style/MultilineBlockChain:
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

group :test do
gem 'voxpupuli-test', '~> 13.0', :require => false
gem 'voxpupuli-test', '~> 14.0', :require => false
gem 'puppet_metadata', '~> 6.0', :require => false
end

Expand All @@ -18,7 +18,7 @@ group :system_tests do
end

group :release do
gem 'voxpupuli-release', '~> 5.0', :require => false
gem 'voxpupuli-release', '~> 5.3', :require => false
end

gem 'rake', :require => false
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/catalog-diff/comparer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ def compare_resources(old, new, options)

next if new_resource[:parameters] == resource[:parameters]

parameters_in_old[resource[:resource_id]] = \
parameters_in_old[resource[:resource_id]] =
(resource[:parameters].to_a - new_resource[:parameters].to_a).to_h

parameters_in_new[resource[:resource_id]] = \
parameters_in_new[resource[:resource_id]] =
(new_resource[:parameters].to_a - resource[:parameters].to_a).to_h

if options[:show_resource_diff]
Puppet.debug("Resource diff: #{resource[:resource_id]}")

diff_array = str_diff(
Puppet::CatalogDiff::Formater.new.resource_to_string(resource),
Puppet::CatalogDiff::Formater.new.resource_to_string(new_resource)
Puppet::CatalogDiff::Formater.new.resource_to_string(new_resource),
).split("\n")
if diff_array.size >= 3
string_differences[resource[:resource_id]] = diff_array[3..-1]
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/catalog-diff/differ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def diff(options = {})
subtractions = resource_diffs_titles[:titles_only_in_old].size
changes = resource_diffs[:new_params].keys.size

changes_percentage = ((titles[:from].size.zero? && 0) || (100 * (resource_diffs[:new_params].keys.size.to_f / titles[:from].size)))
additions_percentage = ((titles[:to].size.zero? && 0) || (100 * (additions.to_f / titles[:to].size)))
subtractions_percentage = ((titles[:from].size.zero? && 0) || (100 * (subtractions.to_f / titles[:from].size)))
changes_percentage = (titles[:from].size.zero? && 0) || (100 * (resource_diffs[:new_params].keys.size.to_f / titles[:from].size))
additions_percentage = (titles[:to].size.zero? && 0) || (100 * (additions.to_f / titles[:to].size))
subtractions_percentage = (titles[:from].size.zero? && 0) || (100 * (subtractions.to_f / titles[:from].size))

output[:catalag_percentage_added] = '%.2f' % additions_percentage
output[:catalog_percentage_removed] = '%.2f' % subtractions_percentage
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/catalog-diff/formater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def format_hash(v, indent = '', do_indent = false, comma = '')
str = ''
str << indent if do_indent
str << '{' << "\n"
keys = (v.sort_by { |key, _val| key }).to_h
keys = v.sort_by { |key, _val| key }.to_h
keys.each_pair do |key, val|
str << "\t #{indent} #{key} => "
str << format_value(val, "#{indent} ", true, ',', key)
Expand All @@ -51,7 +51,7 @@ def format_value(v, indent = '', do_indent = false, comma = '', k = nil)
def resource_to_string(resource)
str = ''
str << "\t#{resource[:type].downcase}" << '{"' << resource[:title].to_s << '":' << "\n"
params = (resource[:parameters].sort_by { |k, _v| k }).to_h
params = resource[:parameters].sort_by { |k, _v| k }.to_h
params.each_pair do |k, v|
str << "\t #{k} => "
indent = ' ' * k.to_s.size
Expand Down Expand Up @@ -104,7 +104,7 @@ def list_hash(header, value, mark = '%')
list = value.map do |hash|
number += 1
hash.map do |key, val|
header_spacing = ' ' * (79 - ("#{number}. #{key}".length + (((mark == '%' && ('%.2f' % val)) || val)).to_s.to_s.length))
header_spacing = ' ' * (79 - ("#{number}. #{key}".length + ((mark == '%' && ('%.2f' % val)) || val).to_s.length))
"#{number}. #{key}#{header_spacing}#{(mark == '%' && ('%.2f' % val)) || val}#{mark}"
end
end.join("\n")
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/catalog-diff/preprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def convert25(resource, collector)

resource = { type: target.type,
title: target.title,
parameters: {} }
parameters: {}, }

target.each do |param, value|
resource[:parameters][param] = value
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/catalog-diff/searchfacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def find_nodes(options = {})

def build_query(env, version)
base_query = ['and', ['=', %w[node active], true]]
query_field_catalog_environment = Puppet::Util::Package.versioncmp(version, '3') >= 0 ? 'catalog_environment' : 'catalog-environment'
query_field_catalog_environment = (Puppet::Util::Package.versioncmp(version, '3') >= 0) ? 'catalog_environment' : 'catalog-environment'
base_query.concat([['=', query_field_catalog_environment, env]]) if env
real_facts = @facts.compact
query = base_query.concat(real_facts.map { |k, v| ['=', ['fact', k], v] })
Expand All @@ -37,7 +37,7 @@ def build_query(env, version)
['select-resources',
['and',
['=', 'type', 'Class'],
['=', 'title', capit]]]]]]
['=', 'title', capit],],],],]],
)
end
query
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/face/catalog/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@
total_nodes = nodes.size
nodes[:total_percentage] = (nodes.map { |_node, summary| (summary.is_a?(Hash) && summary[:node_percentage]) || nil }.compact.reduce { |acc, elem| acc.to_f + elem } / total_nodes)
nodes[:with_changes] = with_changes.size
nodes[:most_changed] = most_changed.reverse.take(((options.key?(:changed_depth) && options[:changed_depth].to_i) || 10))
nodes[:most_differences] = most_differences.reverse.take(((options.key?(:changed_depth) && options[:changed_depth].to_i) || 10))
nodes[:most_changed] = most_changed.reverse.take((options.key?(:changed_depth) && options[:changed_depth].to_i) || 10)
nodes[:most_differences] = most_differences.reverse.take((options.key?(:changed_depth) && options[:changed_depth].to_i) || 10)
nodes[:total_nodes] = total_nodes
nodes[:date] = Time.new.iso8601
nodes[:all_changed_nodes] = with_changes.keys
Expand Down
Loading