simnos 0.1.2 → 0.1.3.beta1

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
- SHA1:
3
- metadata.gz: 73fc966ae4921824425776121a1e1ebd4d37565a
4
- data.tar.gz: 96ecfd4f27f3623f298146756bf12a96feadd0f1
2
+ SHA256:
3
+ metadata.gz: 0f059e245208fe4b7cf670b9e439c551fb5f7474942f1018b6af99a45404a977
4
+ data.tar.gz: ae316c74adc659d468743006c5f801a48989ac8e1ed3804a9e4f021728baab0a
5
5
  SHA512:
6
- metadata.gz: d07e4938a546a9f96f0fc6676dcb8b5eafd39484a90875507039c5f2878f5f739107eefc8c1db1cc353dfaf88eb3ac2c4acd733e7cb54113d4cf1e03bb5fc679
7
- data.tar.gz: c218d9d6faf53d223188d23e048a84024f52edcc0a977cef0aa0ee40f65043645fd52dda7243905d06b43d4e1a2a1499f92f3e288f225b163353ba7446e82e72
6
+ metadata.gz: cfad7d4cde421b3834ba41fb5af57eeddd1d77732c085089a6472d125bff718e24622380d7ed5336b7abadd4b0c8e6a64c1e6c6e273241f3a0a787a8e4c365b8
7
+ data.tar.gz: 062f8f935d05fb2ed4eb1a2ee7004422d32874bf5b2844de33150b7e7f62c761c18d6403184a4e733ad9d8046b898367cf6cc34fb95e774144a0076042e21b41
data/README.md CHANGED
@@ -54,6 +54,10 @@ Usage: simnos [options]
54
54
  use secret value expansion
55
55
  -i, --include-names NAMES include SNS names
56
56
  -x, --exclude-names NAMES exclude SNS names by regex
57
+ --include-endpoints NAMES
58
+ include SNS subscriptions by endpoint
59
+ --exclude-endpoints NAMES
60
+ exclude SNS subscriptions by endpoint
57
61
  ```
58
62
 
59
63
  ## SNSfile
@@ -16,6 +16,8 @@ module Simnos
16
16
  color: true,
17
17
  includes: [],
18
18
  excludes: [],
19
+ include_endpoints: [],
20
+ exclude_endpoints: [],
19
21
  }
20
22
  parser.order!(@argv)
21
23
  end
@@ -53,6 +55,12 @@ module Simnos
53
55
  name =~ /\A\/(.*)\/\z/ ? Regexp.new($1) : Regexp.new("\A#{Regexp.escape(name)}\z")
54
56
  end
55
57
  end
58
+ opts.on('', '--include-endpoints NAMES', 'include SNS subscriptions by endpoint', Array) { |v| @options[:include_endpoints] = v }
59
+ opts.on('', '--exclude-endpoints NAMES', 'exclude SNS subscriptions by endpoint', Array) do |v|
60
+ @options[:exclude_endpoints] = v.map! do |name|
61
+ name =~ /\A\/(.*)\/\z/ ? Regexp.new($1) : Regexp.new("\A#{Regexp.escape(name)}\z")
62
+ end
63
+ end
56
64
  end
57
65
  end
58
66
 
@@ -73,6 +73,23 @@ module Simnos
73
73
 
74
74
  private
75
75
 
76
+ def target_subscription?(endpoint)
77
+ unless @options[:include_endpoints].empty?
78
+ unless @options[:include_endpoints].include?(endpoint)
79
+ Simnos.logger.debug("skip subscription(with include-endpoints option) #{endpoint}")
80
+ return false
81
+ end
82
+ end
83
+
84
+ unless @options[:exclude_endpoints].empty?
85
+ if @options[:exclude_endpoints].any? { |regex| endpoint =~ regex }
86
+ Simnos.logger.debug("skip subscription(with exclude-endpoints option) #{endpoint}")
87
+ return false
88
+ end
89
+ end
90
+ true
91
+ end
92
+
76
93
  def delete_subscriptions(aws_topic, aws_sub_by_key)
77
94
  aws_sub_by_key.each do |key, aws_sub|
78
95
  Simnos.logger.info("Delete Topic(#{aws_topic[:topic].topic_arn.split(':').last}) Subscription. protocol: #{key[0].inspect}, endpoint: #{key[1].inspect}.#{@options[:dry_run] ? ' [dry-run]' : ''}".colorize(:red))
@@ -87,8 +104,14 @@ module Simnos
87
104
  end
88
105
 
89
106
  def traverse_subscriptions(aws_topic, dsl_subscriptions, aws_subscriptions)
90
- dsl_sub_by_key = dsl_subscriptions.each_with_object({}) { |dsl_sub, h| h[[dsl_sub.protocol, dsl_sub.masked_endpoint]] = dsl_sub }
91
- aws_sub_by_key = aws_subscriptions.each_with_object({}) { |aws_sub, h| h[[aws_sub.protocol, aws_sub.endpoint]] = aws_sub }
107
+ dsl_sub_by_key = dsl_subscriptions.each_with_object({}) do |dsl_sub, h|
108
+ next unless target_subscription?(dsl_sub.endpoint)
109
+ h[[dsl_sub.protocol, dsl_sub.masked_endpoint]] = dsl_sub
110
+ end
111
+ aws_sub_by_key = aws_subscriptions.each_with_object({}) do |aws_sub, h|
112
+ next unless target_subscription?(aws_sub.endpoint)
113
+ h[[aws_sub.protocol, aws_sub.endpoint]] = aws_sub
114
+ end
92
115
 
93
116
  if @options[:recreate_subscriptions]
94
117
  Simnos.logger.info("Subscription recreation flag is on.#{@options[:dry_run] ? ' [dry-run]' : ''}")
@@ -1,3 +1,3 @@
1
1
  module Simnos
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3.beta1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simnos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - wata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-27 00:00:00.000000000 Z
11
+ date: 2018-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -186,12 +186,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  requirements:
189
- - - ">="
189
+ - - ">"
190
190
  - !ruby/object:Gem::Version
191
- version: '0'
191
+ version: 1.3.1
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.5.1
194
+ rubygems_version: 2.7.6
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Codenize AWS SNS