knife-solo_data_bag 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+
6
+ gemfile:
7
+ - ./gemfiles/Gemfile.chef.0.10.10
8
+ - ./gemfiles/Gemfile.chef.10.12.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## head
2
2
 
3
+ ## 0.2.1 (07/08/2012)
4
+ * Fixed an issue with show command and JSON output format (props to Ziad Sawalha)
5
+
3
6
  ## 0.2.0 (07/01/2012)
4
7
  * Add support for specifying JSON content on the command line (props to BK Box)
5
8
 
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Knife Solo Data Bag
2
2
  A knife plugin to make working with data bags easier in a chef solo environment
3
3
 
4
+ ## Build Status
5
+ ![Build Status](https://secure.travis-ci.org/thbishop/knife-solo_data_bag.png)
6
+
4
7
  ## Installation
5
8
 
6
9
  gem install knife-solo_data_bag
@@ -55,13 +58,29 @@ Show the unencrypted content of an encrypted data bag with the provided file con
55
58
 
56
59
  $ knife solo data bag show apps app_1 --secret-file 'SECRET_FILE'
57
60
 
61
+ You can also display any of the above variations in JSON format with `-F json`
62
+
63
+ $ knife solo data bag show apps app_1 -s secret_key -F json
64
+
58
65
  ## Notes
59
66
  This plugin will rely on the configured data_bag_path for placement of the data
60
67
  bags. This defaults to '/var/chef/data_bags', but can be overriden in your chef
61
68
  client config.
62
69
 
63
- ### Chef Support
64
- This plugin has only been tested with version 0.10.10 of chef.
70
+ ## Version Support
71
+ This plugin has been tested on the following:
72
+
73
+ Chef:
74
+ * 0.10.10
75
+ * 10.12.0
76
+
77
+ Ruby:
78
+ * 1.9.2
79
+ * 1.9.3
80
+
81
+ OS:
82
+ * OSX
83
+ * Linux
65
84
 
66
85
  ## Contribute
67
86
  * Fork the project
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'chef', '= 0.10.10'
4
+
5
+ gemspec :path => "../"
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'chef', '~> 10.12.0'
4
+
5
+ gemspec :path => "../"
@@ -15,6 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Knife::SoloDataBag::VERSION
17
17
  gem.add_development_dependency 'chef', '~> 0.10.10'
18
+ gem.add_development_dependency 'rake'
18
19
  gem.add_development_dependency 'rspec', '~> 2.10.0'
19
20
  gem.add_development_dependency 'fakefs', '~> 0.4.0'
20
21
  end
@@ -34,7 +34,8 @@ module KnifeSoloDataBag
34
34
 
35
35
  def bag_item_content
36
36
  if should_be_encrypted?
37
- Chef::EncryptedDataBagItem.load bag_name, item_name, secret_key
37
+ raw = Chef::EncryptedDataBagItem.load(bag_name, item_name, secret_key)
38
+ raw.to_hash
38
39
  else
39
40
  Chef::DataBagItem.load(bag_name, item_name).raw_data
40
41
  end
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module SoloDataBag
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
@@ -57,6 +57,20 @@ describe KnifeSoloDataBag::SoloDataBagShow do
57
57
  @stdout.string.should match /id:\s+foo.+who:\s+bob/m
58
58
  end
59
59
 
60
+ context 'and with -F of json' do
61
+ before do
62
+ @knife.config[:format] = 'json'
63
+ Chef::DataBagItem.should_receive(:load).with('bag_1', 'foo').
64
+ and_return(@bag_item_foo)
65
+ end
66
+
67
+ it 'should show the item as json' do
68
+ @knife.run
69
+ @stdout.string.should match /"id":\s+"foo".+"who":\s+"bob"/m
70
+ @stdout.string.should_not match /json_class/
71
+ end
72
+ end
73
+
60
74
  context 'when encrypting with -s or --secret' do
61
75
  before do
62
76
  @knife.config[:secret] = 'SECRET'
@@ -69,6 +83,18 @@ describe KnifeSoloDataBag::SoloDataBagShow do
69
83
  @knife.run
70
84
  @stdout.string.should match /id:\s+foo.+who:\s+bob/m
71
85
  end
86
+
87
+ context 'and with -F of json' do
88
+ before do
89
+ @knife.config[:format] = 'json'
90
+ end
91
+
92
+ it 'should show the unencrypted item as json' do
93
+ @knife.run
94
+ @stdout.string.should match /"id":\s+"foo".+"who":\s+"bob"/m
95
+ @stdout.string.should_not match /json_class/
96
+ end
97
+ end
72
98
  end
73
99
 
74
100
  context 'when encrypting with --secret-file' do
@@ -86,6 +112,18 @@ describe KnifeSoloDataBag::SoloDataBagShow do
86
112
  @knife.run
87
113
  @stdout.string.should match /id:\s+foo.+who:\s+bob/m
88
114
  end
115
+
116
+ context 'and with -F of json' do
117
+ before do
118
+ @knife.config[:format] = 'json'
119
+ end
120
+
121
+ it 'should show the unencrypted item as json' do
122
+ @knife.run
123
+ @stdout.string.should match /"id":\s+"foo".+"who":\s+"bob"/m
124
+ @stdout.string.should_not match /json_class/
125
+ end
126
+ end
89
127
  end
90
128
 
91
129
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-solo_data_bag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-01 00:00:00.000000000Z
12
+ date: 2012-07-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
16
- requirement: &70100793125240 !ruby/object:Gem::Requirement
16
+ requirement: &70133067504540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,21 @@ dependencies:
21
21
  version: 0.10.10
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70100793125240
24
+ version_requirements: *70133067504540
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70133067504120 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70133067504120
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: rspec
27
- requirement: &70100793124740 !ruby/object:Gem::Requirement
38
+ requirement: &70133067503580 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ~>
@@ -32,10 +43,10 @@ dependencies:
32
43
  version: 2.10.0
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *70100793124740
46
+ version_requirements: *70133067503580
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: fakefs
38
- requirement: &70100793124280 !ruby/object:Gem::Requirement
49
+ requirement: &70133067503080 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ~>
@@ -43,7 +54,7 @@ dependencies:
43
54
  version: 0.4.0
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *70100793124280
57
+ version_requirements: *70133067503080
47
58
  description: A knife plugin for working with data bags and chef solo
48
59
  email:
49
60
  - bishop.thomas@gmail.com
@@ -53,11 +64,14 @@ extra_rdoc_files: []
53
64
  files:
54
65
  - .gitignore
55
66
  - .rspec
67
+ - .travis.yml
56
68
  - CHANGELOG.md
57
69
  - Gemfile
58
70
  - LICENSE
59
71
  - README.md
60
72
  - Rakefile
73
+ - gemfiles/Gemfile.chef.0.10.10
74
+ - gemfiles/Gemfile.chef.10.12.0
61
75
  - knife-solo_data_bag.gemspec
62
76
  - lib/chef/knife/helpers.rb
63
77
  - lib/chef/knife/solo_data_bag_create.rb