mkit 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 567f1ce28fb7c14d9eb23ddd36c4f98f68516b1c967450ec11188bfc460f5fdb
4
- data.tar.gz: 389a9060968047e9efb35ba47cdf3492d4ed47d8f92ce5e82203bb0668dd5ec1
3
+ metadata.gz: 5c7293226251f8d031a6b864f4ef7e9932a6046be6a7e78e07e203b1d9e4ff9a
4
+ data.tar.gz: 8a4993da20b730eb02f3f0605e257d255348861f84c3b8412e7b46b94316886c
5
5
  SHA512:
6
- metadata.gz: c86fc61f402f4559bbda5eb4bb89fa1a11073e0ad228f954a0cee370c50d3d3367469f64acf6073bb702985dcb99a9c655c4b38cc95f9a010e8623102742a2cd
7
- data.tar.gz: 9387d17b7394fa1619ad0ca7b03cda17ff4b98d1de7a56624a60fe96382a95b2501a11c07f41cbe36b7f3a2d569253903b2288aebb71430ed6d671ceebd17464
6
+ metadata.gz: bdd7a977df1915b70778fb7626836d0718563efc523cd128c2ee797ace0da1cb4c0f20e6b9dc2667bc1cfb03ec8efd0447b891a3a62179af68c01e6418c1d2de
7
+ data.tar.gz: e2783cd197695782478e29c075343a2bd6a1d5b84f5fe9d97ac7701a9329b1d26f874ab50a4493f85c629cbf2f3f2cf2761223700806d7c7adc322138e0d6cdc
@@ -43,12 +43,14 @@ class ServicesController < MKIt::Server
43
43
  srv.log
44
44
  else
45
45
  pod = find_srv_pod_by_id_or_name(srv)
46
- options_parameter = build_options_hash(params: params, options: [:nr_lines, :pods, :follow])
46
+ options_parameter = build_options_hash(params: params, options: [
47
+ :nr_lines, :pods, :follow, :details, :timestamps, :clear
48
+ ])
47
49
  request.websocket do |ws|
48
50
  listener = nil
49
51
  ws.onopen do
50
52
  settings.sockets << ws
51
- ws.send("<<<< %s | %s >>>>\n" % [srv.name, srv.pod.first.name])
53
+ ws.send("<<<< %s | %s >>>>\n" % [srv.name, pod.name])
52
54
  listener = MKIt::DockerLogListener.new(pod, ws, options: options_parameter)
53
55
  settings.listeners << listener
54
56
  listener.register
@@ -38,6 +38,14 @@ module MKIt
38
38
  `docker logs -n 20 #{instance_id}`
39
39
  end
40
40
 
41
+ def logfile(instance_id)
42
+ `docker inspect --format='{{.LogPath}}' #{instance_id}`
43
+ end
44
+
45
+ def clear_logs(instance_id)
46
+ `echo > #{logfile(instance_id)}`
47
+ end
48
+
41
49
  #
42
50
  # network
43
51
  #
@@ -26,10 +26,10 @@ module MKIt
26
26
  def find_srv_pod_by_id_or_name(srv)
27
27
  if params[:pod_id]
28
28
  pod = srv.find_pod_by_id_or_name(params[:pod_id])
29
- error 404, "Service pod not found." unless pod
30
29
  else
31
30
  pod = srv.pod.first
32
31
  end
32
+ error 404, "Service pod not found." unless pod
33
33
  pod
34
34
  end
35
35
 
@@ -271,7 +271,7 @@ class Service < ActiveRecord::Base
271
271
  end
272
272
  srv['ports'] = []
273
273
  self.service_port.each { |p|
274
- "#{p.internal_port}:#{p.external_port}:#{p.mode}:#{p.load_bal}".tap { |x|
274
+ "#{p.external_port}:#{p.internal_port}:#{p.mode}:#{p.load_bal}".tap { |x|
275
275
  if p.ssl == 'true'
276
276
  x << ':ssl'
277
277
  if !p.crt.nil? && p.crt != MKIt::Utils.proxy_cert
@@ -245,6 +245,25 @@
245
245
  type: option
246
246
  switch:
247
247
  - "-n"
248
+ - name: timestamps
249
+ help:
250
+ - -t
251
+ - Show timestamps
252
+ mandatory: false
253
+ param: "<%=true%>"
254
+ type: flag
255
+ switch:
256
+ - "-t"
257
+ - "--timestamps"
258
+ - name: details
259
+ help:
260
+ - -d
261
+ - Show extra details
262
+ mandatory: false
263
+ param: "<%=true%>"
264
+ type: flag
265
+ switch:
266
+ - "-d"
248
267
  - cmd: version
249
268
  help: prints mkit client and server version
250
269
  request:
@@ -1,15 +1,25 @@
1
1
  require "mkit/cmd/shell_client"
2
+ require "mkit/app/helpers/docker_helper"
2
3
 
3
4
  module MKIt
4
5
  class DockerLogListener < MKIt::ShellClient
5
6
 
7
+ include DockerHelper
8
+
6
9
  def initialize(pod, ws, options: {})
10
+ if options[:clear]
11
+ clear_logs(pod.name)
12
+ end
7
13
  @pod = pod
8
14
  @ws = ws
9
15
  command = "docker logs"
10
16
  command += " -f" if options[:follow] == 'true'
11
17
  command += " -n #{options[:nr_lines]}" if options[:nr_lines]
12
18
  command += " -n 10" unless options[:nr_lines]
19
+ command += " -t" if options[:timestamps] == 'true'
20
+ command += " --since #{options[:since]}" if options[:since]
21
+ command += " --until #{options[:until]}" if options[:until]
22
+ command += " --details" if options[:details] == 'true'
13
23
  command += " #{@pod.name}"
14
24
  super(command: command)
15
25
  end
data/lib/mkit/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module MKIt
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasco Santos
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-26 00:00:00.000000000 Z
11
+ date: 2025-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-dns
@@ -457,7 +457,7 @@ homepage: https://github.com/valexsantos/mkit
457
457
  licenses:
458
458
  - MIT
459
459
  metadata: {}
460
- post_install_message:
460
+ post_install_message:
461
461
  rdoc_options: []
462
462
  require_paths:
463
463
  - lib
@@ -472,8 +472,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
472
472
  - !ruby/object:Gem::Version
473
473
  version: '0'
474
474
  requirements: []
475
- rubygems_version: 3.3.5
476
- signing_key:
475
+ rubygems_version: 3.4.20
476
+ signing_key:
477
477
  specification_version: 4
478
478
  summary: Micro Kubernets on Ruby
479
479
  test_files: []