diff options
author | John Keiser <jkeiser@opscode.com> | 2013-06-07 08:54:15 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-06-07 13:12:37 -0700 |
commit | bfad4ea7f7dd2925520386c197b2c76c5ddd6d2a (patch) | |
tree | c6807b173f27b8f4c3cad1cf6e9678ce91ca6095 | |
parent | 378a590876d82695655f7239cd74bbc3b026aa02 (diff) | |
download | chef-bfad4ea7f7dd2925520386c197b2c76c5ddd6d2a.tar.gz |
Allow knife remote commands to work when chef_repo_path is not specified
-rw-r--r-- | lib/chef/chef_fs/config.rb | 20 | ||||
-rw-r--r-- | lib/chef/chef_fs/knife.rb | 2 |
2 files changed, 17 insertions, 5 deletions
diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb index 71a32f91eb..ab4cea89f2 100644 --- a/lib/chef/chef_fs/config.rb +++ b/lib/chef/chef_fs/config.rb @@ -101,7 +101,13 @@ class Chef # The current directory, relative to server root def base_path - @base_path ||= server_path(File.expand_path(@cwd)) + @base_path ||= begin + if @chef_config[:chef_repo_path] + server_path(File.expand_path(@cwd)) + else + nil + end + end end # Print the given server path, relative to the current directory @@ -119,14 +125,18 @@ class Chef server_path end + def require_chef_repo_path + if !@chef_config[:chef_repo_path] + Chef::Log.error("Must specify either chef_repo_path or cookbook_path in Chef config file") + exit(1) + end + end + private def object_paths @object_paths ||= begin - if !@chef_config[:chef_repo_path] - Chef::Log.error("Must specify either chef_repo_path or cookbook_path in Chef config file") - exit(1) - end + require_chef_repo_path result = {} case @chef_config[:repo_mode] diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb index ce621d2231..5900c29f61 100644 --- a/lib/chef/chef_fs/knife.rb +++ b/lib/chef/chef_fs/knife.rb @@ -95,6 +95,8 @@ class Chef # Could be super useful in a world with multiple repo paths args.map do |arg| if !@chef_fs_config.base_path && !Chef::ChefFS::PathUtils.is_absolute?(arg) + # Check if chef repo path is specified to give a better error message + @chef_fs_config.require_chef_repo_path ui.error("Attempt to use relative path '#{arg}' when current directory is outside the repository path") exit(1) end |