heirloom 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ ## HEAD:
2
+
3
+ ## 0.10.1 (02/28/2013):
4
+
5
+ * Minor refactoring of lib/heirloom/cipher/shared.rb
6
+ * Additional validation of download location
7
+
1
8
  ## 0.10.0:
2
9
 
3
10
  * Confirm tar and gpg executables are present when necessary
@@ -8,7 +8,7 @@ module Heirloom
8
8
 
9
9
  def gpg_in_path?
10
10
  unless which('gpg')
11
- @logger.error "gpg not found in path."
11
+ logger.error "gpg not found in path."
12
12
  return false
13
13
  end
14
14
  true
@@ -37,7 +37,8 @@ module Heirloom
37
37
  end
38
38
 
39
39
  def download
40
- ensure_directory :path => @opts[:output], :config => @config
40
+ ensure_path_is_directory :path => @opts[:output], :config => @config
41
+ ensure_directory_is_writable :path => @opts[:output], :config => @config
41
42
  secret = read_secret :opts => @opts,
42
43
  :config => @config
43
44
  archive = @archive.download :output => @opts[:output],
@@ -81,7 +81,7 @@ module Heirloom
81
81
  end
82
82
  end
83
83
 
84
- def ensure_directory(args)
84
+ def ensure_path_is_directory(args)
85
85
  config = args[:config]
86
86
  path = args[:path]
87
87
  logger = config.logger
@@ -92,6 +92,17 @@ module Heirloom
92
92
  end
93
93
  end
94
94
 
95
+ def ensure_directory_is_writable(args)
96
+ config = args[:config]
97
+ path = args[:path]
98
+ logger = config.logger
99
+
100
+ unless File.writable? path
101
+ logger.error "You don't have permissions to write to #{path}."
102
+ exit 1
103
+ end
104
+ end
105
+
95
106
  def ensure_buckets_exist(args)
96
107
  config = args[:config]
97
108
  bucket_prefix = args[:bucket_prefix]
@@ -13,7 +13,7 @@ module Heirloom
13
13
  :opts => @opts
14
14
  @catalog = Heirloom::Catalog.new :name => @opts[:name],
15
15
  :config => @config
16
- ensure_valid_options :provided => @opts,
16
+ ensure_valid_options :provided => @opts,
17
17
  :required => [:name, :id, :directory],
18
18
  :config => @config
19
19
  ensure_catalog_domain_exists :config => @config,
@@ -31,14 +31,14 @@ module Heirloom
31
31
  def upload
32
32
  ensure_valid_region :region => @opts[:metadata_region],
33
33
  :config => @config
34
- ensure_domain_exists :name => @opts[:name],
34
+ ensure_domain_exists :name => @opts[:name],
35
35
  :config => @config
36
36
  ensure_buckets_exist :bucket_prefix => @bucket_prefix,
37
37
  :name => @opts[:name],
38
38
  :regions => @regions,
39
39
  :config => @config
40
- ensure_directory :path => @opts[:directory],
41
- :config => @config
40
+ ensure_path_is_directory :path => @opts[:directory],
41
+ :config => @config
42
42
 
43
43
  secret = read_secret :opts => @opts,
44
44
  :config => @config
@@ -46,7 +46,7 @@ module Heirloom
46
46
  :config => @config
47
47
 
48
48
  @archive.destroy if @archive.exists?
49
-
49
+
50
50
  @file = Tempfile.new('archive.tar.gz')
51
51
 
52
52
  unless @archive.build :bucket_prefix => @bucket_prefix,
@@ -89,16 +89,16 @@ Can be specified multiple times.", :type => :string, :multi => true
89
89
  opt :id, "ID for Heirloom.", :type => :string
90
90
  opt :level, "Log level [debug|info|warn|error].", :type => :string,
91
91
  :default => 'info'
92
- opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
92
+ opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
93
93
  :default => 'us-west-1'
94
94
  opt :name, "Name of Heirloom.", :type => :string
95
95
  opt :public, "Set this Heirloom as public readable?"
96
96
  opt :secret, "Encrypt the Heirloom with given secret.", :type => :string
97
97
  opt :secret_file, "Read secret from file.", :type => :string,
98
98
  :short => :none
99
- opt :aws_access_key, "AWS Access Key ID", :type => :string,
99
+ opt :aws_access_key, "AWS Access Key ID", :type => :string,
100
100
  :short => :none
101
- opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
101
+ opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
102
102
  :short => :none
103
103
  end
104
104
  end
@@ -1,3 +1,3 @@
1
1
  module Heirloom
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
@@ -46,10 +46,14 @@ describe Heirloom do
46
46
  :extract => false,
47
47
  :secret => nil).
48
48
  and_return '/tmp/test123'
49
- @cli_download.should_receive(:ensure_directory).
49
+ @cli_download.should_receive(:ensure_path_is_directory).
50
50
  with(:config => @config_mock,
51
51
  :path => '/tmp/test123').
52
52
  and_return true
53
+ @cli_download.should_receive(:ensure_directory_is_writable).
54
+ with(:config => @config_mock,
55
+ :path => '/tmp/test123').
56
+ and_return true
53
57
  @cli_download.download
54
58
  end
55
59
  end
@@ -89,10 +93,14 @@ describe Heirloom do
89
93
  :extract => false,
90
94
  :secret => nil).
91
95
  and_return '/tmp/test123'
92
- @cli_download.should_receive(:ensure_directory).
96
+ @cli_download.should_receive(:ensure_path_is_directory).
93
97
  with(:config => @config_mock,
94
98
  :path => '/tmp/test123').
95
99
  and_return true
100
+ @cli_download.should_receive(:ensure_directory_is_writable).
101
+ with(:config => @config_mock,
102
+ :path => '/tmp/test123').
103
+ and_return true
96
104
  @cli_download.download
97
105
  end
98
106
  end
@@ -8,8 +8,8 @@ describe Heirloom do
8
8
 
9
9
  before do
10
10
  @config_mock = mock 'config'
11
- @logger_mock = mock 'logger'
12
- @config_mock.stub :logger => @logger_mock,
11
+ @logger_mock = mock 'logger'
12
+ @config_mock.stub :logger => @logger_mock,
13
13
  :access_key => 'key',
14
14
  :secret_key => 'secret',
15
15
  :metadata_region => 'us-west-1'
@@ -27,9 +27,9 @@ describe Heirloom do
27
27
 
28
28
  it "should return false if a required array is emtpy" do
29
29
  @logger_mock.should_receive(:error)
