avrolution 0.4.0.rc0 → 0.4.0.rc1

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
2
  SHA1:
3
- metadata.gz: 1927a0ffec1ea39c555e51d324281899ca9142ff
4
- data.tar.gz: 91f7c6723e95df2ef2562f9dd3a33d725c458a8e
3
+ metadata.gz: 6828c0755e2ea2576aa2b0e5cdcc45cc76e32d04
4
+ data.tar.gz: 06f859b1c6b91e4b2feb61f7fa30607b66f2c469
5
5
  SHA512:
6
- metadata.gz: 91842dec6fd051daecbf2c51f67f16b94feee0acfb764f10b9499516f5357738e9c3b81b9fa0cf7a8cedede8a7764bdf2087f9c7b462c7168ee14866b5478de0
7
- data.tar.gz: 10602cc66b3dd61bfba1db610f5faf9c070586e3fb2eb4c3ee88161eecfc4d40d38231cdc8bcf4fdefb68189dafadb7ac2db588c120bf1825e5f51561e583662
6
+ metadata.gz: fac16048c96d048c2642c80882cac45f496d4ad779da7b2e8cb75d4fa428bdf42f071b918fcfe6394b2c1c0eddbf28b28a1e9e505c458ee6974496b33230e771
7
+ data.tar.gz: 14471e54f6de841e73b7f831a1e899ace19df23de9639fcb2a6e9a8ab9877a097c1ec9f147b762f27e1580027ea8e19cfa8377c0fe3c2b7dc53ccad8db7e1fb6
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
3
3
  ## v0.4.0
4
4
  - Support a Proc for the configuration of `compatibility_schema_registry_url`
5
5
  and `deployment_schema_registry_url`.
6
+ - Environment variables now take priority over assigned values for
7
+ `Avrolution.compatibility_schema_registry_url` and
8
+ `Avrolution.deployment_schema_registry_url`.
6
9
 
7
10
  ## v0.3.0
8
11
  - Add rake task to register new schema versions.
data/README.md CHANGED
@@ -39,11 +39,11 @@ The gem supports the following configuration:
39
39
  * `compatibility_breaks_file` - The path to the compability breaks file. Defaults
40
40
  to `#{Avrolution}.root/avro_compatibility_breaks.txt`.
41
41
  * `compatibility_schema_registry_url` - The URL for the schema registry to use
42
- for compatibility checking. `ENV['COMPATIBILITY_SCHEMA_REGISTRY_URL']` is used
43
- as the default.
42
+ for compatibility checking, or a Proc to determine the value.
43
+ `ENV['COMPATIBILITY_SCHEMA_REGISTRY_URL']` overrides this value if set.
44
44
  * `deployment_schema_registry_url` - The URL for the schema registry to use
45
- when registering new schema version. `ENV['DEPLOYMENT_SCHEMA_REGISTRY_URL']`
46
- is used as the default.
45
+ when registering new schema version, or a Proc to determine the value.
46
+ `ENV['DEPLOYMENT_SCHEMA_REGISTRY_URL']` overrides this value if set.
47
47
  * `logger` - A logger used by the rake tasks in this gem. This does _NOT_ default
48
48
  to `Rails.logger` in Rails applications.
49
49
 
@@ -59,8 +59,8 @@ defined via a Railtie.
59
59
 
60
60
  This task does not require any arguments. It checks the
61
61
  compatibility of all Avro JSON schemas found recursively under `Avrolution.root`
62
- against the schema registry `Avroluion.compatibility_schema_registry_url` or
63
- `ENV['COMPATIBILITY_SCHEMA_REGISTRY_URL']`.
62
+ against the schema registry `ENV['COMPATIBILITY_SCHEMA_REGISTRY_URL']` or
63
+ `Avroluion.compatibility_schema_registry_url`.
64
64
 
65
65
  ```bash
66
66
  rake avro:check_compatibility
@@ -92,8 +92,8 @@ rake avro:register_schemas schemas=/app/avro/schemas/one.avsc,/app/avro/schema/t
92
92
  ```
93
93
 
94
94
  Schemas are registered against the schema registry
95
- `Avroluion.deployment_schema_registry_url` or
96
- `ENV['DEPLOYMENT_SCHEMA_REGISTRY_URL']`.
95
+ `ENV['DEPLOYMENT_SCHEMA_REGISTRY_URL']` or
96
+ `Avroluion.deployment_schema_registry_url`.
97
97
 
98
98
  The `Avrolution.compatibility_breaks_file` is consulted prior to registering the
99
99
  schema, and if an entry is found then the specified compatibility settings are
@@ -1,8 +1,5 @@
1
1
  module Avrolution
2
2
 
3
- COMPATIBILITY_SCHEMA_REGISTRY_URL = 'COMPATIBILITY_SCHEMA_REGISTRY_URL'.freeze
4
- DEPLOYMENT_SCHEMA_REGISTRY_URL = 'DEPLOYMENT_SCHEMA_REGISTRY_URL'.freeze
5
-
6
3
  class << self
7
4
  # Root directory to search for schemas, and default location for
8
5
  # compatibility breaks file
@@ -21,6 +18,22 @@ module Avrolution
21
18
  attr_writer :deployment_schema_registry_url
22
19
 
23
20
  attr_accessor :logger
21
+
22
+ def fetch_url(label)
23
+ env_name = "#{label.upcase}_SCHEMA_REGISTRY_URL"
24
+ ivar_name = "@#{env_name.downcase}"
25
+ env_value = ENV[env_name]
26
+ result = if env_value
27
+ env_value
28
+ elsif instance_variable_get(ivar_name)
29
+ ivar_value = instance_variable_get(ivar_name)
30
+ ivar_value = instance_variable_set(ivar_name, ivar_value.call) if ivar_value.is_a?(Proc)
31
+ ivar_value
32
+ end
33
+
34
+ raise "#{env_name.downcase} must be set" if result.blank?
35
+ result
36
+ end
24
37
  end
25
38
 
26
39
  self.logger = Avrolution::PassthruLogger.new($stdout)
@@ -34,17 +47,11 @@ module Avrolution
34
47
  end
35
48
 
36
49
  def self.compatibility_schema_registry_url
37
- @compatibility_schema_registry_url = @compatibility_schema_registry_url.call if @compatibility_schema_registry_url.is_a?(Proc)
38
- @compatibility_schema_registry_url ||= ENV.fetch(COMPATIBILITY_SCHEMA_REGISTRY_URL) do
39
- raise 'compatibility_schema_registry_url must be set'
40
- end
50
+ fetch_url('compatibility')
41
51
  end
42
52
 
43
53
  def self.deployment_schema_registry_url
44
- @deployment_schema_registry_url = @deployment_schema_registry_url.call if @deployment_schema_registry_url.is_a?(Proc)
45
- @deployment_schema_registry_url ||= ENV.fetch(DEPLOYMENT_SCHEMA_REGISTRY_URL) do
46
- raise 'deployment_schema_registry_url must be set'
47
- end
54
+ fetch_url('deployment')
48
55
  end
49
56
 
50
57
  def self.configure
@@ -1,3 +1,3 @@
1
1
  module Avrolution
2
- VERSION = '0.4.0.rc0'.freeze
2
+ VERSION = '0.4.0.rc1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avrolution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.rc0
4
+ version: 0.4.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-13 00:00:00.000000000 Z
11
+ date: 2017-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler