summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-09-22 16:37:46 -0700
committerTim Smith <tsmith@chef.io>2021-09-22 16:37:46 -0700
commit78c57973e8a8ae304abb28d2bacf3b4b7366dcca (patch)
tree297934e888e50ce6239a81d0f2df96be8da0d9e3
parentc3edd1914486c41b845781a32a0a4d45625a81d4 (diff)
downloadchef-78c57973e8a8ae304abb28d2bacf3b4b7366dcca.tar.gz
Add additional documentation to remote_file
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/remote_file.rb40
1 files changed, 35 insertions, 5 deletions
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index 774ca25af4..80fe86df0c 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -35,7 +35,7 @@ class Chef
description "Use the **remote_file** resource to transfer a file from a remote location using file specificity. This resource is similar to the **file** resource. Note: Fetching files from the `files/` directory in a cookbook should be done with the **cookbook_file** resource."
examples <<~DOC
- **Download a file from an http server**:
+ **Download a file without checking the checksum**:
```ruby
remote_file '/tmp/remote.txt' do
@@ -43,7 +43,17 @@ class Chef
end
```
- **Set Chef::HTTP options and configure the Net::HTTP object**
+ **Download a file with a checksum to validate**:
+
+ ```ruby
+ remote_file '/tmp/testfile' do
+ source 'http://www.example.com/tempfiles/testfile'
+ mode '0755'
+ checksum '3a7dac00b1' # A SHA256 (or portion thereof) of the file.
+ end
+ ```
+
+ **Specify advanced http connection options including Net::HTTP (nethttp) options**
```ruby
remote_file '/tmp/remote.txt' do
@@ -126,9 +136,29 @@ class Chef
description: "Whether #{ChefUtils::Dist::Infra::PRODUCT} uses active or passive FTP. Set to `true` to use active FTP."
property :headers, Hash, default: {},
- description: "A Hash of custom HTTP headers."
-
- property :show_progress, [ TrueClass, FalseClass ], default: false
+ description: <<~'DOCS'
+ A Hash of custom headers. For example:
+
+ ```ruby
+ headers({ "Cookie" => "user=grantmc; pass=p@ssw0rd!" })
+ ```
+
+ or:
+
+ ```ruby
+ headers({ "Referer" => "#{header}" })
+ ```
+
+ or:
+
+ ```ruby
+ headers( "Authorization"=>"Basic #{ Base64.encode64("#{username}:#{password}").gsub("\n", "") }" )
+ ```
+ DOCS
+
+ property :show_progress, [ TrueClass, FalseClass ],
+ description: "Displays the progress of the file download.",
+ default: false
property :ssl_verify_mode, Symbol, equal_to: %i{verify_none verify_peer},
introduced: "16.2",