skull_island 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/README.md +18 -4
- data/lib/skull_island.rb +3 -0
- data/lib/skull_island/helpers/resource.rb +3 -3
- data/lib/skull_island/resource.rb +1 -1
- data/lib/skull_island/resources/basicauth_credential.rb +100 -0
- data/lib/skull_island/resources/certificate.rb +1 -1
- data/lib/skull_island/resources/consumer.rb +64 -1
- data/lib/skull_island/resources/keyauth_credential.rb +92 -0
- data/lib/skull_island/resources/plugin.rb +12 -4
- data/lib/skull_island/resources/route.rb +1 -1
- data/lib/skull_island/resources/service.rb +6 -2
- data/lib/skull_island/resources/upstream.rb +2 -2
- data/lib/skull_island/resources/upstream_target.rb +1 -1
- data/lib/skull_island/version.rb +1 -1
- data/skull_island.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7c23619533ea2d31b5c07763270b49b90567bd9c4286579de345791dc3e2ae6
|
4
|
+
data.tar.gz: 172d74c57ef9263fb9511aedde42f7d0287ed746888bdb781cfcf9ae2fb5b297
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93d0089177792126e8a72a47d6843de52edba872e0e3f6a43ec471a5d058ba6834f3388b35193bcb899b841e5f15c11fc65d37362b790af7e9df8a353ec05d67
|
7
|
+
data.tar.gz: 2e626e9e42511472e7deab0ce83db1e2adb4e3b54c62a51cc7107d8b171e5b6dc5e42254936a2691f0c4da597056acb1b1cf58b5a7fbc753b2da60134809b370
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
skull_island (0.2.
|
4
|
+
skull_island (0.2.2)
|
5
|
+
deepsort (~> 0.4)
|
5
6
|
erubi (~> 1.8)
|
6
7
|
json (~> 2.1)
|
7
8
|
linguistics (~> 2.1)
|
@@ -15,6 +16,7 @@ GEM
|
|
15
16
|
addressable (2.4.0)
|
16
17
|
ast (2.4.0)
|
17
18
|
backports (3.12.0)
|
19
|
+
deepsort (0.4.1)
|
18
20
|
diff-lcs (1.3)
|
19
21
|
docile (1.3.1)
|
20
22
|
domain_name (0.5.20180417)
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ gem install skull_island
|
|
13
13
|
Or add this to your Gemfile:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
gem 'skull_island', '~>0.
|
16
|
+
gem 'skull_island', '~>0.2'
|
17
17
|
```
|
18
18
|
|
19
19
|
Or add this to your .gemspec:
|
@@ -21,14 +21,14 @@ Or add this to your .gemspec:
|
|
21
21
|
```ruby
|
22
22
|
Gem::Specification.new do |spec|
|
23
23
|
# ...
|
24
|
-
spec.add_runtime_dependency 'skull_island', '~> 0.
|
24
|
+
spec.add_runtime_dependency 'skull_island', '~> 0.2'
|
25
25
|
# ...
|
26
26
|
end
|
27
27
|
```
|
28
28
|
|
29
29
|
## CLI Usage
|
30
30
|
|
31
|
-
Skull Island comes with an executable called `skull_island` that leverages the SDK under the hood. Learn about what
|
31
|
+
Skull Island comes with an executable called `skull_island` that leverages the SDK under the hood. Learn about what it can do via `help`:
|
32
32
|
|
33
33
|
```
|
34
34
|
$ skull_island help
|
@@ -246,7 +246,7 @@ resource.created_at
|
|
246
246
|
# => #<DateTime: 2018-07-17T12:51:28+00:00 ((2458317j,46288s,0n),+0s,2299161j)>
|
247
247
|
```
|
248
248
|
|
249
|
-
#### Consumers
|
249
|
+
#### Consumers (and their Credentials)
|
250
250
|
|
251
251
|
```ruby
|
252
252
|
resource = Resources::Consumer.new
|
@@ -264,6 +264,20 @@ resource.created_at
|
|
264
264
|
# => #<DateTime: 2018-07-17T12:51:28+00:00 ((2458317j,46288s,0n),+0s,2299161j)>
|
265
265
|
resource.plugins
|
266
266
|
# => #<SkullIsland::ResourceCollection:0x00007f9f1e564f3e...
|
267
|
+
resource.credentials
|
268
|
+
# => {}
|
269
|
+
resource.add_credential!(key: '932948e89e09e2989d8092') # adds a KeyauthCredential
|
270
|
+
# => true
|
271
|
+
resource.credentials['key-auth']
|
272
|
+
# => #<SkullIsland::ResourceCollection:0x00007f9f1e564f3f...
|
273
|
+
resource.credentials['key-auth'].first.key
|
274
|
+
# => "932948e89e09e2989d8092"
|
275
|
+
resource.add_credential!(username: 'test', password: 'passw0rd') # adds a BasicauthCredential
|
276
|
+
# => true
|
277
|
+
resource.credentials['basic-auth']
|
278
|
+
# => #<SkullIsland::ResourceCollection:0x00007f9f1e564f3f...
|
279
|
+
resource.credentials['basic-auth'].first.username
|
280
|
+
# => "test"
|
267
281
|
```
|
268
282
|
|
269
283
|
#### Plugins
|
data/lib/skull_island.rb
CHANGED
@@ -9,6 +9,7 @@ require 'uri'
|
|
9
9
|
require 'yaml'
|
10
10
|
|
11
11
|
# External Library Requirements
|
12
|
+
require 'deepsort'
|
12
13
|
require 'erubi'
|
13
14
|
require 'linguistics'
|
14
15
|
Linguistics.use(:en)
|
@@ -42,6 +43,8 @@ require 'skull_island/helpers/resource_class'
|
|
42
43
|
require 'skull_island/validations/resource'
|
43
44
|
require 'skull_island/resource'
|
44
45
|
require 'skull_island/resources/certificate'
|
46
|
+
require 'skull_island/resources/basicauth_credential'
|
47
|
+
require 'skull_island/resources/keyauth_credential'
|
45
48
|
require 'skull_island/resources/consumer'
|
46
49
|
require 'skull_island/resources/plugin'
|
47
50
|
require 'skull_island/resources/service'
|
@@ -79,11 +79,11 @@ module SkullIsland
|
|
79
79
|
if find_by_digest
|
80
80
|
puts "[INFO] Skipping #{self.class} index #{index} (#{id})" if verbose
|
81
81
|
elsif test
|
82
|
-
puts "[INFO] Would have saved #{
|
82
|
+
puts "[INFO] Would have saved #{self.class} index #{index}"
|
83
83
|
elsif modified_existing?
|
84
84
|
puts "[INFO] Modified #{self.class} index #{index} (#{id})" if verbose
|
85
85
|
elsif save
|
86
|
-
puts "[INFO]
|
86
|
+
puts "[INFO] Created #{self.class} index #{index} (#{id})" if verbose
|
87
87
|
else
|
88
88
|
puts "[ERR] Failed to save #{self.class} index #{index}"
|
89
89
|
end
|
@@ -187,7 +187,7 @@ module SkullIsland
|
|
187
187
|
@lazy = true
|
188
188
|
else
|
189
189
|
@api_client.invalidate_cache_for(relative_uri.to_s)
|
190
|
-
@entity = @api_client.
|
190
|
+
@entity = @api_client.patch(relative_uri, saveable_data)
|
191
191
|
end
|
192
192
|
@api_client.invalidate_cache_for(self.class.relative_uri.to_s) # clear any collection class
|
193
193
|
@tainted = false
|
@@ -58,7 +58,7 @@ module SkullIsland
|
|
58
58
|
raise Exceptions::ImmutableModification if immutable?
|
59
59
|
|
60
60
|
if opts[:validate]
|
61
|
-
raise Exceptions::InvalidArguments unless send("validate_#{name}".to_sym, value)
|
61
|
+
raise Exceptions::InvalidArguments, name unless send("validate_#{name}".to_sym, value)
|
62
62
|
end
|
63
63
|
@entity[name.to_s] = if opts[:preprocess]
|
64
64
|
send("preprocess_#{name}".to_sym, value)
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SkullIsland
|
4
|
+
# Resource classes go here...
|
5
|
+
module Resources
|
6
|
+
# The BasicauthCredential resource class
|
7
|
+
#
|
8
|
+
# @see https://docs.konghq.com/hub/kong-inc/key-auth/ Key-Auth API definition
|
9
|
+
class BasicauthCredential < Resource
|
10
|
+
property :username, required: true, validate: true
|
11
|
+
property :password, validated: true
|
12
|
+
property(
|
13
|
+
:consumer_id,
|
14
|
+
required: true, validate: true, preprocess: true, postprocess: true, as: :consumer
|
15
|
+
)
|
16
|
+
property :created_at, read_only: true, postprocess: true
|
17
|
+
|
18
|
+
def self.batch_import(data, verbose: false, test: false)
|
19
|
+
raise(Exceptions::InvalidArguments) unless data.is_a?(Array)
|
20
|
+
|
21
|
+
data.each_with_index do |resource_data, index|
|
22
|
+
resource = new
|
23
|
+
resource.username = resource_data['username']
|
24
|
+
resource.password = resource_data['password'] if resource_data['password']
|
25
|
+
resource.delayed_set(:consumer, resource_data, 'consumer_id')
|
26
|
+
resource.import_update_or_skip(index: index, verbose: verbose, test: test)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.relative_uri
|
31
|
+
'basic-auths'
|
32
|
+
end
|
33
|
+
|
34
|
+
def relative_uri
|
35
|
+
consumer ? "#{consumer.relative_uri}/basic-auth/#{id}" : nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def save_uri
|
39
|
+
consumer ? "#{consumer.relative_uri}/basic-auth" : nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def export(options = {})
|
43
|
+
hash = { 'username' => username, 'password' => password }
|
44
|
+
hash['consumer_id'] = "<%= lookup :consumer, '#{consumer.username}' %>" if consumer
|
45
|
+
[*options[:exclude]].each do |exclude|
|
46
|
+
hash.delete(exclude.to_s)
|
47
|
+
end
|
48
|
+
[*options[:include]].each do |inc|
|
49
|
+
hash[inc.to_s] = send(inc.to_sym)
|
50
|
+
end
|
51
|
+
hash.reject { |_, value| value.nil? }
|
52
|
+
end
|
53
|
+
|
54
|
+
# Keys can't be updated, only created or deleted
|
55
|
+
def modified_existing?
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def postprocess_consumer_id(value)
|
62
|
+
if value.is_a?(String)
|
63
|
+
Consumer.new(
|
64
|
+
entity: { 'id' => value },
|
65
|
+
lazy: true,
|
66
|
+
tainted: false
|
67
|
+
)
|
68
|
+
else
|
69
|
+
value
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def preprocess_consumer_id(input)
|
74
|
+
if input.is_a?(String)
|
75
|
+
input
|
76
|
+
else
|
77
|
+
input.id
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Used to validate {#consumer} on set
|
82
|
+
def validate_consumer_id(value)
|
83
|
+
# allow either a Consumer object or a String
|
84
|
+
value.is_a?(Consumer) || value.is_a?(String)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Used to validate {#password} on set
|
88
|
+
def validate_password(value)
|
89
|
+
# allow a String
|
90
|
+
value.is_a?(String)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Used to validate {#username} on set
|
94
|
+
def validate_username(value)
|
95
|
+
# allow a String
|
96
|
+
value.is_a?(String)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -19,9 +19,53 @@ module SkullIsland
|
|
19
19
|
resource.username = resource_data['username']
|
20
20
|
resource.custom_id = resource_data['custom_id']
|
21
21
|
resource.import_update_or_skip(index: index, verbose: verbose, test: test)
|
22
|
+
|
23
|
+
BasicauthCredential.batch_import(
|
24
|
+
(
|
25
|
+
resource_data.dig('credentials', 'basic-auth') || []
|
26
|
+
).map { |t| t.merge('consumer_id' => resource.id) },
|
27
|
+
verbose: verbose,
|
28
|
+
test: test
|
29
|
+
)
|
30
|
+
|
31
|
+
KeyauthCredential.batch_import(
|
32
|
+
(
|
33
|
+
resource_data.dig('credentials', 'key-auth') || []
|
34
|
+
).map { |t| t.merge('consumer_id' => resource.id) },
|
35
|
+
verbose: verbose,
|
36
|
+
test: test
|
37
|
+
)
|
22
38
|
end
|
23
39
|
end
|
24
40
|
|
41
|
+
# Convenience method to add upstream targets
|
42
|
+
def add_credential!(details)
|
43
|
+
r = if [BasicauthCredential, KeyauthCredential].include? details.class
|
44
|
+
details
|
45
|
+
elsif details.is_a?(Hash) && details.key?(:key)
|
46
|
+
cred = KeyauthCredential.new(api_client: api_client)
|
47
|
+
cred.key = details[:key]
|
48
|
+
cred
|
49
|
+
elsif details.is_a?(Hash) && details.key?(:username)
|
50
|
+
cred = BasicauthCredential.new(api_client: api_client)
|
51
|
+
cred.username = details[:username]
|
52
|
+
cred.password = details[:password]
|
53
|
+
cred
|
54
|
+
end
|
55
|
+
|
56
|
+
r.consumer = self
|
57
|
+
r.save
|
58
|
+
end
|
59
|
+
|
60
|
+
def credentials
|
61
|
+
creds = {}
|
62
|
+
keyauth_creds = KeyauthCredential.where(:consumer, self, api_client: api_client)
|
63
|
+
creds['key-auth'] = keyauth_creds if keyauth_creds
|
64
|
+
basicauth_creds = BasicauthCredential.where(:consumer, self, api_client: api_client)
|
65
|
+
creds['basic-auth'] = basicauth_creds if basicauth_creds
|
66
|
+
creds
|
67
|
+
end
|
68
|
+
|
25
69
|
# Provides a collection of related {Plugin} instances
|
26
70
|
def plugins
|
27
71
|
Plugin.where(:consumer, self, api_client: api_client)
|
@@ -29,11 +73,13 @@ module SkullIsland
|
|
29
73
|
|
30
74
|
def export(options = {})
|
31
75
|
hash = { 'username' => username, 'custom_id' => custom_id }
|
76
|
+
creds = credentials_for_export
|
77
|
+
hash['credentials'] = creds unless creds.empty?
|
32
78
|
[*options[:exclude]].each do |exclude|
|
33
79
|
hash.delete(exclude.to_s)
|
34
80
|
end
|
35
81
|
[*options[:include]].each do |inc|
|
36
|
-
hash[inc.to_s] = send(
|
82
|
+
hash[inc.to_s] = send(inc.to_sym)
|
37
83
|
end
|
38
84
|
hash.reject { |_, value| value.nil? }
|
39
85
|
end
|
@@ -53,6 +99,23 @@ module SkullIsland
|
|
53
99
|
false
|
54
100
|
end
|
55
101
|
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def credentials_for_export
|
106
|
+
creds = {}
|
107
|
+
unless credentials['key-auth'].empty?
|
108
|
+
creds['key-auth'] = credentials['key-auth'].collect do |cred|
|
109
|
+
cred.export(exclude: 'consumer_id')
|
110
|
+
end
|
111
|
+
end
|
112
|
+
unless credentials['basic-auth'].empty?
|
113
|
+
creds['basic-auth'] = credentials['basic-auth'].collect do |cred|
|
114
|
+
cred.export(exclude: 'consumer_id')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
creds
|
118
|
+
end
|
56
119
|
end
|
57
120
|
end
|
58
121
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SkullIsland
|
4
|
+
# Resource classes go here...
|
5
|
+
module Resources
|
6
|
+
# The KeyauthCredential resource class
|
7
|
+
#
|
8
|
+
# @see https://docs.konghq.com/hub/kong-inc/key-auth/ Key-Auth API definition
|
9
|
+
class KeyauthCredential < Resource
|
10
|
+
property :key, validate: true
|
11
|
+
property(
|
12
|
+
:consumer_id,
|
13
|
+
required: true, validate: true, preprocess: true, postprocess: true, as: :consumer
|
14
|
+
)
|
15
|
+
property :created_at, read_only: true, postprocess: true
|
16
|
+
|
17
|
+
def self.batch_import(data, verbose: false, test: false)
|
18
|
+
raise(Exceptions::InvalidArguments) unless data.is_a?(Array)
|
19
|
+
|
20
|
+
data.each_with_index do |resource_data, index|
|
21
|
+
resource = new
|
22
|
+
resource.key = resource_data['key']
|
23
|
+
resource.delayed_set(:consumer, resource_data, 'consumer_id')
|
24
|
+
resource.import_update_or_skip(index: index, verbose: verbose, test: test)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.relative_uri
|
29
|
+
'key-auths'
|
30
|
+
end
|
31
|
+
|
32
|
+
def relative_uri
|
33
|
+
consumer ? "#{consumer.relative_uri}/key-auth/#{id}" : nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def save_uri
|
37
|
+
consumer ? "#{consumer.relative_uri}/key-auth" : nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def export(options = {})
|
41
|
+
hash = { 'key' => key }
|
42
|
+
hash['consumer_id'] = "<%= lookup :consumer, '#{consumer.username}' %>" if consumer
|
43
|
+
[*options[:exclude]].each do |exclude|
|
44
|
+
hash.delete(exclude.to_s)
|
45
|
+
end
|
46
|
+
[*options[:include]].each do |inc|
|
47
|
+
hash[inc.to_s] = send(inc.to_sym)
|
48
|
+
end
|
49
|
+
hash.reject { |_, value| value.nil? }
|
50
|
+
end
|
51
|
+
|
52
|
+
# Keys can't be updated, only created or deleted
|
53
|
+
def modified_existing?
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def postprocess_consumer_id(value)
|
60
|
+
if value.is_a?(String)
|
61
|
+
Consumer.new(
|
62
|
+
entity: { 'id' => value },
|
63
|
+
lazy: true,
|
64
|
+
tainted: false
|
65
|
+
)
|
66
|
+
else
|
67
|
+
value
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def preprocess_consumer_id(input)
|
72
|
+
if input.is_a?(String)
|
73
|
+
input
|
74
|
+
else
|
75
|
+
input.id
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Used to validate {#consumer} on set
|
80
|
+
def validate_consumer_id(value)
|
81
|
+
# allow either a Consumer object or a String
|
82
|
+
value.is_a?(Consumer) || value.is_a?(String)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Used to validate {#key} on set
|
86
|
+
def validate_key(value)
|
87
|
+
# allow a String
|
88
|
+
value.is_a?(String)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -10,7 +10,7 @@ module SkullIsland
|
|
10
10
|
property :name
|
11
11
|
property :enabled, type: :boolean
|
12
12
|
# property :run_on # 1.0.x only
|
13
|
-
property :config, validate: true
|
13
|
+
property :config, validate: true, preprocess: true, postprocess: true
|
14
14
|
property :consumer_id, validate: true, preprocess: true, postprocess: true, as: :consumer
|
15
15
|
property :route_id, validate: true, preprocess: true, postprocess: true, as: :route
|
16
16
|
property :service_id, validate: true, preprocess: true, postprocess: true, as: :service
|
@@ -23,7 +23,7 @@ module SkullIsland
|
|
23
23
|
resource = new
|
24
24
|
resource.name = resource_data['name']
|
25
25
|
resource.enabled = resource_data['enabled']
|
26
|
-
resource.config = resource_data['config'] if resource_data['config']
|
26
|
+
resource.config = resource_data['config'].deep_sort if resource_data['config']
|
27
27
|
resource.delayed_set(:consumer, resource_data, 'consumer_id')
|
28
28
|
resource.delayed_set(:route, resource_data, 'route_id')
|
29
29
|
resource.delayed_set(:service, resource_data, 'service_id')
|
@@ -43,7 +43,7 @@ module SkullIsland
|
|
43
43
|
hash = {
|
44
44
|
'name' => name,
|
45
45
|
'enabled' => enabled?,
|
46
|
-
'config' => config
|
46
|
+
'config' => config.deep_sort
|
47
47
|
}
|
48
48
|
hash['consumer_id'] = "<%= lookup :consumer, '#{consumer.username}' %>" if consumer
|
49
49
|
hash['route_id'] = "<%= lookup :route, '#{route.name}' %>" if route
|
@@ -52,7 +52,7 @@ module SkullIsland
|
|
52
52
|
hash.delete(exclude.to_s)
|
53
53
|
end
|
54
54
|
[*options[:include]].each do |inc|
|
55
|
-
hash[inc.to_s] = send(
|
55
|
+
hash[inc.to_s] = send(inc.to_sym)
|
56
56
|
end
|
57
57
|
hash.reject { |_, value| value.nil? }
|
58
58
|
end
|
@@ -86,6 +86,14 @@ module SkullIsland
|
|
86
86
|
|
87
87
|
private
|
88
88
|
|
89
|
+
def preprocess_config(input)
|
90
|
+
input.deep_sort
|
91
|
+
end
|
92
|
+
|
93
|
+
def postprocess_config(value)
|
94
|
+
value.deep_sort
|
95
|
+
end
|
96
|
+
|
89
97
|
# TODO: 1.0.x requires refactoring as `consumer_id` becomes `consumer`
|
90
98
|
def postprocess_consumer_id(value)
|
91
99
|
if value.is_a?(Hash)
|
@@ -19,6 +19,8 @@ module SkullIsland
|
|
19
19
|
property :created_at, read_only: true, postprocess: true
|
20
20
|
property :updated_at, read_only: true, postprocess: true
|
21
21
|
|
22
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
23
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
22
24
|
# rubocop:disable Metrics/AbcSize
|
23
25
|
def self.batch_import(data, verbose: false, test: false)
|
24
26
|
raise(Exceptions::InvalidArguments) unless data.is_a?(Array)
|
@@ -37,12 +39,14 @@ module SkullIsland
|
|
37
39
|
resource.import_update_or_skip(index: index, verbose: verbose, test: test)
|
38
40
|
|
39
41
|
Route.batch_import(
|
40
|
-
rdata['routes'].map { |r| r.merge('service' => { 'id' => resource.id }) },
|
42
|
+
(rdata['routes'] || []).map { |r| r.merge('service' => { 'id' => resource.id }) },
|
41
43
|
verbose: verbose,
|
42
44
|
test: test
|
43
45
|
)
|
44
46
|
end
|
45
47
|
end
|
48
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
49
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
46
50
|
# rubocop:enable Metrics/AbcSize
|
47
51
|
|
48
52
|
# Convenience method to add routes
|
@@ -80,7 +84,7 @@ module SkullIsland
|
|
80
84
|
hash.delete(exclude.to_s)
|
81
85
|
end
|
82
86
|
[*options[:include]].each do |inc|
|
83
|
-
hash[inc.to_s] = send(
|
87
|
+
hash[inc.to_s] = send(inc.to_sym)
|
84
88
|
end
|
85
89
|
hash.reject { |_, value| value.nil? }
|
86
90
|
end
|
@@ -43,7 +43,7 @@ module SkullIsland
|
|
43
43
|
puts '[INFO] Processing UpstreamTarget entries...' if verbose
|
44
44
|
|
45
45
|
UpstreamTarget.batch_import(
|
46
|
-
rdata['targets'].map { |t| t.merge('upstream_id' => resource.id) },
|
46
|
+
(rdata['targets'] || []).map { |t| t.merge('upstream_id' => resource.id) },
|
47
47
|
verbose: verbose,
|
48
48
|
test: test
|
49
49
|
)
|
@@ -120,7 +120,7 @@ module SkullIsland
|
|
120
120
|
hash.delete(exclude.to_s)
|
121
121
|
end
|
122
122
|
[*options[:include]].each do |inc|
|
123
|
-
hash[inc.to_s] = send(
|
123
|
+
hash[inc.to_s] = send(inc.to_sym)
|
124
124
|
end
|
125
125
|
hash.reject { |_, value| value.nil? }
|
126
126
|
end
|
data/lib/skull_island/version.rb
CHANGED
data/skull_island.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.required_ruby_version = '~> 2.5'
|
28
28
|
|
29
|
+
spec.add_runtime_dependency 'deepsort', '~> 0.4'
|
29
30
|
spec.add_runtime_dependency 'erubi', '~> 1.8'
|
30
31
|
spec.add_runtime_dependency 'json', '~> 2.1'
|
31
32
|
spec.add_runtime_dependency 'linguistics', '~> 2.1'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skull_island
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Gnagy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: deepsort
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.4'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: erubi
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,8 +246,10 @@ files:
|
|
232
246
|
- lib/skull_island/lru_cache.rb
|
233
247
|
- lib/skull_island/resource.rb
|
234
248
|
- lib/skull_island/resource_collection.rb
|
249
|
+
- lib/skull_island/resources/basicauth_credential.rb
|
235
250
|
- lib/skull_island/resources/certificate.rb
|
236
251
|
- lib/skull_island/resources/consumer.rb
|
252
|
+
- lib/skull_island/resources/keyauth_credential.rb
|
237
253
|
- lib/skull_island/resources/plugin.rb
|
238
254
|
- lib/skull_island/resources/route.rb
|
239
255
|
- lib/skull_island/resources/service.rb
|