kongfigure 0.0.3 → 0.0.4

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
  SHA256:
3
- metadata.gz: 723613b6634757801133620d7297116b5a2b3c1fb5f6d4ac8bd6e86cc0e3abc3
4
- data.tar.gz: 0706d49ad8363ef707df443ad230d3bb80c5f3d61c0d0772ca6a0adb82a4b84d
3
+ metadata.gz: cf57cebf09bbe6f5d2a0be2ef0b963d26b8482fdf3be87d38308db576593effe
4
+ data.tar.gz: f072f428db96554d2fd79b1121af4fe414cf8a61153d71ff853d3720f71b59fc
5
5
  SHA512:
6
- metadata.gz: f9ba869ee4e68ea8659b2295989284d3811378e6cccd70369b54656a0e2b8d4cc90502437ec925b4af632d777035146ea678aef2ded4dc1dbe0378375b701648
7
- data.tar.gz: b752a3e0ac7e89b3d4906b018045bca442cb658878f017ee5822e17cc1d8292d87733efb524e1dcc82232ebe0ab4b8d33021e9d07c1511443771327e43413de0
6
+ metadata.gz: 90325a8f142dbf70982d3d3d5e05d8f1d7eb9c85d5283c202334cc32c9fb97b500768a24b81b909e27522b4b0e94f8c09c0ed54b89a441f6c17b0545b2f726a4
7
+ data.tar.gz: 114692c7a0dae4e049cfd0b5441d2817ceeb7bf126fb8a922ff0c82aa7811846b1efe1cd962400927b421bb5aa8488ee0f9f838547069c021118b77b6c324ebe
@@ -10,6 +10,9 @@ module Kongfigure
10
10
  parser.on("-f", "--file FILE", "Path to the Kongfigure configuration file.") do |file|
11
11
  @options[:file] = file
12
12
  end
13
+ parser.on("-u", "--url URL", "Url to the kong admin API.") do |url|
14
+ @options[:url] = url
15
+ end
13
16
  end
14
17
  end
15
18
 
@@ -5,10 +5,10 @@ require "awesome_print"
5
5
  module Kongfigure
6
6
  class Configuration
7
7
 
8
- attr_accessor :host, :services, :consumers, :plugins, :upstreams
8
+ attr_accessor :url, :services, :consumers, :plugins, :upstreams
9
9
 
10
10
  def initialize
11
- @host = nil
11
+ @url = nil
12
12
  @services = []
13
13
  @consumers = []
14
14
  @plugins = []
@@ -9,11 +9,11 @@ module Kongfigure
9
9
  accept_encoding: "gzip"
10
10
  }
11
11
 
12
- def initialize
12
+ def initialize(parser, url)
13
13
  @configuration = {
14
14
  ssl_ca_path: nil,
15
15
  verify_ssl: OpenSSL::SSL::VERIFY_NONE,
16
- url: "https://localhost:8445"
16
+ url: url || parser.parse!.url
17
17
  }
18
18
  @inflector = Dry::Inflector.new
19
19
  end
@@ -5,15 +5,16 @@ module Kongfigure
5
5
 
6
6
  def initialize(file)
7
7
  @yaml_configuration = File.read(file)
8
- @configuration = Kongfigure::Configuration.new
9
8
  end
10
9
 
11
10
  def parse!
11
+ return @configuration unless @configuration.nil?
12
+ @configuration = Kongfigure::Configuration.new
12
13
  puts "Parsing YAML configuration...".colorize(:color => :white, :background => :red)
13
14
  YAML.load(@yaml_configuration).each do |key, value|
14
15
  case key
15
- when "host"
16
- @configuration.host = value
16
+ when "url"
17
+ @configuration.url = value
17
18
  when "services"
18
19
  @configuration.add_services(value || [])
19
20
  when "consumers"
@@ -11,7 +11,7 @@ module Kongfigure::Services
11
11
 
12
12
  def cleanup(http_client, resource, related_resource)
13
13
  return unless related_resource.is_global?
14
- puts "-> Cleanup #{remote_resource.class.name} (#{remote_resource.identifier}).".colorize(:magenta)
14
+ puts "-> Cleanup #{related_resource.class.name} (#{related_resource.identifier}).".colorize(:magenta)
15
15
  http_client.delete("#{resource_name}/#{related_resource.id}")
16
16
  end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Kongfigure
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/kongfigure.rb CHANGED
@@ -39,7 +39,7 @@ module Kongfigure
39
39
  options = cli.parse!(args)
40
40
  # Parser
41
41
  parser = Kongfigure::Parser.new(options[:file])
42
- http_client = Kongfigure::HTTPClient.new
42
+ http_client = Kongfigure::HTTPClient.new(parser, options[:url])
43
43
  kong = Kongfigure::Kong.new(parser, http_client)
44
44
  kong.apply!
45
45
  end
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.3
4
+ version: 0.0.4
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-06 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler