Sha256: c35cd71778d421e866c5874e60e2579bd9a06bdac2fbf990271cb46ba830cac7

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require_relative 'common'
require 'kontena/cli/helpers/log_helper'

module Kontena::Cli::Apps
  class LogsCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions
    include Kontena::Cli::Helpers::LogHelper

    include Common

    option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
    option ['-p', '--project-name'], 'NAME', 'Specify an alternate project name (default: directory name)'
    parameter "[SERVICE] ...", "Show only specified service logs"

    def execute
      require_config_file(filename)

      services = services_from_yaml(filename, service_list, service_prefix, true)

      if services.empty? && !service_list.empty?
        signal_error "No such service: #{service_list.join(', ')}"
      elsif services.empty?
        signal_error "No services for application"
      end

      query_services = services.map{|service_name, opts| prefixed_name(service_name)}.join ','
      query_params = {
        services: query_services,
      }

      show_logs("grids/#{current_grid}/container_logs", query_params) do |log|
        show_log(log)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kontena-plugin-app-command-0.1.0 lib/kontena/cli/apps/logs_command.rb
kontena-plugin-app-command-0.1.0.rc1 lib/kontena/cli/apps/logs_command.rb