Class: Runner::ReverseProxy

Inherits:
Base
  • Object
show all
Defined in:
lib/shared_infrastructure/runner/reverse_proxy.rb

Overview

Generate reverse proxy config files for Nginx.

Instance Attribute Summary

Attributes inherited from Base

#builder_class

Instance Method Summary collapse

Methods inherited from Base

#main

Instance Method Details

#options_for_config(options) ⇒ Object



7
8
9
# File 'lib/shared_infrastructure/runner/reverse_proxy.rb', line 7

def options_for_config(options)
  super(options).merge(proxy_url: ARGV[1])
end

#process_args(opts = nil) ⇒ Object

Raises:



11
12
13
14
15
16
17
# File 'lib/shared_infrastructure/runner/reverse_proxy.rb', line 11

def process_args(opts = nil)
  raise MissingArgument.new("domain and target url required", opts) unless ARGV.size == 2
  {
    domain_name: [ARGV.first],
    proxy_url: ARGV[1]
  }
end

#process_optionsObject



19
20
21
# File 'lib/shared_infrastructure/runner/reverse_proxy.rb', line 19

def process_options
  super(Nginx::Builder::ReverseProxyHttp, Nginx::Builder::ReverseProxyHttps)
end

#protocol_factory(options) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/shared_infrastructure/runner/reverse_proxy.rb', line 23

def protocol_factory(options)
  protocol_class = super(
    options,
    Nginx::Builder::ReverseProxyHttp,
    Nginx::Builder::ReverseProxyHttps
  )

  domain_name = options.delete(:domain_name)
  proxy_url = options.delete(:proxy_url)
  certificate_domain = options.delete(:certificate_domain)
  domain = SharedInfrastructure::Domain.new(domain_name)
  protocol_class.new(proxy_url, certificate_domain, domain: domain)
end