record_store 6.4.0 → 6.5.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 +4 -4
- data/.github/workflows/ci.yml +28 -0
- data/lib/record_store/version.rb +1 -1
- data/lib/record_store/zone/config.rb +3 -3
- data/lib/record_store/zone/yaml_definitions.rb +4 -1
- data/lib/record_store/zone.rb +33 -2
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f5d50f38de714c7b8d6d316070fc9d6bca5ac4d40751629c3c565866178d628
|
|
4
|
+
data.tar.gz: 14e3171ad53e5903404fcda9404bbfa109ec63db0c9253d8f3f7df76ee0e0ff1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac87302ec7f2d9e1afcbac7af6ef340a7a6fdd7d503a2f941fb7e7f021a46eb3a2b071841a152b264ba1956c50aa45141853a3bfdda4e8101a5e226ddec595ac
|
|
7
|
+
data.tar.gz: 17fdee4d8ca5b4e9692e6a3718cdbb143e076890b2752a9dd4516c110835edbd73208056c8be8bfc5d18b926d97050d33300a04c29639d77cdc1429b2caf41cc
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
env:
|
|
6
|
+
SRB_SKIP_GEM_RBIS: true
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
ruby: [ 2.7.1 ]
|
|
15
|
+
name: Test Ruby ${{ matrix.ruby }}
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v2
|
|
18
|
+
- name: Set up Ruby
|
|
19
|
+
uses: ruby/setup-ruby@v1
|
|
20
|
+
with:
|
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
|
22
|
+
bundler-cache: true
|
|
23
|
+
- name: rubocop
|
|
24
|
+
run: bin/rubocop --version && bin/rubocop
|
|
25
|
+
- name: setup
|
|
26
|
+
run: bin/setup
|
|
27
|
+
- name: test
|
|
28
|
+
run: bundle exec rake test
|
data/lib/record_store/version.rb
CHANGED
|
@@ -3,15 +3,15 @@ module RecordStore
|
|
|
3
3
|
class Config
|
|
4
4
|
include ActiveModel::Validations
|
|
5
5
|
|
|
6
|
-
attr_reader :ignore_patterns, :providers, :supports_alias, :
|
|
6
|
+
attr_reader :ignore_patterns, :providers, :supports_alias, :implicit_records_templates
|
|
7
7
|
|
|
8
8
|
validate :validate_zone_config
|
|
9
9
|
|
|
10
|
-
def initialize(ignore_patterns: [], providers: nil, supports_alias: nil,
|
|
10
|
+
def initialize(ignore_patterns: [], providers: nil, supports_alias: nil, implicit_records_templates: [])
|
|
11
11
|
@ignore_patterns = ignore_patterns.map do |ignore_pattern|
|
|
12
12
|
Zone::Config::IgnorePattern.new(ignore_pattern)
|
|
13
13
|
end
|
|
14
|
-
@
|
|
14
|
+
@implicit_records_templates = implicit_records_templates.map do |filename|
|
|
15
15
|
Zone::Config::ImplicitRecordTemplate.from_file(filename: filename)
|
|
16
16
|
end
|
|
17
17
|
@providers = providers
|
|
@@ -66,7 +66,10 @@ module RecordStore
|
|
|
66
66
|
Dir["#{dir}/#{name}/*__*.yml"].each do |record_file|
|
|
67
67
|
definition['records'] += load_yml_record_definitions(name, record_file)
|
|
68
68
|
end
|
|
69
|
-
|
|
69
|
+
|
|
70
|
+
asts = { filename => Psych.parse_file(filename) }
|
|
71
|
+
|
|
72
|
+
Zone.new(name: name, records: definition['records'], config: definition['config'], abstract_syntax_trees: asts)
|
|
70
73
|
end
|
|
71
74
|
|
|
72
75
|
def load_yml_record_definitions(name, record_file)
|
data/lib/record_store/zone.rb
CHANGED
|
@@ -20,6 +20,7 @@ module RecordStore
|
|
|
20
20
|
validate :validate_provider_can_handle_zone_records
|
|
21
21
|
validate :validate_no_empty_non_terminal
|
|
22
22
|
validate :validate_can_handle_alias_records
|
|
23
|
+
validate :validate_no_duplicate_keys
|
|
23
24
|
|
|
24
25
|
class << self
|
|
25
26
|
def download(name, provider_name, **write_options)
|
|
@@ -70,10 +71,11 @@ module RecordStore
|
|
|
70
71
|
end
|
|
71
72
|
end
|
|
72
73
|
|
|
73
|
-
def initialize(name:, records: [], config: {})
|
|
74
|
+
def initialize(name:, records: [], config: {}, abstract_syntax_trees: {})
|
|
74
75
|
@name = Record.ensure_ends_with_dot(name)
|
|
75
76
|
@config = RecordStore::Zone::Config.new(config.deep_symbolize_keys)
|
|
76
77
|
@records = build_records(records)
|
|
78
|
+
@abstract_syntax_trees = abstract_syntax_trees
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
def build_changesets(all: false)
|
|
@@ -191,7 +193,7 @@ module RecordStore
|
|
|
191
193
|
def build_records(records)
|
|
192
194
|
all_records = records.map { |record| Record.build_from_yaml_definition(record) }
|
|
193
195
|
|
|
194
|
-
config.
|
|
196
|
+
config.implicit_records_templates.each do |template|
|
|
195
197
|
all_records.push(*template.generate_records_to_inject(current_records: all_records))
|
|
196
198
|
end
|
|
197
199
|
|
|
@@ -307,5 +309,34 @@ module RecordStore
|
|
|
307
309
|
|
|
308
310
|
errors.add(:records, "ALIAS record should be defined on the root of the zone: #{alias_record}")
|
|
309
311
|
end
|
|
312
|
+
|
|
313
|
+
def validate_no_duplicate_keys
|
|
314
|
+
@abstract_syntax_trees.each do |filename, ast|
|
|
315
|
+
validate_no_duplicate_keys_in_node(filename, ast)
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def validate_no_duplicate_keys_in_node(filename, node)
|
|
320
|
+
if node.mapping?
|
|
321
|
+
keys = node
|
|
322
|
+
.children
|
|
323
|
+
.each_slice(2)
|
|
324
|
+
.map(&:first)
|
|
325
|
+
.map(&:value)
|
|
326
|
+
.sort
|
|
327
|
+
dup_keys = keys
|
|
328
|
+
.find_all { |k| keys.count(k) > 1 }
|
|
329
|
+
.uniq
|
|
330
|
+
unless dup_keys.empty?
|
|
331
|
+
location = "#{File.basename(filename)}:#{node.start_line}"
|
|
332
|
+
description = "multiple definitions for keys #{dup_keys}"
|
|
333
|
+
errors.add(:records, "#{location}: #{description}")
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
node.children&.each do |child|
|
|
338
|
+
validate_no_duplicate_keys_in_node(filename, child)
|
|
339
|
+
end
|
|
340
|
+
end
|
|
310
341
|
end
|
|
311
342
|
end
|
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: 6.
|
|
4
|
+
version: 6.5.0
|
|
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:
|
|
12
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: thor
|
|
@@ -335,6 +335,7 @@ executables:
|
|
|
335
335
|
extensions: []
|
|
336
336
|
extra_rdoc_files: []
|
|
337
337
|
files:
|
|
338
|
+
- ".github/workflows/ci.yml"
|
|
338
339
|
- ".gitignore"
|
|
339
340
|
- ".rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml"
|
|
340
341
|
- ".rubocop.yml"
|
|
@@ -416,7 +417,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
416
417
|
- !ruby/object:Gem::Version
|
|
417
418
|
version: '0'
|
|
418
419
|
requirements: []
|
|
419
|
-
rubygems_version: 3.
|
|
420
|
+
rubygems_version: 3.2.17
|
|
420
421
|
signing_key:
|
|
421
422
|
specification_version: 4
|
|
422
423
|
summary: Manage DNS using git
|