diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-24 16:12:51 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-28 11:19:48 -0800 |
commit | 0ca58ffd12e5399792e0f8a3b54c6f3ba7bddab2 (patch) | |
tree | 4c6ffee87fac90600b0ba386c6a329a8a27c2abb /lib/chef/resource/script.rb | |
parent | d8a2bc810381f58eeb4ecd4db7ff104038f8f97c (diff) | |
download | chef-0ca58ffd12e5399792e0f8a3b54c6f3ba7bddab2.tar.gz |
Chef-13 break: script and all its subclasses now errors on 'command' property
This was always a coding bug. The `command` property is only used
internally but is exposed for users to twiddle because script
subclasses execute. Thus this still violates Liskov Substitution and
this is not an is-a relationship where inheritance might be appropriate,
because the script resource should /use/ the execute resource and
not /be an/ execute resource.
The more you know...
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/resource/script.rb')
-rw-r--r-- | lib/chef/resource/script.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb index 5173a76542..e1d71c2924 100644 --- a/lib/chef/resource/script.rb +++ b/lib/chef/resource/script.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,13 +23,11 @@ require "chef/provider/script" class Chef class Resource class Script < Chef::Resource::Execute - # Chef-13: go back to using :name as the identity attr - identity_attr :command + identity_attr :name def initialize(name, run_context = nil) super - # Chef-13: the command variable should be initialized to nil - @command = name + @command = nil @code = nil @interpreter = nil @flags = nil @@ -38,9 +36,7 @@ class Chef def command(arg = nil) unless arg.nil? - # Chef-13: change this to raise if the user is trying to set a value here - Chef::Log.warn "Specifying command attribute on a script resource is a coding error, use the 'code' attribute, or the execute resource" - Chef::Log.warn "This attribute is deprecated and must be fixed or this code will fail on Chef 13" + raise Chef::Exceptions::Script, "Do not use the command attribute on a #{resource_name} resource, use the 'code' attribute instead." end super end |