kubetailrb 0.3.2 → 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: 5d65ae35af371643129787b391585cf8dfe636fdcee05bce4c6e4e5a7d8cb4a0
4
- data.tar.gz: 43905900ca1be1ded3263ae2a43605283cbffaa6879016f255b54cbc55858232
3
+ metadata.gz: 5ef04b916de92589cb98bac04813a76ea95f763250af27f9212271088b144bc3
4
+ data.tar.gz: c928856a0949ea26bdbdddeeb31754fc83edc8f1b9d4f9680197d1bb209bcb3c
5
5
  SHA512:
6
- metadata.gz: 62b9f8373d2084749148179444317fc80bdc3dfd78e5c83cb437a42874dea9b6f4ce6ab984a9a726938b5e1ebb9903d3cede6da74bc489f12bceeec8cccef99f
7
- data.tar.gz: be92b4539793d423e5fdfc59b8b37128c619465b1334a5f06c98dbaade4b33cb5c485865ff1cd8bf5272b2956c0daa29a0e55e19cc3159eb9123892c2fa749f9
6
+ metadata.gz: b28fe6c39843832ed4cd944455024cb4169226d1cc508b486cb1ebc5770a7492c6abc7bff34ada5244b1b301730d20a04978243fbb0be82871a149f4d66fb690
7
+ data.tar.gz: 16de81e80ae6f367adf781b5a217650662f4fe6ed17018726ce0306fcdc91e697413b98edf4a38dc2dd704c9da61effd3fc8ea2dd76dc3a997751f9d49860985
@@ -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
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kubetailrb
4
- VERSION = '0.3.2'
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.2
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-16 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