kubetailrb 0.3.1 → 0.3.3

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: 67fe04a21f2e2786f73e8ef768b91d48384911fbf739f4e2d1ad0edf1586b6e6
4
- data.tar.gz: c11d7bd08c7dde04d0c67b480e32c623d359e42fc8f7dc75b300242badd5a474
3
+ metadata.gz: 5ef04b916de92589cb98bac04813a76ea95f763250af27f9212271088b144bc3
4
+ data.tar.gz: c928856a0949ea26bdbdddeeb31754fc83edc8f1b9d4f9680197d1bb209bcb3c
5
5
  SHA512:
6
- metadata.gz: f2b54247b74a338cac3735bb55e8910cd4edddabb151e6a180f0a1f5a09560f0fdc5c75dcbcd1a3138e50236984a02757a5fecb481be0e3ec5f9626a528f6626
7
- data.tar.gz: aad83dfdfeef7add0e14f5eeb1c80f41b947d8270618100643856ac615807e9231d4a89a58950fcd4f2bfcd2ed2d41d8e37636f763ce3316e3f6e67987d4f820
6
+ metadata.gz: b28fe6c39843832ed4cd944455024cb4169226d1cc508b486cb1ebc5770a7492c6abc7bff34ada5244b1b301730d20a04978243fbb0be82871a149f4d66fb690
7
+ data.tar.gz: 16de81e80ae6f367adf781b5a217650662f4fe6ed17018726ce0306fcdc91e697413b98edf4a38dc2dd704c9da61effd3fc8ea2dd76dc3a997751f9d49860985
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.3.2] - 2024-12-16
2
+
3
+ - support `DEBUG` and `TRACE` levels
4
+
1
5
  ## [0.3.1] - 2024-12-13
2
6
 
3
7
  - fix reading rails log messages
data/README.md CHANGED
@@ -60,11 +60,6 @@ kubetailrb 'clock' -n sandbox -f --mdcs thread.name,service.version
60
60
  # Open interactive prompt to allow you to experiment.
61
61
  ./bin/console
62
62
 
63
- # Release new version
64
- NEW_VERSION=1.0.1 \
65
- && sed "s/VERSION = \".*\"/VERSION = \"${NEW_VERSION}\"/" lib/kubetailrb/version.rb
66
- && bundle exec rake release
67
-
68
63
  # Check available tasks that can be run
69
64
  bundle exec rake --tasks
70
65
 
@@ -87,7 +82,7 @@ Update the version in
87
82
  Then execute the script:
88
83
 
89
84
  ```sh
90
- ./bin/release
85
+ ./bin/release
91
86
  ```
92
87
 
93
88
  ## Contributing
@@ -11,7 +11,7 @@ module Kubetailrb
11
11
  Tail your Kubernetes pod logs at the same time.
12
12
 
13
13
  Usage:
14
- kubetailrb pod-query [flags]
14
+ kubetailrb [flags] pod-query
15
15
 
16
16
  Flags:
17
17
  -v, --version Display version.
@@ -21,6 +21,14 @@ module Kubetailrb
21
21
 
22
22
  MDCS_FLAGS = %w[-m --mdcs].freeze
23
23
 
24
+ FLAGS_WITH_VALUES = (
25
+ NAMESPACE_FLAGS +
26
+ [TAIL_FLAG] +
27
+ CONTAINER_FLAGS +
28
+ EXCLUDES_FLAGS +
29
+ MDCS_FLAGS
30
+ ).freeze
31
+
24
32
  attr_reader :reader
25
33
 
26
34
  def initialize(pod_query:, container_query:, opts:)
@@ -38,7 +46,7 @@ module Kubetailrb
38
46
  class << self
39
47
  def create(*args)
40
48
  new(
41
- pod_query: parse_pod_query(*args),
49
+ pod_query: parse_pod_query(args),
42
50
  container_query: parse_container_query(*args),
43
51
  opts: K8sOpts.new(
44
52
  namespace: parse_namespace(*args),
@@ -52,15 +60,21 @@ module Kubetailrb
52
60
  )
53
61
  end
54
62
 
55
- def parse_pod_query(*args)
56
- # TODO: We could be smarter here? For example, if the pod names are
57
- # provided at the end of the command, like this:
58
- # kubetailrb --tail 3 some-pod
59
- # The above command will not work because this method will return 3
60
- # instead of 'some-pod'...
61
- args.find { |arg| !arg.start_with? '-' }
63
+ def parse_pod_query(args)
64
+ args.each_with_index.find do |arg, idx|
65
+ !arg.start_with?('-') && !consumed_by_flag?(args, idx)
66
+ end&.first
62
67
  end
63
68
 
69
+ private
70
+
71
+ def consumed_by_flag?(args, idx)
72
+ prev = args[idx - 1]
73
+ FLAGS_WITH_VALUES.include?(prev)
74
+ end
75
+
76
+ public
77
+
64
78
  #
65
79
  # Parse k8s namespace from arguments provided in the CLI, e.g.
66
80
  #
@@ -62,9 +62,10 @@ module Kubetailrb
62
62
  " #{code} "
63
63
  end
64
64
 
65
- def format_log_level(json)
65
+ def format_log_level(json) # rubocop:disable Metrics/CyclomaticComplexity
66
66
  level = json['log.level'] || json.dig('log', 'level')
67
67
  return ' ' if level.nil? || level.strip.empty?
68
+ return " #{highlight_grey(" D ")} " if %w[DEBUG TRACE].include?(level)
68
69
  return " #{highlight_blue(" I ")} " if level == 'INFO'
69
70
  return " #{highlight_yellow(" W ")} " if level == 'WARN'
70
71
  return " #{highlight_red(" E ")} " if level == 'ERROR'
@@ -15,6 +15,10 @@ module Kubetailrb
15
15
  colorize(text, '36')
16
16
  end
17
17
 
18
+ def highlight_grey(text)
19
+ colorize(text, '1;30;47')
20
+ end
21
+
18
22
  def highlight_blue(text)
19
23
  colorize(text, '1;30;44')
20
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kubetailrb
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubetailrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Lin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-13 00:00:00.000000000 Z
11
+ date: 2026-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kubeclient