chef-vault 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.gitignore +2 -0
- data/CONTRIBUTING.md +3 -3
- data/Changelog.md +11 -1
- data/KNIFE_EXAMPLES.md +102 -72
- data/README.md +37 -35
- data/lib/chef-vault/item.rb +30 -18
- data/lib/chef-vault/item_keys.rb +15 -6
- data/lib/chef-vault/version.rb +1 -1
- data/lib/chef/knife/decrypt.rb +33 -0
- data/lib/chef/knife/encrypt_create.rb +25 -74
- data/lib/chef/knife/encrypt_delete.rb +10 -39
- data/lib/chef/knife/encrypt_remove.rb +18 -75
- data/lib/chef/knife/encrypt_rotate_keys.rb +10 -39
- data/lib/chef/knife/encrypt_update.rb +25 -73
- data/lib/chef/knife/vault_base.rb +46 -0
- data/lib/chef/knife/vault_create.rb +95 -0
- data/lib/chef/knife/vault_decrypt.rb +59 -0
- data/lib/chef/knife/vault_delete.rb +49 -0
- data/lib/chef/knife/vault_edit.rb +70 -0
- data/lib/chef/knife/vault_remove.rb +86 -0
- data/lib/chef/knife/vault_rotate_all_keys.rb +57 -0
- data/lib/chef/knife/vault_rotate_keys.rb +49 -0
- data/lib/chef/knife/vault_show.rb +89 -0
- data/lib/chef/knife/vault_update.rb +87 -0
- data/spec/chef-vault_spec.rb +11 -36
- data/spec/item_keys_spec.rb +6 -18
- data/spec/item_spec.rb +16 -21
- metadata +13 -3
- data/lib/chef/knife/Decrypt.rb +0 -71
data/spec/item_spec.rb
CHANGED
@@ -1,33 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ChefVault::Item do
|
4
|
+
subject(:item) { ChefVault::Item.new("foo", "bar") }
|
5
|
+
|
4
6
|
describe '#new' do
|
5
|
-
before(:each) do
|
6
|
-
@item = ChefVault::Item.new("foo", "bar")
|
7
|
-
end
|
8
7
|
|
9
|
-
it
|
10
|
-
expect(@item).to be_an_instance_of ChefVault::Item
|
11
|
-
end
|
8
|
+
it { should be_an_instance_of ChefVault::Item }
|
12
9
|
|
13
|
-
|
14
|
-
expect(@item.data_bag).to eq "foo"
|
15
|
-
end
|
10
|
+
its(:keys) { should be_an_instance_of ChefVault::ItemKeys }
|
16
11
|
|
17
|
-
|
18
|
-
expect(@item["id"]).to eq "bar"
|
19
|
-
end
|
12
|
+
its(:data_bag) { should eq "foo" }
|
20
13
|
|
21
|
-
|
22
|
-
expect(@item.keys).to be_an_instance_of ChefVault::ItemKeys
|
23
|
-
end
|
14
|
+
specify { item["id"].should eq "bar" }
|
24
15
|
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
specify { item.keys["id"].should eq "bar_keys" }
|
17
|
+
|
18
|
+
specify { item.keys.data_bag.should eq "foo" }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#save' do
|
22
|
+
context 'when item["id"] is bar.bar' do
|
23
|
+
let(:item) { ChefVault::Item.new("foo", "bar.bar") }
|
28
24
|
|
29
|
-
|
30
|
-
expect(@item.keys["id"]).to eq "bar_keys"
|
25
|
+
specify { expect { item.save }.to raise_error }
|
31
26
|
end
|
32
27
|
end
|
33
|
-
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-vault
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Moser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
@@ -81,7 +81,7 @@ files:
|
|
81
81
|
- lib/chef-vault/item_keys.rb
|
82
82
|
- lib/chef-vault/user.rb
|
83
83
|
- lib/chef-vault/version.rb
|
84
|
-
- lib/chef/knife/
|
84
|
+
- lib/chef/knife/decrypt.rb
|
85
85
|
- lib/chef/knife/encrypt_create.rb
|
86
86
|
- lib/chef/knife/encrypt_delete.rb
|
87
87
|
- lib/chef/knife/encrypt_remove.rb
|
@@ -89,6 +89,16 @@ files:
|
|
89
89
|
- lib/chef/knife/encrypt_update.rb
|
90
90
|
- lib/chef/knife/mixin/compat.rb
|
91
91
|
- lib/chef/knife/mixin/helper.rb
|
92
|
+
- lib/chef/knife/vault_base.rb
|
93
|
+
- lib/chef/knife/vault_create.rb
|
94
|
+
- lib/chef/knife/vault_decrypt.rb
|
95
|
+
- lib/chef/knife/vault_delete.rb
|
96
|
+
- lib/chef/knife/vault_edit.rb
|
97
|
+
- lib/chef/knife/vault_remove.rb
|
98
|
+
- lib/chef/knife/vault_rotate_all_keys.rb
|
99
|
+
- lib/chef/knife/vault_rotate_keys.rb
|
100
|
+
- lib/chef/knife/vault_show.rb
|
101
|
+
- lib/chef/knife/vault_update.rb
|
92
102
|
- spec/chef-vault_spec.rb
|
93
103
|
- spec/item_keys_spec.rb
|
94
104
|
- spec/item_spec.rb
|
data/lib/chef/knife/Decrypt.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# Description: Chef-Vault Decrypt class
|
2
|
-
# Copyright 2013, Nordstrom, Inc.
|
3
|
-
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
|
16
|
-
require 'chef/knife'
|
17
|
-
require 'chef-vault'
|
18
|
-
|
19
|
-
class Decrypt < Chef::Knife
|
20
|
-
deps do
|
21
|
-
require 'chef/search/query'
|
22
|
-
require File.expand_path('../mixin/compat', __FILE__)
|
23
|
-
require File.expand_path('../mixin/helper', __FILE__)
|
24
|
-
include ChefVault::Mixin::KnifeCompat
|
25
|
-
include ChefVault::Mixin::Helper
|
26
|
-
end
|
27
|
-
|
28
|
-
banner "knife decrypt VAULT ITEM [VALUES] --mode MODE"
|
29
|
-
|
30
|
-
option :mode,
|
31
|
-
:short => '-M MODE',
|
32
|
-
:long => '--mode MODE',
|
33
|
-
:description => 'Chef mode to run in default - solo'
|
34
|
-
|
35
|
-
def run
|
36
|
-
vault = @name_args[0]
|
37
|
-
item = @name_args[1]
|
38
|
-
values = @name_args[2]
|
39
|
-
|
40
|
-
if vault && item
|
41
|
-
set_mode(config[:mode])
|
42
|
-
|
43
|
-
print_values(vault, item, values)
|
44
|
-
else
|
45
|
-
show_usage
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def show_usage
|
50
|
-
super
|
51
|
-
exit 1
|
52
|
-
end
|
53
|
-
|
54
|
-
def print_values(vault, item, values)
|
55
|
-
vault_item = ChefVault::Item.load(vault, item).raw_data
|
56
|
-
|
57
|
-
if values
|
58
|
-
included_values = %W( id )
|
59
|
-
|
60
|
-
values.split(",").each do |value|
|
61
|
-
value.strip! # remove white space
|
62
|
-
included_values << value
|
63
|
-
end
|
64
|
-
|
65
|
-
output(Hash[vault_item.find_all{|k,v| included_values.include?(k)}])
|
66
|
-
else
|
67
|
-
output(vault_item)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|