soror 0.1.0 → 0.2.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 +7 -3
- data/bin/soror +0 -5
- data/lib/soror.rb +26 -5
- data/lib/soror/version.rb +1 -1
- data/soror.gemspec +1 -1
- metadata +8 -10
- data/lib/soror/ec2.rb +0 -13
- data/lib/soror/ec2/instance.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab8b39b3eccef7a690c16da4975c4a9dd59632b7
|
4
|
+
data.tar.gz: 0356f90edb7ba6d14c788e66fe058cb39fb7378b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 109c87056a530122720b520f07a2576bc93382a39678bd610b66f285cb149fc92ff685b4397f1f4e087d763dc15925a7ba4c1a7dcecdfb8a64783553f0e870d3
|
7
|
+
data.tar.gz: 4b389288e835f0daa08ef2caf9c74c481bc3a61c15dda009a85db6efd74bdf3c903b01a347abdb525cacccdf3d626aa363b5b213dc473b90ba8e0ddaf77c258d
|
data/README.md
CHANGED
@@ -12,11 +12,15 @@ gem 'soror'
|
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
15
|
-
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
16
18
|
|
17
19
|
Or install it yourself as:
|
18
20
|
|
19
|
-
|
21
|
+
```
|
22
|
+
$ gem install soror
|
23
|
+
```
|
20
24
|
|
21
25
|
## Usage
|
22
26
|
|
@@ -42,7 +46,7 @@ In addition, Soror supports [a new and standardized way to manage credentials](h
|
|
42
46
|
```
|
43
47
|
$ soror --help
|
44
48
|
Usage: soror [options]
|
45
|
-
|
49
|
+
-t, --tags='KEY=VAL,KEY=VAL,...'
|
46
50
|
-a, --attributes=ATTR,ATTR,...
|
47
51
|
--[no-]header
|
48
52
|
--profile-name=NAME
|
data/bin/soror
CHANGED
@@ -7,11 +7,6 @@ Version = Soror::VERSION
|
|
7
7
|
|
8
8
|
options = { header: true, attributes: [], config: {}, credentials: {}, tag: {} }
|
9
9
|
OptionParser.new do |opt|
|
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.'
|
12
|
-
key, val = v.split('=')
|
13
|
-
options[:tag][key] = val
|
14
|
-
end
|
15
10
|
opt.on(%q{--tags='KEY=VAL,KEY=VAL,...'}, Array) do |a|
|
16
11
|
a.map{ |s| s.split('=') }.each{ |k, v| options[:tag][k] = v }
|
17
12
|
end
|
data/lib/soror.rb
CHANGED
@@ -1,13 +1,34 @@
|
|
1
|
-
require 'aws-sdk'
|
1
|
+
require 'aws-sdk-ec2'
|
2
2
|
require 'forwardable'
|
3
|
-
require 'soror/ec2'
|
4
3
|
require 'soror/version'
|
5
|
-
require 'yaml'
|
6
4
|
|
7
|
-
|
5
|
+
class Soror
|
8
6
|
class << self
|
9
7
|
extend Forwardable
|
8
|
+
|
10
9
|
def_delegators Aws, :config, :config=
|
11
|
-
def_delegators
|
10
|
+
def_delegators new, :search_by
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@ec2 = Aws::EC2::Client.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def search_by(tags)
|
18
|
+
filters = [{ name: 'instance-state-name', values: ['running'] }]
|
19
|
+
tags.each do |k, v|
|
20
|
+
filters << { name: "tag:#{k}", values: [v] }
|
21
|
+
end
|
22
|
+
|
23
|
+
@ec2.describe_instances(filters: filters).reservations.map(&:instances).flatten
|
24
|
+
end
|
25
|
+
|
26
|
+
module EC2
|
27
|
+
class Instance
|
28
|
+
# Deprecated
|
29
|
+
def self.search_by(tags)
|
30
|
+
Soror.search_by(tags)
|
31
|
+
end
|
32
|
+
end
|
12
33
|
end
|
13
34
|
end
|
data/lib/soror/version.rb
CHANGED
data/soror.gemspec
CHANGED
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kirikiriyamama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: aws-sdk
|
42
|
+
name: aws-sdk-ec2
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
description: Search for EC2 instances by tags
|
56
56
|
email:
|
57
57
|
- kirikiriyamama@icloud.com
|
@@ -67,8 +67,6 @@ files:
|
|
67
67
|
- Rakefile
|
68
68
|
- bin/soror
|
69
69
|
- lib/soror.rb
|
70
|
-
- lib/soror/ec2.rb
|
71
|
-
- lib/soror/ec2/instance.rb
|
72
70
|
- lib/soror/version.rb
|
73
71
|
- soror.gemspec
|
74
72
|
homepage: https://github.com/kirikiriyamama/soror
|
@@ -91,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
89
|
version: '0'
|
92
90
|
requirements: []
|
93
91
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.6.13
|
95
93
|
signing_key:
|
96
94
|
specification_version: 4
|
97
95
|
summary: Search for EC2 instances by tags
|
data/lib/soror/ec2.rb
DELETED
data/lib/soror/ec2/instance.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Soror
|
2
|
-
module EC2
|
3
|
-
class Instance
|
4
|
-
class << self
|
5
|
-
include Soror::EC2
|
6
|
-
|
7
|
-
def search_by(tags)
|
8
|
-
filters = [].tap do |array|
|
9
|
-
array << { name: 'instance-state-name', values: ['running'] }
|
10
|
-
tags.each do |k, v|
|
11
|
-
array << { name: "tag:#{k}", values: [v] }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
resource.instances(filters: filters).to_a
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|