Class: KuberKit::Actions::ServiceDeployer
- Defined in:
- lib/kuber_kit/actions/service_deployer.rb
Instance Method Summary collapse
- #call(services:, tags:) ⇒ Object
- #compile_images(images_names) ⇒ Object
- #deploy_services(service_names) ⇒ Object
- #show_service_selection ⇒ Object
- #show_tags_selection ⇒ Object
Instance Method Details
#call(services:, tags:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kuber_kit/actions/service_deployer.rb', line 16 def call(services:, tags:) if services.empty? && .empty? services, = end service_names = service_list_resolver.resolve( services: services || [], tags: || [] ) unless service_names.any? ui.print_warning "WARNING", "No service found with given options, nothing will be deployed." end services = service_names.map do |service_name| service_store.get_service(service_name.to_sym) end images_names = services.map(&:images).flatten.uniq compile_images(images_names) deploy_services(service_names) true rescue KuberKit::Error => e ui.print_error("Error", e.) false end |
#compile_images(images_names) ⇒ Object
63 64 65 |
# File 'lib/kuber_kit/actions/service_deployer.rb', line 63 def compile_images(images_names) image_compiler.call(images_names, {}) if images_names.any? end |
#deploy_services(service_names) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/kuber_kit/actions/service_deployer.rb', line 46 def deploy_services(service_names) task_group = ui.create_task_group service_names.each do |service_name| logger.info("Started deploying: #{service_name.to_s.green}") task_group.add("Deploying #{service_name.to_s.yellow}") do |task| service_deployer.call(local_shell, service_name.to_sym) task.update_title("Deployed #{service_name.to_s.green}") logger.info("Finished deploying: #{service_name.to_s.green}") end end task_group.wait end |
#show_service_selection ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/kuber_kit/actions/service_deployer.rb', line 90 def show_service_selection() services = service_store .all_definitions .values .map(&:service_name) .uniq .sort .map(&:to_s) ui.prompt("Please select which service to deploy", services) do |selected_service| return [[selected_service], []] end end |
#show_tags_selection ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/kuber_kit/actions/service_deployer.rb', line 67 def () specific_service_option = "deploy specific service" = [specific_service_option] += service_store .all_definitions .values .map(&:to_service_attrs) .map(&:tags) .flatten .uniq .sort .map(&:to_s) ui.prompt("Please select which tag to deploy", ) do |selected_tag| if selected_tag == specific_service_option show_service_selection else return [[], [selected_tag]] end end end |