summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-01-30 22:09:48 -0800
committerGitHub <noreply@github.com>2019-01-30 22:09:48 -0800
commitac6174de5a304b4be671528ca88e55bfc421fa98 (patch)
treea3a8cbc3bb211af45931a53f8b432c7b6da310a9
parentdcb6b50efda2bf85eb6330263a9ec63a7713239d (diff)
parent75b5a490bb4ca85b857793bfb18ed3c2aabca691 (diff)
downloadchef-ac6174de5a304b4be671528ca88e55bfc421fa98.tar.gz
Merge pull request #8178 from MsysTechnologiesllc/vasundhara/MSYS-964_Convert_execute_resource_to_setup_properties_via_property_DSL
Convert execute_resource remaining properties to use properties
-rw-r--r--lib/chef/resource/execute.rb18
-rw-r--r--lib/chef/resource/script.rb2
2 files changed, 7 insertions, 13 deletions
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
index 9eb86a2fef..3f4b74bd96 100644
--- a/lib/chef/resource/execute.rb
+++ b/lib/chef/resource/execute.rb
@@ -24,9 +24,6 @@ class Chef
class Execute < Chef::Resource
resource_name :execute
provides :execute
-
- identity_attr :command
-
description "Use the execute resource to execute a single command. Commands that"\
" are executed with this resource are (by their nature) not idempotent,"\
" as they are typically unique to the environment in which they are run."\
@@ -48,13 +45,10 @@ class Chef
@is_guard_interpreter = false
end
- def command(arg = nil)
- set_or_return(
- :command,
- arg,
- kind_of: [ String, Array ]
- )
- end
+ property :command, [ String, Array ],
+ name_property: true, identity: true,
+ description: "An optional property to set the command to be executed if it differs from the resource block's name."
+
property :umask, [ String, Integer ],
description: "The file mode creation mask, or umask."
@@ -67,8 +61,6 @@ class Chef
property :environment, Hash,
description: "A Hash of environment variables in the form of ({'ENV_VARIABLE' => 'VALUE'})."
- alias :env :environment
-
property :group, [ String, Integer ],
description: "The group name or group ID that must be changed before running a command."
@@ -106,6 +98,8 @@ class Chef
description: "Determines whether the script will run with elevated permissions to circumvent User Access Control (UAC) interactively blocking the process.\nThis will cause the process to be run under a batch login instead of an interactive login. The user running Chef needs the “Replace a process level token” and “Adjust Memory Quotas for a process” permissions. The user that is running the command needs the “Log on as a batch job” permission.\nBecause this requires a login, the user and password properties are required.",
introduced: "13.3"
+ alias :env :environment
+
def self.set_guard_inherited_attributes(*inherited_attributes)
@class_inherited_attributes = inherited_attributes
end
diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb
index ac3af619e5..0d7e6a10d5 100644
--- a/lib/chef/resource/script.rb
+++ b/lib/chef/resource/script.rb
@@ -39,10 +39,10 @@ class Chef
# FIXME: remove this and use an execute sub-resource instead of inheriting from Execute
def command(arg = nil)
+ super
unless arg.nil?
raise Chef::Exceptions::Script, "Do not use the command property on a #{resource_name} resource, use the 'code' property instead."
end
- super
end
property :code, String, required: true