roadworker 0.3.10 → 0.4.0

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjIzOTY2MjJjYmYzODVjMDE0NzFkZTIyMzhiNjRlNzJlZjYwMjljNA==
5
- data.tar.gz: !binary |-
6
- NWNiMzA2Nzk5YmE4NTllY2ZlMDFiMWNjZTYxYjYxYmM4MGEzNTRkMQ==
2
+ SHA1:
3
+ metadata.gz: efa1def64b9857b4163dec7834451bd043691b02
4
+ data.tar.gz: 22896a3d8aec83cbe1e8cd35902a19bae813a9ff
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MmU4Y2U0MTYyYThhYzcwZDBiODFlMmYzZWFkOTY0YWExMTVlM2ViNWVlYjUy
10
- OGMzYzc2YzNlN2E1NjJjNGIwM2FmM2UxOTBlYTI4YjA4OTNiY2RlZThjOTZi
11
- ZmYwNDUyMjVhMDQyNDhhNGU0MDVhYmRjMTU4NmI0Yzk4MjQ5OGI=
12
- data.tar.gz: !binary |-
13
- ZGYxMzFkZGY5M2M0YjM5YWYyZWJlODc1YmU0MzNmODE3ZWRjOWQyODhkZDEw
14
- ZGZiMmIyNTFmOWFhNjJhMzgxMjZiNWRhMDMzNmYyNmY4MWNmMzM3MDcyNmZj
15
- MjE2ZDUyMTVhNTM0NTA3YzUzMjA2NzM5MzM3NjNmOTE5OTdhZjA=
6
+ metadata.gz: 0ff0d8d411d8946dcf5d6c603176fec39ce612ad9ff0b32ef5d197735c9e697d6d5f7c1bb20c26dbacec5fa498145a44877fc015cd61711df2d11d3772149ce3
7
+ data.tar.gz: 58a926b9dd085d59a817cd0a4b8a72fe922daddee9f1b1199f3b00f63598eece18d88dcc2b4d006d249c58ef7c85d08e5e422d4c1b01ffd3ff039577a007402f
data/README.md CHANGED
@@ -4,6 +4,7 @@ Roadworker is a tool to manage Route53.
4
4
 
5
5
  It defines the state of Route53 using DSL, and updates Route53 according to DSL.
6
6
 
