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

Commit

Permalink
Merge pull request #238 from tmatilai/chef-version-check
Browse files Browse the repository at this point in the history
Parse Chef version even if chef-solo command prints warnings
  • Loading branch information
tmatilai committed May 3, 2013
2 parents e92f970 + f09cbac commit e9572f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
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

0 comments on commit e9572f2

Please sign in to comment.