soror 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -4
- data/bin/soror +5 -1
- data/lib/soror/version.rb +1 -1
- data/lib/soror.rb +0 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bff2dc21e2da2264062e8b5df495aa0d6de4a07
|
4
|
+
data.tar.gz: 1929169d3c2f4062dcc9b37c2f6e53e0bb296106
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3986d1d96c69b3de84749185b37f14e6b2d95e41b38a4833aadc002cc316c7311965e36a167bfb78193daa2ac712bc28ca0be27198d25dbf88705e0ab6d0b1b8
|
7
|
+
data.tar.gz: 3f1fcb90291200f467b253d60a12b80d57d7491f8f2207e6b09b4974ecc19bdf4468c44afe169e03a8025c48f1a7b615eb9aed2d9c99a766945434befe9163be
|
data/README.md
CHANGED
@@ -21,10 +21,10 @@ Or install it yourself as:
|
|
21
21
|
## Usage
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
# Search for EC2 instances which have the tag `{ "Key": "
|
24
|
+
# Search for EC2 instances which have the tag `[{ "Key": "role", "Value": "app" }, { "Key": "stage", "Value": "production" }]`
|
25
25
|
# You can use methods of Aws::EC2::Instance to an element of return value
|
26
26
|
# See http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Instance.html
|
27
|
-
Soror::EC2::Instance.search_by(
|
27
|
+
Soror::EC2::Instance.search_by(role: 'app', stage: 'production') #=> [<Aws::EC2::Instance>, ...]
|
28
28
|
```
|
29
29
|
|
30
30
|
### Configuration
|
@@ -37,10 +37,12 @@ In addition, Soror supports [a new and standardized way to manage credentials](h
|
|
37
37
|
|
38
38
|
## CLI
|
39
39
|
|
40
|
+
`ATTR` is an instance method name of `Aws::EC2::Instance`
|
41
|
+
|
40
42
|
```
|
41
43
|
$ soror --help
|
42
44
|
Usage: soror [options]
|
43
|
-
|
45
|
+
--tags='KEY=VAL,KEY=VAL,...'
|
44
46
|
-a, --attributes=ATTR,ATTR,...
|
45
47
|
--[no-]header
|
46
48
|
--profile-name=NAME
|
@@ -48,13 +50,21 @@ Usage: soror [options]
|
|
48
50
|
--access-key=KEY
|
49
51
|
--secret-key=KEY
|
50
52
|
--region=REGION
|
53
|
+
```
|
51
54
|
|
52
|
-
|
55
|
+
### Example
|
56
|
+
|
57
|
+
```
|
58
|
+
$ soror --tags 'role=app,stage=production' --attributes 'instance_id,public_ip_address' --profile-name 'kirikiriyamama' --region 'ap-northeast-1'
|
53
59
|
instance_id public_ip_address
|
54
60
|
i-xxxxx xxx.xxx.xxx.xxx
|
55
61
|
i-xxxxx xxx.xxx.xxx.xxx
|
56
62
|
```
|
57
63
|
|
64
|
+
```
|
65
|
+
$ ssh -i ~/.ssh/id_rsa ec2-user@$(soror --tags 'role=app,stage=production' --attributes 'instance_id,public_ip_address' --profile-name 'kirikiriyamama' --region 'ap-northeast-1' --no-header | peco | awk '$0 = $2')
|
66
|
+
```
|
67
|
+
|
58
68
|
## Required permissions
|
59
69
|
|
60
70
|
```js
|
data/bin/soror
CHANGED
@@ -8,9 +8,13 @@ Version = Soror::VERSION
|
|
8
8
|
options = { header: true, attributes: [], config: {}, credentials: {}, tag: {} }
|
9
9
|
OptionParser.new do |opt|
|
10
10
|
opt.on('-t', '--tag=\'KEY=VALUE\'', /\A[^=]+=[^=]+\z/) do |v|
|
11
|
+
warn '[DEPRECATION] The option `--tag` will be removed, and `-t` will be assigned to `--tags`. Please use `--tags` instead.'
|
11
12
|
key, val = v.split('=')
|
12
13
|
options[:tag][key] = val
|
13
14
|
end
|
15
|
+
opt.on(%q{--tags='KEY=VAL,KEY=VAL,...'}, Array) do |a|
|
16
|
+
a.map{ |s| s.split('=') }.each{ |k, v| options[:tag][k] = v }
|
17
|
+
end
|
14
18
|
opt.on('-a', '--attributes=ATTR,ATTR,...', Array) { |a| options[:attributes] = a }
|
15
19
|
opt.on('--[no-]header') { |v| options[:header] = v }
|
16
20
|
opt.on('--profile-name=NAME') { |v| options[:credentials][:profile_name] = v }
|
@@ -20,7 +24,7 @@ OptionParser.new do |opt|
|
|
20
24
|
opt.on('--region=REGION') { |v| options[:config][:region] = v }
|
21
25
|
opt.parse!(ARGV)
|
22
26
|
end
|
23
|
-
fail OptionParser::MissingArgument, '--
|
27
|
+
fail OptionParser::MissingArgument, '--tags' if options[:tag].empty?
|
24
28
|
fail OptionParser::InvalidArgument, '--attributes' if options[:attributes].empty?
|
25
29
|
|
26
30
|
unless options[:credentials].empty?
|
data/lib/soror/version.rb
CHANGED
data/lib/soror.rb
CHANGED
@@ -4,21 +4,6 @@ require 'soror/ec2'
|
|
4
4
|
require 'soror/version'
|
5
5
|
require 'yaml'
|
6
6
|
|
7
|
-
unless {}.respond_to?(:symbolize_keys)
|
8
|
-
class Hash
|
9
|
-
def symbolize_keys
|
10
|
-
dup.symbolize_keys!
|
11
|
-
end
|
12
|
-
|
13
|
-
def symbolize_keys!
|
14
|
-
keys.each do |key|
|
15
|
-
self[(key.to_sym rescue key) || key] = delete(key)
|
16
|
-
end
|
17
|
-
self
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
7
|
module Soror
|
23
8
|
class << self
|
24
9
|
extend Forwardable
|
@@ -26,10 +11,3 @@ module Soror
|
|
26
11
|
def_delegators Soror::EC2::Instance, :search_by
|
27
12
|
end
|
28
13
|
end
|
29
|
-
|
30
|
-
File.expand_path('~/.soror').tap do |path|
|
31
|
-
if File.exists?(path)
|
32
|
-
warn '[DEPRECATION] Support of `~/.soror` will be removed. Please use such as `~/.aws/credentials` instead.'
|
33
|
-
Soror.config.update(YAML.load_file(path).symbolize_keys)
|
34
|
-
end
|
35
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soror
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kirikiriyamama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|