diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-15 20:58:35 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-15 20:58:35 -0700 |
commit | 3d4827a9a01acfedc0748fec088b9cf0650d6c9d (patch) | |
tree | c558e3503e8c5cdad290fca69b7eb0a1f418ded7 | |
parent | 940f27de6acaca411ed349b77f45254f887224f3 (diff) | |
download | chef-3d4827a9a01acfedc0748fec088b9cf0650d6c9d.tar.gz |
normalize fetch_recipe_tarball
this makes solo behave like client does.
client was modified in these pulls:
https://github.com/chef/chef/pull/7223
https://github.com/chef/chef/pull/7523
but those changes were never "ported" to solo.
-rw-r--r-- | lib/chef/application/base.rb | 15 | ||||
-rw-r--r-- | lib/chef/application/client.rb | 16 | ||||
-rw-r--r-- | lib/chef/application/solo.rb | 9 |
3 files changed, 15 insertions, 25 deletions
diff --git a/lib/chef/application/base.rb b/lib/chef/application/base.rb index 6eddbe1864..a40a257610 100644 --- a/lib/chef/application/base.rb +++ b/lib/chef/application/base.rb @@ -191,4 +191,19 @@ class Chef::Application::Base < Chef::Application "\nEnable #{Chef::Dist::CLIENT} interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options." end + def fetch_recipe_tarball(url, path) + Chef::Log.trace("Download recipes tarball from #{url} to #{path}") + if File.exist?(url) + FileUtils.cp(url, path) + elsif url =~ URI.regexp + File.open(path, "wb") do |f| + open(url) do |r| + f.write(r.read) + end + end + else + Chef::Application.fatal! "You specified --recipe-url but the value is neither a valid URL nor a path to a file that exists on disk." + + "Please confirm the location of the tarball and try again." + end + end end diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index e8a5242aac..4355c0f04b 100644 --- a/lib/chef/application/client.rb +++ b/lib/chef/application/client.rb @@ -356,20 +356,4 @@ class Chef::Application::Client < Chef::Application::Base sleep(sec) end end - - def fetch_recipe_tarball(url, path) - Chef::Log.trace("Download recipes tarball from #{url} to #{path}") - if File.exist?(url) - FileUtils.cp(url, path) - elsif url =~ URI.regexp - File.open(path, "wb") do |f| - open(url) do |r| - f.write(r.read) - end - end - else - Chef::Application.fatal! "You specified --recipe-url but the value is neither a valid URL nor a path to a file that exists on disk." + - "Please confirm the location of the tarball and try again." - end - end end diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb index 099fb46834..caaa1e832e 100644 --- a/lib/chef/application/solo.rb +++ b/lib/chef/application/solo.rb @@ -194,13 +194,4 @@ class Chef::Application::Solo < Chef::Application::Base end end end - - def fetch_recipe_tarball(url, path) - Chef::Log.trace("Download recipes tarball from #{url} to #{path}") - File.open(path, "wb") do |f| - open(url) do |r| - f.write(r.read) - end - end - end end |