summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-17 19:03:47 -0700
committerTim Smith <tsmith@chef.io>2018-03-19 15:27:56 -0700
commit6d55193a85fbce552fc51cd71c21ef44093f3a52 (patch)
treeda8409a3191ae8ee3dc468c05934e35d1a6d4fbb
parent4e6c7972620e68753946abe109895762a6301efd (diff)
downloadchef-6d55193a85fbce552fc51cd71c21ef44093f3a52.tar.gz
Add more resource descriptions and convert more resources to use propertiesminor_resource_cleanup
More minor cleanup Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/link.rb20
-rw-r--r--lib/chef/resource/log.rb14
-rw-r--r--lib/chef/resource/ohai.rb2
-rw-r--r--lib/chef/resource/ohai_hint.rb3
-rw-r--r--lib/chef/resource/package.rb14
-rw-r--r--lib/chef/resource/perl.rb10
-rw-r--r--lib/chef/resource/remote_file.rb53
-rw-r--r--lib/chef/resource/sudo.rb1
8 files changed, 38 insertions, 79 deletions
diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb
index b3f8819d2b..c4ab1e0a75 100644
--- a/lib/chef/resource/link.rb
+++ b/lib/chef/resource/link.rb
@@ -22,21 +22,21 @@ require "chef/mixin/securable"
class Chef
class Resource
- # Use the link resource to create symbolic or hard links.
- #
- # A symbolic link—sometimes referred to as a soft link—is a directory entry that associates a file name with a string
- # that contains an absolute or relative path to a file on any file system. In other words, “a file that contains a path
- # that points to another file.” A symbolic link creates a new file with a new inode that points to the inode location
- # of the original file.
- #
- # A hard link is a directory entry that associates a file with another file in the same file system. In other words,
- # “multiple directory entries to the same file.” A hard link creates a new file that points to the same inode as the
- # original file.
class Link < Chef::Resource
include Chef::Mixin::Securable
resource_name :link
provides :link
+ description "Use the link resource to create symbolic or hard links.\n\n"\
+ "A symbolic link—sometimes referred to as a soft link—is a directory entry"\
+ " that associates a file name with a string that contains an absolute or"\
+ " relative path to a file on any file system. In other words, “a file that"\
+ " contains a path that points to another file.” A symbolic link creates a new"\
+ " file with a new inode that points to the inode location of the original file.\n\n"\
+ "A hard link is a directory entry that associates a file with another file in the"\
+ " same file system. In other words, “multiple directory entries to the same file.”"\
+ " A hard link creates a new file that points to the same inode as the original file."
+
state_attrs :owner # required since it's not a property below
default_action :create
diff --git a/lib/chef/resource/log.rb b/lib/chef/resource/log.rb
index 66c8e820f4..a9dea6b104 100644
--- a/lib/chef/resource/log.rb
+++ b/lib/chef/resource/log.rb
@@ -21,13 +21,6 @@ require "chef/resource"
class Chef
class Resource
- # Use the log resource to create log entries. The log resource behaves like any other resource: built into the resource
- # collection during the compile phase, and then run during the execution phase. (To create a log entry that is not built
- # into the resource collection, use Chef::Log instead of the log resource.)
- #
- # Allows logging a :debug, :info, :warn, and :error levels
- # Defaults to :info level
- #
# @example logging at default info level
# log "your string to log"
#
@@ -35,10 +28,15 @@ class Chef
# log "a debug string" do
# level :debug
# end
- #
class Log < Chef::Resource
resource_name :log
+ description "Use the log resource to create log entries. The log resource behaves"\
+ " like any other resource: built into the resource collection during the"\
+ " compile phase, and then run during the execution phase. (To create a log"\
+ " entry that is not built into the resource collection, use Chef::Log instead"\
+ " of the log resource.)"
+
property :message, String, name_property: true, identity: true
property :level, Symbol, equal_to: [ :debug, :info, :warn, :error, :fatal ], default: :info
diff --git a/lib/chef/resource/ohai.rb b/lib/chef/resource/ohai.rb
index b506d511ba..a84d521333 100644
--- a/lib/chef/resource/ohai.rb
+++ b/lib/chef/resource/ohai.rb
@@ -28,7 +28,7 @@ class Chef
" that adds a user) to refer to those attributes later on during the chef-client run."
property :ohai_name, name_property: true
- property :plugin, [String]
+ property :plugin, String
default_action :reload
allowed_actions :reload
diff --git a/lib/chef/resource/ohai_hint.rb b/lib/chef/resource/ohai_hint.rb
index 90755300ca..e40eee6daf 100644
--- a/lib/chef/resource/ohai_hint.rb
+++ b/lib/chef/resource/ohai_hint.rb
@@ -31,8 +31,7 @@ class Chef
property :content, Hash,
description: "Values to include in the hint file."
- property :compile_time,
- [TrueClass, FalseClass],
+ property :compile_time, [TrueClass, FalseClass],
description: "Should the resource execute during the compile time phase",
default: true
diff --git a/lib/chef/resource/package.rb b/lib/chef/resource/package.rb
index 60810fd5ad..8362dde47e 100644
--- a/lib/chef/resource/package.rb
+++ b/lib/chef/resource/package.rb
@@ -21,15 +21,17 @@ require "chef/resource"
class Chef
class Resource
- # Use the package resource to manage packages. When the package is installed from a local file (such as with RubyGems,
- # dpkg, or RPM Package Manager), the file must be added to the node using the remote_file or cookbook_file resources.
- #
- # This resource is the base resource for several other resources used for package management on specific platforms.
- # While it is possible to use each of these specific resources, it is recommended to use the package resource as often
- # as possible.
class Package < Chef::Resource
resource_name :package
+ description "Use the package resource to manage packages. When the package is"\
+ " installed from a local file (such as with RubyGems, dpkg, or RPM"\
+ " Package Manager), the file must be added to the node using the remote_file"\
+ " or cookbook_file resources.\n\nThis resource is the base resource for"\
+ " several other resources used for package management on specific platforms."\
+ " While it is possible to use each of these specific resources, it is"\
+ " recommended to use the package resource as often as possible."
+
default_action :install
allowed_actions :install, :upgrade, :remove, :purge, :reconfig, :lock, :unlock
diff --git a/lib/chef/resource/perl.rb b/lib/chef/resource/perl.rb
index c00246ac6b..f3079eb40e 100644
--- a/lib/chef/resource/perl.rb
+++ b/lib/chef/resource/perl.rb
@@ -21,16 +21,18 @@ require "chef/provider/script"
class Chef
class Resource
- # Use the perl resource to execute scripts using the Perl interpreter. This resource may also use any of the actions
- # and properties that are available to the execute resource. 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. Use not_if and
- # only_if to guard this resource for idempotence.
class Perl < Chef::Resource::Script
def initialize(name, run_context = nil)
super
@interpreter = "perl"
end
+ description "Use the perl resource to execute scripts using the Perl interpreter."\
+ " This resource may also use any of the actions and properties that are"\
+ " available to the execute resource. 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. Use not_if and only_if"\
+ " to guard this resource for idempotence."
end
end
end
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index 7aaff890ef..832fd3568e 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -34,10 +34,6 @@ class Chef
def initialize(name, run_context = nil)
super
@source = []
- @use_etag = true
- @use_last_modified = true
- @ftp_active_mode = false
- @headers = {}
end
# source can take any of the following as arguments
@@ -74,13 +70,7 @@ class Chef
end
end
- def checksum(args = nil)
- set_or_return(
- :checksum,
- args,
- :kind_of => String
- )
- end
+ property :checksum, String
# Disable or enable ETag and Last Modified conditional GET. Equivalent to
# use_etag(true_or_false)
@@ -90,48 +80,17 @@ class Chef
use_last_modified(true_or_false)
end
- def use_etag(args = nil)
- set_or_return(
- :use_etag,
- args,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
+ property :use_etag, [ TrueClass, FalseClass ], default: true
alias :use_etags :use_etag
- def use_last_modified(args = nil)
- set_or_return(
- :use_last_modified,
- args,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
+ property :use_last_modified, [ TrueClass, FalseClass ], default: true
- def ftp_active_mode(args = nil)
- set_or_return(
- :ftp_active_mode,
- args,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
+ property :ftp_active_mode, [ TrueClass, FalseClass ], default: false
- def headers(args = nil)
- set_or_return(
- :headers,
- args,
- :kind_of => Hash
- )
- end
+ property :headers, Hash, default: lazy { Hash.new }
- def show_progress(args = nil)
- set_or_return(
- :show_progress,
- args,
- :default => false,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
+ property :show_progress, [ TrueClass, FalseClass ], default: false
property :remote_user, String
diff --git a/lib/chef/resource/sudo.rb b/lib/chef/resource/sudo.rb
index 01318c0ca3..d9d61338a8 100644
--- a/lib/chef/resource/sudo.rb
+++ b/lib/chef/resource/sudo.rb
@@ -32,7 +32,6 @@ class Chef
" '#includedir' directive introduced in version 1.7.2. The resource does not enforce"\
" installing the version. Supported releases of Ubuntu, Debian and RHEL (6+) all support"\
" this feature."
-
introduced "14.0"
# acording to the sudo man pages sudo will ignore files in an include dir that have a `.` or `~`