Skip to content

Commit 31bf31d

Browse files
authored
Merge branch 'master' into kpaulisse-git-submodule-example
2 parents a335dfb + ffe6de7 commit 31bf31d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+540
-73
lines changed

.rubocop.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Metrics/AbcSize:
2222
Max: 100
2323
Severity: warning
2424

25+
Metrics/BlockLength:
26+
Enabled: false
27+
2528
Metrics/ClassLength:
2629
Max: 500
2730
Severity: warning
@@ -40,12 +43,33 @@ Metrics/PerceivedComplexity:
4043

4144
# Indentation
4245
CaseIndentation:
43-
IndentWhenRelativeTo: end
4446
IndentOneStep: false
4547

4648
Lint/EndAlignment:
47-
AlignWith: variable
49+
EnforcedStyleAlignWith: variable
4850

4951
# To let us use a '-' in the gem name
5052
Style/FileName:
5153
Enabled: false
54+
55+
# To fix later
56+
Style/PercentLiteralDelimiters:
57+
Enabled: false
58+
Style/VariableNumber:
59+
Enabled: false
60+
Security/YAMLLoad:
61+
Enabled: false
62+
Lint/AmbiguousBlockAssociation:
63+
Enabled: false
64+
Lint/UnifiedInteger:
65+
Enabled: false
66+
Style/GuardClause:
67+
Enabled: false
68+
Style/EmptyMethod:
69+
Enabled: false
70+
Style/SymbolArray:
71+
Enabled: false
72+
Style/IndentHeredoc:
73+
Enabled: false
74+
Style/ExtraSpacing:
75+
Enabled: false

doc/advanced-dynamic-ignores.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Using the `--ignore-tags` command line option, it is possible to ignore all resources with particular Puppet tags. This allows dynamic ignoring of wrappers or other resources that are not of interest.
44

5+
NOTE: This option is separate and distinct from `--include-tags`, which controls whether differences in tags themselves will appear as a difference. For more on `--include-tags`, consult the [options reference](/doc/optionsref.md).
6+
57
## Getting Started
68

79
To use ignored tags, you first need to decide what the name of your tag will be. The standard is `ignored_octocatalog_diff`.

doc/dev/releasing.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ The project maintainers are responsible for bumping the version number, regenera
44

55
## Local testing
66

7-
To test the new version of `octocatalog-diff` in the Puppet repository:
7+
*This procedure is performed by a GitHubber.*
88

