diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-11 19:19:19 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-11 19:19:19 -0800 |
commit | ee8e333ad7c23aa3b84d510c3804cf840620924a (patch) | |
tree | a93d1858b2496072aac6563980fbf99bd9c229ee /lib/chef/knife | |
parent | 1aa9b128d22a21a39e6d7b7a833538ae3e15929d (diff) | |
download | chef-ee8e333ad7c23aa3b84d510c3804cf840620924a.tar.gz |
prepend bootstrap_ to all CLI argslcg/1923
also rename vault_item to bootstrap_vault_json
Diffstat (limited to 'lib/chef/knife')
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 18 | ||||
-rw-r--r-- | lib/chef/knife/bootstrap/chef_vault_handler.rb | 38 |
2 files changed, 28 insertions, 28 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index 79d9db0e97..dde1037a66 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -199,22 +199,22 @@ class Chef :description => "Verify the SSL cert for HTTPS requests to the Chef server API.", :boolean => true - option :vault_file, - :long => '--vault-file VAULT_FILE', + option :bootstrap_vault_file, + :long => '--bootstrap-vault-file VAULT_FILE', :description => 'A JSON file with a list of vault(s) and item(s) to be updated' - option :vault_list, - :long => '--vault-list VAULT_LIST', + option :bootstrap_vault_json, + :long => '--bootstrap-vault-json VAULT_JSON', :description => 'A JSON string with the vault(s) and item(s) to be updated' - option :vault_item, - :long => '--vault-item VAULT_ITEM', + option :bootstrap_vault_item, + :long => '--bootstrap-vault-item VAULT_ITEM', :description => 'A single vault and item to update as "vault:item"', :proc => Proc.new { |i| (vault, item) = i.split(/:/) - vault_item ||= {} - vault_item[vault] ||= [] - vault_item[vault].push(item) + bootstrap_vault_item ||= {} + bootstrap_vault_item[vault] ||= [] + bootstrap_vault_item[vault].push(item) } def initialize(argv=[]) diff --git a/lib/chef/knife/bootstrap/chef_vault_handler.rb b/lib/chef/knife/bootstrap/chef_vault_handler.rb index c421d2cb15..749f61e6da 100644 --- a/lib/chef/knife/bootstrap/chef_vault_handler.rb +++ b/lib/chef/knife/bootstrap/chef_vault_handler.rb @@ -50,7 +50,7 @@ class Chef ui.info("Updating Chef Vault, waiting for client to be searchable..") while wait_for_client - update_vault_list! + update_bootstrap_vault_json! end # Iterate through all the vault items to update. Items may be either a String @@ -61,7 +61,7 @@ class Chef # "vault2": [ "item1", "item2", "item2" ] # } # - def update_vault_list! + def update_bootstrap_vault_json! vault_json.each do |vault, items| [ items ].flatten.each do |item| update_vault(vault, item) @@ -71,35 +71,35 @@ class Chef # @return [Boolean] if we've got chef vault options to act on or not def doing_chef_vault? - !!(vault_list || vault_file || vault_item) + !!(bootstrap_vault_json || bootstrap_vault_file || bootstrap_vault_item) end private # warn if the user has given mutual conflicting options def sanity_check - if vault_item && (vault_list || vault_file) + if bootstrap_vault_item && (bootstrap_vault_json || bootstrap_vault_file) ui.warn "--vault-item given with --vault-list or --vault-file, ignoring the latter" end - if vault_list && vault_file + if bootstrap_vault_json && bootstrap_vault_file ui.warn "--vault-list given with --vault-file, ignoring the latter" end end # @return [String] string with serialized JSON representing the chef vault items - def vault_list - knife_config[:vault_list] + def bootstrap_vault_json + knife_config[:bootstrap_vault_json] end # @return [String] JSON text in a file representing the chef vault items - def vault_file - knife_config[:vault_file] + def bootstrap_vault_file + knife_config[:bootstrap_vault_file] end # @return [Hash] Ruby object representing the chef vault items to create - def vault_item - knife_config[:vault_item] + def bootstrap_vault_item + knife_config[:bootstrap_vault_item] end # Helper to return a ruby object represeting all the data bags and items @@ -109,10 +109,10 @@ class Chef def vault_json @vault_json ||= begin - if vault_item - vault_item + if bootstrap_vault_item + bootstrap_vault_item else - json = vault_list ? vault_list : File.read(vault_file) + json = bootstrap_vault_json ? bootstrap_vault_json : File.read(bootstrap_vault_file) Chef::JSONCompat.from_json(json) end end @@ -124,9 +124,9 @@ class Chef # @param item [String] name of the chef-vault encrypted item def update_vault(vault, item) require_chef_vault! - vault_item = load_chef_vault_item(vault, item) - vault_item.clients("name:#{node_name}") - vault_item.save + bootstrap_vault_item = load_chef_bootstrap_vault_item(vault, item) + bootstrap_vault_item.clients("name:#{node_name}") + bootstrap_vault_item.save end # Hook to stub out ChefVault @@ -134,11 +134,11 @@ class Chef # @param vault [String] name of the chef-vault encrypted data bag # @param item [String] name of the chef-vault encrypted item # @returns [ChefVault::Item] ChefVault::Item object - def load_chef_vault_item(vault, item) + def load_chef_bootstrap_vault_item(vault, item) ChefVault::Item.load(vault, item) end - public :load_chef_vault_item # for stubbing + public :load_chef_bootstrap_vault_item # for stubbing # Helper used to spin waiting for the client to appear in search. # |