File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -267,6 +267,7 @@ def configure_chef
267267 Chef ::Config [ :node_name ] = config [ :node_name ] if config [ :node_name ]
268268 Chef ::Config [ :client_key ] = config [ :client_key ] if config [ :client_key ]
269269 Chef ::Config [ :chef_server_url ] = config [ :chef_server_url ] if config [ :chef_server_url ]
270+ Chef ::Config [ :environment ] = config [ :environment ] if config [ :environment ]
270271 Mixlib ::Log ::Formatter . show_time = false
271272 Chef ::Log . init ( Chef ::Config [ :log_location ] )
272273 Chef ::Log . level ( Chef ::Config [ :log_level ] )
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ class CookbookList < Knife
3131 :description => "Show corresponding URIs"
3232
3333 def run
34- env = config [ :environment ]
34+ env = Chef :: Config [ :environment ]
3535 api_endpoint = env ? "/environments/#{ env } /cookbooks" : "/cookbooks/_latest"
3636 output ( format_cookbooks_for_display ( rest . get_rest ( api_endpoint ) ) )
3737 end
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ class NodeList < Knife
3232 :description => "Show corresponding URIs"
3333
3434 def run
35- output ( format_list_for_display ( config [ :environment ] ? Chef ::Node . list_by_environment ( config [ :environment ] ) : Chef ::Node . list ) )
35+ env = Chef ::Config [ :environment ]
36+ output ( format_list_for_display ( env ? Chef ::Node . list_by_environment ( env ) : Chef ::Node . list ) )
3637 end
3738
3839 end
Original file line number Diff line number Diff line change 5050 end
5151
5252 describe "with environment configuration" do
53- it "should default to the 'default' environment" do
53+ it "should default to no environment" do
5454 with_argv ( *%w{ test yourself } ) do
5555 @knife . should_receive ( :exit ) . with ( 0 )
5656 @knife . run
5757 end
58- Chef ::Config [ :environment ] . should == 'default'
58+ Chef ::Config [ :environment ] . should == nil
5959 end
6060
6161 it "should load the environment from the config file" do
Original file line number Diff line number Diff line change 2121describe Chef ::Knife ::NodeList do
2222 before ( :each ) do
2323 Chef ::Config [ :node_name ] = "webmonkey.example.com"
24+ Chef ::Config [ :environment ] = nil # reset this value each time, as it is not reloaded
2425 @knife = Chef ::Knife ::NodeList . new
2526 @knife . stub! ( :output ) . and_return ( true )
2627 @list = {
4445 end
4546
4647 it "should list nodes in the specific environment if -E ENVIRONMENT is specified" do
47- @knife . config = { : environment => "prod" }
48+ Chef :: Config [ : environment] = "prod"
4849 Chef ::Node . should_receive ( :list_by_environment ) . with ( "prod" ) . and_return ( @list )
4950 @knife . run
5051 end
You can’t perform that action at this time.
0 commit comments