diff options
author | David Calavera <david.calavera@gmail.com> | 2011-12-27 09:49:11 -0800 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2012-01-23 09:12:38 -0800 |
commit | e1509990b559984b43e428d4d801c394e970f432 (patch) | |
tree | 74cc8b231c8e292062cde51934b530a58b41f524 | |
parent | 0db66b1127621af8022509f1f3350c4ca78900d7 (diff) | |
download | chef-e1509990b559984b43e428d4d801c394e970f432.tar.gz |
modify log keys to work with the new mixlib-shellout
-rw-r--r-- | chef/lib/chef/provider/deploy.rb | 8 | ||||
-rw-r--r-- | chef/lib/chef/provider/execute.rb | 4 | ||||
-rw-r--r-- | chef/lib/chef/provider/git.rb | 12 | ||||
-rw-r--r-- | chef/spec/unit/provider/deploy_spec.rb | 6 | ||||
-rw-r--r-- | chef/spec/unit/provider/git_spec.rb | 22 |
5 files changed, 26 insertions, 26 deletions
diff --git a/chef/lib/chef/provider/deploy.rb b/chef/lib/chef/provider/deploy.rb index 7e7ba5a8d2..db613d1021 100644 --- a/chef/lib/chef/provider/deploy.rb +++ b/chef/lib/chef/provider/deploy.rb @@ -170,7 +170,7 @@ class Chef end.join(" ") Chef::Log.info "#{@new_resource} migrating #{@new_resource.user} with environment #{env_info}" - run_command(run_options(:command => @new_resource.migration_command, :cwd=>release_path, :command_log_level => :info)) + run_command(run_options(:command => @new_resource.migration_command, :cwd=>release_path, :log_level => :info)) end end @@ -338,9 +338,9 @@ class Chef run_opts[:user] = @new_resource.user if @new_resource.user run_opts[:group] = @new_resource.group if @new_resource.group run_opts[:environment] = @new_resource.environment if @new_resource.environment - run_opts[:command_log_prepend] = @new_resource.to_s - run_opts[:command_log_level] ||= :debug - if run_opts[:command_log_level] == :info + run_opts[:log_tag] = @new_resource.to_s + run_opts[:log_level] ||= :debug + if run_opts[:log_level] == :info if STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.info? run_opts[:live_stream] = STDOUT end diff --git a/chef/lib/chef/provider/execute.rb b/chef/lib/chef/provider/execute.rb index fde4f965e5..da2fe7f580 100644 --- a/chef/lib/chef/provider/execute.rb +++ b/chef/lib/chef/provider/execute.rb @@ -49,8 +49,8 @@ class Chef opts[:group] = @new_resource.group if @new_resource.group opts[:cwd] = @new_resource.cwd if @new_resource.cwd opts[:umask] = @new_resource.umask if @new_resource.umask - opts[:command_log_level] = :info - opts[:command_log_prepend] = @new_resource.to_s + opts[:log_level] = :info + opts[:log_tag] = @new_resource.to_s if STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.info? opts[:live_stream] = STDOUT end diff --git a/chef/lib/chef/provider/git.rb b/chef/lib/chef/provider/git.rb index 126ea324cb..1b176085da 100644 --- a/chef/lib/chef/provider/git.rb +++ b/chef/lib/chef/provider/git.rb @@ -104,7 +104,7 @@ class Chef @new_resource.additional_remotes.each_pair do |remote_name, remote_url| Chef::Log.info "#{@new_resource} adding git remote #{remote_name} = #{remote_url}" command = "git remote add #{remote_name} #{remote_url}" - if shell_out(command, run_options(:cwd => @new_resource.destination, :command_log_level => :info)).exitstatus != 0 + if shell_out(command, run_options(:cwd => @new_resource.destination, :log_level => :info)).exitstatus != 0 @new_resource.updated_by_last_action(true) end end @@ -121,7 +121,7 @@ class Chef Chef::Log.info "#{@new_resource} cloning repo #{@new_resource.repository} to #{@new_resource.destination}" clone_cmd = "git clone #{args.join(' ')} #{@new_resource.repository} #{@new_resource.destination}" - shell_out!(clone_cmd, run_options(:command_log_level => :info)) + shell_out!(clone_cmd, run_options(:log_level => :info)) end def checkout @@ -135,7 +135,7 @@ class Chef if @new_resource.enable_submodules Chef::Log.info "#{@new_resource} enabling git submodules" command = "git submodule init && git submodule update" - shell_out!(command, run_options(:cwd => @new_resource.destination, :command_log_level => :info)) + shell_out!(command, run_options(:cwd => @new_resource.destination, :log_level => :info)) end end @@ -195,9 +195,9 @@ class Chef run_opts[:user] = @new_resource.user if @new_resource.user run_opts[:group] = @new_resource.group if @new_resource.group run_opts[:environment] = {"GIT_SSH" => @new_resource.ssh_wrapper} if @new_resource.ssh_wrapper - run_opts[:command_log_prepend] = @new_resource.to_s - run_opts[:command_log_level] ||= :debug - if run_opts[:command_log_level] == :info + run_opts[:log_tag] = @new_resource.to_s + run_opts[:log_level] ||= :debug + if run_opts[:log_level] == :info if STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.info? run_opts[:live_stream] = STDOUT end diff --git a/chef/spec/unit/provider/deploy_spec.rb b/chef/spec/unit/provider/deploy_spec.rb index b05d76472c..acdeb648fc 100644 --- a/chef/spec/unit/provider/deploy_spec.rb +++ b/chef/spec/unit/provider/deploy_spec.rb @@ -283,8 +283,8 @@ describe Chef::Provider::Deploy do STDOUT.stub!(:tty?).and_return(true) @provider.should_receive(:run_command).with(:command => "migration_foo", :cwd => @expected_release_dir, :user => "deployNinja", :group => "deployNinjas", - :command_log_level => :info, :live_stream => STDOUT, - :command_log_prepend => "deploy[/my/deploy/dir]", + :log_level => :info, :live_stream => STDOUT, + :log_tag => "deploy[/my/deploy/dir]", :environment => {"RAILS_ENV"=>"production"}) @provider.migrate end @@ -354,7 +354,7 @@ describe Chef::Provider::Deploy do it "runs the restart command in the current application dir when the resource has a restart_command" do @resource.restart_command "restartcmd" - @provider.should_receive(:run_command).with(:command => "restartcmd", :cwd => "/my/deploy/dir/current", :command_log_prepend => "deploy[/my/deploy/dir]", :command_log_level => :debug) + @provider.should_receive(:run_command).with(:command => "restartcmd", :cwd => "/my/deploy/dir/current", :log_tag => "deploy[/my/deploy/dir]", :log_level => :debug) @provider.restart end diff --git a/chef/spec/unit/provider/git_spec.rb b/chef/spec/unit/provider/git_spec.rb index 62168412a9..1f92bf53ff 100644 --- a/chef/spec/unit/provider/git_spec.rb +++ b/chef/spec/unit/provider/git_spec.rb @@ -90,7 +90,7 @@ describe Chef::Provider::Git do it "converts resource.revision from a tag to a SHA" do @resource.revision "v1.0" @stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" - @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0", {:command_log_prepend=>"git[web2.0 app]", :command_log_level=>:debug}).and_return(mock("ShellOut result", :stdout => @stdout)) + @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0", {:log_tag=>"git[web2.0 app]", :log_level=>:debug}).and_return(mock("ShellOut result", :stdout => @stdout)) @provider.target_revision.should eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -123,7 +123,7 @@ b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{} ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package SHAS @resource.revision '' - @provider.should_receive(:shell_out!).with(@git_ls_remote, {:command_log_prepend=>"git[web2.0 app]", :command_log_level=>:debug}).and_return(mock("ShellOut result", :stdout => @stdout)) + @provider.should_receive(:shell_out!).with(@git_ls_remote, {:log_tag=>"git[web2.0 app]", :log_level=>:debug}).and_return(mock("ShellOut result", :stdout => @stdout)) @provider.target_revision.should eql("28af684d8460ba4793eda3e7ac238c864a5d029a") end end @@ -137,34 +137,34 @@ SHAS @resource.ssh_wrapper "do_it_this_way.sh" expected_cmd = 'git clone git://github.com/opscode/chef.git /my/deploy/dir' @provider.should_receive(:shell_out!).with(expected_cmd, :user => "deployNinja", - :environment =>{"GIT_SSH"=>"do_it_this_way.sh"}, :command_log_level => :info, :command_log_prepend => "git[web2.0 app]", :live_stream => STDOUT) + :environment =>{"GIT_SSH"=>"do_it_this_way.sh"}, :log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT) @provider.clone end it "compiles a clone command using --depth for shallow cloning" do @resource.depth 5 expected_cmd = 'git clone --depth 5 git://github.com/opscode/chef.git /my/deploy/dir' - @provider.should_receive(:shell_out!).with(expected_cmd, {:command_log_level => :info, :command_log_prepend => "git[web2.0 app]", :live_stream => STDOUT}) + @provider.should_receive(:shell_out!).with(expected_cmd, {:log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT}) @provider.clone end it "compiles a clone command with a remote other than ``origin''" do @resource.remote "opscode" expected_cmd = 'git clone -o opscode git://github.com/opscode/chef.git /my/deploy/dir' - @provider.should_receive(:shell_out!).with(expected_cmd, {:command_log_level => :info, :command_log_prepend => "git[web2.0 app]", :live_stream => STDOUT}) + @provider.should_receive(:shell_out!).with(expected_cmd, {:log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT}) @provider.clone end it "runs a checkout command with default options" do expected_cmd = 'git checkout -b deploy d35af14d41ae22b19da05d7d03a0bafc321b244c' - @provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :command_log_level => :debug, :command_log_prepend => "git[web2.0 app]") + @provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_level => :debug, :log_tag => "git[web2.0 app]") @provider.checkout end it "runs an enable_submodule command" do @resource.enable_submodules true expected_cmd = "git submodule init && git submodule update" - @provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :command_log_level => :info, :command_log_prepend => "git[web2.0 app]", :live_stream => STDOUT) + @provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT) @provider.enable_submodules end @@ -175,7 +175,7 @@ SHAS it "runs a sync command with default options" do expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - @provider.should_receive(:shell_out!).with(expected_cmd, :cwd=> "/my/deploy/dir", :command_log_level => :debug, :command_log_prepend => "git[web2.0 app]") + @provider.should_receive(:shell_out!).with(expected_cmd, :cwd=> "/my/deploy/dir", :log_level => :debug, :log_tag => "git[web2.0 app]") @provider.fetch_updates end @@ -184,7 +184,7 @@ SHAS @resource.group("thisis") expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" @provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", - :user => "whois", :group => "thisis", :command_log_level => :debug, :command_log_prepend => "git[web2.0 app]") + :user => "whois", :group => "thisis", :log_level => :debug, :log_tag => "git[web2.0 app]") @provider.fetch_updates end @@ -192,9 +192,9 @@ SHAS @resource.remote "opscode" conf_tracking_branches = "git config remote.opscode.url git://github.com/opscode/chef.git && " + "git config remote.opscode.fetch +refs/heads/*:refs/remotes/opscode/*" - @provider.should_receive(:shell_out!).with(conf_tracking_branches, :cwd => "/my/deploy/dir", :command_log_prepend => "git[web2.0 app]", :command_log_level => :debug) + @provider.should_receive(:shell_out!).with(conf_tracking_branches, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]", :log_level => :debug) fetch_command = "git fetch opscode && git fetch opscode --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - @provider.should_receive(:shell_out!).with(fetch_command, :cwd => "/my/deploy/dir", :command_log_level => :debug, :command_log_prepend => "git[web2.0 app]") + @provider.should_receive(:shell_out!).with(fetch_command, :cwd => "/my/deploy/dir", :log_level => :debug, :log_tag => "git[web2.0 app]") @provider.fetch_updates end |