9-
0. In the Puppet checkout, start a new branch based off master.
9+
To test the new version of `octocatalog-diff` in the GitHub Puppet repository:
10+
11+
0. In a checkout of the GitHub Puppet repository, start a new branch based off master.
1012
0. In the `octocatalog-diff` checkout:
1113
- Ensure that the desired branch is checked out.
1214
- Choose a unique internal version number which has never been used in CI. A good guideline is that if you're planning to release a version `0.6.0` then for these tests, use `0.6.0a`, `0.6.0b`, ...
@@ -23,25 +25,62 @@ To test the new version of `octocatalog-diff` in the Puppet repository:
2325
2426
0. Back in the Puppet checkout, ensure that the changes are as expected (updates to Gemfile / Gemfile.lock, addition of new gem). Push the change and build appropriate CI job(s) to validate the changes.
2527
26-
## Merging
28+
## Merging one PR
29+
30+
This section is useful when releasing a new version based on one PR submitted by a contributor. Following this workflow is important so that the contributor gets appropriate credit in the revision history for his or her work.
31+
32+
0. In your local checkout, start a new branch based off master.
33+
0. Add the contributor's repository as a remote. For example:
34+
35+
```
36+
git remote add octocat https://github.com/octocat/octocatalog-diff.git
37+
```
38+
39+
0. Merge in the contributor's branch into your own. For example:
40+
41+
```
42+
git merge octocat/some-branch
43+
```
44+
45+
0. Update `.version` and `doc/CHANGELOG.md` appropriately. In CHANGELOG you should link to the PR submitted by the contributor (not the PR you're creating now).
46+
0. Commit your changes to `.version` and `doc/CHANGELOG.md`.
47+
0. If necessary, auto-generate the build documentation, and commit the changes to your branch.
48+
49+
```
50+
rake doc:build
51+
```
52+
53+
0. Open a Pull Request based on your branch. Confirm that the history is correct, showing the contributor's commits first, and then your commit(s) updating the version file, change log, and/or auto-generated documentation.
54+
0. Ensure that CI tests are all passing.
55+
0. Ensure that you've performed "local testing" within GitHub (typically, ~1 day) to confirm the changes.
56+
0. Merge your PR and delete your branch.
57+
0. Confirm that the contributor's PR now appears as merged, and any associated issues have been closed.
58+
59+
## Merging multiple PRs
60+
61+
If multiple PRs will constitute a release, it's generally easier to merge each such PR individually, and then create a separate PR afterwards to update the necessary files.
2762
28-
0. If necessary, complete a Pull Request to update the [version file](/.version).
29-
0. If necessary, auto-generate the build documentation.
63+
0. Merge all constituent PRs and ensure that any associated issues have been closed.
64+
0. Create your own branch based off master.
65+
0. Update `.version` and `doc/CHANGELOG.md` appropriately. In CHANGELOG you should link to the PR submitted by the contributor (not the PR you're creating now).
66+
0. Commit your changes to `.version` and `doc/CHANGELOG.md`.
67+
0. If necessary, auto-generate the build documentation, and commit the changes to your branch.
3068
3169
```
3270
rake doc:build
3371
```
3472
73+
0. Open a Pull Request based on your branch.
3574
0. Ensure that CI tests are all passing.
36-
0. Merge and delete the branch.
75+
0. Ensure that you've performed "local testing" within GitHub (typically, ~1 day) to confirm the changes.
76+
0. Merge your PR and delete your branch.
3777
3878
## Releasing
3979
4080
Generally, a new release will correspond to a merge to master of one or more Pull Requests.
4181
4282
0. Ensure that all changes associated with the release have been merged to master.
43-
- Merge all Pull Requests associated with release.
44-
- If necessary, complete a Pull Request to update the [change log](/doc/CHANGELOG.md).
83+
- Merge all Pull Requests associated with release, including the version number bump, change log update, etc.
4584
- If necessary (for significant changes), complete a Pull Request to update the top-level README file.
4685
0. Ensure the the master branch is checked out on your system.
4786
0. Run the release procedure:

lib/octocatalog-diff/catalog-diff/differ.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,8 @@ def filter_and_cleanup(catalog_resources)
266266
hsh[k] = cleansed_param unless cleansed_param.nil? || cleansed_param.empty?
267267
elsif k == 'tags'
268268
# The order of tags is unimportant. Sort this array to avoid false diffs if order changes.
269-
# Also if tags is empty, don't add. Most uses of catalog diff will want to ignore tags,
270-
# and if you're ignoring tags you won't get here anyway. Also, don't add empty array of tags.
271-
unless @opts[:ignore_tags]
272-
hsh[k] = v.sort if v.is_a?(Array) && v.any?
273-
end
269+
# Also if tags is empty, don't add.
270+
hsh[k] = v.sort if v.is_a?(Array) && v.any?
274271
elsif k == 'file' || k == 'line'
275272
# We don't care, for the purposes of catalog-diff, from which manifest and line this resource originated.
276273
# However, we may report this to the user, so we will keep it in here for now.

lib/octocatalog-diff/catalog-util/builddir.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def install_hiera_config(logger, options)
234234

235235
# Munge datadir in hiera config file
236236
obj = YAML.load_file(file_src)
237-
(obj[:backends] || %w(yaml json)).each do |key|
237+
([obj[:backends]].flatten || %w(yaml json)).each do |key|
238238
next unless obj.key?(key.to_sym)
239239
if options[:hiera_path_strip].is_a?(String)
240240
next if obj[key.to_sym][:datadir].nil?

lib/octocatalog-diff/catalog.rb

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -201,29 +201,56 @@ def validate_references
201201
end
202202
return if missing.empty?
203203

204-
# At this point there is at least one broken/missing reference. Format an error message and
205-
# raise. Error message will look like this:
206-
# ---
207-
# Catalog has broken references: exec[subscribe caller 1] -> subscribe[Exec[subscribe target]];
208-
# exec[subscribe caller 2] -> subscribe[Exec[subscribe target]]; exec[subscribe caller 2] ->
209-
# subscribe[Exec[subscribe target 2]]
210-
# ---
204+
# At this point there is at least one broken/missing reference. Format an error message and raise.
205+
errors = format_missing_references(missing)
206+
plural = errors =~ /;/ ? 's' : ''
207+
raise OctocatalogDiff::Errors::ReferenceValidationError, "Catalog has broken reference#{plural}: #{errors}"
208+
end
209+
210+
private
211+
212+
# Private method: Format the name of the source file and line number, based on compilation directory and
213+
# other settings. This is used by format_missing_references.
214+
# @param source_file [String] Raw source file name from catalog
215+
# @param line_number [Fixnum] Line number from catalog
216+
# @return [String] Formatted source file
217+
def format_source_file_line(source_file, line_number)
218+
return '' if source_file.nil? || source_file.empty?
219+
filename = if compilation_dir && source_file.start_with?(compilation_dir)
220+
stripped_file = source_file[compilation_dir.length..-1]
221+
stripped_file.start_with?('/') ? stripped_file[1..-1] : stripped_file
222+
else
223+
source_file
224+
end
225+
"(#{filename.sub(%r{^environments/production/}, '')}:#{line_number})"
226+
end
227+
228+
# Private method: Format the missing references into human-readable text
229+
# Error message will look like this:
230+
# ---
231+
# Catalog has broken references: exec[subscribe caller 1](file:line) -> subscribe[Exec[subscribe target]];
232+
# exec[subscribe caller 2](file:line) -> subscribe[Exec[subscribe target]]; exec[subscribe caller 2](file:line) ->
233+
# subscribe[Exec[subscribe target 2]]
234+
# ---
235+
# @param missing [Array] Array of missing references
236+
# @return [String] Formatted references
237+
def format_missing_references(missing)
238+
unless missing.is_a?(Array) && missing.any?
239+
raise ArgumentError, 'format_missing_references() requires a non-empty array as input'
240+
end
241+
211242
formatted_references = missing.map do |obj|
212243
# obj[:target_value] can be a string or an array. If it's an array, create a
213244
# separate error message per element of that array. This allows the total number
214245
# of errors to be correct.
215-
src = "#{obj[:source]['type'].downcase}[#{obj[:source]['title']}]"
246+
src_ref = "#{obj[:source]['type'].downcase}[#{obj[:source]['title']}]"
247+
src_file = format_source_file_line(obj[:source]['file'], obj[:source]['line'])
216248
target_val = obj[:target_value].is_a?(Array) ? obj[:target_value] : [obj[:target_value]]
217-
target_val.map { |tv| "#{src} -> #{obj[:target_type].downcase}[#{tv}]" }
218-
end
219-
formatted_references.flatten!
220-
plural = formatted_references.size == 1 ? '' : 's'
221-
errors = formatted_references.join('; ')
222-
raise OctocatalogDiff::Errors::ReferenceValidationError, "Catalog has broken reference#{plural}: #{errors}"
249+
target_val.map { |tv| "#{src_ref}#{src_file} -> #{obj[:target_type].downcase}[#{tv}]" }
250+
end.flatten
251+
formatted_references.join('; ')
223252
end
224253

225-
private
226-
227254
# Private method: Given a list of resources to check, return the references from
228255
# that list that are missing from the catalog. (An empty array returned would indicate
229256
# all references are present in the catalog.)

octocatalog-diff.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require_relative 'lib/octocatalog-diff/version'
22

3-
DEFAULT_PUPPET_VERSION = '4.5.3'.freeze
3+
DEFAULT_PUPPET_VERSION = '4.10.0'.freeze
44

55
Gem::Specification.new do |s|
66
s.required_ruby_version = '>= 2.0.0'
@@ -26,19 +26,19 @@ EOF
2626
s.add_runtime_dependency 'diffy', '>= 3.1.0'
2727
s.add_runtime_dependency 'httparty', '>= 0.11.0'
2828
s.add_runtime_dependency 'hashdiff', '>= 0.3.0'
29-
s.add_runtime_dependency 'parallel', '>= 1.9.0'
29+
s.add_runtime_dependency 'parallel', '>= 1.11.1'
3030
s.add_runtime_dependency 'rugged', '>= 0.25.0b2'
3131

3232
s.add_development_dependency 'rspec', '~> 3.4.0'
3333
s.add_development_dependency 'rake', '11.2.2'
3434
s.add_development_dependency 'parallel_tests', '2.7.1'
3535
s.add_development_dependency 'rspec-retry', '0.5.0'
3636

37-
s.add_development_dependency 'rubocop', '~> 0.35'
37+
s.add_development_dependency 'rubocop', '= 0.48.1'
3838

3939
s.add_development_dependency 'puppetdb-terminus', '3.2.4'
4040

41-
s.add_development_dependency 'simplecov'
41+
s.add_development_dependency 'simplecov', '>= 0.14.1'
4242
s.add_development_dependency 'simplecov-json'
4343

4444
if ENV['PUPPET_VERSION']

script/cibuild

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@
66
# with one or more Puppet versions, with PUPPET_VERSIONS set to a space-separated list
77
# of versions to test.
88

9-
[ -z "$PUPPET_VERSIONS" ] && export PUPPET_VERSIONS='3.8.7 4.5.3'
9+
[ -z "$PUPPET_VERSIONS" ] && export PUPPET_VERSIONS='3.8.7 4.5.3 4.10.0'
1010
[ -z "$RUBOCOP_TEST" ] && export RUBOCOP_TEST='true'
1111
[ -z "$RSPEC_TEST" ] && export RSPEC_TEST='true'
1212

13-
# FIXME: Needed only for Janky. Remove for travis.
14-
if env | grep ^JANKY_ >/dev/null 2>&1; then
15-
export PATH=/usr/share/rbenv/shims:$PATH
16-
export RBENV_VERSION=2.1.2-github
17-
fi
18-
1913
echo 'Starting script/cibuild'
2014

2115
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
2216

2317
# Create a temporary file to capture output of various steps.
24-
export OUTPUT_FILE=$(mktemp)
18+
export OUTPUT_FILE="$(mktemp)"
2519
function cleanup() {
2620
rm -rf "$OUTPUT_FILE"
2721
}
@@ -79,12 +73,12 @@ if [ "$RSPEC_TEST" = "true" ]; then
7973

8074
# Make sure `script/puppet` returns the desired puppet version
8175
pv_test=$( "${DIR}/script/puppet" --version 2>&1 )
82-
if [ $? -eq 0 -a "$pv_test" = "$pv" ]; then
76+
if [ $? -eq 0 ] && [ "$pv_test" = "$pv" ]; then
8377
echo "Confirmed Puppet version = ${pv_test}"
8478
else
8579
echo "Failures:"
8680
echo "- Unable to confirm that Puppet version = ${pv}"
87-
echo $pv_test
81+
echo "$pv_test"
8882
RSPEC_EXITCODE=255
8983
fi
9084

@@ -108,4 +102,4 @@ fi
108102
echo "Finished script/cibuild:"
109103
[ "$RUBOCOP_EXITCODE" -ge 0 ] && echo " - rubocop: exit ${RUBOCOP_EXITCODE}"
110104
[ "$RSPEC_EXITCODE" -ge 0 ] && echo " - rspec: exit ${RSPEC_EXITCODE}"
111-
if [ "$RUBOCOP_EXITCODE" -gt 0 -o "$RSPEC_EXITCODE" -gt 0 ]; then exit 1; else exit 0; fi
105+
if [ "$RUBOCOP_EXITCODE" -gt 0 ] || [ "$RSPEC_EXITCODE" -gt 0 ]; then exit 1; else exit 0; fi
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"document_type": "Catalog",
3+
"data": {
4+
"tags": ["settings"],
5+
"name": "my.rspec.node",
6+
"version": "production",
7+
"environment": "production",
8+
"resources": [
9+
{
10+
"type": "Stage",
11+
"title": "main",
12+
"tags": ["stage"],
13+
"exported": false,
14+
"parameters": {
15+
"name": "main"
16+
}
17+
},
18+
{
19+
"type": "Class",
20+
"title": "Settings",
21+
"tags": ["class","settings"],
22+
"exported": false
23+
},
24+
{
25+
"type": "File",
26+
"title": "/tmp/foo",
27+
"tags": ["tag-one-new","tag-too","ignore-tag__file"],
28+
"parameters": {
29+
"content": "foofoo",
30+
"owner": "root"
31+
}
32+
}
33+
],
34+
"classes": [
35+
"settings"
36+
]
37+
},
38+
"metadata": {
39+
"api_version": 1
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"document_type": "Catalog",
3+
"data": {
4+
"tags": ["settings"],
5+
"name": "my.rspec.node",
6+
"version": "production",
7+
"environment": "production",
8+
"resources": [
9+
{
10+
"type": "Stage",
11+
"title": "main",
12+
"tags": ["stage"],
13+
"exported": false,
14+
"parameters": {
15+
"name": "main"
16+
}
17+
},
18+
{
19+
"type": "Class",
20+
"title": "Settings",
21+
"tags": ["class","settings"],
22+
"exported": false
23+
},
24+
{
25+
"type": "File",
26+
"title": "/tmp/foo",
27+
"tags": ["tag-one","tag-two"],
28+
"parameters": {
29+
"content": "foofoo",
30+
"owner": "root"
31+
}
32+
}
33+
],
34+
"classes": [
35+
"settings"
36+
]
37+
},
38+
"metadata": {
39+
"api_version": 1
40+
}
41+
}

0 commit comments

Comments
 (0)