7
+ [![Gem Version](https://badge.fury.io/rb/roadworker.png)](http://badge.fury.io/rb/roadworker)
7
8
  [![Build Status](https://drone.io/bitbucket.org/winebarrel/roadworker/status.png)](https://drone.io/bitbucket.org/winebarrel/roadworker/latest)
8
9
 
9
10
  **Notice**
@@ -66,7 +67,7 @@ hosted_zone "info.winebarrel.jp." do
66
67
  rrset "zzz.info.winebarrel.jp", "A" do
67
68
  set_identifier "Primary"
68
69
  failover "PRIMARY"
69
- health_check "http://192.0.43.10:80/path", :host => "example.com"
70
+ health_check "http://192.0.43.10:80/path", :host => "example.com", :search_string => "ANY_RESPONSE_STRING"
70
71
  ttl 456
71
72
  resource_records(
72
73
  "127.0.0.1",
@@ -33,8 +33,14 @@ module Roadworker
33
33
  end
34
34
  when :health_check_id
35
35
  config = HealthCheck.config_to_hash(@health_checks[value])
36
- hc_args = config[:url].inspect
37
- hc_args << ", #{config[:host_name].inspect}" if config[:host_name]
36
+ hc_args = config[:url].sub(/\A(https?)_str_match:/) { $1 + ':' }.inspect
37
+
38
+ [:host, :search_string].each do |key|
39
+ if config[key]
40
+ hc_args << ", :#{key} => #{config[key].inspect}"
41
+ end
42
+ end
43
+
38
44
  "health_check #{hc_args}"
39
45
  else
40
46
  "#{key} #{value.inspect}"
@@ -91,8 +91,9 @@ module Roadworker
91
91
  expected_value = expected_value.map {|i| i.downcase.sub(/\.\Z/, '') }
92
92
  actual_value = actual_value.map {|i| i.downcase.sub(/\.\Z/, '') }
93
93
  when 'TXT', 'SPF'
94
- expected_value = expected_value.map {|i| i.scan(/"([^"]+)"/).join.strip.gsub(/\s+/, ' ') }
95
- actual_value = actual_value.map {|i| i.strip.gsub(/\s+/, ' ') }
94
+ # see https://github.com/bluemonk/net-dns/blob/651dc1006d9ee0c167fa515e4b9d2494af415ae9/lib/net/dns/rr/txt.rb#L46
95
+ expected_value = expected_value.map {|i| i.scan(/"([^"]+)"/).join(' ').strip }
96
+ actual_value = actual_value.map {|i| i.strip }
96
97
  end
97
98
 
98
99
  expected_message = record.resource_records ? expected_value.map {|i| "#{i}(#{expected_ttl})" }.join(',') : "#{record.dns_name}(#{expected_ttl})"
@@ -120,18 +120,34 @@ module Roadworker
120
120
  @result.failover = value
121
121
  end
122
122
 
123
- def health_check(url, options = nil)
123
+ def health_check(url, *options)
124
124
  config = HealthCheck.parse_url(url)
125
125
 
126
- if options
127
- if options.kind_of?(Hash)
128
- config[:fully_qualified_domain_name] = options.fetch(:host)
129
- else
130
- config[:fully_qualified_domain_name] = options.to_s
126
+ if options.length == 1 and options.first.kind_of?(Hash)
127
+ options = options.first
128
+
129
+ {
130
+ :host => :fully_qualified_domain_name,
131
+ :search_string => :search_string,
132
+ }.each do |option_key, config_key|
133
+ config[config_key] = options[option_key] if options[option_key]
134
+ end
135
+ else
136
+ options.each_with_index do |value, i|
137
+ key = [
138
+ :fully_qualified_domain_name,
139
+ :search_string,
140
+ ][i]
141
+
142
+ config[key] = value
131
143
  end
132
144
  end
133
145
 
134
- @result.health_check = config
146
+ if config[:search_string]
147
+ config[:type] += '_STR_MATCH'
148
+ end
149
+
150
+ @result.health_check = config
135
151
  end
136
152
 
137
153
  def resource_records(*values)
@@ -1,6 +1,52 @@
1
1
  require 'aws-sdk'
2
2
 
3
3
  module AWS
4
+ module Core
5
+ class Client
6
+
7
+ # PTF:
8
+ class << self
9
+ alias load_api_config_orig load_api_config
10
+
11
+ def load_api_config(api_version)
12
+ yaml = load_api_config_orig(api_version)
13
+
14
+ if service_name == 'Route53'
15
+ replace_api_version(yaml)
16
+ end
17
+
18
+ return yaml
19
+ end
20
+
21
+ private
22
+
23
+ def replace_api_version(value)
24
+ case value
25
+ when String
26
+ if value =~ /2012-12-12/
27
+ value.gsub!(/2012-12-12/, '2013-04-01')
28
+ end
29
+ when Array
30
+ value.each {|v| replace_api_version(v) }
31
+ when Hash
32
+ value.each do |k, v|
33
+ if k == :health_check_config
34
+ v[:members][:search_string] = {
35
+ :name => 'SearchString',
36
+ :type => :string,
37
+ :position => 5,
38
+ }
39
+ end
40
+
41
+ replace_api_version(v)
42
+ end
43
+ end
44
+ end
45
+ end # of class method
46
+
47
+ end # Client
48
+ end # Core
49
+
4
50
  class Route53
5
51
 
6
52
  # http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
@@ -18,12 +18,14 @@ module Roadworker
18
18
  port = config[:port]
19
19
  type = config[:type].downcase
20
20
  path = config[:resource_path]
21
- fqdn = config[:fully_qualified_domain_name].downcase
21
+ fqdn = config[:fully_qualified_domain_name]
22
+ fqdn = fqdn.downcase if fqdn
23
+ search_string = config[:search_string]
22
24
 
23
25
  url = "#{type}://#{ipaddr}:#{port}"
24
26
  url << path if path && path != '/'
25
27
 
26
- {:url => url, :host_name => fqdn}
28
+ {:url => url, :host => fqdn, :search_string => search_string}
27
29
  end
28
30
 
29
31
  def parse_url(url)
@@ -61,7 +61,7 @@ module Roadworker
61
61
  HostedZoneWrapper.new(zone, @options)
62
62
  end
63
63
  end # HostedZoneCollection
64
-
64
+
65
65
  class HostedZoneWrapper
66
66
  include Roadworker::Log
67
67
 
@@ -115,7 +115,7 @@ module Roadworker
115
115
  end
116
116
 
117
117
  def create(name, type, expected_record)
118
- log(:info, 'Create ResourceRecordSet', :cyan) do
118
+ log(:info, 'Create ResourceRecordSet', :cyan) do
119
119
  log_id = [name, type].join(' ')
120
120
  rrset_setid = expected_record.set_identifier
121
121
  rrset_setid ? (log_id + " (#{rrset_setid})") : log_id
@@ -13,11 +13,11 @@ class String
13
13
  end
14
14
  end # of class method
15
15
 
16
- Term::ANSIColor::Attribute.named_attributes.map do |attr|
16
+ Term::ANSIColor::Attribute.named_attributes.map do |attribute|
17
17
  class_eval(<<-EOS, __FILE__, __LINE__ + 1)
18
- def #{attr.name}
18
+ def #{attribute.name}
19
19
  if @@colorize
20
- Term::ANSIColor.send(#{attr.name.inspect}, self)
20
+ Term::ANSIColor.send(#{attribute.name.inspect}, self)
21
21
  else
22
22
  self
23
23
  end
@@ -1,5 +1,5 @@
1
1
  module Roadworker
2
- VERSION = "0.3.10"
2
+ VERSION = "0.4.0"
3
3
  end
4
4
 
5
5
  Version = Roadworker::VERSION
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadworker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-10 00:00:00.000000000 Z
11
+ date: 2014-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.14.1
19
+ version: 1.33.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.14.1
26
+ version: 1.33.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: term-ansicolor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.2.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.2.2
41
41
  - !ruby/object:Gem::Dependency
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: uuid
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 2.3.7
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.3.7
69
69
  - !ruby/object:Gem::Dependency
@@ -84,14 +84,14 @@ dependencies:
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
@@ -142,17 +142,17 @@ require_paths:
142
142
  - lib
143
143
  required_ruby_version: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ! '>='
145
+ - - '>='
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - '>='
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  requirements: []
154
154
  rubyforge_project:
155
- rubygems_version: 2.1.5
155
+ rubygems_version: 2.0.14
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Roadworker is a tool to manage Route53.