cookstyle icon indicating copy to clipboard operation
cookstyle copied to clipboard

Conditional use of `unified_mode true` needs to warn

Open lamont-granquist opened this issue 3 years ago • 1 comments

unified_mode true if respond_to?(:unified_mode)

That isn't a coherent thing to ever want to do, since you get unified_mode true behavior on newer chef-client and unified_mode false behavior on older chef-client and will require careful testing on all versions, and crazy questions to me on how to write code so that it works the same both ways.

In general people need to pick one way or the other, and have backwards compatibility via unified_mode false (and suffer the deprecation warning forever reminding you that support for Chef 12 has been dropped ages ago) or else set unified_mode true and properly drop support for old Chef 12

lamont-granquist avatar Jan 25 '22 00:01 lamont-granquist

What is okay to do is the other boolean:

unified_mode false if respond_to?(:unified_mode)

That is fine. That turns off unified_mode everywhere and you can write your resources old-style forever and opt-out of unified mode.

Individual sites can ever put this in config.rb (or kitchen.yml settings):

silence_deprecation_warnings %w{unified_mode}

lamont-granquist avatar Jan 25 '22 00:01 lamont-granquist