Module: Aptible::CLI::Helpers::Vhost
- Defined in:
- lib/aptible/cli/helpers/vhost.rb,
lib/aptible/cli/helpers/vhost/option_set_builder.rb
Defined Under Namespace
Classes: OptionSetBuilder
Instance Method Summary
collapse
Instance Method Details
#each_service(resource, &block) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/aptible/cli/helpers/vhost.rb', line 31
def each_service(resource, &block)
return enum_for(:each_service, resource) if block.nil?
klass = resource.class
if klass == Aptible::Api::App
resource.each_service(&block)
elsif klass == Aptible::Api::Database
[resource.service].each(&block)
else
raise "Unexpected resource: #{klass}"
end
end
|
#find_vhost(service_enumerator, hostname) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/aptible/cli/helpers/vhost.rb', line 16
def find_vhost(service_enumerator, hostname)
seen = []
service_enumerator.each do |service|
service.each_vhost do |vhost|
seen << vhost.external_host
return vhost if vhost.external_host == hostname
end
end
e = "Endpoint with hostname #{hostname} does not exist"
e = "#{e} (valid hostnames: #{seen.join(', ')})" if seen.any?
raise Thor::Error, e
end
|
#provision_vhost_and_explain(service, vhost) ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/aptible/cli/helpers/vhost.rb', line 5
def provision_vhost_and_explain(service, vhost)
op = vhost.create_operation!(type: 'provision')
attach_to_operation_logs(op)
Formatter.render(Renderer.current) do |root|
root.object do |node|
ResourceFormatter.inject_vhost(node, vhost.reload, service)
end
end
end
|