Sha256: 8b27da73e0b70c95131a43f67f061d20b2f107abc0926a8362c3fcc739c7238e

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

class KuberKit::Actions::ServiceApplier
  include KuberKit::Import[
    "core.service_store",
    "service_deployer.service_reader",
    "service_deployer.service_list_resolver",
    "shell.local_shell",
    "shell.kubectl_commands",
    "configs",
    "ui"
  ]

  Contract KeywordArgs[
    services:   Maybe[ArrayOf[String]],
    tags:       Maybe[ArrayOf[String]],
  ] => Any
  def call(services:, tags:)
    service_names = service_list_resolver.resolve(
      services: services || [],
      tags:     tags || []
    )
    service_names.each do |service_name|
      apply_service(service_name.to_sym)
    end
  end

  def apply_service(service_name)
    service = service_store.get_service(service_name)
    kubecfg_path = KuberKit.current_configuration.kubecfg_path

    result = service_reader.read(local_shell, service)
    file_path = "#{configs.service_config_dir}/#{service.name}.yml"
    local_shell.write(file_path, result)

    ui.create_task("Applying file: #{file_path}") do |task|
      kubectl_commands.apply_file(local_shell, file_path, kubecfg_path: kubecfg_path)
      task.update_title("Applied file: #{file_path}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kuber_kit-0.1.1 lib/kuber_kit/actions/service_applier.rb
kuber_kit-0.1.0 lib/kuber_kit/actions/service_applier.rb