lib/chef-dk/command/install.rb in chef-dk-0.7.0 vs lib/chef-dk/command/install.rb in chef-dk-0.8.0
- old
+ new
@@ -16,35 +16,42 @@
#
require 'chef-dk/command/base'
require 'chef-dk/ui'
require 'chef-dk/policyfile_services/install'
+require 'chef-dk/configurable'
module ChefDK
module Command
class Install < Base
+ include Configurable
+
banner(<<-E)
Usage: chef install [ POLICY_FILE ] [options]
`chef install` evaluates a `Policyfile.rb` to find a compatible set of
cookbooks for the policy's run_list and caches them locally. It emits a
Policyfile.lock.json describing the locked cookbook set. You can use the
lockfile to install the locked cookbooks on another machine. You can also push
the lockfile to a "policy group" on a Chef Server and apply that exact set of
cookbooks to nodes in your infrastructure.
-The Policyfile feature is incomplete and beta quality. See our detailed README
-for more information.
+See our detailed README for more information:
https://github.com/opscode/chef-dk/blob/master/POLICYFILE_README.md
Options:
E
+ option :config_file,
+ short: "-c CONFIG_FILE",
+ long: "--config CONFIG_FILE",
+ description: "Path to configuration file"
+
option :debug,
short: "-D",
long: "--debug",
description: "Enable stacktraces and other debug output",
default: false
@@ -60,11 +67,16 @@
@policyfile_relative_path = nil
@installer = nil
end
def run(params = [])
- apply_params!(params)
+ return 1 unless apply_params!(params)
+ # Force config file to be loaded. We don't use the configuration
+ # directly, but the user may have SSL configuration options that they
+ # need to talk to a private supermarket (e.g., trusted_certs or
+ # ssl_verify_mode)
+ chef_config
installer.run
0
rescue PolicyfileServiceError => e
handle_error(e)
1
@@ -76,10 +88,14 @@
def debug?
!!config[:debug]
end
+ def config_path
+ config[:config_file]
+ end
+
def handle_error(error)
ui.err("Error: #{error.message}")
if error.respond_to?(:reason)
ui.err("Reason: #{error.reason}")
ui.err("")
@@ -89,13 +105,14 @@
end
def apply_params!(params)
remaining_args = parse_options(params)
if remaining_args.size > 1
- ui.err(banner)
- return 1
+ ui.err(opt_parser)
+ return false
else
@policyfile_relative_path = remaining_args.first
+ true
end
end
end
end