kong_schema 1.1.0 → 1.1.1

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: ce66ed2926b783ba19d2eee0e5e85d2606ead664
4
- data.tar.gz: f040ed071ff55f64c1ea86906403b3f093c4e4b6
3
+ metadata.gz: 8ccf080d9311fc62088bf690a8d86af06fae4a97
4
+ data.tar.gz: fcba834c6e444a18c805e08487504a42186abe67
5
5
  SHA512:
6
- metadata.gz: b2ff0756f8345d767ac68f28a57b07b05336252360906cf901386f247dbd12320fe8e501b2c736a45051e0a8878a969ba3ae315e9bd945f9aa9d158fb25c4975
7
- data.tar.gz: 75e4876cd89fcb9ab5dd1538427f79d0a52f5670ae4bb4429d95b60859be221b6140b4d6be98bc469d750bfa9abc9a75904fb2973c458b9d0172567e5256eee5
6
+ metadata.gz: 932e679e8c807a03e75e73ebdfe510a4374442ba6fcec7b43c7312532ef38d189c14005ad26cdbc7f2222faf12f75e21d53543ab3700e125f67dbeb8bd7270e3
7
+ data.tar.gz: dc34b51e197f958ab0708cd5a1bc6be8607fa7769780324a5f7b4e7f6ce5724da45593cfcd3e645d185e6f379a9ee2dcc52135f8e7c38bf5f04dc46c46790704
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  /.bundle
2
2
  /coverage
3
- /bin
3
+ /bin
4
+ /*.gem
data/CHANGELOG.md CHANGED
@@ -1,11 +1,23 @@
1
- # 1.0.1
1
+ ## 1.1.1
2
+
3
+ - Fixed an issue assigning the "methods" attribute of Kong::Api objects
4
+ - Empty array values (like "hosts" and "methods") will no longer display
5
+ as having changed if their API value is "null"
6
+ - CLI command `kong_schema up` will now print an error message if the required
7
+ argument was not passed
8
+
9
+ ## 1.1.0
10
+
11
+ - Added a CLI binary: `kong_schema`
12
+
13
+ ## 1.0.1
2
14
 
3
15
  - Fixed a bug where an empty array of "hosts", "uris", or "methods" in "apis"
4
16
  would raise an exception.
5
17
  - An error will now be raised if `admin_host` is not defined in config (and a
6
18
  connection to Kong admin can not be established)
7
19
 
8
- # 1.0.0
20
+ ## 1.0.0
9
21
 
10
22
  Initial release with support for the following Kong objects:
11
23
 
@@ -14,15 +14,15 @@ module KongSchema
14
14
  @model.create(params)
15
15
  end
16
16
 
17
- def changed?(record, directive)
18
- directive.keys.any? do |key|
19
- !record.send(key).eql?(directive[key])
17
+ def changed?(current_attributes, next_attributes)
18
+ next_attributes.keys.any? do |key|
19
+ !current_attributes[key].eql?(next_attributes[key])
20
20
  end
21
21
  end
22
22
 
23
23
  def update(record, params)
24
24
  params.keys.each do |key|
25
- record.send "#{key}=", params[key]
25
+ record.attributes[key] = params[key]
26
26
  end
27
27
 
28
28
  record.save
@@ -38,6 +38,8 @@ module KongSchema
38
38
  })
39
39
 
40
40
  c.action do |global_options, options, args|
41
+ help_now! "Missing path to .yml or .json config file" if args.first.nil?
42
+
41
43
  up(filepath: args.first, options: options)
42
44
  end
43
45
  end
@@ -0,0 +1,7 @@
1
+ module KongSchema
2
+ module Functional
3
+ def blank?(object)
4
+ object.nil? || object.empty?
5
+ end
6
+ end
7
+ end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require 'kong'
4
4
  require_relative '../adapter'
5
+ require_relative '../functional'
5
6
 
6
7
  module KongSchema
7
8
  module Resource
8
9
  module Api
9
10
  extend self
11
+ extend Functional
10
12
 
11
13
  def identify(record)
12
14
  case record
@@ -26,7 +28,20 @@ module KongSchema
26
28
  end
27
29
 
28
30
  def changed?(record, attributes)
29
- Adapter.for(Kong::Api).changed?(record, attributes)
31
+ current = record.attributes.keys.reduce({}) do |map, key|
32
+ value = record.attributes[key]
33
+
34
+ case key
35
+ when 'hosts', 'methods', 'uris'
36
+ map[key] = blank?(value) ? nil : Array(value)
37
+ else
38
+ map[key] = value
39
+ end
40
+
41
+ map
42
+ end
43
+
44
+ Adapter.for(Kong::Api).changed?(current, attributes)
30
45
  end
31
46
 
32
47
  def update(record, partial_attributes)
@@ -43,7 +58,7 @@ module KongSchema
43
58
  def serialize_outbound(attributes)
44
59
  attributes.keys.reduce({}) do |map, key|
45
60
  case key
46
- when 'hosts', 'uris', 'methods'
61
+ when 'hosts', 'methods', 'uris'
47
62
  map[key] = Array(attributes[key]).join(',')
48
63
  else
49
64
  map[key] = attributes[key]
@@ -27,7 +27,7 @@ module KongSchema
27
27
  end
28
28
 
29
29
  def changed?(record, attributes)
30
- Adapter.for(Kong::Upstream).changed?(record, attributes)
30
+ Adapter.for(Kong::Upstream).changed?(record.attributes, attributes)
31
31
  end
32
32
 
33
33
  def update(record, partial_attributes)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KongSchema
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.1".freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kong_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Amireh
@@ -161,6 +161,7 @@ files:
161
161
  - lib/kong_schema/adapter.rb
162
162
  - lib/kong_schema/cli.rb
163
163
  - lib/kong_schema/client.rb
164
+ - lib/kong_schema/functional.rb
164
165
  - lib/kong_schema/reporter.rb
165
166
  - lib/kong_schema/resource.rb
166
167
  - lib/kong_schema/resource/api.rb