kongfigure 0.0.4 → 0.0.5
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/lib/kongfigure/cli.rb +6 -1
- data/lib/kongfigure/configuration.rb +0 -4
- data/lib/kongfigure/parser.rb +6 -5
- data/lib/kongfigure/services/base.rb +1 -1
- data/lib/kongfigure/services/service.rb +1 -1
- data/lib/kongfigure/version.rb +1 -1
- data/lib/kongfigure.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65d5602bfed712c59cc8c2dba6c00e13f782d42155dabed11a3483f57d52ee8e
|
4
|
+
data.tar.gz: 0ebe8e6a7404fa178b7b57c0fe9c299d3993488a055fd8f005911d5b181618c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0773bea047fca72dc0316252a8e4d67ccd5de7088b82833fef789882c8526928a54a6229a9da4854dbecb802e9e1dedc5edf1ce6e54d9a7389f8c3b8bd0d71a7
|
7
|
+
data.tar.gz: e7ec43aa67c41d17d5f8735d83f1601a55eb3b728a411b82cabe5fa117a69221c6b7e1f432dd9ca220105669932cd117c349aa18139000b236d19d1a604b63df
|
data/lib/kongfigure/cli.rb
CHANGED
@@ -5,7 +5,9 @@ module Kongfigure
|
|
5
5
|
attr_accessor :options
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@options = {
|
8
|
+
@options = {
|
9
|
+
debug: false
|
10
|
+
}
|
9
11
|
@option_parser = OptionParser.new do |parser|
|
10
12
|
parser.on("-f", "--file FILE", "Path to the Kongfigure configuration file.") do |file|
|
11
13
|
@options[:file] = file
|
@@ -13,6 +15,9 @@ module Kongfigure
|
|
13
15
|
parser.on("-u", "--url URL", "Url to the kong admin API.") do |url|
|
14
16
|
@options[:url] = url
|
15
17
|
end
|
18
|
+
parser.on("-d", "--debug", "Debug mode.") do
|
19
|
+
@options[:debug] = true
|
20
|
+
end
|
16
21
|
end
|
17
22
|
end
|
18
23
|
|
data/lib/kongfigure/parser.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
-
require "yaml"
|
2
|
-
|
3
1
|
module Kongfigure
|
4
2
|
class Parser
|
5
3
|
|
6
|
-
def initialize(file)
|
7
|
-
@
|
4
|
+
def initialize(file, debug=false)
|
5
|
+
@yaml_erb_configuration = File.read(file)
|
6
|
+
@debug = debug
|
8
7
|
end
|
9
8
|
|
10
9
|
def parse!
|
11
10
|
return @configuration unless @configuration.nil?
|
12
11
|
@configuration = Kongfigure::Configuration.new
|
13
12
|
puts "Parsing YAML configuration...".colorize(:color => :white, :background => :red)
|
14
|
-
YAML.load(@
|
13
|
+
parsed_configuration = YAML.load(ERB.new(@yaml_erb_configuration).result)
|
14
|
+
ap parsed_configuration if @debug
|
15
|
+
parsed_configuration.each do |key, value|
|
15
16
|
case key
|
16
17
|
when "url"
|
17
18
|
@configuration.url = value
|
@@ -155,7 +155,7 @@ module Kongfigure::Services
|
|
155
155
|
|
156
156
|
def cleanup_plugins(http_client, local_resource, remote_resource)
|
157
157
|
remote_resource.plugins.each do |plugin|
|
158
|
-
|
158
|
+
if local_resource.nil? || find_related_resource(plugin, local_resource.plugins).nil?
|
159
159
|
http_client.delete("#{resource_name}/#{remote_resource.identifier}/plugins/#{plugin.id}")
|
160
160
|
end
|
161
161
|
end
|
@@ -44,7 +44,7 @@ module Kongfigure::Services
|
|
44
44
|
end
|
45
45
|
# cleanup useless routes
|
46
46
|
remote_resource.routes.each do |remote_resource_route|
|
47
|
-
|
47
|
+
if local_resource.nil? || !local_resource.has_route?(remote_resource_route)
|
48
48
|
http_client.delete("routes/#{remote_resource_route.id}")
|
49
49
|
end
|
50
50
|
end
|
data/lib/kongfigure/version.rb
CHANGED
data/lib/kongfigure.rb
CHANGED
@@ -27,6 +27,11 @@ require_relative "kongfigure/errors/invalid_configuration.rb"
|
|
27
27
|
|
28
28
|
require "rest-client"
|
29
29
|
require "logger"
|
30
|
+
require "yaml"
|
31
|
+
require "erb"
|
32
|
+
require "optparse"
|
33
|
+
require "pp"
|
34
|
+
require "awesome_print"
|
30
35
|
|
31
36
|
module Kongfigure
|
32
37
|
def self.logger
|
@@ -38,7 +43,7 @@ module Kongfigure
|
|
38
43
|
cli = Kongfigure::CLI.new
|
39
44
|
options = cli.parse!(args)
|
40
45
|
# Parser
|
41
|
-
parser = Kongfigure::Parser.new(options[:file])
|
46
|
+
parser = Kongfigure::Parser.new(options[:file], options[:debug])
|
42
47
|
http_client = Kongfigure::HTTPClient.new(parser, options[:url])
|
43
48
|
kong = Kongfigure::Kong.new(parser, http_client)
|
44
49
|
kong.apply!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kongfigure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ibanity
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|