kanmon 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b86b5720d0e9a1091f268c95417798f229b8cb0e3a0dbc56578e1ac0dcd88c04
4
- data.tar.gz: 0aeca4174abd12f9e5a916856c8d596f43ae51c85b769b3fd9f11dc9405b42bf
3
+ metadata.gz: c7763fbbed4cecabc922125a30caacb18d0d5574e93af3da56598f7d3e08eb9b
4
+ data.tar.gz: 2d0dfa4d5a4e2871333db6d0be1215840da0b1f407b6deea2ad437091eef78ae
5
5
  SHA512:
6
- metadata.gz: 24c2c7e15d5b0bdcbf321478e4fdaddd71efc26bcd2d0d73e92558e1e645e1cfc5d2e5ff3f28404ac3b1a1ed2d2bc7290a06ae7ef1991e633a5b97c9988e8bb3
7
- data.tar.gz: 70e05239cfc92015d3b6c5ed8ee151ec018f8daf6aa0dba9f0da47f714a5d1de0497f7831ce43faff3a5179a83f2d2248e6a8b6b8f741149c43dbff938b4171b
6
+ metadata.gz: 51137dade3e5a63e1fa0fbdef6d7a20d791c8dfc90d42941df701632eed20d468a5aa79ab96ce3770fd9674b55594a053524d9e11e7e83c3d09f230cc7d6fe8c
7
+ data.tar.gz: 9ef021e917c5868a1d65324dde73ba8a1e8676bd0f5d852b3588324e25fee4fb869e40812ce5acfbc278cd870c9f09a230c6a7e7e22c7e273b36b91c26832656
data/README.md CHANGED
@@ -27,6 +27,15 @@ targetB:
27
27
  server: 33344444-5555-6666-7777-888800000000
28
28
  ```
29
29
 
30
+ 実行する環境の IP で追加・削除したくないものがあれば、予め exclude\_ips にリストを記載しておくことで除外できます。
31
+
32
+ ```yaml
33
+ $ cat kanmon.yml
34
+ security_group: 11122233-4444-5555-6666-777788889999
35
+ exclude_ips:
36
+ - 203.0.113.0
37
+ ```
38
+
30
39
  環境変数を設定します。
31
40
 
32
41
  ```
data/lib/kanmon/cli.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  require "thor"
2
2
  require "shellwords"
3
3
 
4
+ require "kanmon/version"
4
5
  require "kanmon/securitygroup"
5
6
  require "kanmon/server"
7
+ require "kanmon/exclude_ips"
6
8
 
7
9
  module Yao::Resources
8
10
  class Server < Yao::Resources::Base
@@ -38,7 +40,7 @@ module Kanmon
38
40
 
39
41
  desc "ssh HOSTNAME", "Commands about exec ssh"
40
42
  def ssh(*args)
41
- invoke CLI, [:exec], args.unshift("ssh")
43
+ invoke :exec, args.unshift("ssh")
42
44
  end
43
45
 
44
46
  desc "exec COMMAND", "Commands about open, exec command, close"
@@ -67,6 +69,12 @@ module Kanmon
67
69
  if @config.key?('server')
68
70
  @kanmon = Server.new(@config["server"])
69
71
  end
72
+
73
+ exclude_ips = ExcludeIps.new(@config["exclude_ips"])
74
+ if exclude_ips.include?(@kanmon.ip)
75
+ puts "MyIP(#{@kanmon.ip}) is included in exclude IPs."
76
+ exit
77
+ end
70
78
  end
71
79
 
72
80
  super
@@ -0,0 +1,11 @@
1
+ module Kanmon
2
+ class ExcludeIps
3
+ def initialize(ips)
4
+ @ips = ips || Array.new
5
+ end
6
+
7
+ def include?(ip)
8
+ @ips.include?(ip)
9
+ end
10
+ end
11
+ end
@@ -4,6 +4,8 @@ require "kanmon/myip"
4
4
 
5
5
  module Kanmon
6
6
  class SecurityGroup
7
+ attr_reader :ip
8
+
7
9
  def initialize(id, ip = nil)
8
10
  @id = id
9
11
  @ip = ip || Kanmon::MyIP.get
data/lib/kanmon/server.rb CHANGED
@@ -4,6 +4,8 @@ require "kanmon/myip"
4
4
 
5
5
  module Kanmon
6
6
  class Server
7
+ attr_reader :ip
8
+
7
9
  def initialize(id, ip = nil)
8
10
  @id = id
9
11
  @ip = ip || Kanmon::MyIP.get
@@ -1,3 +1,3 @@
1
1
  module Kanmon
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanmon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Koya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-10 00:00:00.000000000 Z
11
+ date: 2018-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yao
@@ -101,6 +101,7 @@ files:
101
101
  - kanmon.gemspec
102
102
  - lib/kanmon.rb
103
103
  - lib/kanmon/cli.rb
104
+ - lib/kanmon/exclude_ips.rb
104
105
  - lib/kanmon/myip.rb
105
106
  - lib/kanmon/securitygroup.rb
106
107
  - lib/kanmon/server.rb