30
- lambda { @object.ensure_valid_options(:provided => {
30
+ lambda { @object.ensure_valid_options(:provided => {
31
31
  :array => [],
32
- :string => 'present'
32
+ :string => 'present'
33
33
  },
34
34
  :required => [:array, :string],
35
35
  :config => @config_mock) }.
@@ -38,9 +38,9 @@ describe Heirloom do
38
38
 
39
39
  it "should return false if a required string is nil" do
40
40
  @logger_mock.should_receive(:error)
41
- lambda { @object.ensure_valid_options(:provided => {
41
+ lambda { @object.ensure_valid_options(:provided => {
42
42
  :array => ['present'],
43
- :string => nil
43
+ :string => nil
44
44
  },
45
45
  :required => [:array, :string],
46
46
  :config => @config_mock) }.
@@ -49,9 +49,9 @@ describe Heirloom do
49
49
 
50
50
  it "should return false if a require string is nil & array is empty" do
51
51
  @logger_mock.should_receive(:error).exactly(2).times
52
- lambda { @object.ensure_valid_options(:provided => {
52
+ lambda { @object.ensure_valid_options(:provided => {
53
53
  :array => [],
54
- :string => nil
54
+ :string => nil
55
55
  },
56
56
  :required => [:array, :string],
57
57
  :config => @config_mock) }.
@@ -115,15 +115,29 @@ describe Heirloom do
115
115
  it "should exit when path is not a directory" do
116
116
  File.should_receive(:directory?).with('/tmp/test').
117
117
  and_return false
118
- lambda { @object.ensure_directory(:path => '/tmp/test',
119
- :config => @config_mock) }.
118
+ lambda { @object.ensure_path_is_directory(:path => '/tmp/test',
119
+ :config => @config_mock) }.
120
120
  should raise_error SystemExit
121
121
  end
122
122
 
123
123
  it "should not exit when path is a directory" do
124
124
  File.should_receive(:directory?).with('/tmp/test').
125
125
  and_return true
126
- @object.ensure_directory :path => '/tmp/test', :config => @config_mock
126
+ @object.ensure_path_is_directory :path => '/tmp/test', :config => @config_mock
127
+ end
128
+
129
+ it "should exit when directory is not writable" do
130
+ File.should_receive(:writable?).with('/tmp/test').
131
+ and_return false
132
+ lambda { @object.ensure_directory_is_writable(:path => '/tmp/test',
133
+ :config => @config_mock) }.
134
+ should raise_error SystemExit
135
+ end
136
+
137
+ it "should not exit when directory is writable" do
138
+ File.should_receive(:writable?).with('/tmp/test').
139
+ and_return true
140
+ @object.ensure_directory_is_writable :path => '/tmp/test', :config => @config_mock
127
141
  end
128
142
 
129
143
  end
@@ -243,7 +257,7 @@ describe Heirloom do
243
257
  @logger_stub = stub 'logger', :error => true
244
258
  @config_stub = stub 'config', :logger => @logger_stub,
245
259
  :metadata_region => 'us-west-1'
246
- @options = { :config => @config_stub,
260
+ @options = { :config => @config_stub,
247
261
  :catalog => @catalog_mock,
248
262
  :entry => 'entry' }
249
263
  @object = Object.new
@@ -271,7 +285,7 @@ describe Heirloom do
271
285
 
272
286
  it "should return the latest id" do
273
287
  Heirloom::Archive.should_receive(:new).
274
- with(:name => 'test',
288
+ with(:name => 'test',
275
289
  :config => @config_stub).
276
290
  and_return @archive_mock
277
291
  @archive_mock.should_receive(:list).
@@ -336,7 +350,7 @@ describe Heirloom do
336
350
 
337
351
  it "should return true if buckets available in all regions" do
338
352
  @checker_mock.should_receive(:bucket_name_available?).
339
- with(:bucket_prefix => 'intu-lc',
353
+ with(:bucket_prefix => 'intu-lc',
340
354
  :regions => ['us-west-1', 'us-west-2'],
341
355
  :config => @config_stub).
342
356
  and_return true
@@ -345,7 +359,7 @@ describe Heirloom do
345
359
 
346
360
  it "should return raise and error if any bucket un-available in all regions" do
347
361
  @checker_mock.should_receive(:bucket_name_available?).
348
- with(:bucket_prefix => 'intu-lc',
362
+ with(:bucket_prefix => 'intu-lc',
349
363
  :regions => ['us-west-1', 'us-west-2'],
350
364
  :config => @config_stub).
351
365
  and_return false
@@ -365,9 +379,9 @@ describe Heirloom do
365
379
  end
366
380
 
367
381
  it "should exit if the entry exists in catalog and not forced" do
368
- options = { :config => @config_stub,
382
+ options = { :config => @config_stub,
369
383
  :catalog => @catalog_mock,
370
- :entry => 'entry',
384
+ :entry => 'entry',
371
385
  :force => false }
372
386
  @catalog_mock.should_receive(:entry_exists_in_catalog?).
373
387
  with('entry').
@@ -377,9 +391,9 @@ describe Heirloom do
377
391
  end
378
392
 
379
393
  it "should not exit if the entry exists in catalog and forced" do
380
- options = { :config => @config_stub,
394
+ options = { :config => @config_stub,
381
395
  :catalog => @catalog_mock,
382
- :entry => 'entry',
396
+ :entry => 'entry',
383
397
  :force => true }
384
398
  @catalog_mock.should_receive(:entry_exists_in_catalog?).
385
399
  with('entry').
@@ -388,9 +402,9 @@ describe Heirloom do
388
402
  end
389
403
 
390
404
  it "should not exit if the does not exists in catalog" do
391
- options = { :config => @config_stub,
405
+ options = { :config => @config_stub,
392
406
  :catalog => @catalog_mock,
393
- :entry => 'entry',
407
+ :entry => 'entry',
394
408
  :force => false }
395
409
  @catalog_mock.should_receive(:entry_exists_in_catalog?).
396
410
  with('entry').
@@ -60,7 +60,7 @@ describe Heirloom do
60
60
  :name => 'archive_name',
61
61
  :regions => @regions,
62
62
  :config => @config_mock)
63
- @upload.should_receive(:ensure_directory).
63
+ @upload.should_receive(:ensure_path_is_directory).
64
64
  with(:path => '/buildme',
65
65
  :config => @config_mock)
66
66
  @upload.should_receive(:ensure_valid_secret).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heirloom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.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-12-14 00:00:00.000000000 Z
12
+ date: 2013-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70327489259240 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 2.11.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70327489259240
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.11.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &70327489258580 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70327489258580
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: fog
38
- requirement: &70327489582820 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,21 +53,31 @@ dependencies:
43
53
  version: 1.6.0
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70327489582820
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.6.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: trollop
49
- requirement: &70327489581740 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
- - - =
67
+ - - '='
53
68
  - !ruby/object:Gem::Version
54
69
  version: '2.0'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70327489581740
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - '='
76
+ - !ruby/object:Gem::Version
77
+ version: '2.0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: xml-simple
60
- requirement: &70327489581060 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,7 +85,12 @@ dependencies:
65
85
  version: 1.1.2
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *70327489581060
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.1.2
69
94
  description: I help build and manage building tar.gz files and deploying them into
70
95
  the cloud
71
96
  email:
@@ -78,7 +103,7 @@ files:
78
103
  - .gitignore
79
104
  - .rvmrc
80
105
  - .travis.yml
81
- - CHANGELOG
106
+ - CHANGELOG.md
82
107
  - Gemfile
83
108
  - LICENSE
84
109
  - README.md
@@ -204,21 +229,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
229
  - - ! '>='
205
230
  - !ruby/object:Gem::Version
206
231
  version: '0'
207
- segments:
208
- - 0
209
- hash: -166474931629253916
210
232
  required_rubygems_version: !ruby/object:Gem::Requirement
211
233
  none: false
212
234
  requirements:
213
235
  - - ! '>='
214
236
  - !ruby/object:Gem::Version
215
237
  version: '0'
216
- segments:
217
- - 0
218
- hash: -166474931629253916
219
238
  requirements: []
220
239
  rubyforge_project: heirloom
221
- rubygems_version: 1.8.16
240
+ rubygems_version: 1.8.24
222
241
  signing_key:
223
242
  specification_version: 3
224
243
  summary: I help with deploying code into the cloud