summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-16 11:07:29 -0700
committerTim Smith <tsmith@chef.io>2018-03-16 13:46:50 -0700
commitc0cb0506eda1679418911842f6250e2f54f8871f (patch)
tree1be60682cb8c5b920442f3ea707fa23938cdc71d
parent8e9c3623b2a37dd51dc0e57466661306dd30a77d (diff)
downloadchef-c0cb0506eda1679418911842f6250e2f54f8871f.tar.gz
Use properties in scm, subversion, and template
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/scm.rb81
-rw-r--r--lib/chef/resource/subversion.rb5
-rw-r--r--lib/chef/resource/template.rb29
3 files changed, 13 insertions, 102 deletions
diff --git a/lib/chef/resource/scm.rb b/lib/chef/resource/scm.rb
index 178dcca640..179a3adefd 100644
--- a/lib/chef/resource/scm.rb
+++ b/lib/chef/resource/scm.rb
@@ -21,20 +21,11 @@ require "chef/resource"
class Chef
class Resource
class Scm < Chef::Resource
- state_attrs :revision
-
default_action :sync
allowed_actions :checkout, :export, :sync, :diff, :log
def initialize(name, run_context = nil)
super
- @enable_submodules = false
- @enable_checkout = true
- @remote = "origin"
- @ssh_wrapper = nil
- @depth = nil
- @checkout_branch = "deploy"
- @environment = nil
end
property :destination, String, name_property: true, identity: true
@@ -44,6 +35,15 @@ class Chef
property :group, [String, Integer]
property :svn_username, String
property :svn_password, String, sensitive: true, desired_state: false
+ # Capistrano and git-deploy use ``shallow clone''
+ property :depth, Integer
+ property :enable_submodules, [TrueClass, FalseClass], default: false
+ property :enable_checkout, [TrueClass, FalseClass], default: true
+ property :remote, String, default: "origin"
+ property :ssh_wrapper, String
+ property :timeout, Integer
+ property :checkout_branch, String, default: "deploy"
+ property :environment, [Hash, nil], default: nil
def svn_arguments(arg = nil)
@svn_arguments, arg = nil, nil if arg == false
@@ -62,70 +62,7 @@ class Chef
:kind_of => String)
end
- # Capistrano and git-deploy use ``shallow clone''
- def depth(arg = nil)
- set_or_return(
- :depth,
- arg,
- :kind_of => Integer
- )
- end
-
- def enable_submodules(arg = nil)
- set_or_return(
- :enable_submodules,
- arg,
- :kind_of => [TrueClass, FalseClass]
- )
- end
-
- def enable_checkout(arg = nil)
- set_or_return(
- :enable_checkout,
- arg,
- :kind_of => [TrueClass, FalseClass]
- )
- end
-
- def remote(arg = nil)
- set_or_return(
- :remote,
- arg,
- :kind_of => String
- )
- end
-
- def ssh_wrapper(arg = nil)
- set_or_return(
- :ssh_wrapper,
- arg,
- :kind_of => String
- )
- end
-
- def timeout(arg = nil)
- set_or_return(
- :timeout,
- arg,
- :kind_of => Integer
- )
- end
-
- def checkout_branch(arg = nil)
- set_or_return(
- :checkout_branch,
- arg,
- :kind_of => String
- )
- end
- def environment(arg = nil)
- set_or_return(
- :environment,
- arg,
- :kind_of => [ Hash ]
- )
- end
alias :env :environment
end
diff --git a/lib/chef/resource/subversion.rb b/lib/chef/resource/subversion.rb
index 59f7cd73fd..b093ad3097 100644
--- a/lib/chef/resource/subversion.rb
+++ b/lib/chef/resource/subversion.rb
@@ -31,7 +31,6 @@ class Chef
super
@svn_arguments = "--no-auth-cache"
@svn_info_args = "--no-auth-cache"
- @svn_binary = nil
end
# Override exception to strip password if any, so it won't appear in logs and different Chef notifications
@@ -39,9 +38,7 @@ class Chef
"#{self} (#{defined_at}) had an error: #{e.class.name}: #{svn_password ? e.message.gsub(svn_password, "[hidden_password]") : e.message}"
end
- def svn_binary(arg = nil)
- set_or_return(:svn_binary, arg, :kind_of => [String])
- end
+ property :svn_binary, String
end
end
end
diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb
index 59e8a76937..c722bf493c 100644
--- a/lib/chef/resource/template.rb
+++ b/lib/chef/resource/template.rb
@@ -44,9 +44,6 @@ class Chef
def initialize(name, run_context = nil)
super
@source = "#{::File.basename(name)}.erb"
- @cookbook = nil
- @local = false
- @variables = Hash.new
@inline_helper_blocks = {}
@inline_helper_modules = []
@helper_modules = []
@@ -60,29 +57,9 @@ class Chef
)
end
- def variables(args = nil)
- set_or_return(
- :variables,
- args,
- :kind_of => [ Hash ]
- )
- end
-
- def cookbook(args = nil)
- set_or_return(
- :cookbook,
- args,
- :kind_of => [ String ]
- )
- end
-
- def local(args = nil)
- set_or_return(
- :local,
- args,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
+ property :variables, Hash, default: {}
+ property :cookbook, String
+ property :local, [ TrueClass, FalseClass ], default: false
# Declares a helper method to be defined in the template context when
# rendering.