Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Parse Chef version even if chef-solo command prints warnings #238

Merged
merged 1 commit into from
May 3, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/chef/knife/solo_cook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ def check_chef_version

# Parses "Chef: x.y.z" from the chef-solo version output
def chef_version
v = run_command('sudo chef-solo --version').stdout.split(':')
v[0].strip == 'Chef' ? v[1].strip : ''
cmd = %q{sudo chef-solo --version 2>/dev/null | awk '$1 == "Chef:" {print $2}'}
run_command(cmd).stdout.strip
end

def cook
Expand Down
7 changes: 0 additions & 7 deletions test/solo_cook_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,6 @@ def test_barks_if_chef_not_found
end
end

def test_parses_chef_version_output
version_string = "\r\nChef: 11.2.0\r\n"
cmd = command("somehost")
cmd.stubs(:run_command).returns(OpenStruct.new(:stdout => version_string))
assert_equal '11.2.0', cmd.chef_version
end

def test_barks_if_chef_too_old
in_kitchen do
cmd = command("somehost")
Expand Down