Module: Chef::Sugar::RecipeDSL

Defined in:
lib/chef/sugar/filters.rb

Instance Method Summary collapse

Instance Method Details

#compile_time(&block) ⇒ Object

Deprecated.

The description is in the method body pretty accurately…



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/chef/sugar/filters.rb', line 157

def compile_time(&block)
  message = <<-EOH

The Chef Sugar recipe DSL method `compile_time' has been renamed to
`at_compile_time'! This is a breaking change that was released in a patch
version, so please continue reading to understand the necessary semantic
versioning violation.

Chef Software implemented a version of `compile_time' in Chef 12.1, breaking any 
cookbook that uses or depends on Chef Sugar on Chef 12.1:

    https://www.chef.io/blog/2015/03/03/chef-12-1-0-released

In order to progress Chef Sugar forward, the DSL method has been renamed to
avoid the namespace collision.

In short, you should change this:

    compile_time do
# ...
    end

to this:

    at_compile_time do
# ...
    end

EOH

  if Chef::Resource::ChefGem.instance_methods(false).include?(:compile_time)
    message << <<-EOH
You are running a version of Chef Client that includes the `compile_time'
attribute on core Chef resources (most likely Chef 12.1+). Instead of continuing
and having Chef provide you with an obscure error message, I am going to error
here. There is no way for the Chef Recipe to successfully continue unless you
change the Chef Sugar `compile_time' method to `at_compile_time' in your Chef
recipes.

You should NOT change resource-level `compile_time' attributes:

    package "foo" do
compile_time true # Do NOT change these
    end

I truly apologize for the inconvienence and hope the reason for introducing this
breaking change is clear. I am sorry if it causes extra work, but I promise this
error message is much more informative than "wrong number of arguments".

If you have any questions, please feel free to open an issue on GitHub at:

    https://github.com/sethvargo/chef-sugar

Thank you, and have a great day!
EOH
    raise RuntimeError, message
  else
    message << <<-EOH
You are running a version of Chef Client that does not include the
`compile_time' attribute on core Chef resources (most likely less than
Chef 12.1), so this is just a warning. Please consider changing the Chef Sugar
`compile_time' method to `at_compile_time' in your Chef recipes. If you upgrade
Chef, your recipes WILL break.
EOH
    Chef::Log.warn(message)
    at_compile_time(&block)
  end
end