odania 0.0.35 → 0.0.36
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/Gemfile.lock +1 -1
- data/features/plugin.feature +8 -8
- data/features/step_definitions/plugin_steps.rb +0 -4
- data/lib/odania/config/global_config.rb +14 -4
- data/lib/odania/config/plugin_config.rb +7 -3
- data/lib/odania/version.rb +1 -1
- data/spec/fixtures/global_config.json +9 -2
- data/spec/fixtures/plugin_config_1.json +9 -2
- data/spec/lib/odania/config/global_config_spec.rb +16 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae87f0f013140efcdf8328a06001147992f74057
|
4
|
+
data.tar.gz: 50e7e1e500ad4c62e4d15ebcab5fd6d6394ffcad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb9bbcf5a1b578af277a70b651bf6dadbe7fa199ea31083689e351c7ff4876ea781b44f5f03b36c06f0d6d5900a86967e06484589c8dfbbd99a55368aef90393
|
7
|
+
data.tar.gz: 97e32bec1b907584c1dab1d9c4948d5900e9334a5e967eabc7e7e0059f7a1ddb59339053ddb444efe13ccb2296ffe0e5015308fdd357454517f7f0e0adfde2b7
|
data/Gemfile.lock
CHANGED
data/features/plugin.feature
CHANGED
@@ -9,27 +9,27 @@ Feature: Plugins
|
|
9
9
|
Scenario: Registering multiple instances of one plugin
|
10
10
|
Given I initialize the gem
|
11
11
|
When I registered the plugin "test-plugin"
|
12
|
-
|
13
|
-
|
12
|
+
And I registered the plugin "test-plugin"
|
13
|
+
And I registered the plugin "test-plugin"
|
14
14
|
Then I should see "3" instances of the plugin "test-plugin"
|
15
15
|
|
16
16
|
Scenario: Registering multiple plugins
|
17
17
|
Given I initialize the gem
|
18
18
|
When I registered the plugin "test-plugin"
|
19
|
-
|
20
|
-
|
19
|
+
And I registered the plugin "test-plugin"
|
20
|
+
And I registered the plugin "test-plugin-2"
|
21
21
|
Then I should see "2" instances of the plugin "test-plugin"
|
22
|
-
|
22
|
+
And I should see "1" instances of the plugin "test-plugin-2"
|
23
23
|
|
24
24
|
Scenario: Retrieving plugin instance name
|
25
25
|
Given I initialize the gem
|
26
26
|
When I retrieve plugin instance name for "test-plugin"
|
27
|
-
|
27
|
+
And I retrieve plugin instance name for "test-plugin"
|
28
28
|
Then I should retrieve "test-plugin_1"
|
29
29
|
|
30
30
|
Scenario: Build new joined plugin config
|
31
31
|
Given I initialize the gem
|
32
32
|
When I registered the plugin "test-plugin"
|
33
|
-
|
33
|
+
And I generate the joined plugin config
|
34
34
|
Then I have a joined plugin config
|
35
|
-
|
35
|
+
And The joined plugin config contains the plugin "test-plugin"
|
@@ -20,9 +20,6 @@ Given(/^I registered the plugin "([^"]*)"$/) do |plugin_name|
|
|
20
20
|
'ip' => '127.0.0.1',
|
21
21
|
'port' => 80,
|
22
22
|
'tags' => ["plugin-#{plugin_name}"],
|
23
|
-
'default_subdomains' => {
|
24
|
-
'_general' => 'default_sub'
|
25
|
-
},
|
26
23
|
'domains' => {
|
27
24
|
'odania.com' => {
|
28
25
|
'contents' => {
|
@@ -34,7 +31,6 @@ Given(/^I registered the plugin "([^"]*)"$/) do |plugin_name|
|
|
34
31
|
'languages' => %w(de en),
|
35
32
|
'layout' => 'simple',
|
36
33
|
'language_selector' => 'prefix',
|
37
|
-
'default_subdomain' => 'page_sub',
|
38
34
|
'redirects' => {
|
39
35
|
'^/test' => '/games'
|
40
36
|
}
|
@@ -7,6 +7,8 @@ module Odania
|
|
7
7
|
|
8
8
|
reset
|
9
9
|
@default_backend_groups = config['default_backend_groups'] unless config['default_backend_groups'].nil?
|
10
|
+
@valid_domains = config['valid_domains'] unless config['valid_domains'].nil?
|
11
|
+
@default_domains = config['default_domains'] unless config['default_domains'].nil?
|
10
12
|
|
11
13
|
unless config['domains'].nil?
|
12
14
|
config['domains'].each_pair do |name, data|
|
@@ -80,7 +82,8 @@ module Odania
|
|
80
82
|
end
|
81
83
|
|
82
84
|
@plugin_config[group_name] = plugin_cfg['plugin-config']
|
83
|
-
@
|
85
|
+
@valid_domains.deep_merge!(plugin_cfg['valid_domains']) unless plugin_cfg['valid_domains'].nil?
|
86
|
+
@default_domains.deep_merge!(plugin_cfg['default_domains']) unless plugin_cfg['default_domains'].nil?
|
84
87
|
|
85
88
|
# Add this service as a default backend if specified
|
86
89
|
@default_backend_groups << group_name if plugin_cfg['plugin-config']['default']
|
@@ -121,7 +124,8 @@ module Odania
|
|
121
124
|
@default_backend_groups = []
|
122
125
|
@duplicates = Duplicates.new
|
123
126
|
@backend_groups = Hash.new { |hash, key| hash[key] = BackendGroup.new(key) }
|
124
|
-
@
|
127
|
+
@valid_domains = {}
|
128
|
+
@default_domains = {}
|
125
129
|
|
126
130
|
@domains['_general'].add_subdomain('_general')
|
127
131
|
end
|
@@ -141,8 +145,12 @@ module Odania
|
|
141
145
|
@backend_groups[group_name].backends.first
|
142
146
|
end
|
143
147
|
|
144
|
-
def
|
145
|
-
@
|
148
|
+
def valid_domains
|
149
|
+
@valid_domains
|
150
|
+
end
|
151
|
+
|
152
|
+
def default_domains
|
153
|
+
@default_domains
|
146
154
|
end
|
147
155
|
|
148
156
|
def default_redirects
|
@@ -154,6 +162,8 @@ module Odania
|
|
154
162
|
def dump
|
155
163
|
cfg = super
|
156
164
|
cfg['default_backend_groups'] = @default_backend_groups
|
165
|
+
cfg['default_domains'] = @default_domains
|
166
|
+
cfg['valid_domains'] = @valid_domains
|
157
167
|
cfg
|
158
168
|
end
|
159
169
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Odania
|
2
2
|
module Config
|
3
3
|
class PluginConfig
|
4
|
-
attr_accessor :domains, :config, :
|
4
|
+
attr_accessor :domains, :config, :valid_domains, :default_domains, :plugin_config
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
reset
|
@@ -12,7 +12,8 @@ module Odania
|
|
12
12
|
reset
|
13
13
|
@config = data['config'] unless data['config'].nil?
|
14
14
|
@plugin_config = data['plugin-config'] unless data['plugin-config'].nil?
|
15
|
-
@
|
15
|
+
@valid_domains = data['valid_domains'] unless data['valid_domains'].nil?
|
16
|
+
@default_domains = data['default_domains'] unless data['default_domains'].nil?
|
16
17
|
unless data['domains'].nil?
|
17
18
|
data['domains'].each_pair do |name, domain_data|
|
18
19
|
@domains[name].load(domain_data)
|
@@ -30,6 +31,8 @@ module Odania
|
|
30
31
|
def reset
|
31
32
|
@config = {}
|
32
33
|
@plugin_config = {}
|
34
|
+
@default_domains = {}
|
35
|
+
@valid_domains = {}
|
33
36
|
@domains = Hash.new { |hash, key| hash[key] = Domain.new(key) }
|
34
37
|
end
|
35
38
|
|
@@ -42,7 +45,8 @@ module Odania
|
|
42
45
|
{
|
43
46
|
'plugin-config' => plugin_config,
|
44
47
|
'config' => config,
|
45
|
-
'
|
48
|
+
'default_domains' => @default_domains,
|
49
|
+
'valid_domains' => @valid_domains,
|
46
50
|
'domains' => domain_data
|
47
51
|
}
|
48
52
|
end
|
data/lib/odania/version.rb
CHANGED
@@ -13,8 +13,15 @@
|
|
13
13
|
"config": {
|
14
14
|
"title": "This is my awesome title"
|
15
15
|
},
|
16
|
-
"
|
17
|
-
"
|
16
|
+
"valid_domains": {
|
17
|
+
"example.com": [
|
18
|
+
"www"
|
19
|
+
]
|
20
|
+
},
|
21
|
+
"default_domains": {
|
22
|
+
"example.com": [
|
23
|
+
"www"
|
24
|
+
]
|
18
25
|
},
|
19
26
|
"domains": {
|
20
27
|
"_general": {
|
@@ -42,23 +42,23 @@ describe Odania::Config::GlobalConfig do
|
|
42
42
|
$consul_mock.service.services = {
|
43
43
|
cfg_name => [
|
44
44
|
OpenStruct.new({
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
'Node' => 'agent-one',
|
46
|
+
'Address' => '172.20.20.1',
|
47
|
+
'ServiceID' => "#{cfg_name}_1",
|
48
|
+
'ServiceName' => cfg_name,
|
49
|
+
'ServiceTags' => [],
|
50
|
+
'ServicePort' => 80,
|
51
|
+
'ServiceAddress' => '172.20.20.1'
|
52
|
+
}),
|
53
53
|
OpenStruct.new({
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
54
|
+
'Node' => 'agent-two',
|
55
|
+
'Address' => '172.20.20.2',
|
56
|
+
'ServiceID' => "#{cfg_name}_2",
|
57
|
+
'ServiceName' => cfg_name,
|
58
|
+
'ServiceTags' => [],
|
59
|
+
'ServicePort' => 80,
|
60
|
+
'ServiceAddress' => '172.20.20.1'
|
61
|
+
})
|
62
62
|
]
|
63
63
|
}
|
64
64
|
|