Class: Kongfigure::Kong
- Inherits:
-
Object
- Object
- Kongfigure::Kong
- Defined in:
- lib/kongfigure/kong.rb
Constant Summary collapse
- SYNCHRONIZER_MODULES =
[ Kongfigure::Synchronizers::Upstream, Kongfigure::Synchronizers::Service, Kongfigure::Synchronizers::Consumer, Kongfigure::Synchronizers::Plugin ]
Instance Method Summary collapse
- #apply! ⇒ Object
- #apply_all(synchronizer) ⇒ Object
- #display_information ⇒ Object
-
#initialize(parser, http_client) ⇒ Kong
constructor
A new instance of Kong.
Constructor Details
#initialize(parser, http_client) ⇒ Kong
Returns a new instance of Kong.
11 12 13 14 15 16 17 18 |
# File 'lib/kongfigure/kong.rb', line 11 def initialize(parser, http_client) @parser = parser @http_client = http_client @synchronizers = {} @configuration = @parser.parse! load_synchronizers display_information end |
Instance Method Details
#apply! ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kongfigure/kong.rb', line 20 def apply! puts @configuration.to_s puts "Fetching actual configuration..." puts "Do you want to apply this configuration to '#{@configuration.url}' (yes/no)".colorize(:color => :white, :background => :red) exit 1 unless gets.strip.downcase == "yes" puts "Applying configuration...".colorize(:color => :white, :background => :red) SYNCHRONIZER_MODULES.each do |synchronizer_module| apply_all(@synchronizers[synchronizer_module]) end puts "Done.".colorize(:color => :white, :background => :red) end |
#apply_all(synchronizer) ⇒ Object
32 33 34 35 |
# File 'lib/kongfigure/kong.rb', line 32 def apply_all(synchronizer) puts "<- Applying #{synchronizer.resource_api_name}..." synchronizer.synchronize_all end |
#display_information ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/kongfigure/kong.rb', line 37 def display_information data = @http_client.get("/") puts "Kong information:".colorize(:color => :white, :background => :red) puts "* hostname: \t#{data['version']}" puts "* version: \t#{data['hostname']}" puts "* lua_version: \t#{data['lua_version']}" end |