Sha256: 145d7d1bc5ce76865d2ccc5a5685690459857f68169f56ca1edb213f23be3bb8

Contents?: true

Size: 1.63 KB

Versions: 94

Compression:

Stored size: 1.63 KB

Contents

require "chef/knife"
require "chef/local_mode"

class Chef
  class Knife
    class Serve < Knife

      banner "knife serve (options)"

      option :repo_mode,
        :long => "--repo-mode MODE",
        :description => "Specifies the local repository layout. Values: static (only environments/roles/data_bags/cookbooks), everything (includes nodes/clients/users), hosted_everything (includes acls/groups/etc. for Enterprise/Hosted Chef). Default: everything/hosted_everything"

      option :chef_repo_path,
        :long => "--chef-repo-path PATH",
        :description => "Overrides the location of chef repo. Default is specified by chef_repo_path in the config"

      option :chef_zero_host,
        :long => "--chef-zero-host IP",
        :description => "Overrides the host upon which chef-zero listens. Default is 127.0.0.1."

      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

      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
    end
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
chef-13.12.14 lib/chef/knife/serve.rb
chef-13.12.3 lib/chef/knife/serve.rb
chef-13.11.3 lib/chef/knife/serve.rb
chef-13.10.4 lib/chef/knife/serve.rb
chef-13.10.0 lib/chef/knife/serve.rb
chef-13.9.4 lib/chef/knife/serve.rb
chef-14.2.0 lib/chef/knife/serve.rb
chef-12.22.5 lib/chef/knife/serve.rb
chef-12.22.5-universal-mingw32 lib/chef/knife/serve.rb
chef-14.1.12 lib/chef/knife/serve.rb
chef-14.1.1 lib/chef/knife/serve.rb
chef-13.9.1 lib/chef/knife/serve.rb
chef-14.0.202-universal-mingw32 lib/chef/knife/serve.rb
chef-14.0.202 lib/chef/knife/serve.rb
chef-12.22.3 lib/chef/knife/serve.rb
chef-12.22.3-universal-mingw32 lib/chef/knife/serve.rb
chef-14.0.190 lib/chef/knife/serve.rb
chef-13.8.5 lib/chef/knife/serve.rb
chef-13.8.3 lib/chef/knife/serve.rb
chef-13.8.0 lib/chef/knife/serve.rb