cknife 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +6 -6
- data/README.md +16 -7
- data/VERSION +1 -1
- data/cknife.gemspec +2 -2
- data/lib/cknife/cknife_aws.rb +49 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7870ad7c8c9c58e3d5b7b74bc2e021d60a87a21a
|
4
|
+
data.tar.gz: 41c4dbed7df35ec62fbfbcdc829e7d4b4dab6965
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ca47285a7655a8720e3b77b6cab4d567dbe69e9264496d88f80fdeaa2d228a864f5ed028aebfb557fb46f29242cc18513856d934ed1a1bbbca187afbd6f4f3c
|
7
|
+
data.tar.gz: 10d540700a6615dce43e2298650227d74425e23dec9ea66d9c15e3e1d70f299041a305031684fd248026f55cb34d7d928abf6b9f4ea6f406192ae9280958dad4
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2018 Michael Rivera
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
10
10
|
furnished to do so, subject to the following conditions:
|
11
11
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
14
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -17,9 +17,11 @@ Install ruby and possibly bundler:
|
|
17
17
|
|
18
18
|
Create a Gemfile with cknife and its git repository.
|
19
19
|
|
20
|
+
|
20
21
|
source "http://rubygems.org"
|
21
|
-
|
22
|
-
|
22
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
23
|
+
|
24
|
+
gem "cknife", '~> 1.1.0'
|
23
25
|
|
24
26
|
Run bundle.
|
25
27
|
|
@@ -76,9 +78,10 @@ Setup your AWS key and secret in any of these methods, in order of priority:
|
|
76
78
|
- $CWD/cknife.yml
|
77
79
|
- $CWD/tmp/cknife.yml
|
78
80
|
- environment variables: `KEY`, `SECRET`
|
79
|
-
- environment
|
81
|
+
- environment variables: `AMAZON_ACCESS_KEY_ID`, `AMAZON_SECRET_ACCESS_KEY`
|
80
82
|
|
81
|
-
|
83
|
+
If using one of the above cknife.yml files to define your keys, the format
|
84
|
+
is as follows:
|
82
85
|
|
83
86
|
---
|
84
87
|
key: AKIAblahblahb...
|
@@ -360,13 +363,19 @@ One of the following, like patch. This will create a git commit.
|
|
360
363
|
bundle exec rake version:bump:minor
|
361
364
|
bundle exec rake version:bump:patch
|
362
365
|
|
363
|
-
Create the gem spec
|
366
|
+
Do a git flow release. Create the gem spec and commit it:
|
364
367
|
|
365
368
|
bundle exec rake gemspec:generate
|
366
369
|
git commit -am "Generated gemspec for version 0.1.4"
|
367
370
|
|
368
|
-
|
369
|
-
|
371
|
+
Do a git flow finish release. Push to github. You can
|
372
|
+
then do a release to Rubygems. This command will
|
373
|
+
try to generate the gemspec, but nothing will happen
|
374
|
+
since the gemspec is already valid.
|
375
|
+
|
376
|
+
rake release
|
377
|
+
|
378
|
+
### Building Locally (Optional)
|
370
379
|
|
371
380
|
You may build a local gem:
|
372
381
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/cknife.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: cknife 1.1.
|
5
|
+
# stub: cknife 1.1.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "cknife".freeze
|
9
|
-
s.version = "1.1.
|
9
|
+
s.version = "1.1.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
data/lib/cknife/cknife_aws.rb
CHANGED
@@ -71,6 +71,37 @@ class CKnifeAws < Thor
|
|
71
71
|
@cdn ||= Fog::CDN.new(fog_opts)
|
72
72
|
end
|
73
73
|
|
74
|
+
def get_bucket(bucket_name)
|
75
|
+
d = fog_storage.directories.select { |d| d.key == bucket_name }.first
|
76
|
+
|
77
|
+
if d.nil?
|
78
|
+
say ("Found no bucket by name #{bucket_name}")
|
79
|
+
return
|
80
|
+
end
|
81
|
+
d
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_file(bucket, file_name)
|
85
|
+
f = bucket.files.select { |f| f.key == file_name }.first
|
86
|
+
if f.nil?
|
87
|
+
say("Found no file in #{bucket.key} having name #{file_name}.")
|
88
|
+
return
|
89
|
+
end
|
90
|
+
f
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_bucket_and_file(bucket_name, file_name)
|
94
|
+
d = get_bucket(bucket_name)
|
95
|
+
return [nil, nil] if d.nil?
|
96
|
+
|
97
|
+
f = get_file(d, file_name)
|
98
|
+
return [nil, nil] if f.nil?
|
99
|
+
|
100
|
+
[d, f]
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
|
74
105
|
def show_buckets
|
75
106
|
fog_storage.directories.sort { |a,b| a.key <=> b.key }.each { |b| puts "#{b.key}" }
|
76
107
|
end
|
@@ -196,15 +227,26 @@ class CKnifeAws < Thor
|
|
196
227
|
show_buckets
|
197
228
|
end
|
198
229
|
|
230
|
+
desc "url [BUCKET_NAME] [FILE]", "Generate a temporary (15 minute) URL for a file."
|
231
|
+
method_options :region => "us-east-1"
|
232
|
+
method_options :duration => 15
|
233
|
+
def url(bucket_name, file_name)
|
234
|
+
d, f = get_bucket_and_file(bucket_name, file_name)
|
235
|
+
return if d.nil? || f.nil?
|
236
|
+
|
237
|
+
minutes = options[:duration].to_i
|
238
|
+
expiry = (Time.now + minutes.minutes).to_i
|
239
|
+
url = f.url(expiry, path_style: true)
|
240
|
+
say("URL created.")
|
241
|
+
say(url)
|
242
|
+
end
|
243
|
+
|
199
244
|
desc "afew [BUCKET_NAME]", "Show first 5 files in bucket"
|
200
245
|
method_options :count => "5"
|
201
246
|
method_options :glob => "*"
|
202
247
|
def afew(bucket_name)
|
203
|
-
d =
|
204
|
-
if d.nil?
|
205
|
-
say ("Found no bucket by name #{bucket_name}")
|
206
|
-
return
|
207
|
-
end
|
248
|
+
d = get_bucket(bucket_name)
|
249
|
+
return if d.nil?
|
208
250
|
|
209
251
|
found = n_file_heads(d, options[:glob], options[:count].to_i)
|
210
252
|
|
@@ -448,18 +490,8 @@ class CKnifeAws < Thor
|
|
448
490
|
method_options :noprompt => false
|
449
491
|
method_options :region => "us-east-1"
|
450
492
|
def fdelete(bucket_name, file_name)
|
451
|
-
d =
|
452
|
-
|
453
|
-
if d.nil?
|
454
|
-
say ("Found no bucket by name #{bucket_name}")
|
455
|
-
return
|
456
|
-
end
|
457
|
-
|
458
|
-
f = d.files.select { |f| f.key == file_name }.first
|
459
|
-
if f.nil?
|
460
|
-
say("Found no file in #{d.key} having name #{file_name}.")
|
461
|
-
return
|
462
|
-
end
|
493
|
+
d, f = get_bucket_and_file(bucket_name, file_name)
|
494
|
+
return if d.nil? || f.nil?
|
463
495
|
|
464
496
|
if options[:noprompt] || yes?("Are you sure you want to delete #{f.key} in #{d.key}?", :red)
|
465
497
|
f.destroy
|