Class: Chef::Knife::Serve

Inherits:
Knife
  • Object
show all
Defined in:
lib/chef/knife/serve.rb

Instance Method Summary collapse

Instance Method Details

#configure_chefObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/chef/knife/serve.rb', line 39

def configure_chef
  super
  Chef::Config.local_mode = true
  Chef::Config[:repo_mode] = config[:repo_mode] if config[:repo_mode]

  # --chef-repo-path forcibly overrides all other paths
  if config[:chef_repo_path]
    Chef::Config.chef_repo_path = config[:chef_repo_path]
    %w{acl client cookbook container data_bag environment group node role user}.each do |variable_name|
      Chef::Config.delete("#{variable_name}_path".to_sym)
    end
  end
end

#runObject



53
54
55
56
57
58
59
60
61
62
# File 'lib/chef/knife/serve.rb', line 53

def run
  server = Chef::LocalMode.chef_zero_server
  begin
    output "Serving files from:\n#{Chef::LocalMode.chef_fs.fs_description}"
    server.stop
    server.start(stdout) # to print header
  ensure
    server.stop
  end
end