summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-16 18:06:21 -0700
committerGitHub <noreply@github.com>2018-03-16 18:06:21 -0700
commit0f270e4c596a85acfec69c37fa34bc29fe5048fe (patch)
treefbdf9d05ba2d6ca288688e5ceedfa53167b8ae34
parentd39a39b87706fc85a43c0f40aef7625c7148a041 (diff)
parent9f3354f9fa70f400222448f30adaae03a4cb9baa (diff)
downloadchef-0f270e4c596a85acfec69c37fa34bc29fe5048fe.tar.gz
Merge pull request #6997 from chef/cleanup
Lazy eval empty Hash/Array resource properties.
-rw-r--r--lib/chef/resource/apt_repository.rb4
-rw-r--r--lib/chef/resource/chef_handler.rb2
-rw-r--r--lib/chef/resource/cron.rb2
-rw-r--r--lib/chef/resource/git.rb2
-rw-r--r--lib/chef/resource/http_request.rb2
-rw-r--r--lib/chef/resource/mdadm.rb2
-rw-r--r--lib/chef/resource/sudo.rb12
7 files changed, 13 insertions, 13 deletions
diff --git a/lib/chef/resource/apt_repository.rb b/lib/chef/resource/apt_repository.rb
index 6b044afe27..920bfa278f 100644
--- a/lib/chef/resource/apt_repository.rb
+++ b/lib/chef/resource/apt_repository.rb
@@ -31,13 +31,13 @@ class Chef
property :repo_name, String, name_property: true
property :uri, String
property :distribution, [ String, nil, false ], default: lazy { node["lsb"]["codename"] }, coerce: proc { |x| x ? x : nil }
- property :components, Array, default: []
+ property :components, Array, default: lazy { [] }
property :arch, [String, nil, false], default: nil, coerce: proc { |x| x ? x : nil }
property :trusted, [TrueClass, FalseClass], default: false
# whether or not to add the repository as a source repo, too
property :deb_src, [TrueClass, FalseClass], default: false
property :keyserver, [String, nil, false], default: "keyserver.ubuntu.com", coerce: proc { |x| x ? x : nil }
- property :key, [String, Array, nil, false], default: [], coerce: proc { |x| x ? Array(x) : nil }
+ property :key, [String, Array, nil, false], default: lazy { [] }, coerce: proc { |x| x ? Array(x) : nil }
property :key_proxy, [String, nil, false], default: nil, coerce: proc { |x| x ? x : nil }
property :cookbook, [String, nil, false], default: nil, desired_state: false, coerce: proc { |x| x ? x : nil }
diff --git a/lib/chef/resource/chef_handler.rb b/lib/chef/resource/chef_handler.rb
index 2c80a1a9c9..ad9fab0077 100644
--- a/lib/chef/resource/chef_handler.rb
+++ b/lib/chef/resource/chef_handler.rb
@@ -33,7 +33,7 @@ class Chef
property :arguments, [Array, Hash],
description: "Arguments to pass the handler's class initializer.",
- default: []
+ default: lazy { [] }
property :type, Hash,
description: "The type of Chef Handler to register as, i.e. :report, :exception or both.",
diff --git a/lib/chef/resource/cron.rb b/lib/chef/resource/cron.rb
index 32c47b963f..3c11d83d9a 100644
--- a/lib/chef/resource/cron.rb
+++ b/lib/chef/resource/cron.rb
@@ -143,7 +143,7 @@ class Chef
property :shell, String
property :command, String, identity: true
property :user, String, default: "root"
- property :environment, Hash, default: {}
+ property :environment, Hash, default: lazy { Hash.new }
private
diff --git a/lib/chef/resource/git.rb b/lib/chef/resource/git.rb
index 58200815d4..7e756db78f 100644
--- a/lib/chef/resource/git.rb
+++ b/lib/chef/resource/git.rb
@@ -25,7 +25,7 @@ class Chef
" in a git repository. git version 1.6.5 (or higher) is required to"\
" use all of the functionality in the git resource."
- property :additional_remotes, Hash, default: {}
+ property :additional_remotes, Hash, default: lazy { Hash.new }
alias :branch :revision
alias :reference :revision
diff --git a/lib/chef/resource/http_request.rb b/lib/chef/resource/http_request.rb
index 6c890f2149..f209e419dd 100644
--- a/lib/chef/resource/http_request.rb
+++ b/lib/chef/resource/http_request.rb
@@ -33,7 +33,7 @@ class Chef
allowed_actions :get, :patch, :put, :post, :delete, :head, :options
property :url, String, identity: true
- property :headers, Hash, default: {}
+ property :headers, Hash, default: lazy { Hash.new }
def initialize(name, run_context = nil)
super
diff --git a/lib/chef/resource/mdadm.rb b/lib/chef/resource/mdadm.rb
index c8752ba038..3b54a53e98 100644
--- a/lib/chef/resource/mdadm.rb
+++ b/lib/chef/resource/mdadm.rb
@@ -33,7 +33,7 @@ class Chef
allowed_actions :create, :assemble, :stop
property :chunk, Integer, default: 16
- property :devices, Array, default: []
+ property :devices, Array, default: lazy { [] }
property :exists, [ TrueClass, FalseClass ], default: false
property :level, Integer, default: 1
property :metadata, String, default: "0.90"
diff --git a/lib/chef/resource/sudo.rb b/lib/chef/resource/sudo.rb
index f1e517a275..01318c0ca3 100644
--- a/lib/chef/resource/sudo.rb
+++ b/lib/chef/resource/sudo.rb
@@ -44,12 +44,12 @@ class Chef
property :users, [String, Array],
description: "User(s) to provide sudo privileges to. This accepts either an array or a comma separated.",
- default: [],
+ default: lazy { [] },
coerce: proc { |x| x.is_a?(Array) ? x : x.split(/\s*,\s*/) }
property :groups, [String, Array],
description: "Group(s) to provide sudo privileges to. This accepts either an array or a comma separated list. Leading % on group names is optional.",
- default: [],
+ default: lazy { [] },
coerce: proc { |x| coerce_groups(x) }
property :commands, Array,
@@ -81,11 +81,11 @@ class Chef
property :defaults, Array,
description: "An array of defaults for the user/group.",
- default: []
+ default: lazy { [] }
property :command_aliases, Array,
description: "Command aliases that can be used as allowed commands later in the config",
- default: []
+ default: lazy { [] }
property :setenv, [TrueClass, FalseClass],
description: "Whether to permit the preserving of environment with sudo -E.",
@@ -93,11 +93,11 @@ class Chef
property :env_keep_add, Array,
description: "An array of strings to add to env_keep.",
- default: []
+ default: lazy { [] }
property :env_keep_subtract, Array,
description: "An array of strings to remove from env_keep.",
- default: []
+ default: lazy { [] }
property :visudo_path, String,
description: "The path to visudo for config verification.",