elastip 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac1e342a3ee90d62cc1098ee778c9f0fb2066951
4
- data.tar.gz: 4187ecde13a4838275d9e8dc367da51e3df76552
3
+ metadata.gz: ff1d5f3740ed41c6d7eaa06ed7197172b48808cb
4
+ data.tar.gz: 9afd039f16780c72d0023d2d3955d2ccaaea29f1
5
5
  SHA512:
6
- metadata.gz: 2d37abc6473d4ce5ba8e153be37faa450aa85e4be5d6e5442accae9c5c9186de2490176b44389bcbefe4ea0d653b2a4a514fce370711d48b59e4197d5bd6376a
7
- data.tar.gz: c7c8b2f1f7786c5fd5ae2461d44d45feb523f8d82fd44222fa85ed301c369b51e3f7270c7b1b778cf0765f854a3675e551556f57903663db05de21c03b995692
6
+ metadata.gz: 48343542e107537447a62042cef0f2e2765e61699556b4733c5c672a622b636d44cdb16d979be149426801938afe5d4771574f7f7b8b7b18e2d13a0cce74aaba
7
+ data.tar.gz: 7779d9a8e8e86ee34d1943d6b028c1eafd5673cba116dd78fac40aeac5fff166593b1d821b25951beae292f5faffe7f92898f9e353fd2a91e1acfd2f88b6c147
data/README.md CHANGED
@@ -29,6 +29,14 @@ $> elastip 'pr*ject\d+' staging
29
29
  10.0.15.42
30
30
  ```
31
31
 
32
+ If you want to also list the non Healthy instances (the red ones for instance), you can add the --all option
33
+
34
+ ```
35
+ $> elastip project_name production --all
36
+ 10.0.15.12
37
+ 10.0.15.16
38
+ ```
39
+
32
40
  You got the idea. You can then use it directly in an alias doing `ssh ec2-user@$(elastip project-name production)`
33
41
 
34
42
 
data/exe/elastip CHANGED
@@ -1,12 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'elastip'
3
+ begin
4
+ Object.const_get('Elastip')
5
+ rescue NameError
6
+ require 'bundler/setup'
7
+ end
4
8
 
5
- project, env = ARGV.take(2)
9
+ require 'elastip'
6
10
 
11
+ project, env, options = ARGV
12
+ options ||= []
7
13
  if !project or !env
8
- abort "Usage: elastip <project name regexp> <environnement (e.g staging production)>\n" \
14
+ abort "Usage: elastip <project name regexp> <environnement (e.g staging production)> [--all]\n" \
9
15
  "Example: elastip 'my_pro*ect' production"
10
16
  end
11
17
 
12
- puts Elastip::Elastip.new(project, env).ip.join("\n")
18
+ puts Elastip::Elastip.new(project, env, options).ip.join("\n")
data/lib/elastip.rb CHANGED
@@ -5,16 +5,19 @@ require 'aws-sdk'
5
5
 
6
6
  module Elastip
7
7
  class Elastip
8
- def initialize(project, env)
8
+ def initialize(project, env, options=[])
9
9
  abort "You need to specify a project and an environnement (e.g staging,production)" if !project or !env
10
10
  @project_re = Regexp.new(project)
11
11
  @env = env
12
+ @all = options.include?('--all')
12
13
  end
13
14
 
14
15
  def ip
15
16
  active_envs = environments.map do |env|
16
- if env[:health] == "Green" && @project_re =~ env[:application_name].downcase && env[:environment_name].include?(@env)
17
- env[:environment_name]
17
+ if @project_re =~ env[:application_name].downcase && env[:environment_name].include?(@env)
18
+ if @all || env[:health] == 'Green'
19
+ env[:environment_name]
20
+ end
18
21
  end
19
22
  end.compact
20
23
 
@@ -22,8 +25,9 @@ module Elastip
22
25
 
23
26
  target_instances = active_envs.map do |active|
24
27
  instance = instances.find{|x| x[:tags].any?{|y| active == y[:value] } && x[:state][:name] != 'terminated'}
25
- {instance: active, ip: instance[:private_ip_address]}
26
- end
28
+ {instance: active, ip: instance[:private_ip_address]} if instance
29
+ end.compact
30
+ STDERR.puts target_instances.inspect
27
31
  target_instances.map{|x| x[:ip]}
28
32
  end
29
33
 
@@ -1,3 +1,3 @@
1
1
  module Elastip
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pcboy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-21 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler