Class: KuberKit::ServiceDeployer::DeploymentOptionsSelector

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/service_deployer/deployment_options_selector.rb

Constant Summary collapse

OPTION_SPECIFIC_SERVICE =
"deploy specific service".freeze
OPTION_ALL_SERVICES =
"deploy all services"

Instance Method Summary collapse

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kuber_kit/service_deployer/deployment_options_selector.rb', line 10

def call()
  tags = [OPTION_SPECIFIC_SERVICE, OPTION_ALL_SERVICES]
  tags += service_store
    .all_definitions
    .values
    .map(&:to_service_attrs)
    .map(&:tags)
    .flatten
    .uniq
    .sort
    .map(&:to_s)

  selected_tag = ui.prompt("Please select which tag to deploy", tags)

  if selected_tag == OPTION_SPECIFIC_SERVICE
    show_service_selection
  elsif selected_tag == OPTION_ALL_SERVICES
    [["*"], []]
  else
    [[], [selected_tag]]
  end
end

#show_service_selectionObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/kuber_kit/service_deployer/deployment_options_selector.rb', line 33

def show_service_selection()
  services = service_store
    .all_definitions
    .values
    .map(&:service_name)
    .uniq
    .sort
    .map(&:to_s)

  if services.empty?
    return [[], []]
  end

  selected_service = ui.prompt("Please select which service to deploy", services)
  [[selected_service], []]
end