summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2014-09-25 15:48:10 -0700
committertyler-ball <tyleraball@gmail.com>2014-09-29 08:31:09 -0700
commit049672e8335a7a3190fcf3acd59d63b42f1f0ba0 (patch)
treeb24f4c971587a438c1915114c69a86e4520ec529 /lib
parent75a90633b5015f91425644670d839377837fb8d3 (diff)
downloadchef-049672e8335a7a3190fcf3acd59d63b42f1f0ba0.tar.gz
Fixing `data bag edit` according to spec, no longer requires --encrypttball/encrypted-data-bag-ux
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/knife/data_bag_edit.rb10
-rw-r--r--lib/chef/knife/data_bag_from_file.rb1
2 files changed, 5 insertions, 6 deletions
diff --git a/lib/chef/knife/data_bag_edit.rb b/lib/chef/knife/data_bag_edit.rb
index 7c187f56f1..6ef4b33f59 100644
--- a/lib/chef/knife/data_bag_edit.rb
+++ b/lib/chef/knife/data_bag_edit.rb
@@ -36,14 +36,14 @@ class Chef
def load_item(bag, item_name)
item = Chef::DataBagItem.load(bag, item_name)
if encrypted?(item.raw_data)
- if encryption_secret_provided?
- Chef::EncryptedDataBagItem.new(item, read_secret).to_hash
+ if encryption_secret_provided_ignore_encrypt_flag?
+ return Chef::EncryptedDataBagItem.new(item, read_secret).to_hash, true
else
ui.fatal("You cannot edit an encrypted data bag without providing the secret.")
exit(1)
end
else
- item
+ return item, false
end
end
@@ -54,10 +54,10 @@ class Chef
exit 1
end
- item = load_item(@name_args[0], @name_args[1])
+ item, was_encrypted = load_item(@name_args[0], @name_args[1])
edited_item = edit_data(item)
- if encryption_secret_provided?
+ if was_encrypted || encryption_secret_provided?
ui.info("Encrypting data bag using provided secret.")
item_to_save = Chef::EncryptedDataBagItem.encrypt_data_bag_item(edited_item, read_secret)
else
diff --git a/lib/chef/knife/data_bag_from_file.rb b/lib/chef/knife/data_bag_from_file.rb
index 598a935160..d1b7daa4a2 100644
--- a/lib/chef/knife/data_bag_from_file.rb
+++ b/lib/chef/knife/data_bag_from_file.rb
@@ -24,7 +24,6 @@ require 'chef/knife/data_bag_secret_options'
class Chef
class Knife
class DataBagFromFile < Knife
- include DataBagCommon
include DataBagSecretOptions
deps do