record_store 5.0.3 → 5.0.4

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
  SHA1:
3
- metadata.gz: 20f615c4e0d831a68c4512a476a6f1b92726d553
4
- data.tar.gz: e2999c24c3e3511840c509a9c1b86fc287eeacf8
3
+ metadata.gz: 3e8f21e1bb405e185727380fc0c7760116ef5deb
4
+ data.tar.gz: 29bed06e5aa2e8a4e3f78690015ee3bcc5f96c92
5
5
  SHA512:
6
- metadata.gz: afac206b2589b07b923ac23ab02611e2674f14a93513e87605ee2e791304cd10eea6d941cf6182315614484cade3dbdfba3d07b145d535ee6a7e2b577e31a5b9
7
- data.tar.gz: 90beeda20787c602529e65b626cd5f985b11c5467cc2e20ba84d6066baafc61c18c1a5ab88f0321ded54ca2d33b413b27e5d34f672a5344f8d8c24979fab168b
6
+ metadata.gz: d72af6c709460b9b81c44722e6ddd13cfa7f89f18659c7341f7512a6486c44e28364f512d49fee9f16d21240db229d16df07936447f6214356e76a64df862a02
7
+ data.tar.gz: 35ae3d3718486153cdd9d763de16ca4ef478e0a58f283fd43f6a39a537455547a75687f02daacc8add2db21c3415df42a26308fe08d7ba6691816eb8a551cdb5
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # CHANGELOG
2
+
3
+ ## 5.0.4
4
+ - Replaces fog-dnsimple with dnsimple-ruby gem.
5
+
6
+ ## ¯\_(ツ)_/¯
@@ -1,4 +1,4 @@
1
- require 'fog/dnsimple'
1
+ require 'dnsimple'
2
2
 
3
3
  module RecordStore
4
4
  class Provider::DNSimple < Provider
@@ -9,14 +9,7 @@ module RecordStore
9
9
 
10
10
  def add(record, zone)
11
11
  record_hash = api_hash(record, zone)
12
- res = session.create_record(
13
- zone,
14
- record_hash.fetch(:name),
15
- record.type,
16
- record_hash.fetch(:content),
17
- ttl: record_hash.fetch(:ttl),
18
- priority: record_hash.fetch(:priority, nil)
19
- )
12
+ res = session.zones.create_record(account_id, zone, record_hash)
20
13
 
21
14
  if record.type == 'ALIAS'
22
15
  txt_alias = retrieve_current_records(zone: zone).detect do |rr|
@@ -29,20 +22,20 @@ module RecordStore
29
22
  end
30
23
 
31
24
  def remove(record, zone)
32
- session.delete_record(zone, record.id)
25
+ session.zones.delete_record(account_id, zone, record.id)
33
26
  end
34
27
 
35
28
  def update(id, record, zone)
36
- session.update_record(zone, id, api_hash(record, zone))
29
+ session.zones.update_record(account_id, zone, id, api_hash(record, zone))
37
30
  end
38
31
 
39
32
  # returns an array of Record objects that match the records which exist in the provider
40
33
  def retrieve_current_records(zone:, stdout: $stdout)
41
- session.list_records(zone).body["data"].map do |record_body|
34
+ session.zones.all_records(account_id, zone).data.map do |record|
42
35
  begin
43
- build_from_api(record_body, zone)
36
+ build_from_api(record, zone)
44
37
  rescue StandardError
45
- stdout.puts "Cannot build record: #{record_body}"
38
+ stdout.puts "Cannot build record: #{record}"
46
39
  raise
47
40
  end
48
41
  end.compact
@@ -50,21 +43,20 @@ module RecordStore
50
43
 
51
44
  # Returns an array of the zones managed by provider as strings
52
45
  def zones
53
- session.zones.map(&:domain)
46
+ session.zones.all_zones(account_id).data.map(&:name)
54
47
  end
55
48
 
56
49
  private
57
50
 
58
51
  def session
59
- @dns ||= Fog::DNS.new(session_params)
52
+ @dns ||= Dnsimple::Client.new(
53
+ base_url: secrets.fetch('base_url'),
54
+ access_token: secrets.fetch('api_token')
55
+ )
60
56
  end
61
57
 
