-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from github/kpaulisse-release-branch
Release version 1.5.2
- Loading branch information
Showing
20 changed files
with
639 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.5.1 | ||
1.5.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
lib/octocatalog-diff/catalog-diff/filter/single_item_array.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../filter' | ||
|
||
module OctocatalogDiff | ||
module CatalogDiff | ||
class Filter | ||
# Filter out changes in parameters when one catalog has a parameter that's an object and | ||
# the other catalog has that same parameter as an array containing the same object. | ||
# For example, under this filter, the following is not a change: | ||
# catalog1: notify => "Service[foo]" | ||
# catalog2: notify => ["Service[foo]"] | ||
class SingleItemArray < OctocatalogDiff::CatalogDiff::Filter | ||
# Public: Implement the filter for single-item arrays whose item exactly matches the | ||
# item that's not in an array in the other catalog. | ||
# | ||
# @param diff [OctocatalogDiff::API::V1::Diff] Difference | ||
# @param _options [Hash] Additional options (there are none for this filter) | ||
# @return [Boolean] true if this should be filtered out, false otherwise | ||
def filtered?(diff, _options = {}) | ||
# Skip additions or removals - focus only on changes | ||
return false unless diff.change? | ||
old_value = diff.old_value | ||
new_value = diff.new_value | ||
|
||
# Skip unless there is a single-item array under consideration | ||
return false unless | ||
(old_value.is_a?(Array) && old_value.size == 1) || | ||
(new_value.is_a?(Array) && new_value.size == 1) | ||
|
||
# Skip if both the old value and new value are arrays | ||
return false if old_value.is_a?(Array) && new_value.is_a?(Array) | ||
|
||
# Do comparison | ||
if old_value.is_a?(Array) | ||
old_value.first == new_value | ||
else | ||
new_value.first == old_value | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
# Specify the PE RBAC token to access the PuppetDB API. Refer to | ||
# https://puppet.com/docs/pe/latest/rbac/rbac_token_auth_intro.html#generate-a-token-using-puppet-access | ||
# for details on generating and obtaining a token. Use this option to specify the text | ||
# of the token. (Use --puppetdb-token-file to read the content of the token from a file.) | ||
# @param parser [OptionParser object] The OptionParser argument | ||
# @param options [Hash] Options hash being constructed; this is modified in this method. | ||
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_token) do | ||
has_weight 310 | ||
|
||
def parse(parser, options) | ||
parser.on('--puppetdb-token TOKEN', 'Token to access the PuppetDB API') do |token| | ||
options[:puppetdb_token] = token | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
# Specify the PE RBAC token to access the PuppetDB API. Refer to | ||
# https://puppet.com/docs/pe/latest/rbac/rbac_token_auth_intro.html#generate-a-token-using-puppet-access | ||
# for details on generating and obtaining a token. Use this option to specify the text | ||
# in a file, to read the content of the token from the file. | ||
# @param parser [OptionParser object] The OptionParser argument | ||
# @param options [Hash] Options hash being constructed; this is modified in this method. | ||
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_token_file) do | ||
has_weight 310 | ||
|
||
def parse(parser, options) | ||
parser.on('--puppetdb-token-file PATH', 'Path containing token for PuppetDB API, relative or absolute') do |x| | ||
proposed_token_path = x.start_with?('/') ? x : File.join(options[:basedir], x) | ||
unless File.file?(proposed_token_path) | ||
raise Errno::ENOENT, "Provided PuppetDB API token (#{proposed_token_path}) does not exist" | ||
end | ||
options[:puppetdb_token] = File.read(proposed_token_path) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
spec/octocatalog-diff/fixtures/catalogs/filter-single-item-array-1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"document_type": "Catalog", | ||
"data": { | ||
"tags": [ | ||
"settings" | ||
], | ||
"name": "my.rspec.node", | ||
"version": "production", | ||
"environment": "production", | ||
"resources": [ | ||
{ | ||
"type": "File", | ||
"title": "/tmp/amazing", | ||
"file": "/environments/production/modules/foo/manifests/init.pp", | ||
"line": 10, | ||
"exported": false, | ||
"parameters": { | ||
"content": "This is my file.\nMy file is amazing.\n", | ||
"group": "root", | ||
"mode": "0755", | ||
"notify": "Service[foo]", | ||
"owner": "root" | ||
} | ||
}, | ||
{ | ||
"type": "File", | ||
"title": "/tmp/awesome", | ||
"file": "/environments/production/modules/foo/manifests/init.pp", | ||
"line": 20, | ||
"exported": false, | ||
"parameters": { | ||
"content": "This is my file.\nMy file is awesome.\n", | ||
"group": "root", | ||
"mode": "0755", | ||
"notify": [ | ||
"Service[foo]", | ||
"Service[bar]" | ||
], | ||
"owner": "root", | ||
"subscribe": [ | ||
"Service[baz]" | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "File", | ||
"title": "/tmp/fizzbuzz", | ||
"file": "/environments/production/modules/foo/manifests/init.pp", | ||
"line": 30, | ||
"exported": false, | ||
"parameters": { | ||
"content": "1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz\n", | ||
"group": "root", | ||
"mode": "0755", | ||
"owner": "root" | ||
} | ||
}, | ||
{ | ||
"type": "File", | ||
"title": "/tmp/foobar", | ||
"file": "/environments/production/modules/foo/manifests/init.pp", | ||
"line": 40, | ||
"exported": false, | ||
"parameters": { | ||
"content": "foo\nbar\n", | ||
"group": "root", | ||
"mode": "0755", | ||
"owner": "root", | ||
"notify": "Service[foobar]" | ||
} | ||
} | ||
], | ||
"classes": [ | ||
"settings" | ||
] | ||
}, | ||
"metadata": { | ||
"api_version": 1 | ||
} | ||
} |
Oops, something went wrong.