github / octocatalog-diff

Compile Puppet catalogs from 2 branches, versions, etc., and compare them
https://rubygems.org/gems/octocatalog-diff/
MIT License
238 stars 85 forks source link

Support nil / undef values for resource params #250

Closed avbm closed 3 years ago

avbm commented 3 years ago

Overview

This pull request adds support for Nil values for resources in the catalog. Currently if any resource has a parameter explicitly set to undef / nil, octocatalog-diff raises an exception along the lines of:

bundler: failed to load command: octocatalog-diff (/builds/puppet/control-repo/vendor/bundle/bin/octocatalog-diff)
RuntimeError: Bug (please report): Unexpected data structure in hashdiff_result: ["+", "Class\fSomeClass\fparameters\fconfig\fSomeResoruce\fSomekey", nil]
  /builds/puppet/control-repo/vendor/bundle/gems/octocatalog-diff-2.1.0/lib/octocatalog-diff/catalog-diff/differ.rb:569:in `block in hashdiff_initial'

Having certain resource values is supported in puppet and is useful to certain patterns where we set a parameter if certain complex business logic is met otherwise leave as undef so the class/resource can use the default.

Note: I haven't added new tests as the existing ones cover adding the NilClass as a supported value.

Checklist

/cc [related issues] [teams and individuals, making sure to mention why you're CC-ing them]