62
- def session_params
63
- {
64
- provider: 'DNSimple',
65
- dnsimple_token: secrets.fetch('api_token'),
66
- dnsimple_account: secrets.fetch('account_id'),
67
- }
58
+ def account_id
59
+ @account_id ||= secrets.fetch('account_id')
68
60
  end
69
61
 
70
62
  def secrets
@@ -72,33 +64,33 @@ module RecordStore
72
64
  end
73
65
 
74
66
  def build_from_api(api_record, zone)
75
- record_type = api_record.fetch('type')
67
+ record_type = api_record.type
76
68
  record = {
77
- record_id: api_record.fetch('id'),
78
- ttl: api_record.fetch('ttl'),
79
- fqdn: api_record.fetch('name').present? ? "#{api_record.fetch('name')}.#{zone}" : zone,
69
+ record_id: api_record.id,
70
+ ttl: api_record.ttl,
71
+ fqdn: api_record.name.present? ? "#{api_record.name}.#{zone}" : zone,
80
72
  }
81
73
 
82
74
  return if record_type == 'SOA'
83
75
 
84
76
  case record_type
85
77
  when 'A', 'AAAA'
86
- record.merge!(address: api_record.fetch('content'))
78
+ record.merge!(address: api_record.content)
87
79
  when 'ALIAS'
88
- record.merge!(alias: api_record.fetch('content'))
80
+ record.merge!(alias: api_record.content)
89
81
  when 'CNAME'
90
- record.merge!(cname: api_record.fetch('content'))
82
+ record.merge!(cname: api_record.content)
91
83
  when 'MX'
92
- record.merge!(preference: api_record.fetch('priority'), exchange: api_record.fetch('content'))
84
+ record.merge!(preference: api_record.priority, exchange: api_record.content)
93
85
  when 'NS'
94
- record.merge!(nsdname: api_record.fetch('content'))
86
+ record.merge!(nsdname: api_record.content)
95
87
  when 'SPF', 'TXT'
96
- record.merge!(txtdata: api_record.fetch('content').gsub(';', '\;'))
88
+ record.merge!(txtdata: api_record.content.gsub(';', '\;'))
97
89
  when 'SRV'
98
- weight, port, host = api_record.fetch('content').split(' ')
90
+ weight, port, host = api_record.content.split(' ')
99
91
 
100
92
  record.merge!(
101
- priority: api_record.fetch('priority').to_i,
93
+ priority: api_record.priority,
102
94
  weight: weight.to_i,
103
95
  port: port.to_i,
104
96
  target: Record.ensure_ends_with_dot(host),
@@ -1,3 +1,3 @@
1
1
  module RecordStore
2
- VERSION = '5.0.3'.freeze
2
+ VERSION = '5.0.4'.freeze
3
3
  end
data/record_store.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_runtime_dependency 'fog-json'
29
29
  spec.add_runtime_dependency 'fog-xml'
30
30
  spec.add_runtime_dependency 'fog-dynect', '~> 0.2.0'
31
- spec.add_runtime_dependency 'fog-dnsimple', '~> 2.0.0'
31
+ spec.add_runtime_dependency 'dnsimple-ruby', '~> 2.0'
32
32
  spec.add_runtime_dependency 'google-cloud-dns'
33
33
 
34
34
  spec.add_development_dependency 'rake'
@@ -5,6 +5,7 @@
5
5
  "password": "dynect_password"
6
6
  },
7
7
  "dnsimple": {
8
+ "base_url": "base_url",
8
9
  "account_id": "dnsimple_account_id",
9
10
  "api_token": "dnsimple_api_token"
10
11
  },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.3
4
+ version: 5.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-14 00:00:00.000000000 Z
12
+ date: 2018-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -124,19 +124,19 @@ dependencies:
124
124
  - !ruby/object:Gem::Version
125
125
  version: 0.2.0
126
126
  - !ruby/object:Gem::Dependency
127
- name: fog-dnsimple
127
+ name: dnsimple-ruby
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: 2.0.0
132
+ version: '2.0'
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: 2.0.0
139
+ version: '2.0'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: google-cloud-dns
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -246,6 +246,7 @@ extensions: []
246
246
  extra_rdoc_files: []
247
247
  files:
248
248
  - ".gitignore"
249
+ - CHANGELOG.md
249
250
  - Gemfile
250
251
  - LICENSE
251
252
  - README.md