summaryrefslogtreecommitdiff
path: root/chef-config/lib
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2017-12-15 15:52:15 +0000
committerThom May <thom@chef.io>2017-12-18 11:26:34 +0000
commit57732ab92cc315c6161fbdef4ee17ceaebffc656 (patch)
tree1b426b0cd5916098da2452b3706a11525bf46922 /chef-config/lib
parentd390c679654a92511f67e0a6fdebd211d5c84426 (diff)
downloadchef-57732ab92cc315c6161fbdef4ee17ceaebffc656.tar.gz
Specify a profile on the command line
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'chef-config/lib')
-rw-r--r--chef-config/lib/chef-config/config.rb3
-rw-r--r--chef-config/lib/chef-config/workstation_config_loader.rb8
2 files changed, 9 insertions, 2 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 63dd4ecda2..4855533266 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -698,6 +698,9 @@ module ChefConfig
# on running chef-client
default :count_log_resource_updates, true
+ # The selected profile when using credentials.
+ default :profile, nil
+
# knife configuration data
config_context :knife do
# XXX: none of these default values are applied to knife (and would create a backcompat
diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb
index 4c07cac702..fdde1e0255 100644
--- a/chef-config/lib/chef-config/workstation_config_loader.rb
+++ b/chef-config/lib/chef-config/workstation_config_loader.rb
@@ -31,7 +31,9 @@ module ChefConfig
# Path to a config file requested by user, (e.g., via command line option). Can be nil
attr_accessor :explicit_config_file
- attr_reader :profile
+ # The name of a credentials profile. Can be nil
+ attr_accessor :profile
+ attr_reader :credentials_found
# TODO: initialize this with a logger for Chef and Knife
def initialize(explicit_config_file, logger = nil, profile: nil)
@@ -40,10 +42,11 @@ module ChefConfig
@config_location = nil
@profile = profile
@logger = logger || NullLogger.new
+ @credentials_found = false
end
def no_config_found?
- config_location.nil?
+ config_location.nil? && !credentials_found
end
def config_location
@@ -152,6 +155,7 @@ module ChefConfig
extract_key(creds, "validation_key", :validation_key, :validation_key_contents)
extract_key(creds, "validator_key", :validation_key, :validation_key_contents)
extract_key(creds, "client_key", :client_key, :client_key_contents)
+ @credentials_found = true
end
def extract_key(creds, name, config_path, config_contents)